Files
iverilog/ivtest/ivltests/pr2901556.v
T
Stephen Williams cea237b407 Add ivtest to the iverilog source tree
By adding ivtest to the iverilog source tree, it is easier to keep
the regression test synchronized with the source that is being tested.
This should be especially helpful for PRs that add a new feature, and
have a matching ivtest PR with the regression test for that feature.
2022-01-15 10:18:50 -08:00

27 lines
800 B
Verilog

module top;
integer lp;
wire signed [5:0] in = lp[5:0];
// If these two are combined "$signed({1'b0,in[5]})" then this will work
// as expected.
wire [5:0] #1 base = (in + (in >>> 2)) >>> 2;
wire signed [5:0] #1 fix = base + in[5];
// wire [5:0] base; // If this is missing the program will core dump!
// wire signed [5:0] #1 fix = ((in + (in >>> 2)) >>> 2) + $signed({1'b0,in[5]});
wire [6:0] #1 res = in + fix;
always @(*) $display("%0d: %d %d %d %d", $time, $signed(in), $signed(base),
$signed(fix), $signed(res));
// It appears that the final calculation event is being lost for fix == -1.
initial begin
lp = -7;
#5 lp = -5;
#1 lp = -6;
#5 if ($signed(res) !== -7) $display("FAILED");
else $display("PASSED");
end
endmodule