YosysHQ / yosys

Yosys Open SYnthesis Suite
https://yosyshq.net/yosys/
ISC License
3.3k stars 860 forks source link

peepopt: avoid shift-amount underflow #4452

Open phsauter opened 2 weeks ago

phsauter commented 2 weeks ago

This solves issue #4413. shiftadd did not consider underflows for unsigned shift-amounts.
Specifically the issue arises if peepopt receives an expression like

wire [6:0] shift;
wire [7:0] data, shift2;
assign shift2 = shift - 1'b1;
assign out = data >> shift2;

Here an intended underflow occurs if shift<1. (by intended I mean it is what the current network implies, no matter what the designer might have wanted).
This adds a filter for the case described and adds the bug to the tests.