# Tests for opt_priokey # # The pass detects a serial "priority-by-key" set accumulator: several sources # each carry a small key and claim it if no earlier source already did. This # elaborates into a chain of dynamic-index reads/writes ($shiftx / $shift) into # a wide one-hot "taken" vector, whose depth grows with both the number of # sources P and the accumulator width S. Every dynamic read taken[key[j]] is # provably equal to the pairwise reduction # # OR over i full equiv). # B: structural win -- the $shiftx chain is gone after the rewrite. # C: negative / no-op cases (no false rewrites). # # Convention: every object the pass emits is named with a `priokey_` suffix, so # `select w:*priokey*` is a reliable "did the rewrite fire" probe. # ============================================================================ # Group A: formal equivalence (equiv_opt -assert) # ============================================================================ # A1: P=3 sources into a 64-slot accumulator (SW=6, all keys reachable). log -header "A1: priority-by-key dedup P=3 S=64 (equiv)" log -push design -reset read_verilog -sv < no rewrite" log -push design -reset read_verilog -sv < no rewrite" log -push design -reset read_verilog -sv < no rewrite" log -push design -reset read_verilog -sv <= SW'(S)) ? (k - SW'(S)) : k; // into [0,S) end logic [P-1:0] w1, w2; pk_dut #(P,S,SW) u1(.act(act), .sel_flat(sel_c), .win(w1)); pk_ref #(P,S,SW) u2(.act(act), .sel_flat(sel_c), .win(w2)); always_comb assert (w1 == w2); endmodule EOF hierarchy -top tb flatten chformal -lower opt -full sat -verify -prove-asserts -show-ports tb design -reset log -pop # E4: SAME non-pow2 S=12 under -strict. Strict validation sweeps the FULL key # range and rejects rewrites that only hold via out-of-range don't-cares, so # the pass must decline to rewrite. This is the safety mode used by formal # synthesis flows: no reliance on out-of-range freedom. log -header "E4: non-pow2 S=12 -strict -> no rewrite (safety)" log -push design -reset read_verilog -sv < no rewrite" log -push design -reset read_verilog -sv < no rewrite" log -push design -reset read_verilog -sv <