Professional Documents
Culture Documents
Brief Introduction To Logic Simulation: Kinds of Logic Simulators
Brief Introduction To Logic Simulation: Kinds of Logic Simulators
Logic Simulation
ECE 255 1
Logic States for Simulation
• Combinational and synchronous circuits with a
known initial state
– Two logic states (0, 1)
•Good to compute logic behavior
•Not enough for detecting hazards
ECE 255 2
Information Loss of 3-Valued Logic
Related to unknown:
a d (0)
1 (1)
u
u (1)
(0) f
b u u
(1)
(0) (1)
c1 e
when b = 0 ⇒ e = 1 ⇒ f=1
b=1 ⇒ d=1 ⇒ f=1
⇒ ( abc ) = ( 1u1 ) should produce f = 1 instead of f = u
⇒ The use of u may cause information loss
Logic Simulation K.T. Tim Cheng 5
Compiled Simulation
• Given circuit C:
1. Levelize circuit a e e
b
2. Generate code
i
g
c
f j
d
• Level 0: a, b, c, d
• Level 1: e, f
• Level 2: g
• Level 3: i
• Level 4: j
Logic Simulation K.T. Tim Cheng 6
ECE 255 3
• Code:
while(1) {
Read_in ( a, b, c, d ) ;
e = NAND ( a, b ) ;
f = INV ( c ) ;
g = NOR ( b, f ) ;
i = AND ( e, i ) ;
j = NAND ( i, d );
Print ( e, i, j ) ;
}
• Levelizing circuit:
– Assign all PI lines level 0
– The level of a gate g is:
Lg = 1 + max ( Li1, Li2, …Lin)
i1, i2…in are inputs of gate g.
Logic Simulation K.T. Tim Cheng 7
ECE 255 4
Event-Driven Simulation
• For each new input vector, the ratio of lines which
change values to the total number of lines in the
circuit is called the activity A.
– Typically A = 2 - 10 %
• An event is a change in value of a signal line
• The output of a gate i will only change value when
one or more of its inputs change value.
– Element i need only be simulated when an event occurs
at one of its inputs
0
0
0 1
0 0
0 1 1 1
0000 0001
Only simulated NOR & NAND gates.
Logic Simulation K.T. Tim Cheng 10
ECE 255 5
Algorithm - a simplified version
• 0-delay assumption
Read
Readinininitial
initialstate
state
information
information
More No
Moreinput
input Stop
Vector?
Vector?
Yes Yes
IsIs Read
Readinin(new)
(new)input
inputvector
vector
event
eventqueue
queue For
Foreach
eachline
linei isuch (i)≠≠VVold(i)
thatVVnew(i)
suchthat new (i)
old
empty?
empty? Put
Put(i,
(i,VVnew(i) ) on event queue Q1
new(i) ) on event queue Q1
No
Evaluate element i, i ∈ Q1.
If element i changes state,
put Fanout(i) in Q1
Data Structure
• Two types of objects:
– Signals : X1 - X8
X1 X5
– Elements : A - D X2
A
C
X7
• elementÆinputs
elementÆoutputs X3 X6 X8
B D
elementÆfunction X4
Example: AÆinputs = X1 , X2
AÆoutput = X5
• signalÆfanout
signalÆfanin
Example: X6Æfanout = C , D
X6Æfanin = B
Logic Simulation K.T. Tim Cheng 12
ECE 255 6
Delay Models
• Zero delay: Output changes instantly in
response to an input
• Unit delay: All gates have one unit delay
• Transport delay:
– transition independent
– transition dependent : rise & fall delays are
specified separately
• Ambiguous delay or Minmax delay
ECE 255 7
• Ex. A C
B=1
A 3
transition-indep.
C 2 3
transport delay = 2
3
1 rise delay = 1
C fall delay = 3
1
1 ambiguous delay
C (transition indep.)
3 3 1≤d≤3
C inertial delay = 4
2
inertial delay = 2
C 3 & transport delay = 2
Logic Simulation K.T. Tim Cheng 15
0 1 1 1
1 0
• Unit - delay model:
1 (t = 1)
0 (t = 0) 0 (t = 2)
1 (t = 1)
1 (t = 3)
1 (t = 1)
0 (t = 2)
Need a “ time - flow” mechanism.
Logic Simulation K.T. Tim Cheng 16
ECE 255 8
Time Flow Mechanism & Event Scheduling
• When an element i is simulated and it is
determined that its output signal j has changed
state, i.e. Vnew(j) ≠ Vold(j), then signal j must be
scheduled to change to Vnew(j) at time t+Δi
where t : the current simulation time
Δi : the delay of element i
The event ( j, Vnew ( j), t+Δi ) is scheduled to
occur in the future.
• Need an event queue for each time of simulation
• Time wheel -
M-1
0 i Vi’ j Vj’
1
2
3
An array of headers
Events scheduled for time t appear in
array [t modulo M ].
M must be larger than the longest
delay of any element.
ECE 255 9
Event Driven Simulation
• While ( event list is not empty )
{
t = next time in list;
process entries for time t;
}
• Process_entries : Algorithm I
– Two passes
Pass 1: retrieves the entries from event list & determine
the activated gates.
Pass 2: evaluates the activated gates and schedules their
computed values.
Algorithm I
Activated = φ
For every entry (i, vi′) at list time t {
if (vi′ ≠ v(i) ) {
v(i) = vi′;
for every j on fanout list of i {
update input value of j;
add j to Activated;
} /* for */
} /* if */
} /* for */
ECE 255 10
Example : z
a
8
b
a:
0 4
b:
8 10
• Time 0 : event (a, 1)
evaluate z=1 ⇒ (z,1) scheduled for time 8
• Time 2 : event (b, 0)
evaluate z=0 ⇒ (z, 0) scheduled for time 10
• Time 4 : event (a, 0)
evaluate z=0 ⇒ (z, 0) scheduled for time 12
The last scheduled event (at t=12) is not a real event!!
Logic Simulation K.T. Tim Cheng 21
An Improved Algorithm
Change Pass 2 to:
ECE 255 11
• Two-pass strategy performs the evaluations only
after all the concurrent events have been retrieved
to avoid repeated evaluations of gates having
multiple input changes.
• One-pass strategy:
– Evaluates a gate as soon as it is activated
– Avoids the overhead of building the Activated set
One-Pass Algorithm
ECE 255 12
Simulation Engines
• Logic simulation is time-consuming
Logic Emulation
• Implementing the netlist in re-programmable
hardware.
ECE 255 13
Emulation modules
Backplane FPGAs
connector
• The emulation hardware can be operated at 100
kHz to several MHz.
– Simulating 100k to several mega vectors per second
– 10,000 to 1,000,000 times faster than software simulators
Logic Simulation K.T. Tim Cheng 27
Synthesis process:
ASIC netlist
Compilation
(design translation,
partitioning,
placement & routing)
bit streams for
reprogramming FPGAs
FPGAs
Configuration
(reprogram the FPGAs)
Emulation hardware
Logic Simulation K.T. Tim Cheng 28
ECE 255 14