verilator/docs/guide
Geza Lore a37e2ee94b
Optimize wide decoder case statements into decoder expressions (#7804)
Extend the decoder-pattern case optimization to selectors that are too
wide for a full 2^width lookup table. A decoder-pattern case (where
every case item assigns constants to a fixed set of LHSs) is lowered to
a new AstMachMasked expression. AstMachMasked is emitted as a run-time
VL_MATCHMASKEd_* function call. It contains a packed constant pool table,
'matchp', which is a list of '(mask, bits)' pairs. At runtime, the index of the 
first matching entry is returned, and is used to index a value table. This single
(albeit complicated) expression can replace large if-else trees whole, resulting
in much more compact code with fewer static hard to predict branches. It
is worth about 10% speed and 30% code size in some designs.

Example:

```systemverilog
    logic [39:0] sel;
    always_comb
      casez (sel)
        40'b???????????????????????????????????????1: out = 8'h01;
        40'b??????????????????????????????????????1?: out = 8'h02;
        40'b?????????????????????????????????????1??: out = 8'h03;
        default:                                      out = 8'hff;
      endcase
```

is compiled to:

```c++
    out = TABLE_value[VL_MATCHMASKED_Q(sel, CONST_match)];
```

Where 'CONST_match' contains 4 entries, of a 40-bit mask and 40-bit bit
pattern each, and 'TABLE_value' contains 4 entries of the corresponding
8-bit results. (Entries are aligned to word boundaries to avoid runtime
bit swizzling)
2026-06-19 19:46:13 +01:00
..
figures Verilator_gantt now shows the predicted mtask times, eval times, and additional statistics. 2021-09-23 22:59:36 -04:00
changes.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
conf.py Commentary: Changes update 2026-04-23 00:44:50 -04:00
connecting.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
contributing.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
contributors.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
control.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
copyright.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
deprecations.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
environment.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
example_binary.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
example_cc.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
example_common_install.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
example_dist.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
example_sc.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
examples.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
exe_sim.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
exe_verilator.rst Optimize wide decoder case statements into decoder expressions (#7804) 2026-06-19 19:46:13 +01:00
exe_verilator_coverage.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
exe_verilator_gantt.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
exe_verilator_profcfunc.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
executables.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
extensions.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
faq.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
files.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
index.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
install-cmake.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
install.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
languages.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
overview.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
simulating.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
verilating.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00
warnings.rst Commentary: Use standard multiline rst comments, other cleanups 2026-06-18 21:58:01 -04:00