Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.

Slides:



Advertisements
Similar presentations
CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 7 Khurram Kazi.
Advertisements

Synchronous Sequential Logic
Combinational Logic.
Register Transfer Level
Hardware Description Language (HDL)
HDL Programming Fundamentals UNIT 3: Behavioral Descriptions OBJECTIVES  Understand the concept of sequential statements in VHDL and how they are different.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
Verilog - 1 Writing Hardware Programs in Abstract Verilog  Abstract Verilog is a language with special semantics  Allows fine-grained parallelism to.
ECE 551 Digital System Design & Synthesis Lecture 09 Synthesis of Common Verilog Constructs.
Conditional Statements  if and else if statements if (expression) if (expression) statements statements { else if (expression) { else if (expression)
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Digital System Design by Verilog University of Maryland ENEE408C.
ELEN 468 Lecture 91 ELEN 468 Advanced Logic Design Lecture 9 Behavioral Descriptions III.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Verilog HDL (Behavioral Modeling) Bilal Saqib. Behavioral Modeling.
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 Behavioral Modeling (1) Maziar Goudarzi.
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,
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
1 Verilog Digital System Design Z. Navabi, 2006 Digital Design Flow  Digital Design Flow begins with specification of the design at various levels of.
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
ECE 551 Digital System Design & Synthesis Fall 2011 Midterm Exam Overview.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
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.
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.
Chapter 5: Tasks, Functions, and UDPs Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 5-1 Ders - 5 : Görevler,
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
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.
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.
The Verilog Hardware Description Language. GUIDELINES How to write HDL code: How to write HDL code:
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.
Timing Controls in Behavioral Modeling Programmable Logic Design (40-493) Fall 2001 Computer Engineering Department Sharif University of Technology Maziar.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 12 - Introduction.
Chapter 8: Combinational Logic Modules Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 8-1 Chapter 8: Combinational.
Verilog® HDL Behavioral Modeling (2)
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Chapter 5: Tasks, Functions, and UDPs Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 5-1 Chapter 5: Tasks, Functions,
Chapter 6: Hierarchical Structural Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 6-1 Chapter 6: Hierarchical.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Logic Design with Behavioral Models Speaker: 銀子駒 Adviser:
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.
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Supplement on Verilog FF circuit examples
Figure 8.1. The general form of a sequential circuit.
‘if-else’ & ‘case’ Statements
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
101-1 Under-Graduate Project Logic Design with Behavioral Models
Chapter 4: Behavioral Modeling
The Verilog Hardware Description Language
Introduction to Verilog – Part-2 Procedural Statements
Presentation transcript:

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-2 An initial Block  Executes exactly once during simulation  Starts at simulation time 0 reg x, y, z; initial begin // complex statement x = 1`b0; y = 1`b1; z = 1`b0; #10 x = 1`b1; y = 1`b1; z = 1`b1; end initial x = 1`b0; // single statement

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-3 An always block  Starts at simulation time 0  Executes continuously during simulation reg clock; initial clock = 1`b0; always #5 clock = ~clock;

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-4 Procedural Assignments  Syntax variable_lvalue = [timing_control] expression variable_lvalue <= [timing_control] expression [timing_control] variable_lvalue = expression [timing_control] variable_lvalue <= expression  Two types  blocking  nonblocking

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-5 Procedural Assignments  The bit widths  Keeping the least significant bits  Zero-extended in the most significant bits

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-6 Blocking Assignments  Are executed in the specified order  Use the “=“ operator // blocking assignments initial begin x = #5 1'b0; // at time 5 y = #3 1'b1; // at time 8 z = #6 1'b0; // at time 14 end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-7 Blocking Assignments output reg [3:0] sum; output reg c_out; reg [3:0] t; y, c_in) begin t = y ^ {4{c_in}}; {c_out, sum} = x + t + c_in; end Q: What is wrong with: t = y ^ c_in ? Q: Does a reg variable correspond to a memory element to be synthesized?

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-8 Nonblocking Assignments  Use the <= operator  Used to model several concurrent data transfers reg x, y, z; // nonblocking assignments initial begin x <= #5 1'b0; // at time 5 y <= #3 1'b1; // at time 3 z <= #6 1'b0; // at time 6 end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-9 Nonblocking Assignments input clk; input din; output reg [3:0] qout; // a 4-bit shift register clk) qout <= {din, qout[3:1]}; // Right shift

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-10 Race Conditions // using blocking assignment statements clock) // has race condition x = y; clock) y = x; // using nonblocking assignment statements clock) // has no race condition x <= y; clock) y <= x;

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-11 Execution of Nonblocking Statements  Read  Evaluate and schedule  Assign

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-12 Blocking vs. Nonblocking Assignments // A 4-bit shift register clk) begin qout[0] = sin; qout[1] = qout[0]; qout[2] = qout[1]; qout[3] = qout[2]; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-13 Blocking vs. Nonblocking Assignments // A 4-bit shift register clk) begin qout[0] <= sin; qout[1] <= qout[0]; qout[2] <= qout[1]; qout[3] <= qout[2]; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-14 Blocking vs. Nonblocking Assignments  Suppose that count is 1 and finish is 0 before entering the always block clk) begin: block_a count = count – 1; if (count == 0) finish = 1; end clk) begin: block_b count <= count – 1; if (count == 0) finish <= 1; end Result: finish = 1. (Different from that of gate-level.) Result: finish = 0. (Same as that of gate-level.)

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-15 Coding Styles  blocking operators (=)  combinational logic  nonblocking operators (<=)  sequential logic

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-16 Delay Timing Control  Delay timing control  Regular delay control  Intra assignment delay control

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-17 Regular Delay Control  Regular delay control  Defers the execution of the entire statement reg x, y; integer count; #25 y <= ~x; // at time 25 #15 count <= count + 1; // at time 40

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-18 Intra-Assignment Delay Control  Intra-assignment delay control  Defers the assignment to the left-hand-side variable y = #25 ~x; // assign to y at time 25 count = #15 count + 1; // assign to count at time 40 y <= #25 ~x; // assign to y at time 25 count <= #15 count + 1; // assign to count at time 15

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-19 Event Timing Control  Edge-triggered event control  Named event control  Event or control  Level-sensitive event control Q: What is an event?

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-20 Edge-Triggered Event Control  Edge-triggered event control clock) clock) clock) begin reg1 <= #25 in_1; reg2 clock) in_2 ^ in_3; reg3 <= in_1; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-21 Named Event Control  A named event event received_data; // declare clock) if (last_byte) -> received_data; // trigger // recognize begin... end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-22 Event or Control  Event or control  or ,  * or (*) means any signals clock or negedge reset_n) if (!reset_n) q <= 1`b0; else q <= d;

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-23 Level-Sensitive Event Control  Level-sensitive event control always wait (count_enable) count = count –1 ; always wait (count_enable) #10 count = count –1 ;

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-24 if…else Statement  Syntax if ( ) true_statement ; else false_statement; if ( ) true_statement1; else if ( ) true_statement2; else false_statement;

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-25 if…else Statement // using if…else statement begin if (s1) begin if (s0) out = i3; else out = i2; end else begin if (s0) out = i1; else out = i0; end end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-26 A Simple 4-bit Counter // the body of the 4-bit counter. clock or posedge clear) if (clear) qout <= 4'd0; else qout <= (qout + 1) ; // qout = (qout + 1) % 16;

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-27 case (casex/casez) Statement  Syntax case (case_expression) case_item1 {,case_item1}: procedural_statement1 case_item2 {,case_item2}: procedural_statement2... case_itemn {,case_itemn}: procedural_statementn [default: procedural_statement] endcase

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-28 A 4-to-1 MUX Example or I1 or I2 or I3 or S) case (S) 2'b00: Y = I0; 2'b01: Y = I1; 2'b10: Y = I2; 2'b11: Y = I3; endcase Q: Model a 3-to-1 multiplexer.

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-29 casex and casez Statements  casex and casez statements  Compare only non-x or z positions  casez treats all z values as don’t cares  casex treats all x and z values as don’t cares

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-30 casex and casez Statements // count the trailing zeros in a nibble casex (data) 4'bxxx1: out = 0; 4'bxx10: out = 1; 4'bx100: out = 2; 4'b1000: out = 3; 4'b0000: out = 4; default: out = 3'b111; endcase Q: Is the default statement necessary?

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-31 while Loop  Syntax while (condition_expr) statement; while (count < 12) count <= count + 1; while (count <= 100 && flag) begin // put statements wanted to be carried out here end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-32 while Loop // count the zeros in a byte integer i; begin out = 0; i = 0; while (i <= 7) begin // simple condition if (data[i] == 0) out = out + 1; i = i + 1; end Q: Can the if … be replaced with out = out + ~data[i] ?

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-33 while Loop // count the trailing zeros in a byte integer i; begin out = 0; i = 0; while (data[i] == 0 && i <= 7) begin // complex condition out = out + 1; i = i + 1; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-34 for Loop  Syntax for (init_expr; condition_expr; update_expr) statement; init_expr; while (condition_expr) begin statement; update_expr; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-35 for Loop // count the zeros in a byte integer i; begin out = 0; for (i = 0; i <= 7; i = i + 1) // simple condition if (data[i] == 0) out = out + 1; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-36 for Loop // count the trailing zeros in a byte integer i; begin out = 0; for (i = 0; data[i] == 0 && i <= 7; i = i + 1) out = out + 1; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-37 repeat Loop  Syntax repeat (counter_expr) statement; i = 0; repeat (32) begin state[i] = 0; i = i + 1; end repeat (cycles) clock) buffer[i] <= data; i <= i + 1; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-38 forever Loop  Syntax forever statement; initial begin clock <= 0; forever begin #10 clock <= 1; #5 clock <= 0; end

Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-39 The forever Loop Structure reg clock, x, y; initial clock) x <= y;