Docsity

How HDL Simulation Work - Digital Design II | ECE 4514, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download How HDL Simulation Work - Digital Design II | ECE 4514 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

ECE 4514

Digital Design II

Spring 2008

Lecture 5:

Patrick Schaumont

Lecture 5:

How HDL simulation works

A

tool & methodology

Lecture

Patrick Schaumont

Today's topic 

We look at the simulation mechanism of Verilog

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

HDL simulation is different from C execution 

Need to express concurrency (things happeningsimultaneously)

Need to model time

Need to model non-standard wordlengths

Simulation Time + Concurrency Model (events, cycles, ..)

Patrick Schaumont

Need to model non-standard values (X,Z)

Need organization in modules rather than functions

New data types, custom syntax

Focus of this lecture 

Need to express concurrency (things happeningsimultaneously)

Need to model time

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

Objectives:

The need for concurrent hardware models

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 better solution

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?

Cycle-based simulation Thus, we simulate

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

  1. Update**

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

Transition between phases driven by

events

**1. Evaluate

  1. Update**

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

Cycle-based simulation has two types of

events

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

What is the cause of the update event?

a b clk

logic_a logic_b

The cause of the update event is the upgoing clock edge

Cycle-based simulation has two types of

events

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

What is the cause of the evaluate event?

a b clk

logic_a logic_b

But what exactly is an

event

Event = tuple (activity, simulation time)

10

20

30

40

50

60

70

r s

Patrick Schaumont

Events: (r_rises, 20), (s_rises, 20), (r_falls, 30), (s_falls, 35)

A list of events expresses concurrent activities

^

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.

Verilog is an

event-driven

simulator

The Verilog simulator maintains an ordered list ofall future events of interest: the Event Queue

The simulation engine reads events from the queue,executes them, and inserts new events as needed

schedule new event

Patrick Schaumont

SimulationEngine

Time-ordered^ Event Queue

removeevent

Active events with identical timestamps

can be removed in arbitrary order

Some Verilog 'processes'

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

Let's see how gate-level simulation works

a^

b^

c d

G
G2 G
G

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