Algorithm Search⌘K

Problemintro

Logic simulation

Also called gate-level simulation, digital simulation.

Compute the signal values of a gate-level or register-transfer design over time for given input stimuli, under a chosen delay model and value system.

Logic simulation asks for the values of the signals of a digital design over time, for given inputs, when each signal takes values in a small set such as 0, 1 and X and each gate has a delay from a simple model. It is the logic half of the logic and circuit simulation sub-area. The circuit half asks for node voltages as real functions of time and solves differential equations, as in transient circuit analysis. Logic simulation gives up voltages for speed: it can run millions of gates for millions of clock cycles, and it is the main tool to check that a design does what its authors meant before it is built. Every instance fixes three choices: the netlist, the value system and the delay model. With zero delay and one input vector, the problem is the circuit value problem, which is solvable in linear time and P-complete. With delays, the answer is a waveform, and it depends on the delay model as much as on the netlist.

In plain words

A chip design is a large drawing of logic gates joined by wires. Before anyone builds it, the designers want to know what it will do. So a program plays the inputs that a test asks for and works out, gate by gate, what every wire carries, and when.

The program does not compute voltages. A wire is high, low, or "not known". Each gate takes some time to react, and the program uses a fixed rule for that time.

The answer can depend on these rules. With no gate delays, a short spike may vanish. With delays, it may appear. A loop of gates with no delay may never settle.

Definition

Input.

  • A netlist: a set of nets, of which some are primary inputs, and a set of gates. Each gate gg has input nets, one output net out(g)\mathrm{out}(g), a function fgf_g over the value set and a delay d(g)≥0d(g) \ge 0. State elements such as flip-flops are gates whose function reads a clock, or they are loops of gates.
  • A value set VV that contains 0 and 1, often with X, Z or the nine values of IEEE Std 1164; see multi-valued logic for simulation.
  • A delay model: zero delay, unit delay, or nominal delays d(g)d(g), applied as transport or inertial delay; see inertial and transport delay.
  • An initial value for every net, often X, and a stimulus: for each primary input, a list of changes (t,v)(t, v) up to a final time tendt_{\mathrm{end}}.

Semantics. Write zg(t)=fg(the input values of g at time t)z_g(t) = f_g(\text{the input values of } g \text{ at time } t). With transport delay, a nonprimary net is out(g)(t)=zg(t−d(g))\mathrm{out}(g)(t) = z_g(t - d(g)) for t≥d(g)t \ge d(g), and keeps its initial value before. Inertial delay also removes the pieces of zgz_g shorter than d(g)d(g). With zero delay, the values at each time must satisfy out(g)=fg(inputs of g)\mathrm{out}(g) = f_g(\text{inputs of } g) for every gate at once, a fixed point, and the order of changes within one time is given by delta cycles.

Output. For each net, its waveform on [0,tend][0, t_{\mathrm{end}}]: its initial value and the list of its changes in time order. A cycle-based variant asks only for the values at each clock edge. With zero delay the fixed point may not exist or may not be unique, and the output must then say so: an oscillation is reported, and a common rule for two or more fixed points is to give X on the nets where they differ.

Measures of work. Let GG be the number of gates, PP the number of gate input pins, and EE the number of events, the changes of value on nets in the output. The cost of a method is counted in gate evaluations and queue operations.

Variants

  • Combinational, zero delay. One settled output vector per input vector, as in compiled-code logic simulation. Many vectors can share one run in bit-parallel words.
  • Synchronous, one value per cycle. The design is a Mealy machine, and only the register values at each clock edge matter, as in cycle-based simulation.
  • Timed. Unit or nominal delays, with the full waveform, as in event-driven logic simulation. Gate-level simulation with delays from timing analysis is of this kind.
  • Hazard and race analysis. Ask which nets may glitch or end in a value that depends on the delays, for all delays at once, as in ternary simulation.
  • Transistor networks. Nets are nodes with charge, and gates are switches with strengths, as in switch-level simulation.
  • Hardware description languages. The design is a set of processes in VHDL or Verilog that read and write signals; the gates above are processes of a fixed form.
  • Many machines at once. Fault simulation runs the good circuit and many faulty copies on the same stimulus.

Examples

One vector, zero delay. A full adder with s=a⊕b⊕cs = a \oplus b \oplus c and cout=ab+c(a⊕b)c_{\mathrm{out}} = ab + c(a \oplus b), at a=b=1a = b = 1, c=0c = 0, gives s=0s = 0 and cout=1c_{\mathrm{out}} = 1. This is one instance of the circuit value problem.

The delay model changes the answer. Let p=¬ap = \lnot a and y=a∧py = a \land p, a pulse generator. Logically y=0y = 0 always. Let aa rise from 0 to 1 at time 0, so that before it p=1p = 1 and y=0y = 0.

delay model waveform of yy
zero delay 0 at every time; a pulse of zero width in delta cycles at time 0
unit delay, transport 1 on [1,2)[1, 2)
unit delay on NOT, delay 2 on AND, inertial 0 at every time
unit delay on NOT, delay 2 on AND, transport 1 on [2,3)[2, 3)

In the unit-delay case the AND gate sees a=1a = 1 and the old p=1p = 1 during [0,1)[0, 1) and asks for 1 from time 0, which appears at time 1. The inverter output falls at time 1, so the AND gate asks for 0 from time 1, which appears at time 2. With an inertial AND delay of 2, the request for 1 lasts only one time unit and is removed. A script checked all four rows with an event-driven simulator. The event-driven logic simulation page traces the same effect on a multiplexer.

No fixed point. A NOT gate whose output is its own input has no zero-delay fixed point over {0,1}\{0, 1\}. An event-driven simulator makes delta cycles for ever, and with unit delay the net oscillates with period 2. Over {0,1,X}\{0, 1, X\} the value X is a fixed point, which is the answer of ternary simulation.

Two fixed points. A latch of two NOR gates q=¬(r∨qˉ)q = \lnot(r \lor \bar q) and qˉ=¬(s∨q)\bar q = \lnot(s \lor q) with r=s=0r = s = 0 has the fixed points (q,qˉ)=(0,1)(q, \bar q) = (0, 1) and (1,0)(1, 0). Which one a simulation reaches depends on the initial values and the delays. Starting from X, three-valued simulation keeps both nets at X, which says that the state is not known.

Known algorithms

Method Delay model What is known
Compiled-code logic simulation (levelized code, bit-parallel words) zero delay, acyclic exact; O(G+P)O(G + P) word operations per batch of vectors
Cycle-based simulation none inside a cycle exact at the clock edges of a synchronous design
Event-driven logic simulation (Ulrich 1969, time wheel) zero, unit, nominal; transport or inertial exact for the delay model; work grows with the events, not with GG per time step
Ternary simulation (Eichelberger 1965) all delays at once sound; detects static hazards and critical races
Switch-level simulation (Bryant 1984) unit delay per round, or zero sound with X on transistor networks
Parallel discrete-event simulation (Chandy-Misra-Bryant, Time Warp) nominal the same waveforms, on many processors; speedup measured
Fault simulation (concurrent, parallel) as the base simulator one run for many faulty circuits

What is proved: the exactness of each method for its delay model, and the bounds below. What is only measured: the speed of event-driven against compiled-code simulation on real designs, which depends on the share of gates that change per time step, and the speedup of parallel simulation.

AlgorithmTimeSpacePropertiesCode
Compiled-code logic simulationO(G log G + P + (m / W + 1) (G + P)) worst · bestO(N + P) extradeterministicexactiterative1 language
Cycle-based simulationO(N + P + T (G + P)) worst · bestO(N + P) extradeterministicexactiterative1 language
Event-driven logic simulationO(E F k + S M) worstO(N + P) extradeterministicexactiterative1 language
Switch-level simulationO(R (N + T) log N) worstO(N + T) extradeterministicnot exactiterative1 language
Ternary simulationO(n (n + P)) worstO(n + P) extradeterministicnot exactiterative1 language

Bounds

Linear time for one vector. A combinational netlist without loops and with zero delay is evaluated in O(G+P)O(G + P) time by evaluating the gates in topological order. A general algorithm cannot do better: an output can depend on every gate, so every gate must be read. With TT time steps of unit delay, step-by-step evaluation takes O(T(G+P))O(T (G + P)) time, and event-driven evaluation takes time proportional to the number of gate evaluations, at most the events times the largest fanout plus the queue cost.

P-completeness. The circuit value problem, with zero delay and one vector, is complete for P under logarithmic-space reductions (Ladner 1975). So no algorithm evaluates every circuit in time polylogarithmic in its size on a polynomial number of processors, unless every problem in P has such an algorithm, that is, unless NC = P. What parallel hardware can do is evaluate a circuit of depth DD in DD rounds with one processor per gate, one level per round. Long chains of logic, and the sequential steps of a design over time, limit the speedup of parallel logic simulation.

Fixed points of zero-delay loops. For a zero-delay netlist with loops and fixed inputs, deciding whether a binary fixed point exists is NP-complete. Proof. A guessed assignment of all nets is checked gate by gate in linear time, so the problem is in NP. For hardness, take a formula φ(y1,…,yn)\varphi(y_1, \ldots, y_n), make a gate for each yiy_i with i≥2i \ge 2 that copies yiy_i to itself, and give y1y_1 the gate y1⊕¬φ(y)y_1 \oplus \lnot \varphi(y), built from the gates of φ\varphi and fed back to y1y_1. The netlist has size linear in φ\varphi, and yy is a fixed point exactly when ¬φ(y)=0\lnot\varphi(y) = 0, that is, when yy satisfies φ\varphi. So a fixed point exists if and only if φ\varphi is satisfiable, and SAT reduces to the question. □\square Ternary simulation avoids this: starting from X on the loop nets, it reaches the least ternary fixed point in at most as many rounds as there are nets, and every 0 or 1 in it holds in every binary fixed point. It may answer X where a binary fixed point exists.

Lower bound on the output. A waveform with EE events takes Ω(E)\Omega(E) time to write, and EE can be as large as T⋅GT \cdot G for a circuit that changes at every step.

Reductions

  • From the circuit value problem. CVP is logic simulation with zero delay, one vector and no loops. So logic simulation is P-hard.
  • Unit delay to zero delay. Simulation with unit delay for TT steps is zero-delay evaluation of the circuit copied TT times, where copy t+1t + 1 of each gate reads the copies tt of its inputs, as in time-frame expansion. The copied circuit has no loops, even if the original has.
  • To discrete-event simulation. Timed logic simulation is a case of event-driven simulation in which the entities are gates and the events are changes of net values.
  • From circuit simulation. Thresholds on node voltages turn the output of transient circuit analysis into logic waveforms. Timing simulation and mixed-mode simulation sit between the two halves.

Applications

  • Functional verification. Designers run test programs and random stimulus on the register-transfer and gate descriptions and compare the outputs with a model. This is the largest use of logic simulation in chip design.
  • Gate-level timing checks. After layout, the netlist with delays from static timing analysis is simulated to check resets, clock gating and asynchronous paths that static analysis does not cover.
  • Test. Fault simulation grades a test set by its fault coverage, and test generators simulate each new pattern.
  • Power. The waveforms give the switching activity of each net, which power estimation multiplies by the net capacitance.
  • Equivalence and debugging. Simulation finds counterexamples quickly before formal methods such as sequential equivalence checking are run.

References

  1. Miron Abramovici, Melvin A. Breuer and Arthur D. Friedman, Digital Systems Testing and Testable Design, IEEE Press, 1994, the chapter Logic Simulation (the problem, value systems, delay models, compiled and event-driven simulation, and hazard detection; general locator)
  2. Richard E. Ladner, The circuit value problem is log space complete for P, ACM SIGACT News 7(1), 18 to 20, 1975, the reduction from every problem in P to the circuit value problem in logarithmic space
  3. Raymond Greenlaw, H. James Hoover and Walter L. Ruzzo, Limits to Parallel Computation, P-Completeness Theory, Oxford University Press, 1995, the appendix entries for the circuit value problem and its variants, and the chapters on what P-completeness means for parallel speedup (general locator)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml