Gate-Level Simulation
Know what a gate-level run finds that RTL cannot, and which few tests to run on gates. Tell a real unknown from a pessimistic one, and know what equivalence checking does instead.
You Will Be Able To
- Name what gate-level simulation is for: reset of every flip-flop, synthesis mismatches, inserted logic, timing.
- Tell a zero-delay gate run from a timing-annotated one, and say what each can find.
- Decide whether a gate-level unknown is real by replaying each value of its source.
- Explain why equivalence checking, not simulation, proves a netlist matches its RTL.
- Lesson
- V12.7
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
Every RTL test passes. The first gate-level run of power-on reset shows a counter going unknown two cycles after reset. Is the netlist wrong, the RTL wrong, or the simulator?
- Cycle 0
In reset both models hold 00: the reset reaches every flip-flop of the counter.
- Cycle 1
At the first edge the RTL's if treats the unknown enable as false and keeps 00. The gates mix 00 and 01: bit 0 becomes x.
- Cycle 2
At the second edge the unknown spreads to bit 1 in the gates. The RTL still shows a clean 00.
Icarus Verilog version 12.0 (stable), the runnable example below. One column per sample.
Before You Start
Read Unknown Values at Chip Level first: it teaches X-optimism and X-pessimism with one mux. Reset Crossings and the Gate-Level View reads a netlist during a partial reset.
| Question | |
|---|---|
| 1 | What does a gate-level run find that an RTL run cannot? |
| 2 | What is the difference between a zero-delay and a timing-annotated gate run? |
| 3 | Why does a team run only a few tests on gates? |
| 4 | How do you decide whether a gate-level unknown is real? |
| 5 | What does equivalence checking prove that simulation cannot? |
The Idea: Simulate What Will Be Built
RTL is a description. Synthesis turns it into a netlist of gates and flip-flops, and that netlist is what becomes silicon. Later steps change it again: scan chains for test, a clock tree, buffers. A gate-level run simulates the netlist itself, so it sees what those steps did.
Most of what it finds is about reset and unknowns. A flip-flop that RTL resets may have lost its reset in synthesis. A case statement may synthesize differently from how it simulates. And four-state gate models are honest about unknowns where RTL is optimistic, and sometimes too honest.
Gate-level runs are slow, so teams run few of them, chosen for what only gates can show. Proving that the netlist does what the RTL does, for every input, is a different job. Equivalence checking does it formally, without tests.
New Words
| Word | Meaning |
|---|---|
| Netlist | The design as gates and flip-flops, written by synthesis. |
| Gate-level simulation | Simulating the netlist instead of the RTL. |
| Zero-delay run | A gate-level run where every gate switches at once, as in RTL; it checks function and reset, not timing. |
| Timing-annotated run | A gate-level run with each gate's and wire's delay loaded from a delay file of the laid-out chip (SDF). |
| Equivalence checking | A formal proof that two versions of a design, such as RTL and netlist, give the same outputs for every input. |
| Replay | Running the same netlist again with an unknown input forced to 0, then to 1. |
| X-optimism | RTL turning an unknown into a known value, so a real unknown is hidden. An if with an unknown condition takes its else branch. |
| X-pessimism | A gate model showing x where every real value of the unknown input gives the same answer. The x is the simulator's, not the chip's. |
One Picture: From RTL to Two Recordings
- Design
- Tool
- Measure
- Result
- Structure
- Data
- Analysis
- Synthesis
The netlist is what will be built: plain gates and flip-flops, with no if statements left.
- Two views, one stimulus
The same bench drives the RTL and the netlist, and both are recorded each cycle.
- Compare
Most cycles agree. The first cycle that differs is where to look.
- Replay
Force the unknown input to 0, then to 1. Equal answers mean the gates were pessimistic; different answers mean the unknown is real.
Read the diagram as text
- RTL: the description
- Synthesis: Yosys, generic NAND gates
- Netlist: gates and flip-flops
- One stimulus: Icarus, zero delay
- Compare views: cycle by cycle
- Replay at 0 and 1: same: pessimism; different: real
- RTL → Synthesis: read
- Synthesis → Netlist: write
- RTL → One stimulus: view 1
- Netlist → One stimulus: view 2
- One stimulus → Compare views: two recordings
- Compare views → Replay at 0 and 1: where they differ
The flow of the site's gate recordings (stage E16 and module V12), zero delay, one block.
The Smallest Example: One Counter, Two Models
A two-bit counter has an asynchronous reset and an enable. The enable comes from a flip-flop with no reset, so after reset it is unknown. Model the counter twice: as RTL with an if, and as gates with AND, OR and XOR. Work out the first two edges after reset.
| Sample | RTL | Gates | Replay en = 0 | Replay en = 1 |
|---|---|---|---|---|
| in reset | 00 | 00 | 00 | 00 |
| first edge | 00 | 0x | 00 | 01 |
| second edge | 00 | xx | 00 | 10 |
An if with an unknown condition takes the else branch (IEEE 1800 clause 12.4). The example below prints the same.
The RTL looks clean, and it is lying: the real chip could count or not. The gates say x, and the replays prove them right: enable 0 gives 00, enable 1 gives 01 then 10. Two different answers mean the unknown is real. The fix is upstream: reset the enable's flip-flop.
The Rules
Rule 1: Run gates for what RTL cannot show.
Reset of every flip-flop at power-on, logic synthesis changed or added, and timing on the laid-out chip.
Rule 2: Run few tests, chosen.
Power-on reset and a few paths through the slowest logic. The full suite is far too slow on gates.
Rule 3: Zero-delay runs check function; annotated runs check timing.
Only a run with delays from the laid-out chip can show a path that static timing analysis wrongly excused.
Rule 4: When the views differ, replay the unknown.
Same answer for 0 and 1: pessimism. Different answers: a real unknown that the RTL hid.
Rule 5: Prove equivalence formally.
An equivalence checker compares RTL and netlist for every input; no number of gate-level tests can.
Rule 6: Say what your gate runs did not cover.
A zero-delay run on one block says nothing about timing or about the other blocks.
Sources for These Rules
There are two kinds of gate-level simulation. Unit-delay runs without SDF check power-on reset: state that cannot be reset, and RTL-to-gate mismatches such as a case without default. Post-layout runs with SDF check timing, including wrongly declared multi-cycle or false paths. Run power-on reset and the longest paths, not the full suite: MEHTA-DV 15.5.4 (PDF p318-319) and 15.5.5 (PDF p320).
The book calls the first kind unit-delay: library cells with a unit delay and no SDF. This site's runs use zero delay, which checks the same function and reset.
Logic equivalence checking: formal comparison of a golden and a revised model, replacing gate-level simulation for this purpose: MEHTA-DV 10.5 (PDF p226-227).
An if with an unknown condition takes its else branch: IEEE 1800 clause 12.4. Gate-level runs of a whole chip do not scale; formal X checks complement them: MEHTA-DV 10.8 (PDF p242).
The Lab: Two Models, Then the Chip's Netlist
First the counter, on the site's Icarus, with the enable unknown:
in reset: rtl 00 gates 00
first edge: rtl 00 gates 0x
second edge: rtl 00 gates xxRule 4 by replay. Force the enable to 0, then to 1:
en = 0, second edge: rtl 00 gates 00
en = 1, second edge: rtl 10 gates 10The two replays end at 00 and 10, so the gates' xx was the truth. The RTL's 00 was one guess out of two. That is X-optimism: the RTL hid a real unknown.
Now the opposite case. A register holds its word or loads a new one, and the two words are equal. Its select has no reset, so it is unknown:
// The opposite case: hold the old word or load a new one, and the two words are equal.
// sel comes from a flip-flop with no reset, so it is unknown. The gate form is an AND-OR mux per bit.
module tb;
logic [3:0] held = 4'b1010, fresh = 4'b1010, q_rtl, q_gates;
logic sel;
task automatic show(input string label);
if (sel) q_rtl = fresh; else q_rtl = held; // the RTL: an if
q_gates = (fresh & {4{sel}}) | (held & ~{4{sel}}); // the gates: AND-OR, bit by bit
$display("%-14s rtl %b gates %b", label, q_rtl, q_gates);
endtask
initial begin
sel = 1'bx; show("sel unknown:");
sel = 1'b0; show("replay sel 0:");
sel = 1'b1; show("replay sel 1:");
end
endmodule
sel unknown: rtl 1010 gates x0x0
replay sel 0: rtl 1010 gates 1010
replay sel 1: rtl 1010 gates 1010The gates show x on every bit that is 1 in both words. Both replays give 1010, so the chip has no unknown here. That x is X-pessimism. The bits that are 0 in both words stay 0, because an AND with 0 is 0 whatever the select.
Now the chip. This site makes gate netlists of one block only: the boot ROM, ap_ahb_rom. Yosys 0.70+290 reads the RTL, maps memories and flip-flops to plain logic, and writes a netlist of two-input NAND gates. For this block and image that is 73 NAND gates and 34 flip-flops. Icarus then runs one stimulus on the RTL and on the netlist, and records both, cycle by cycle.
Rule 6 applies to everything this site shows. The runs are zero-delay: no cell library, no delays, no layout. One block, not the chip. They show how unknowns behave in gates; they cannot show timing. Two recordings exist: the one in the unknown-values lesson, and a second with another stimulus, which is this lesson's first problem.
Why It Is Built This Way
Why not run the whole regression on gates? A netlist has many more objects than its RTL, and a timing-annotated run is slower again. Teams spend that cost where only gates can answer: power-on reset, and the paths the timing report calls slowest.
Why do teams still run any gates at all, when equivalence checking proves the netlist? Equivalence proves function for inputs that are 0 or 1. It does not simulate reset from power-up with unknowns everywhere, and it does not check delays. Each method covers what the other leaves.
Traps
The first trap is chasing every x. The first gate run shows unknowns on a dozen buses, and the team traces each through the netlist by hand. Most were pessimism a replay would have cleared in minutes.
The second trap is trusting the clean RTL. An unknown appears only in gates, so it is filed as "a gate-level artefact" and closed. It was a real missing reset, and silicon powers up in a state no test ever saw.
The third trap is the gate run as a timing check. A zero-delay run passes, and the team calls timing done. Zero delay checks no timing at all; only static timing analysis and an annotated run do.
At Scale
This section looks ahead. ap_soc's gate runs are one block, zero delay.
Library cells and SDF
Production gate runs use the foundry's cell models and delays from the laid-out chip, at several voltage and temperature corners.
Equivalence at every step
RTL against netlist, netlist against netlist after scan insertion, and again after layout: each change is proved, not simulated.
Timing checks on synchronizers
Cell models check setup and hold. The first flip-flop of a synchronizer breaks them by design, so teams switch those checks off there, or every crossing turns x.
X-propagation modes
Simulators offer RTL modes that treat unknowns more like gates, so optimism shows before the netlist exists.
Try It
Run it: the same counter as RTL and as gates, with an unknown enable.
Force the enable to 1 (the predict question below). Do the views agree?
Add a reset to the enable's flip-flop. What do both views show?
in reset: rtl 00 gates 00 first edge: rtl 00 gates 0x second edge: rtl 00 gates xxCheck Yourself
Common Mistakes
Wrong Run the full regression on the netlist.
It is far slower, and most tests check nothing gates can add.
Fix Run power-on reset and a few slow paths on gates; prove function with equivalence checking.
Wrong Close every gate-only unknown as a simulator artefact.
Some are real: the RTL hid them.
Fix Replay the unknown at 0 and at 1; different answers mean it is real.
Wrong Call timing checked after a zero-delay gate run.
Zero delay checks no timing at all.
Fix Use static timing analysis, and an annotated run where its exceptions need checking.
Remember
- Gate-level runs show what synthesis and later steps built: reset, mismatches, inserted logic, timing.
- Run few gate tests: power-on reset and the slowest paths.
- Replay an unknown at 0 and 1: the same answer is pessimism, different answers are real.
- Equivalence checking proves RTL and netlist agree; gate runs and timing analysis cover what it leaves.