












































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













































Patrick Schaumont
Verilog Model of a hardware circuit
(many gates)
Patrick Schaumont
Modelsim Verilog Simulator
SequentialMachine
Simulator creates the
illusion of parallelactivites in model Simulator is a softwareprogram running on
a PC
Simulation Time + Concurrency Model (events, cycles, ..)
Patrick Schaumont
New data types, custom syntax
Simulation Time + Concurrency Model (events, cycles, ..)
Patrick Schaumont
-^ Understand the concept of event driven simulation •^ Understand how gate-level models are simulated •^ Understand how behavioral models are simulated
a^
b
Let's write a simulation for this circuit in C
clk
Patrick Schaumont
int
a, b; void
clock_cycle() { a = b;b = a; }^
No! a and b will have thesame value after one call
We create a function clock_tick which will be called for eachclock cycle. Is the following a correct implementation of this function?
a^
b
Let's write a simulation for this circuit in C
clk
Is this better?
Patrick Schaumont
int
a, b; int
new_a, new_b; void
clock_cycle() { new_a = b;new_b = a;b = new_b;a = new_a; }
Is this better?
concurrency
by making the simulation progress in
two phases, which alternate at the pace of the clk signal
a b
logic_a logic_b
logic_a and logic_bappear to executeconcurrently
Patrick Schaumont
**1. Evaluate
Find new values at the
inputs of a and b new_value_a = logic(a,b);new_value_b = logic(a,b);
Adjust the 'output' value of aand b to reflect the new values
a = new_value_a;b = new_value_b;
clk
**1. Evaluate
Find what the new values at the
inputs of a and b new_value_a = logic(a,b);new_value_b = logic(a,b);
Adjust the 'old' value of a and b
to reflect the new values
a = new_value_a;b = new_value_b;
Patrick Schaumont
The evaluate event
indicates when a gate or functionwould change its about because
the input has changed
The update event adjusts the value of a variable to reflect a new value
The evaluate event
indicates when a gate or functionwould change its output because
the input has changed
The update event adjusts the value of a variable to reflect a new value
a^
logic_a
Patrick Schaumont
a b clk
logic_a logic_b
The evaluate event
indicates when a gate or functionwould change its output because
the input has changed
The update event adjusts the value of a variable to reflect a new value
a^
logic_a
Patrick Schaumont
a b clk
logic_a logic_b
10
20
30
40
50
60
70
r s
Patrick Schaumont
Events: (r_rises, 20), (s_rises, 20), (r_falls, 30), (s_falls, 35)
^
E.g. (s_rises, 20) and (r_rises, 20) happen at the same time ^
!!!
In fact, the simulator cannot tell which of (s_rises, 20) and (r_rises, 20) happens first.
schedule new event
Patrick Schaumont
SimulationEngine
Time-ordered^ Event Queue
removeevent
Active events with identical timestamps
can be removed in arbitrary order
Variable (
reg
or Net (
wire
ProcessesProcessesProcesses
reg/wire reg/wirereg/wire
Fanout of a net
Patrick Schaumont
^
Primitives (gates) ^
Initial Blocks and Always Blocks ^
Procedural Assignments ^
Continuous Assignments and Ports
We talk aboutthese in this
lecture This is for
later
a^
b^
c d
All gates havepropagation delay
of 5 units
e
Event Queue
initial begin
#20 a
end
Patrick Schaumont
empty T = 0Initialize simulationAll nets are at X