3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2026-07-18 13:15:46 +00:00

Merge pull request #183 from Silimate/opt_argmax_fix1

opt_argmax fixes
This commit is contained in:
Akash Levy 2026-06-09 02:54:05 -07:00 committed by GitHub
commit b60d2daa41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 123 additions and 12 deletions

View file

@ -55,6 +55,42 @@ module opt_argmax_w32 (
end
endmodule
module opt_argmax_identity_w8 (
input wire [7:0] valid_in,
input wire [7:0][4:0] val_in,
output reg [2:0] best_idx
);
always_comb begin
best_idx = '0;
for (int k = 1; k < 8; k++) begin
if (!valid_in[best_idx] && valid_in[k]) begin
best_idx = k;
end else if (valid_in[best_idx] && valid_in[k] &&
(val_in[best_idx] < val_in[k])) begin
best_idx = k;
end
end
end
endmodule
module opt_argmax_identity_w16 (
input wire [15:0] valid_in,
input wire [15:0][7:0] val_in,
output reg [3:0] best_idx
);
always_comb begin
best_idx = '0;
for (int k = 1; k < 16; k++) begin
if (!valid_in[best_idx] && valid_in[k]) begin
best_idx = k;
end else if (valid_in[best_idx] && valid_in[k] &&
(val_in[best_idx] < val_in[k])) begin
best_idx = k;
end
end
end
endmodule
module opt_argmax_flat (
input wire [7:0] sig,
input wire [23:0] sig3,

View file

@ -74,6 +74,49 @@ sat -prove-asserts -verify
design -reset
log -pop
log -header "Identity-index masked argmax self-equivalence"
log -push
design -reset
verific -cfg veri_optimize_wide_selector 1
verific -cfg db_infer_wide_muxes_post_elaboration 0
read -sv opt_argmax.sv
verific -import opt_argmax_identity_w8
proc; opt_clean
rename opt_argmax_identity_w8 gold
read -sv opt_argmax.sv
verific -import opt_argmax_identity_w8
proc; opt_clean
select -module opt_argmax_identity_w8
opt_argmax
select -clear
opt_clean
select -assert-min 1 w:*argmax*
rename opt_argmax_identity_w8 gate
miter -equiv -flatten -make_assert gold gate miter
hierarchy -top miter
proc; opt; memory; opt
sat -prove-asserts -verify
design -reset
log -pop
log -header "Identity-index masked argmax structural rewrite"
log -push
design -reset
verific -cfg veri_optimize_wide_selector 1
verific -cfg db_infer_wide_muxes_post_elaboration 0
read -sv opt_argmax.sv
verific -import opt_argmax_identity_w16
proc; opt_clean
opt_argmax
opt_clean
select -assert-min 1 w:*argmax*
select -assert-none c:*argmax_val*
select -assert-none c:LessThan_*
design -reset
log -pop
log -header "Scaled masked argmax: 8 entries structural"
log -push
design -reset