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

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

Simulation executable (simv)
Supplement on Verilog adder examples
Synchronous Sequential Logic
Combinational Logic.
Register Transfer Level
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
Digital System Design Verilog ® HDL Behavioral Modeling (3) Maziar Goudarzi.
Lecture 12 Latches Section , Block Diagram of Sequential Circuit gates New output is dependent on the inputs and the preceding values.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 2.
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.
Digital System Design Verilog ® HDL Behavioral Modeling (1) Maziar Goudarzi.
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi.
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
More Examples Dataflow/Behavioral Modeling Section 4.12.
Fall 08, Oct 29ELEC Lecture 7 (updated) 1 Lecture 7: VHDL - Introduction ELEC 2200: Digital Logic Circuits Nitin Yogi
each of these is an instantiation of “full_adder”
Advanced FPGA Based System Design Lecture-9 & 10 VHDL Sequential Code By: Dr Imtiaz Hussain 1.
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.
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 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.
2-Jun-16EE5141 Chapter 3 ä The concept of the signal ä Process concurrency ä Delta time ä Concurrent and sequential statements ä Process activation by.
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 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
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
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
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.
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.
TOPIC : SEQUENTIAL AND PARALLEL BLOCKS Module 2.3 : Behavioral modeling in verilog.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Supplement on Verilog FF circuit examples
‘if-else’ & ‘case’ Statements
Lecture 2 Supplement Verilog-01
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
Supplement on Verilog adder examples
Introduction to Verilog – Part-2 Procedural Statements
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 7 Khurram Kazi

CSCI Behavioral Modeling with Verilog  Verilog allows design functionality in an algorithmic manner: i.e. describe the behavior of the model.  Design at this level resembles C programming more than it resembles digital circuit design.  Verilog is rich in behavioral construct

CSCI Topics under Behavioral Modeling  Structured procedures always and initial  Define blocking and nonblocking procedural assignments  Delay based timing control mechanism in behavioral modeling  Event based timing control mechanism in behavioral modeling  Use the level-sensitive timing control mechanism in behavioral modeling  Conditional statements using if and else  Multiway branching, using case, casex and casx statements

CSCI Topics under Behavioral Modeling  Looping statements such as while, for, repeat and forever  Define sequential and parallel blocks  Some examples

CSCI Structured procedures always and initial : Review  All statements inside an initial statement constitute an initial block  Initial block starts at time 0  Executes only once during a simulation  If there are multiple initial blocks, each block starts to execute concurrently at time 0  Each block finishes execution independently of the other blocks  Multiple behavioral statements must be grouped, typically using begin and end.

CSCI Structured procedures always and initial : Review  All statements inside an always statement constitute an always block  always block starts at time 0  Executes the statements continuously in a looping fashion  This statement is typically used to model a block of activity that is repeated continuously in a digital circuit

CSCI Procedural assignments  Procedural assignments update values of reg, integer, real or time variables  The values placed on a variable will remain unchanged until another procedural assignment updates the variable with another value

CSCI Blocking assignments  Blocking assignments are executed in the order they are specified in a sequential block  A blocking assignment will not block execution of statements that follow in a parallel block  The = operator is used to specify blocking assignments

CSCI Blocking assignments reg x, y, z; reg [15:0] reg_a, reg_b; integer count; //All behavioral statements must be inside an initial or always block initial begin x = 0; y = 1; z = 1; //scalar assignments count = 0; //Assignment to integer variables reg_a = 16’b0; reg_b = reg_a; //initialize vectors #15 reg_a[2] = 1’b1; //bit select assignment with delay #10 reg_b[15:13] = {x, y, z} //assign result of concatenation to part of a vector // {variable within these braces are concatenated} count = count + 1; // assignment to an integer (increment) end Executed at time 0 Executed at time = 15 Executed at time = 25

CSCI Nonblocking assignments  Nonblocking assignments allow scheduling of assignments without blocking execution of the statements that follow in a sequential block.  A <= operator is used to specify nonblocking assignments

CSCI Nonblocking assignments affects on the code module blocking; reg clk, reset, enable; reg x, y, z; reg [15:0] reg_a, reg_b; integer counter; initial begin reset = 1'b0; enable = 1'b0; #25 reset = 1'b1; #40 enable = 1'b1; end initial begin clk = 0; forever #10 clk = !clk; end // describing the differences between blocking and non- blocking operator // "=" blocking and "<=" non-blocking operator initial begin x = 0; y = 1; z = 1; counter = 0; reg_a <= 16'b0; reg_a <= reg_b; reg_a[2] <= #15 1'b1; //this value time 15 reg_b[15:13] <= #10 {x, y, z}; //this value time 10 // i.e. changes before reg_a counter <= counter + 1; //this value time 0 end endmodule concatenation operator: values within the curly braces are concatenated Simulator schedules a nonblocking assignment statement to execute and continues to the next statement in the block without waiting for the nonblocking statement to complete execution

CSCI Blocking vs non Blocking  The difference between the two is that one is similar to variable in VHDL and the other acts like a signal  Blocking in synonymous to = assignment (more like a variable)  Where as non blocking is represented by <= assignment (more like a signal)

CSCI Non blocking assignment: Non blocking infers two flip flop after synthesis (when clock is in the sensitivity list) module SimpleFlipFlop (clk, a, b, c); //Input ports input clk; input a; //Output ports output b, c; reg b, c; //Input ports data type //By rule all the input ports should be wires wire clk, a; clk) begin b <= a; c <= b; end endmodule

CSCI blocking assignment: blocking statement infers one flip flop in synthesis all the time (code dependent) module SimpleFlipFlop_blocking (clk, a, b, c); //Input ports input clk; input a; //Output ports output b, c; reg b, c; //Input ports data type //By rule all the input ports should be wires wire clk, a; clk) begin b = a; c = b; end endmodule Not a good way of inferring a flip flop

CSCI Why at times blocking assignment is preferred At times some designers prefer blocking as they can see sharing of resources more readily: reg [15:0] a, b, c, d, e, f, g, h; reg [16:0] x, y, z; (posedge clk) begin x = a + b + c + d + e + f; y = x + g; z = x + h; end reg [15:0] a, b, c, d, e, f, g, h; // In this example resource sharing is synthesizer reg [16:0] y, z; // dependant (posedge clk) begin y <= (a + b + c + d + e + f) + g; z <= (a + b + c + d + e + f) + h; end

CSCI Why at times blocking assignment is not desired Blocking statement can cause race condition: file first.v module first (a, b, clk) input b, clk; output a; (posedge clk) begin a = b; end file second.v module first ( b, c, clk) input c, clk; output b; (posedge clk) begin b = c; end Some simulators may evaluate module second.v and then module first. This effectively transfers contents of c to a in ONE clock cycle. This is known as simulator race condition. While some other simulators will execute module first followed by second. Hence two different simulation results AVOID USING BLOCKING STATEMENT

CSCI Inferring Latches module latches (y1, y2, y3, enable, a1, preset1, a2, preset2, a3, preset3); output y1, y2, y3; input a1, preset1; input a2, preset2; input a3, preset3; input enable; reg y1, y2, y3; (a1 or a2 or a3 or preset1 or preset2 or preset3 or enable) begin if (preset1) y1 <= 1’b1; else if (enable) y1 <= a1; if (preset2) y2 <= 1’b0; else if (enable) y2 <= a2; if (preset3) y3 <= 1’b1; else if (enable) y3 <= a3; end endmodule

CSCI Golden Rule  Golden Rule 1: To synthesize combinational logic using an always block, all inputs to the design must appear in the sensitivity list.  signers_guide/if_statement/ signers_guide/if_statement/ Good website that gives simple Verilog examples

CSCI Inferring counters module counters (y1, y2, y3, y4, y5, y6, d, clk, enable, clear, load, up_down); output [7:0] y1, y2, y3, y4, y5, y6; input [7:0] d; input clk, enable, clear, load, up_load; reg [7:0] y1, y2, y3, y4, y5, y6; integer direction; (posedge clk) begin if (enable) // enable counter y1 <= y1 + 1; end (posedge clk) begin if (load) // loadable counter y2 <= d; else y2 <= y2 + 1; end (posedge clk) begin if (clear) // Sync clear counter y3 <= 0; else y3 <= y3 + 1; end (posedge clk) begin if (up_down) // up down counter direction <= 1; else direction <= -1; y4 = y4 + direction; // NOTICE HERE // y4 assignment is outside the if else end endmodule WOULD THIS CODE GENERATE DANGLING/ UNCONNECTED WIRES OR PORTS???

CSCI Frequency Divider module div11 (clkdiv11, clk, reset_n); output clkdiv11; input clk, reset_n; reg div11; reg [3:0] counter; (posedge clk or negedge reset_n) begin if (!reset_n) counter <= 0; else if (counter == 10) counter <= 0; else counter <= counter + 1; end (posedge clk or negedge reset_n) begin if (!reset_n) div11 <= 0; else if (counter == 10) div11 <= 1; else div11 <= 0; end

CSCI Some simple ALU functions module alu (f, a, b, opcode); parameter addab = 4’b0000, inca = 4’b0001, incb = 4’b0010, andab = 4’b0011, orab = 4’b0100, nega = 4’b0101, shal = 4’b0110, shar = 4’b0111, passa = 4’b1000, passb = 4’b1001; output [7:0] f; input [7:0] a, b; input [3:0] opcode; reg [7:0] f; (a or b or opcode) begin case (opcode) addab: f <= a + b; //add inca: f <= a + 1; //increment a incb: f <= b + 1; //increment b andab: f <= a & b; //a and b orab: f <= a | b; // a or b nega: f <= !a; //negation of a shal: f <= a << 1; //shift “a” left shar: f > 1; //shift “a” right passa: f <= a; //pass a as is passb: f <= b; //pass b as is default: f <= 8’bx; defautl output endcase end endmodule

CSCI FSM with four states module state_machine (lsb, msb, up_down, clk, reset_n); output lsb, msb; input up_down, clk, reset_n; parameter [1:0] st_zero = 2’b00, st_one = 2’b01, st_two = 2’b10, st_three = 2’b11; reg lsb, msb; reg present_state, next state; (up_down or present_state) // combinatorial part begin case (present_state) //0 = up, 1 = down st_zero: if (up_down == 0) begin next_state <= st_one; lsb <= 1; msb <= 0; end else begin next_state <= st_three; lsb <= 1; msb <= 1; end st_one: if (up_down == 0) begin next_state <= st_two; lsb <= 0; msb <= 1; end else begin next_state <= st_zero; lsb <= 0; msb <= 0; end

CSCI FSM with four states cont’d st_two: if (up_down == 0) begin next_state <= st_three; lsb <= 1; msb <= 1; end else begin next_state <= st_one; lsb <= 1; msb <= 0; end st_three: if (up_down == 0) begin next_state <= st_zero; lsb <= 0; msb <= 0; end else begin next_state <= st_two; lsb <= 0; msb <= 1; end endcase end (posedge clk or negedge reset_n) //sequential part begin if (!reset_n) present_state <= st_zero; else present_state <= next_state; end endmodule

CSCI While Loop example module While_example; `define TRU 1'b1; `define FALSE 1'b0; reg [15:0] flag; integer i; //integer to keep the count in "flag" reg continue; integer count; initial begin count = 0; while (count < 128) // Execute loop till count is 27 //Exit loop at count of 128 begin $display ("Count = %d", count); count = count + 1; end initial begin flag = 16'b 0010_0000_0000_0000; i = 0; continue = `TRU; while ((i < 16) && continue) //Multiple conditions using operators begin if (flag[i]) begin $display ("Encountered a TRUE bit at element number %d", i); continue = `FALSE; end i = i + 1; end endmodule