Chapter 15:Introduction to Verilog Testbenches Objectives In this section,you will learn about designing a testbench: Creating clocks Including files Strategic.

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

Hub The Only Co-Simulation Tool of Its Kind on the Market The Only Co-Simulation Tool of Its Kind on the Market.
Stimulus and Response. Simple Stimulus Verifying the Output Self-Checking Testbenches Complex Stimulus Complex Response Predicting the Output.
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.
Verilog.
Simulation executable (simv)
CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 7 Khurram Kazi.
Combinational Logic.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Verilog Modules for Common Digital Functions
Verilog Intro: Part 1.
Hardware Description Language (HDL)
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
1 Brief Introduction to Verilog Weiping Shi. 2 What is Verilog? It is a hardware description language Originally designed to model and verify a design.
How to get a Circuit in verilog converted to hspice, connected to the micron package models, and simulating in hspice and hsimplus.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
ELEN 468 Lecture 91 ELEN 468 Advanced Logic Design Lecture 9 Behavioral Descriptions III.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
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.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 6 - Behavioral Modeling.
ELEN468 Lecture 31 ELEN 468 Advanced Logic Design Lecture 3 Simulation and Testbench.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Overview Logistics Last lecture Today HW5 due today
Week Four Design & Simulation Example slides. Agenda Review the tiny example (Minako “logic”)from last week – look at the detailed static timing report.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
SoC Verification HW #2 TA: Wei-Ting Tu Assignment: 04/12/06
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
Verilog Language Concepts
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 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
Module 2.1 Gate-Level/Structural Modeling UNIT 2: Modeling in Verilog.
CH71 Chapter 7 Hardware Description Language (HDL) By Taweesak Reungpeerakul.
Module 1.2 Introduction to Verilog
Simulating a Verilog Description module bigtest;. calc1_top D1(out_data1, out_data2, out_data3, out_data4, out_resp1, out_resp2, out_resp3, out_resp4,
Chap. 4 Modules and Ports. 2 Modules and Ports Modules Ports Hierarchical Names Summary.
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,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
1 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
George Mason University Simple Testbenches ECE 545 Lecture 4.
Component Design By the end of the course each student will design and test a MIPS processor Datapath components will be designed and tested in the next.
Assignment write a short notes on 1.Manufacturing Testing. 2.Functional Testing. 3.Files and Text I/O. 4.Differentiate the cpld and fpga architecture.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
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.
 A test bench is an HDL program used for applying stimulus to an HDL design in order to test it and observe its response during simulation.  In addition.
Verilog® HDL Behavioral Modeling (2)
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
LECTURE V TEST BENCHES. As your projects become more complex and multiple modules are employed, it will no longer be possible to simulate them as we did.
Lecture 5. Verilog HDL #3 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
TOPIC : SEQUENTIAL AND PARALLEL BLOCKS Module 2.3 : Behavioral modeling in verilog.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Reg and Wire:.
Discussion 2: More to discuss
Verilog Introduction Fall
‘if-else’ & ‘case’ Statements
Test Fixture (Testbench)
The Verilog Hardware Description Language
The Verilog Hardware Description Language
The Verilog Hardware Description Language
ECE 545 Lecture 5 Simple Testbenches.
COE 202 Introduction to Verilog
Presentation transcript:

Chapter 15:Introduction to Verilog Testbenches Objectives In this section,you will learn about designing a testbench: Creating clocks Including files Strategic use of tasks and concurrent statements Controlling and observing the design Reporting warnings and errors

The Simulation Environment This is a simplified picture of the overall simulation environment. This section concentrates on testbench development strategies. design sourcemodel librariestestbench source file input: stimulus,response simulator compile simulate file output: test pats,reports

Creating Clocks Example 1 You can define the clock in either the design or its testbench. You can define the clock either behaviorally or structurally. Here are examples of a symmetric clock: clk reg clk; always begin #10 clk = 1; #10 clk = 0; end reg start; nand #10 (clk,clk,start); initial begin start = 0; #10 start = 1; end

Creating Clocks Example 2 Here are examples of a symmetric clock with delayed startup: clk reg clk; initial begin #20 clk = 1; forever begin #10 clk = 0; #10 clk = 1; end reg start; nand #10 (clk,clk,start); initial begin #10 start = 0; #10 start = 1; end

Creating Clocks Example 3 Here are examples of an asymmetric clock with delayed startup: clk reg clk; initial begin #20 clk = 1; forever begin #5 clk = 0; #15 clk = 1; end reg start; nand #(15,5) (clk,clk,start); initial begin #5 start = 0; #15 start = 1; end

Designing Your Testbench You can make your testbench as simple or as comolex as you want. A comolex testbench would perform response berifivation on-the-fly. contro l design control observ e control observ e design sophisticated testbench simple testbench

Using Include Files Use `include files to ensure project-wide consistency of common source. `include defines.inc module clkgen (clk); output clk; reg clk; always begin #(`PERIOD/2) clk = 0; #(`PERIOD/2) clk = 1; end initial begin #(`TIMEOUT) $display(TIMEOUT ERROR); $finish; end endmodule //defines.inc `timescale 1 ns / 10 ps `define PERIOD 20 `define TIMEOUT

Using Verilog Tasks Use Verilog tasks in your testbench to encapsulate repeated operations. clk data_valid data_read task cpu_read; begin #30 data_valid = 1; wait (data_read = = 1) #20 cpu_data = data_in; wait (data_read = = 0); #20 cpu_data = 8`hzz; #30 data_valid = 0; end endtask

Using Concurrent Statements Use fork-join blocks in your testbench to concurrently activate parallel tasks. in initialize monitor execute forkjoin module inline_tb; //declare variables //instantiate designs initial begin initialize_design; fork monitor_data; monitor_error; monitor_timeout; run_test; join end endmodule

Applying Stimulus Some common stimulus application techniques include: In-line stimulus,applied from an initial block Stimulus applied from a loop or always block Stimulus applied from an array of vectors or integers Stimulus that is recorded during one simulation and played back in another simulation

In-Line Stimulus In-line stimulus has the following characteristics: You list the variables only when their values change You can easily define complex timing relationships between signals The testbench can become very long for tests of real designs module inline_tb; wire [7:0] results; reg [7:0] data_bus,addr; DUT u1 (results,data_bus,addr); initial fork #10 addr = 8`h01; #10 data_bus = 8`h23; #20 data_bus = 8`h45; #30 addr = 8`h67; #30 data_bus = 8`h89; #40 data_bus = 8`hAB; #45 $finish; join endmodule

Stimulus From Loops Stimulus applied from a loop has the following characteristics: For each iteration you assign a new stimulus vector The timing relationships between signals are regular in nature The testbench is compact module loop_tb; wrie [7:0] response; reg [7:0] stimulus; reg clk; integer i; DUT u1 (response,stimulus); inititial clk = 0; always begin #10 clk = 1; #10 clk = 0; end initial begin for (i = 0;i <= 255;i=i + clk) stimulus = i; #20 $finish; end endmodule

Stimulus From Arrays Stimulus applied from an array has the following characteristics: You can load the stimulus from a data file directly into the array For each iteration you read a new stimulus vector from the array module array_tb; wire [7:0] response; reg [7:0] stimulus,stim_array[0:15]; integer i; DUT u1 (response,stimulus); initial begin $readmemb(datafile,stim_array); for (i = 0;i <= 15;i = i + 1); #20 stimulus = stim_array[i] #20 $finish; end endmodule

Vector Capture and Playback You can capture manufacturing test vectors at the boundary of a device model. parameter period = 20 wire [7:0] response; reg [7:0] stimulus; DUT u1 (response,stimulus); always apply (stimulus); always verify (response); task capture_tb; integer MCDR,MCDS; begin MCDR = $fopen(response.dat);if (!MCDR) $finish; MCDS = $fopen(stimulus.dat);if (!MCDS) $finish; clk) #(period - 1) begin $fdisplayb (MCDR, %b,response); $fdisplayb (MCDS, %b,stimulus); end endtask

Vector Capture and Playback You can play back the saved stimulus and response vectors. parameter MAX_VECTOR = 255; wire [7:0] response; reg [7:0] stimulus,stim_array[0:255],resp_arry[0:255]; DUT u1 (response,stimulus); task playback_tb; integer MCDR,MCDS,i; begin $readmemb(response.dat,resp_array); clk) //synchronize to inactive clock stimulus = stim_array[0]; //apply 1st stimulus for (i = 0;i <=MAX_VECTOR;i = i + clk) begin if (response != = resp_array[i]) begin //check response $display(ERROR:response is %b,should be %b, response,resp_array[i], \nTEST FALLED); $finish; end if (i = = MAX_VECTOR) begin $display(TEST PASSED);$finish; end stimulus = stim_array[i + 1]; //apply next stimulus end endtask

Forcing Stimulus You can make two types of procedural continuous assignments: You can assign and deassign a register assign = This overrides any procedural assignment to the register initial begin #10 assign top.dut.fsm1.state_reg = `init_state; #20 deassign top.dut.fsm1.state_reg; end You can force and release a register or net This overrides all drivers of the signal initial begin #10 force top.dut.counter.scan_reg.q = 0; #20 release top.dut.counter.scan_reg.q; end

Reporting Warnings and Errors Use file output system tasks to report errors and warnings. A more sophisticated testbench would: Report an error to a centralized error handler Modify the test flow,depending upon the errors encountered Maintain error statistics,and report them at the end of the test task par_err_task; par_err) err_handle_task (`NONFATAL,`PARITY); endtask task cor_err_task; cor_err) err_handle_task (`NONFATAL,`CORRECTABLE endtask

Summary In this section,you learned about designing a testbench: Creating clocks Including files Strategic use of tasks and concurrent statements Controlling and observing the design Reporting warnings and errors

Review 1.What are some characteristics of a sophisticated testbench? 2.For what purpose might you define a Verilog task in your testbench? 3.What is the difference between a begin-end block and a fork-join block? 4.How can you efficienly generate regular stimulus? 5.What data type would you use to read stimulus from a file?

About Lab 8 This lab is in two parts. The objective of the first part is to use behavioral constructs to model a small combinational Arithmetic Logic Unit (ALU). In this part,you will: Model an ALU at the behavioral level Test the ALU with the proveded testbench The objective of the second part is to create a model of a 5-bit counter using Verilog behavioral constructs. In this part,you will: Model a 5-bit counter at the behavioral level Write a testbench for your xounter design