The Sim/Synth Mismatch Checklist
A simulation-synthesis mismatch occurs when a Verilog logic simulator interprets code differently than a hardware synthesis compiler. These defects are dangerous because behavioral testbenches pass cleanly in simulation. Discrepancies appear only after synthesizing physical silicon or programming an FPGA bitstream. Engineers prevent these defects by avoiding ambiguous Verilog syntax constructs:
The Complete Prevention Checklist
- Avoid
casexConstructs (Section 5.3): Thecasexkeyword treats unknown states (x) as wildcards. In simulation, an uninitializedxinput matches wildcard branches that physical hardware never executes. Usecasezinstead, which treats only high-impedance (z) and explicit wildcard tokens (?) as don’t-care conditions. - Eliminate Hand-Written Combinational Sensitivity Lists (Section 5.2): Omitting an input from an explicit sensitivity list prevents the simulator from updating outputs when that input transitions. Synthesis compilers ignore sensitivity lists and infer hardware that responds to all inputs. Always specify
always @(*)for combinational logic. - Avoid Synthesis Pragmas:
full_caseandparallel_case(Section 5.3): Simulators ignore comment pragmas, while synthesis tools optimize logic based on them. If pragma assertions prove false, synthesized gates behave differently than simulated code. Write explicitdefaultbranches instead of using compiler pragmas. - Prevent Unintended Latch Inference (Section 5.2): Omitting branch conditions in combinational blocks creates level-sensitive transparent latches. Latches complicate static timing analysis and trigger race conditions. Assign default output values at the beginning of combinational
alwaysblocks. - Never Substitute
initialBlocks for Reset Logic (Section 5.1): Simulators initialize registers usinginitialblocks. In ASIC synthesis, compilers ignoreinitialblocks for sequential logic. Physical hardware powers on in undefined states. Always provide physical reset paths for hardware registers. - Enforce Non-Blocking Assignment Discipline (Section 5.1): Mixing blocking (
=) and non-blocking (<=) assignments creates simulation race conditions. Use non-blocking assignments exclusively for sequential registers. Use blocking assignments exclusively for combinational logic blocks. - Prevent Silent Signed-to-Unsigned Coercion (Section 7.2): Mixing signed and unsigned operands forces compilers to evaluate the entire expression as unsigned. Relational comparisons produce incorrect results. Enforce consistent signed declarations across all operands.
Universal Coding Principle
Write RTL source code whose logical interpretation does not depend on specific tool implementations. Prefer unambiguous language constructs over implicit tool assumptions:
- Use
casezinstead ofcasex. - Use
always @(*)instead of explicit sensitivity lists. - Write explicit
defaultbranches instead offull_casepragmas. - Enforce explicit reset nets instead of
initialblocks.
Automated static analysis tools (such as Verilator with --lint-only or Synopsys SpyGlass) flag these patterns before synthesis.
Enforce automated linting in continuous integration pipelines to maintain code quality.
Verification Exercise
Analyze the following Verilog code fragments and identify which checklist items they violate:
// Fragment A
always @(state)
next_state = (state == IDLE) ? ACTIVE : IDLE;
// Fragment B
initial q = 1'b0;
always @(posedge clk) q <= d;
View Solution
- Fragment A Violates Item 2: The block uses an explicit sensitivity list
@(state)for combinational logic. While currently sufficient, subsequent edits that add input signals will introduce simulator update bugs. Replace withalways @(*). - Fragment B Violates Item 5: The register relies on an
initialblock for initialization. Synthesis compilers discardinitialblocks on ASICs. The register powers on with an indeterminate value. Add an explicit reset signal:if (!rst_n) q <= 1'b0; else q <= d;.
This concludes Section 8.1. Section 8.2 examines synthesis-aware coding, predicting gate-level structures, and controlling resource sharing.