Verilog® HDL Behavioral Modeling (2)

Slides:



Advertisements
Similar presentations
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.
Advertisements

Traffic light contoller using FSM
CPSC 321 Computer Architecture Andreas Klappenecker
Synchronous Sequential Logic
Combinational Logic.
Register Transfer Level
Hardware Description Language (HDL)
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
7-Segment LED Display DD: Section Mano: Section 3.10.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Design at the Register Transfer Level
Digital System Design by Verilog University of Maryland ENEE408C.
ELEN 468 Lecture 81 ELEN 468 Advanced Logic Design Lecture 8 Behavioral Descriptions II.
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.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
Verilog HDL (Behavioral Modeling) Bilal Saqib. Behavioral Modeling.
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.
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.
Digital System Design Verilog ® HDL Tasks and Functions Maziar Goudarzi.
Digital System Design Verilog ® HDL Useful Modeling Techniques Maziar Goudarzi.
Advanced Verilog EECS 270 v10/23/06.
Digital System Design Verilog ® HDL Behavioral Modeling (1) Maziar Goudarzi.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Timing control in verilog Module 3.1 Delays in Verilog.
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.
Spring 2007W. Rhett Davis with minor modification by Dean Brock UNCA ECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 7: Design Example,
Sequential Logic in Verilog
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
ECE 2372 Modern Digital System Design
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
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.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU Under-Graduate Project Logic Design with Behavioral Models Speaker: Darcy Tsai Adviser:
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Verilog Part 3 – Chapter.
Digital System Design Verilog ® HDL Behavioral Modeling Maziar Goudarzi.
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,
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.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
Introduction to ASIC flow and Verilog HDL
Timing Controls in Behavioral Modeling Programmable Logic Design (40-493) Fall 2001 Computer Engineering Department Sharif University of Technology Maziar.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Logic Design with Behavioral Models Speaker: 銀子駒 Adviser:
Digital System Design Verilog ® HDL Dataflow Modeling Maziar Goudarzi.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Modern VLSI Design 3e: Chapter 8 Copyright  1998, 2002 Prentice Hall PTR Topics n Verilog register-transfer modeling: –basics using traffic light controller;
TOPIC : SEQUENTIAL AND PARALLEL BLOCKS Module 2.3 : Behavioral modeling in verilog.
Overview Logistics Last lecture Today HW5 due today
Supplement on Verilog FF circuit examples
Figure 8.1. The general form of a sequential circuit.
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
‘if-else’ & ‘case’ Statements
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Chapter 4: Behavioral Modeling
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Verilog® HDL Behavioral Modeling (2) Digital System Design Verilog® HDL Behavioral Modeling (2) Maziar Goudarzi

Today program Behavioral Modeling Timing controls Other features 2005 Verilog HDL

Timing Controls in Behavioral Modeling

Introduction No timing controls  No advance in simulation time Three methods of timing control delay-based event-based level-sensitive 2005 Verilog HDL

Delay-based Timing Controls Delay  Duration between encountering and executing a statement Delay symbol: # Delay specification syntax: <delay> ::= #<NUMBER> ||= #<identifier> ||= #<mintypmax_exp> <,<mintypmax_exp>>*) 2005 Verilog HDL

Delay-based Timing Controls (cont’d) Types of delay-based timing controls 1. Regular delay control 2. Intra-assignment delay control 3. Zero-delay control 2005 Verilog HDL

Delay-based Timing Controls (cont’d) Regular Delay Control Symbol: non-zero delay before a procedural assignment Used in most of our previous examples 2005 Verilog HDL

Delay-based Timing Controls (cont’d) Intra-assignment Delay Control Symbol: non-zero delay to the right of the assignment operator Operation sequence: 1. Compute the right-hand-side expression at the current time. 2. Defer the assignment of the above computed value to the LHS by the specified delay. 2005 Verilog HDL

Delay-based Timing Controls (cont’d) Intra-assignment delay examples 2005 Verilog HDL

Delay-based Timing Controls (cont’d) Zero-Delay Control Symbol: #0 Different initial/always blocks in the same simulation time Execution order non-deterministic Zero-delay ensures execution after all other statements Eliminates race conditions Multiple zero-delay statements Non-deterministic execution order 2005 Verilog HDL

Delay-based Timing Controls (cont’d) Zero-delay control examples 2005 Verilog HDL

Event-based Timing Control Change in the value of a register or net Used to trigger execution of a statement or block (reactive behavior/reactivity) Types of Event-based timing control 1. Regular event control 2. Named event control 3. Event OR control 4. Level-sensitive timing control (next section) 2005 Verilog HDL

Event-based Timing Control (cont’d) Regular event control Symbol: @(<event>) Events to specify: posedge sig Change of sig from any value to 1 or from 0 to any value negedge sig Change of sig from any value to 0 or from 1 to any value sig Any chage in sig value 2005 Verilog HDL

Event-based Timing Control (cont’d) Regular event control examples 2005 Verilog HDL

Event-based Timing Control (cont’d) Named event control You can declare (name) an event, and then trigger and recognize it. Verilog keyword for declaration: event event calc_finished; Verilog symbol for triggering: -> ->calc_finished Verilog symbol for recognizing: @() @(calc_finished) 2005 Verilog HDL

Event-based Timing Control (cont’d) Named event control examples 2005 Verilog HDL

Event-based Timing Control (cont’d) Event OR control Used when need to trigger a block upon occurrence of any of a set of events. The list of the events: sensitivity list Verilog keyword: or 2005 Verilog HDL

Level-sensitive Timing Control Level-sensitive vs. event-based event-based: wait for triggering of an event (change in signal value) level-sensitive: wait for a certain condition (on values/levels of signals) Verilog keyword: wait() always wait(count_enable) #20 count=count+1; 2005 Verilog HDL

Behavioral Modeling Other Features

Contents Sequential and Parallel Blocks Special Features of Blocks 2005 Verilog HDL

Sequential and Parallel Blocks Blocks: used to group multiple statements Sequential blocks Keywords: begin end Statements are processed in order. A statement is executed only after its preceding one completes. Exception: non-blocking assignments with intra-assignment delays A delay or event is relative to the simulation time when the previous statement completed execution 2005 Verilog HDL

Sequential and Parallel Blocks (cont’d) Keywords: fork, join Statements in the blocks are executed concurrently Timing controls specify the order of execution of the statements All delays are relative to the time the block was entered The written order of statements is not important 2005 Verilog HDL

Sequential and Parallel Blocks (cont’d) initial begin x=1’b0; #5 y=1’b1; #10 z={x,y}; #20 w={y,x}; end initial fork x=1’b0; #5 y=1’b1; #10 z={x,y}; #20 w={y,x}; join 2005 Verilog HDL

Sequential and Parallel Blocks (cont’d) Parallel execution  Race conditions may arise initial begin x=1’b0; y=1’b1; z={x,y}; w={y,x}; end z, w can take either 2’b01, 2’b10 or 2’bxx, 2’bxx depending on simulator 2005 Verilog HDL

Special Features of Blocks Contents Nested blocks Named blocks Disabling named blocks 2005 Verilog HDL

Special Features of Blocks (cont’d) Nested blocks Sequential and parallel blocks can be mixed initial begin x=1’b0; fork #5 y=1’b1; #10 z={x,y}; join #20 w={y,x}; end 2005 Verilog HDL

Special Features of Blocks (cont’d) Named blocks Syntax: begin: <the_name> fork: <the_name> … … end join Advantages: Can have local variables Are part of the design hierarchy. Their local variables can be accessed using hierarchical names Can be disabled 2005 Verilog HDL

Special Features of Blocks (cont’d) module top; initial begin : block1 integer i; //hiera. name: top.block1.i … end fork : block2 reg i; //hierarchical name: top.block2.i join endmodule 2005 Verilog HDL

Special Features of Blocks (cont’d) Disabling named blocks Keyword: disable Action: Similar to break in C/C++, but can disable any named block not just the inner-most block. 2005 Verilog HDL

Special Features of Blocks (cont’d) module find_true_bit; reg [15:0] flag; integer i; initial begin flag = 16'b 0010_0000_0000_0000; i = 0; begin: block1 while(i < 16) begin if (flag[i]) $display("Encountered a TRUE bit at element number %d", i); disable block1; end // if i = i + 1; end // while end // block1 end //initial endmodule 2005 Verilog HDL

Behavioral Modeling Examples

4-to-1 Multiplexer // 4-to-1 multiplexer. Port list is taken exactly from // the I/O diagram. module mux4_to_1 (out, i0, i1, i2, i3, s1, s0); // Port declarations from the I/O diagram output out; input i0, i1, i2, i3; input s1, s0; reg out; //output declared as register //recompute the signal out if any input signal changes. //All input signals that cause a recomputation of out to //occur must go into the always @(...) always @(s1 or s0 or i0 or i1 or i2 or i3) begin case ({s1, s0}) 2'b00: out = i0; 2'b01: out = i1; 2'b10: out = i2; 2'b11: out = i3; default: out = 1'bx; endcase end endmodule 2005 Verilog HDL

4-bit Counter //Binary counter module counter(Q , clock, clear); // I/O ports output [3:0] Q; input clock, clear; //output defined as register reg [3:0] Q; always @( posedge clear or negedge clock) begin if (clear) Q = 4'd0; else //Q = (Q + 1) % 16; Q = (Q + 1) ; end endmodule 2005 Verilog HDL

Traffic Signal Controller 2005 Verilog HDL

//State definition HWY CNTRY `define S0 3'd0 //GREEN RED `define TRUE 1'b1 `define FALSE 1'b0 `define RED 2'd0 `define YELLOW 2'd1 `define GREEN 2'd2 //State definition HWY CNTRY `define S0 3'd0 //GREEN RED `define S1 3'd1 //YELLOW RED `define S2 3'd2 //RED RED `define S3 3'd3 //RED GREEN `define S4 3'd4 //RED YELLOW //Delays `define Y2RDELAY 3 //Yellow to red delay `define R2GDELAY 2 //Red to Green Delay module sig_control (hwy, cntry, X, clock, clear); //I/O ports output [1:0] hwy, cntry; //2 bit output for 3 states of signal GREEN, YELLOW, RED; reg [1:0] hwy, cntry; //declare output signals are registers input X; //if TRUE, indicates that there is car on the country road, otherwise FALSE input clock, clear; //Internal state variables reg [2:0] state; reg [2:0] next_state; 2005 Verilog HDL

//Signal controller starts in S0 state initial begin state = `S0; next_state = `S0; hwy = `GREEN; cntry = `RED; end always @(posedge clock) //state changes only at positive edge of clock state = next_state; always @(state) //Compute values of main signal and country signal begin case(state) `S0: begin `S1: begin hwy = `YELLOW; `S2: begin hwy = `RED; `S3: begin cntry = `GREEN; `S4: begin cntry = `YELLOW; endcase 2005 Verilog HDL

//State machine using case statements always @(state or clear or X) begin if(clear) next_state = `S0; else case (state) `S0: if( X) next_state = `S1; `S1: begin //delay some positive edges of clock repeat(`Y2RDELAY) @(posedge clock) ; next_state = `S2; end `S2: begin //delay some positive edges of clock repeat(`R2GDELAY) @(posedge clock) next_state = `S3; `S3: if( X) next_state = `S4; `S4: begin //delay some positive edges of clock default: next_state = `S0; endcase endmodule 2005 Verilog HDL

Today Summary Timing control in behavioral statements Required to advance simulation time Different types Delay-based Event-based Level-sensitive Sequential and Parallel Blocks Special Features of Blocks Nested blocks Named blocks Disabling named blocks 2005 Verilog HDL

Other Notes Homework 6 Chapter 7, the remaining exercises (no. 5-9, 11, 16-18) Due date: Next Sunday (Azar 13th) 2005 Verilog HDL