# Tests for opt_prienc # # Each group exercises a specific facet: # A: basic detection across different RTL styles for a few small widths. # B: depth and cell-count bounds after rewrite. # C: the lzd_for_loop RTL from the user's design at WIDTH=8/16/64. # D: variant detection (full vs short, CLZ vs CTZ). # E: negative / no-op cases. # F: extra fanout / reuse of inputs. # ============================================================================ # Group A: basic shapes (equiv_opt + structural sanity) # ============================================================================ # A1: 4-bit CLZ written as casez (full variant). log -header "A1: 4-bit CLZ via casez (clz_full)" log -push design -reset read_verilog < total network cell count and depth bound. # The recursive halving network has 2^k - 1 muxes for an N=2^k input. The # critical path through the muxes is k = log2(N) levels, which is the win. log -header "B1: 16-bit CLZ structural" log -push design -reset read_verilog -sv < structural bounds. log -header "B2: 32-bit CTZ structural" log -push design -reset read_verilog -sv < W=4" log -push design -reset read_verilog -sv < W=3" log -push design -reset read_verilog -sv < W=4" log -push design -reset read_verilog -sv < W=3" log -push design -reset read_verilog -sv < no rewrite" log -push design -reset read_verilog -sv < no-op. log -header "E3: cone crosses FF boundary" log -push design -reset read_verilog -sv < no-op. log -header "E4: input width 2 below min-width" log -push design -reset read_verilog -sv <= N) ? (si - N) : si; rr_dut #(N,W) u1(.req(req),.s(s),.grant(g1),.idx_next(n1)); rr_ref #(N,W) u2(.req(req),.s(s),.grant(g2),.idx_next(n2)); always_comb begin assert (g1 == g2); assert (n1 == n2); end endmodule EOF hierarchy -top tb flatten chformal -lower opt -full sat -verify -prove-asserts -show-ports tb design -reset log -pop # RR3: negative -- a downward-scanning arbiter (opposite rotation) is a # different function and must not be rewritten as round-robin. log -header "RR3: downward-scan arbiter -> no round-robin rewrite" log -push design -reset read_verilog -sv <= N) ? (si - N) : si; rr_dut #(N,W) u1(.req(req),.s(s),.grant(g1),.idx_next(n1)); rr_ref #(N,W) u2(.req(req),.s(s),.grant(g2),.idx_next(n2)); always_comb begin assert (g1 == g2); assert (n1 == n2); end endmodule EOF hierarchy -top tb flatten chformal -lower opt -full sat -verify -prove-asserts -show-ports tb design -reset log -pop # RR7: DIFFERENT RTL SPELLING of the same rotated-priority function. Instead of # the customer's downward idx-- last-write-wins loop, scan UPWARD from s+1 with # wraparound and keep the FIRST hit. This is a functionally identical arbiter # written in an unrelated style; detection is functional so it must still fire # and prove equivalent. (Combinational, pointer `s` an input -> full equiv at # power-of-2 N over all pointer values.) log -header "RR7: upward-scan spelling variant, N=16 (equiv + fires)" log -push design -reset read_verilog -sv < no round-robin rewrite" log -push design -reset read_verilog -sv <