ECE 491 Senior Design I - PowerPoint PPT Presentation

1 / 37
About This Presentation
Title:

ECE 491 Senior Design I

Description:

Model behavior in each clock cycle. Faster, but doesn't model delay. ECE 491 ... Specify code to be executed on simulation startup. initial sequential_statement ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 38
Provided by: JohnN2
Category:
Tags: ece | clock | design | senior | start | stop | the | to | up

less

Transcript and Presenter's Notes

Title: ECE 491 Senior Design I


1
ECE 491 - Senior Design I
  • Lecture 5 - Verilog Simulation Delay
  • Fall 2006
  • Read Verilog Handout Section 7

Prof. John NestorECE DepartmentLafayette
CollegeEaston, Pennsylvania 18042nestorj_at_lafayet
te.edu
2
Todays Outline
  • Discuss Lab 2
  • Verilog Part 3
  • Coding Guidelines
  • Simulation
  • Basics of Event-Driven Simulation
  • Delay Modeling
  • initial blocks
  • Functions
  • Tasks
  • System Tasks
  • Recent developments in Verilog

3
Verilog Coding Guidelines - 1
  • Use one file for each module.
  • Include a header block in each file that inludes
  • Your names
  • Brief description of module
  • History
  • Use template from ISE Edit menu
  • Use comments liberally.
  • Use meaningful signal names.
  • Be consistent using capitalization and
    underscores.
  • Properly indent your code, as shown in examples.

Dont use offensive signal names - (you dont
know who might read your code someday!)
4
Verilog Coding Guidelines - 2
  • Partition your design into leaf cells and
    non-leaf cells.
  • Leaf cells contain assign statements or always
    blocks but do not instantiate other cells.
  • Non-leaf cells instantiate other cells but
    contain no logic. (Minor exceptions OK to keep
    the code readable.) Define your combinational
    logic using assign statements when practical.
  • Use only nonblocking (lt) assignments in always
    blocks that model sequential logic.
  • Use only blocking () assignments in always
    blocks that model combinational logic.
  • Avoid latch inferences in combinational always
    blocks!

5
Verilog Coding Guidelines - 3
  • Use only positive edge-triggered flip-flops for
    storage.
  • Use parameters to define state names and
    constants.

6
Verilog and Event-Driven Simulation
  • Key idea model circuit operation as sequence of
    events that take place at specific times
  • Input events - when input changes
  • Output events - response to input events (only
    generated when output changes)

7
Event-Driven Simulation
  • Example Modeling and AND Gate
  • Input events changes on A, B input net
  • Output events changes on C output net after
    delay

A
delay12
A
B
C
B
C
8
Event-Driven Simulation
  • Output events from AND input events for OR
  • Simulation time jumps from event to event

A
delay3
B
A
D
delay4
C
B
E
C
D
E
9
Notes about Event-Driven Simulation
  • Why use event-driven simulation? Because it's
    fast
  • Only model when signals change
  • Loss of accuracy assumes ideal logical behavior
  • What are the alternatives?
  • Circuit simulation (e.g. PSpice)
  • Numerical model of continuous behavior
  • More accurate, but slower
  • Cycle-Level Compiled code simulation
  • Model behavior in each clock cycle
  • Faster, but doesnt model delay

10
Event-Driven Simulation (cont'd)
  • Processing Events - Data Structures
  • Event - specifies
  • time event will occur
  • net where signal will change
  • new value of net
  • Event Queue - data structure that sorts events by
    time
  • front of queue - earliest event
  • back of queue - latest event
  • also called a timing wheel

11
Event-Driven Simulation - Algorithm
  • Processing Events - Simulation Algorithm
  • initialization set all nets regs to x
  • while (event queue not empty)
    current_event "earliest" event in queue
    current_time current_event.time
    current_event.net.value current_event.value
    for (each module input connected to net)
    evaluate(module) if output of module
    changes create new event to represent
    output change add new event to queue

12
Verilog Simulation Model
  • assign statement
  • executes when event changes any input
  • produces output event when output values changes
  • always block
  • executes when event changes variable in
    sensitivity list
  • produces output events when outputs change

13
Delays in Event-Driven Simulation
  • Two kinds of delays supported
  • Inertial delays - reflects limited response time
    in real gates
  • Transport delays - try to model delay through a
    wire

14
Inertial Delays
  • What happens here?

15
Inertial Delays in Event-Driven Simulators
  • Each signal change is scheduled in event queue
  • When scheduling, compare to most recent change to
    calculate pulse width
  • If (pulse_width lt prop_delay) deschedule both
    events

5
6
3
4
5
9
11
3
16
Transport Delays
  • What happens here?

17
Modeling Delays in Verilog
  • Delays in Structural Verilog
  • Gate primitives inertial delays and 5 g1(o1, a,
    b)
  • Net delays (transport) wire 5 w1
  • More complex modules specify
  • Delays in Behavioral Verilog
  • assign statements assign 10 a x y
  • always initial blocks
  • blocking delay 10 a x y
  • interassignment delay a 10 x y

18
Structural Delay - Gate Primitives
  • and G1 (y1, a, b)
  • and 5 G2 (y2, a, b)
  • and (7,5) G3 (y3, a, b)
  • and (678,456) G4 (y4, a, b)
  • buf_if1 (6,5,2) B1 (y5, a, enb) // 3-state buf

19
Delay in assign statements
  • Delay specified as in structural specifications
  • assign 5 y1 a b
  • assign (4,5,6) y2 a b
  • Specifies inertial delay

20
Delays in Behavioral Verilog - Blocking Delay
  • Delay control operator - n
  • Simulation effect suspends simulation for n time
    units
  • Example clock generator
  • always
  • begin
  • clk 0
  • 50 clk 1
  • 50
  • end

21
Delays in Behavioral Verilog - Interassignment
Delay
  • Key idea unlike blocking delay, RHS is evaluated
    before delay
  • With blocking assignments
  • a 5 b c
  • d a
  • With nonblocking assignments
  • a lt 5 b c
  • d a

22
Representing Time in Verilog
  • Verilog uses dimensionless time units
  • Mapping time units to real time timescale
  • timescale lttime_unitgt / lttime_precisiongt
  • Examples
  • timescale 1ns / 1ps
  • timescale 10ns / 100ps
  • Each module can have a different timescale(but
    this is not necessarily a good idea!)

23
Simulation Time in Verilog and timescale
  • timescale controls simulation time
  • timescale time_unit time_precision
  • timescale 1ns 100ps
  • operator specifies delay in terms of time units
  • timescale 1ns 100ps
  • 5 // delays 51ns 5ns
  • // rounds times to 100ps
  • timescale 4ns 1ns
  • 3 // delays 34ns 12ns
  • // rounds times to 1ns

24
What happens when no delays are specified?
  • Each output event has a delta delay
  • Events processed in order of scheduling

25
initial statements
  • Specify code to be executed on simulation
    startup initial sequential_statement
  • Not supported in synthesis - tell synthesis to
    ignore using synthesis directives (pragmas)
  • Very useful in testbenches!
  • // synthesis translate_off
  • initial
  • begin
  • code to generate input stimulus
    check outputs
  • end
  • // synthesis translate_on

26
Verilog functions
  • Function Declaration
  • function range_or_type fname
  • input_declarations
  • statement
  • endfunction
  • Return value function body must assign fname
    expression
  • Function call fname ( expression, )

27
Verilog Functions (cont'd)
  • Function characteristics
  • returns a single value (default 1 bit)
  • can have multiple input arguments (must have at
    least one)
  • can access signals in enclosing module
  • can call other functions, but not tasks
  • cannot call itself (no recursion)
  • executes in zero simulation time (no timing ops
    allowed)
  • Synthesized as combinational logic(if proper
    subset is used)

28
Verilog Functions (cont'd)
  • Function examples
  • function calc_parity
  • input 310 val
  • begin
  • calc_parity val
  • end
  • endfunction
  • function 150 average
  • input 150 a, b, c, d
  • begin
  • average (a b c d) gtgt 2
  • end
  • endfunction

29
Verilog Tasks
  • Similar to procedures in VHDL, Pascal
  • Multiple input, output, and inout arguments
  • No explicit return value (use output arguments
    instead)
  • No recursion allowed
  • Can "enable" (call) other tasks and functions
  • May contain delay, event, and timing control
    statements (but not in synthesis)

30
Verilog Tasks (cont'd)
  • Task example
  • task ReverseByte
  • input 70 a
  • output 70 ra
  • integer j
  • begin
  • for (j 7 j gt0 jj-1)
  • raj a7-j
  • end
  • end
  • endtask
  • // Adapted from "Verilog HDL Synthesis A
    Practical
  • // Primer", by J. Bhasker

31
System Tasks and Functions
  • Tasks and functions defined for simulator control
  • All named starting with "" (e.g., monitor)
  • Standard - same for every simulator (almost)
  • See Verilog Quick Reference Card, Section 8 for
    full list of system tasks
  • Example system task display
  • display("format-string", expr1, , exprn)
  • format-string - regular ASCII mixed with
    formatting characters
  • d - decimal, b - binary, h - hex, t - time,
    etc.
  • other arguments any expression, including wires
    and regs
  • display("Error at time t value is h, expected
    h",
  • time, actual_value, expected_value)

32
Some useful System Tasks
  • time - return current simulation time
  • monitor - print message when values change
  • monitor("csb, nsb", cs, ns)
  • Simulation control tasks
  • stop - interrupt simulation
  • finish - terminate simulation
  • Extensive file I/O also available

33
Verilog Stuff we Wont Talk About
  • Parallel Blocks - fork / join
  • Procedural continuous assignment
  • assign / deassign as procedural statements
  • Not synthesizeable
  • User-Defined Primitives (UDPs) - low-level gate
    models
  • Programming Language Interface (PLI) - for
    linking to programming code in C/C

34
Verilog - Recent Developments
  • Verilog 2001(IEEE Standard) - Adds several new
    features
  • Cleaner module specifications
  • Lots of syntatic sugar - features that make
    language nicer to use
  • System Verilog
  • Meant to allow verification and HW/SW codesign
  • Integrates many features of C
  • C primitive types
  • Structures
  • Enumerated Types
  • Recursion

35
Verilog 2001 Port Declarations
  • Combines port list and declarations
  • module counter(
  • input clk,
  • input enb,
  • output reg 30 Q,
  • output carry)
  • always _at_(posedge clk)
  • if (enb) Q lt Q 1
  • endmodule

36
HDLs - What Else is Out There?
  • VHDL
  • More general more verbose
  • Continued extension - VHDL 2001 is current
    standard
  • SystemC
  • C class library of synthesizeable constructs
  • Meant for large system hardware/software codesign
  • Reference www.systemc.org
  • Verification Languages
  • e - Cadence
  • Vera - Synopsys

37
Coming Up
  • Verification and Testbenches
  • Serial Data Communication
Write a Comment
User Comments (0)
About PowerShow.com