Check $mul/$div signedness.

This commit is contained in:
nella
2026-10-05 19:13:55 +02:00
parent 0e8336b4e2
commit 9e759da75f
2 changed files with 43 additions and 0 deletions
+1
View File
@@ -34,6 +34,7 @@ match div
// Check that b_const and c_const is constant
filter b_const.is_fully_const()
filter port(div, \B).is_fully_const()
filter param(div, \A_SIGNED).as_bool() == param(mul, \A_SIGNED).as_bool()
index <SigSpec> remove_bottom_padding(port(div, \A)) === mul_y
endmatch
+42
View File
@@ -365,3 +365,45 @@ end
EOT
equiv_opt -assert peepopt
####################
#6255
design -reset
read_verilog <<EOT
module peepopt_muldiv_c_0(input signed [3:0] a, output [8:0] y);
wire signed [8:0] p = a * 5'sd9;
assign y = $unsigned(p) / 9'd3;
endmodule
EOT
prep -nokeepdc
equiv_opt -assert peepopt
design -load postopt
select -assert-count 1 t:$div
design -reset
read_verilog <<EOT
module peepopt_muldiv_c_1(input [5:0] a, output [7:0] y);
wire [7:0] p = a * 2'd3;
assign y = $signed(p) / 3'sd3;
endmodule
EOT
prep -nokeepdc
equiv_opt -assert peepopt
design -load postopt
select -assert-count 1 t:$div
design -reset
read_verilog <<EOT
module peepopt_muldiv_c_2(input signed [3:0] a, output signed [8:0] y);
wire signed [8:0] p = a * 5'sd9;
assign y = p / 9'sd3;
endmodule
EOT
prep -nokeepdc
equiv_opt -assert peepopt
design -load postopt
select -assert-count 0 t:$div