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

Slides:



Advertisements
Similar presentations
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Advertisements

CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 7 Khurram Kazi.
Combinational Logic.
Table 7.1 Verilog Operators.
Hardware Description Language (HDL)
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
ECE 551 Digital System Design & Synthesis Lecture 09 Synthesis of Common Verilog Constructs.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
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.
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.
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
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,
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
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.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
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.
CH71 Chapter 7 Hardware Description Language (HDL) By Taweesak Reungpeerakul.
Slide 1 6. VHDL/Verilog Behavioral Description. Slide 2 Verilog for Synthesis: Behavioral description Instead of instantiating components, describe them.
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.
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.
ELEN 468 Lecture 131 ELEN 468 Advanced Logic Design Lecture 13 Synthesis of Combinational Logic II.
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
M.Mohajjel. Objectives Learn How to write synthesizable Verilog code Common mistakes and how to avoid them What is synthesized for what we code Digital.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 6: Procedural Modeling Spring 2009 W. Rhett.
Verilog® HDL Behavioral Modeling (2)
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.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Chapter 6 Dataflow Modeling
Overview Logistics Last lecture Today HW5 due today
Figure 8.1. The general form of a sequential circuit.
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
Verilog Introduction Fall
‘if-else’ & ‘case’ Statements
Verilog-HDL-3 by Dr. Amin Danial Asham.
Behavioral Modeling in Verilog
101-1 Under-Graduate Project Logic Design with Behavioral Models
Chapter 4: Behavioral Modeling
The Verilog Hardware Description Language
Supplement on Verilog combinational circuit examples
ECE 551: Digital System Design & Synthesis
Introduction to Digital IC Design
Introduction to Verilog – Part-2 Procedural Statements
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

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

2005Verilog HDL2 Today program Behavioral Modeling  Concepts  Constructs

2005Verilog HDL3 Introduction The move toward higher abstractions  Gate-level modeling Netlist of gates  Dataflow modeling Boolean function assigned to a net  Now, behavioral modeling A sequential algorithm (quite similar to software) that determines the value(s) of signal(s)

2005Verilog HDL4 Structured Procedures Two basic structured procedure statements always initial  All behavioral statements can appear only inside these blocks  Each always or initial block has a separate activity flow (concurrency)  Start from simulation time 0  Cannot be nested

2005Verilog HDL5 Structured Procedures: initial statement Starts at time 0 Executes only once during a simulation Multiple initial blocks, execute in parallel  All start at time 0  Each finishes independently Syntax: initial begin // behavioral statements end

2005Verilog HDL6 Structured Procedures: initial statement (cont’d) Example: module stimulus; reg x, y, a, b, m; initial m= 1’b0; initial begin #5 a=1’b1; #25 b=1’b0; end initial begin #10 x=1’b0; #25 y=1’b1; end initial #50 $finish; endmodule

2005Verilog HDL7 Structured Procedures: always statement Start at time 0 Execute the statements in a looping fashion Example module clock_gen; reg clock; // Initialize clock at time zero initial clock = 1’b0; // Toggle clock every half-cycle (time period =20) always #10 clock = ~clock; initial #1000 $finish; endmodule Can we move this to the always block? What happens if such a $finish is not included?

2005Verilog HDL8 Procedural Assignments Assignments inside initial and always Are used to update values of reg, integer, real, or time variables  The value remains unchanged until another procedural assignment updates it  In contrast to continuous assignment (Dataflow Modeling, previous chapter)

2005Verilog HDL9 Procedural Assignments (cont’d) Syntax  =  can be reg, integer, real, time A bit-select of the above (e.g., addr[0] ) A part-select of the above (e.g., addr[31:16] ) A concatenation of any of the above  is the same as introduced in dataflow modeling  What happens if the widths do not match? LHS wider than RHS => RHS is zero-extended RHS wider than LHS => RHS is truncated (Least significant part is kept)

2005Verilog HDL10 Behavioral Modeling Statements: Conditional Statements Just the same as if-else in C Syntax: if ( ) true_statement; else false_statement; if ( ) true_statement1; else if ( ) true_statement2; else if ( ) true_statement3; else default_statement; True is 1 or non-zero False is 0 or ambiguous ( x or z ) More than one statement: begin end

2005Verilog HDL11 Conditional Statements (cont’d) Examples: if (!lock) buffer = data; if (enable) out = in; if (number_queued < MAX_Q_DEPTH) begin data_queue = data; number_queued = number_queued +1; end else $display(“Queue full! Try again.”); if (alu_control==0) y = x+z; else if (alu_control==1) y = x-z; else if (alu_control==2) y = x*z; else $display(“Invalid ALU control signal.”);

2005Verilog HDL12 Behavioral Modeling Statements: Multiway Branching Similar to switch-case statement in C Syntax: case ( ) alternative1: statement1; alternative2: statement2;... default: default_statement; // optional endcase Notes:  is compared to the alternatives in the order specified.  Default statement is optional

2005Verilog HDL13 Multiway Branching (cont’d) Examples: reg [1:0] alu_control;... case (alu_control) 2’d0: y = x + z; 2’d1: y = x – z; 2’d2: y = x * z; default: $display(“Invalid ALU control signal.”); Now, you write a 4-to-1 multiplexer.

2005Verilog HDL14 Multiway Branching (cont’d) Example 2: module mux4_to_1(out, i0, i1, i2, i3, s1, s0); output out; input i0, i1, i2, i3, s1, s0; reg out; or s0 or i0 or i1 or i2 or i3) case ({s1,s0}) 2’d0: out = i0; 2’d1: out = i1; 2’d2: out = i2; 2’d3: out = i3; endcase endmodule

2005Verilog HDL15 Multiway Branching (cont’d) The case statements compares and alternatives bit-for-bit  x and z values should match module demultiplexer1_to_4(out0, out1, out2, out3, in, s1, s0); output out0, out1, out2, out3; input in, s1, s0; or s0 or in) case( {s1, s0} ) 2’b00: begin... end 2’b01: begin... end 2’b10: begin... end 2’b11: begin... end 2’bx0, 2’bx1, 2’bxz, 2’bxx, 2’b0x, 2’b1x, 2’bzx: begin... end 2’bz0, 2’bz1, 2’bzz, 2’b0z, 2’b1z: begin... end default: $display(“Unspecified control signals”); endcase endmodule

2005Verilog HDL16 Multiway Branching (cont’d) casex and casez keywords  casez treats all z values as “don’t care”  casex treats all x and z values as “don’t care” Example: reg [3:0] integer state; casex(encoding) 4’b1xxx: next_state=3; 4’bx1xx: next_state=2; 4’bxx1x: next_state=1; 4’bxxx1: next_state=0; default: next_state=0; endcase

2005Verilog HDL17 Behavioral Modeling Statements: Loops Loops in Verilog  while, for, repeat, forever The while loop syntax: while ( ) statement; Example:  Look at p. 136 of your book

2005Verilog HDL18 Loops (cont’d) The for loop  Similar to C  Syntax: for( init_expr; cond_expr; change_expr) statement;  Example: Look at p. 137 of your book

2005Verilog HDL19 Loops (cont’d) The repeat loop  Syntax: repeat( number_of_iterations ) statement;  The number is evaluated only when the loop is first encoutered  Example: Look at p. 138 of your book

2005Verilog HDL20 Loops (cont’d) The forever loop  Syntax: forever statement;  Equivalent to while(1)  Example: Look at pp of your book

2005Verilog HDL21 Procedural Assignments (cont’d) The two types of procedural assignments  Blocking assignments  Non-blocking assignments Blocking assignments  are executed in order (sequentially)  Example: reg x, y, z; reg [15:0] reg_a, reg_b; integer count; initial begin x=0; y=1; z=1; count=0; reg_a= 16’b0; reg_b = reg_a; #15 reg_a[2] = 1’b1; #10 reg_b[15:13] = {x, y, z}; count = count + 1; end All executed at time 0 All executed at time 25 executed at time 15

2005Verilog HDL22 Procedural Assignments (cont’d) Non-blocking assignments  The next statements are not blocked for this one  Syntax:  Example: reg x, y, z; reg [15:0] reg_a, reg_b; integer count; initial begin x=0; y=1; z=1; count=0; reg_a= 16’b0; reg_b = reg_a; reg_a[2] <= #15 1’b1; reg_b[15:13] <= #10 {x, y, z}; count <= count + 1; end All executed at time 0 Scheduled to run at time 15 Scheduled to run at time 10

2005Verilog HDL23 Procedural Assignments (cont’d) Application of non-blocking assignments  Used to model concurrent data transfers  Example: Write behavioral statements to swap values of two variables  Another example clock) begin reg1 <= #1 in1; reg2 clock) in2 ^ in3; reg3 <= #1 reg1; end The old value of reg1 is used

2005Verilog HDL24 Procedural Assignments (cont’d) Race condition  When the final result of simulating two (or more) concurrent processes depends on their order of execution Example: clock) b = a; clock) a = b; Solution: clock) b <= a; clock) a <= b; clock) begin temp_b = b; temp_a = a; b = temp_a; a = temp_b; end

2005Verilog HDL25 Procedural Assignments (cont’d) Recommendation  Concurrent data transfers => race condition  Use non-blocking assignments wherever concurrent data transfers  Example: pipeline modeling  Disadvantage: Lower simulation performance Higher memory usage in the simulator

2005Verilog HDL26 What we learned today What is behavioral modeling What are the Verilog constructs for behavioral modeling Statements used in behavioral modeling  Procedural assignment Blocking vs. non-blocking  Conditional  Multiway branching  Loops

2005Verilog HDL27 Other Notes Homework 5  Chapter 7 exercises 1-4, 10, 12, 13, 14, 15  Due date: Next Sunday (Azar 6 th )