Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania 18042 ECE 491 - Senior Design I Lecture 6 - Behavioral Modeling.

Slides:



Advertisements
Similar presentations
Verilog HDL -Introduction
Advertisements

Chapter 15:Introduction to Verilog Testbenches Objectives In this section,you will learn about designing a testbench: Creating clocks Including files Strategic.
CS 3850 Lecture 6 Tasks and Functions. 6.1 Tasks and Functions Tasks are like procedures in other programming languages. e. g., tasks may have zero or.
Simulation executable (simv)
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Synchronous Sequential Logic
ELEN 468 Lecture 61 ELEN 468 Advanced Logic Design Lecture 6 Delay Models.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
16/04/20151 Hardware Descriptive Languages these notes are taken from Mano’s book It can represent: Truth Table Boolean Expression Diagrams of gates and.
2/9/20031 ECE 551: Digital System Design & Synthesis Lecture Set 4 4.1: Verilog – Procedural Assignments &Scheduling Semantics 4.2: Verilog – More Behavioral.
ECE 553: TESTING AND TESTABLE DESIGN OF DIGITAL SYSTES Logic Simulation.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI System Design Lecture 3 - Verilog Delay.
Verilog Tutorial. Outline Numbers(A.2.7) Vectors in Verilog (Section 4.1.7) Four value logic (Section 4.2.1) Comments and White Space (A.2.2) Test Methodology.
Copyright 2001, Agrawal & BushnellDay-1 PM Lecture 4a1 Design for Testability Theory and Practice Lecture 4a: Simulation n What is simulation? n Design.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 5 - Coding Guidelines;
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 7 - Verification.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
HDL-Based Digital Design Part I: Introduction to VHDL (I) Dr. Yingtao Jiang Department Electrical and Computer Engineering University of Nevada Las Vegas.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 4 - Verilog 2 (Sequential.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI System Design Lecture 4 - Advanced Verilog.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 2 FPGAs & Verilog.
Digital System Design Verilog ® HDL Tasks and Functions Maziar Goudarzi.
2/3/03ΗΥ220 - Μαυροειδής Ιάκωβος1 Delays in Behavioral Verilog - Interassignment Delay  Key idea: unlike blocking delay, RHS is evaluated before delay.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Overview Logistics Last lecture Today HW5 due today
Tasks and Functions Programmable Logic Design (40-493) Fall 2001 Computer Engineering Department Sharif University of Technology Maziar Gudarzi.
ECE 2372 Modern Digital System Design
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
1 An Update on Verilog Ξ – Computer Architecture Lab 28/06/2005 Kypros Constantinides.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Slide 1 2. Verilog Elements. Slide 2 Why (V)HDL? (VHDL, Verilog etc.), Karen Parnell, Nick Mehta, “Programmable Logic Design Quick Start Handbook”, Xilinx.
Timing Model VHDL uses the following simulation cycle to model the stimulus and response nature of digital hardware Start Simulation Update Signals Execute.
3/4/20031 ECE 551: Digital System Design * & Synthesis Lecture Set 3 3.1: Verilog - User-Defined Primitives (UDPs) (In separate file) 3.2: Verilog – Operators,
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Modern VLSI Design 4e: Chapter 8 Copyright  2008 Wayne Wolf Topics Modeling with hardware description languages (HDLs).
Modern VLSI Design 3e: Chapter 8 Copyright  1998, 2002 Prentice Hall PTR Topics n Modeling with hardware description languages (HDLs).
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
1/8/ L16 Timing & Concurrency III Copyright Joanne DeGroat, ECE, OSU1 Timing & Concurrency III Delay Model foundations for simulation and.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 4: Testing, Dataflow Modeling Spring 2009.
FPGA-Based System Design Copyright  2004 Prentice Hall PTR Topics n Modeling with hardware description languages (HDLs).
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
Chapter1: Introduction Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 1-1 Chapter 1: Introduction Prof. Ming-Bo.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
Verification Presentation to SystemVerilog Basic Committee Peter Flake Nov 15, 2002.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
HDL simulation and Synthesis (Marks16)
Topics Modeling with hardware description languages (HDLs).
VLSI Testing Lecture 5: Logic Simulation
‘if-else’ & ‘case’ Statements
Timing Model Start Simulation Delay Update Signals Execute Processes
Vishwani D. Agrawal Department of ECE, Auburn University
Hardware Description Languages: Verilog
Topics Modeling with hardware description languages (HDLs).
Chapter 3: Dataflow Modeling
ECE 434 Advanced Digital System L08
The Verilog Hardware Description Language
COE 202 Introduction to Verilog
Presentation transcript:

Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 6 - Behavioral Modeling and Simulation Fall 2008 Read Verilog Handout Section 7 R. Colwell, “At Random: The Power of the Most Likely”

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling2 Today’s Outline  Motivation  Basics of Event-Driven Simulation  Delay Modeling  Structural  Behavioral  initial blocks  Functions  Tasks  System Tasks

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling3 Behavioral Modeling - Motivation  An important tool for getting designs right!  Before programming FPGA (save time)  Before ASIC fab (save $$$$)  In this case, think of behavior rather than hardware

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling4 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) A B C A B C delay=4 input event output event

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling5 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 B C A B C t=5 A=1 t=17 B=1 t=33 B=0 t=29 C=1 delay=12 t=45 C=0 Input Events Output Events

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling6 Event-Driven Simulation  Output events from AND = input events for OR  Simulation time “jumps” from event to event A B C A B C delay=3 D E delay=4 D E

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling7 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 doesn’t model delay

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling8 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

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling9 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 } } }

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling10 Representing Time in Verilog  Verilog uses “dimensionless” time units  Mapping time units to “real” time: `timescale `timescale /  Examples `timescale 1ns / 1ps `timescale 10ns / 100ps  Each module can have a different timescale (but this is not necessarily a good idea!) Time Units of # Delay Values Minimum step time used by simulator

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling11 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

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling12 Inertial Delays  What happens here? A B C A B C delay=t d t1t1 t2t2 tdtd t 2 - t 1 > t d A B C A B C delay=t d t1t1 t2t2 tdtd t 2 - t 1 < t d Event-driven model: Narrow Pulse Real gate: No change (why?)

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling13 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 < prop_delay) deschedule both events 3 Delay = De-scheduled Events

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling14 Transport Delays  What happens here? A C delay=t d Long Wire B A B tdtd Change propagated independent of pulse width

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling15 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;

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling16 Structural Delay - Gate Primitives and G1 (y1, a, b); and #5 G2 (y2, a, b); and #(7,5) G3 (y3, a, b); and #(6:7:8,4:5:6) G4 (y4, a, b); buf_if1 #(6,5,2) B1 (y5, a, enb); // 3-state buf rising delayfalling delaysingle delay value rising delay min : typ : max falling delay min : typ : max no delay value (delay = 0)rising delayturnoff delay falling delay

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling17 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

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling18 Delays in Behavioral Verilog  “Parallel” statements for procedural modeling  always - for repeated activity list) sequential_statement OR always sequential_statement  initial - for one-time activity which starts in simulation initial sequential_statement  Combine with delay operators to create complex timing behavior Event control statement

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling19 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 with delays to generate input stimulus & check outputs end // synthesis translate_on Synthesis Directive

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling20 Delays in Behavioral Verilog - Blocking Delay  Delay control statement - #n sequential_statement  Simulation effect: suspends simulation for n time units before simulating following statement  Example: clock generator always begin clk = 0; #50 clk = 1; #50 ; end null statement (suspends simulation 50 time units)

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling21 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 <= #5 b + c; d = a; b + c evaluated; change in a scheduled delayed until 5 time units elapse b + c evaluated; change in a scheduled executes immediately; gets OLD value of a!

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling22 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 5*1ns = 5ns; // rounds times to 100ps `timescale 4ns 1ns #3 // delays 3*4ns = 12ns // rounds times to 1ns

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling23 What happens when no delays are specified?  Each output event has a “delta” delay  Events processed in order of scheduling

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling24 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,… )

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling25 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)

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling26 Verilog Functions (cont'd)  Function examples: function calc_parity; input [31:0] val; begin calc_parity = ^val; end endfunction function [15:0] average; input [15:0] a, b, c, d; begin average = (a + b + c + d) >> 2; end endfunction;

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling27 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)

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling28 Verilog Tasks (cont'd)  Task example: task ReverseByte; input [7:0] a; output [7:0] ra; integer j; begin for (j = 7; j >=0; j=j-1) ra[j] = a[7-j]; end endtask // Adapted from "Verilog HDL Synthesis: A Practical // Primer", by J. Bhasker

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling29 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 wire s and reg s $display("Error at time %t: value is %h, expected %h", $time, actual_value, expected_value);

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling30 Some useful System Tasks  $time - return current simulation time  $monitor - print message when values change $monitor("cs=%b, ns=%b", cs, ns)  Simulation control tasks  $stop - interrupt simulation  $finish - terminate simulation  Extensive file I/O also available

ECE 491 Fall 2008Lecture 6 - Behavioral Modeling31 Coming Up  Verification and Testbenches  Engineering Design  Serial Data Communication