Merge pull request #19 from alainmarcel/new_peepopts

New peepopts
This commit is contained in:
alaindargelas 2024-12-20 09:34:11 -08:00 committed by GitHub
commit a497be5ae7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -75,11 +75,15 @@ code
b_const_int = sign2sComplement(b_const_int, b_const.size()) * twosComplement(b_const_int, b_const.size()); b_const_int = sign2sComplement(b_const_int, b_const.size()) * twosComplement(b_const_int, b_const.size());
if (c_const_signed) if (c_const_signed)
c_const_int = sign2sComplement(c_const_int, c_const.size()) * twosComplement(c_const_int, c_const.size()); 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 // Calculate the constant and compress the width to fit the value
Const const_ratio; Const const_ratio;
Const b_const_actual;
if (c_const_int == 0) if (c_const_int == 0)
// Avoid division by zero // Avoid division by zero
reject; 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 = b_const_int_shifted / c_const_int;
const_ratio.compress(b_const_signed | c_const_signed); const_ratio.compress(b_const_signed | c_const_signed);
@ -92,7 +96,7 @@ code
reject; reject;
// Check for potential mult overflow // 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; reject;
} }

View File

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