Overflow test fix

This commit is contained in:
Alain Dargelas 2024-12-20 09:32:20 -08:00
parent 48a971c436
commit b6d079bb62
2 changed files with 7 additions and 2 deletions

View File

@ -77,9 +77,13 @@ code
c_const_int = sign2sComplement(c_const_int, c_const.size()) * twosComplement(c_const_int, c_const.size());
// Calculate the constant and compress the width to fit the value
Const const_ratio;
Const b_const_actual;
if (c_const_int == 0)
// Avoid division by zero
reject;
b_const_actual = b_const_int_shifted;
b_const_actual.compress(b_const_signed);
const_ratio = b_const_int_shifted / c_const_int;
const_ratio.compress(b_const_signed | c_const_signed);
@ -92,7 +96,7 @@ code
reject;
// Check for potential mult overflow
if (b_const.size() + a.size() > mul_y.size()) {
if (b_const_actual.size() + a.size() > mul_y.size()) {
reject;
}

View File

@ -268,7 +268,7 @@ module top(
output [7:0] y,
);
wire [6:0] mul;
assign mul = a * 4'd4;
assign mul = a * 4'd8;
assign y = mul / 8'd2;
endmodule
EOT
@ -278,6 +278,7 @@ select -assert-count 1 t:$mul
select -assert-count 1 t:$div
design -reset
log -pop
log -header "No transform when (a*b) and x/c fitting criteria but not connected (x != a*b)"
log -push