Introduction to Verilog – Part-2 Procedural Statements

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

CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 7 Khurram Kazi.
Supplement on Verilog adder examples
EE 361 Fall 2003University of Hawaii1 Hardware Design Tips EE 361 University of Hawaii.
Combinational Logic.
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
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 II CPSC 321 Andreas Klappenecker Today’s Menu Verilog, Verilog.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
Advanced Verilog EECS 270 v10/23/06.
Overview Logistics Last lecture Today HW5 due today
each of these is an instantiation of “full_adder”
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
Figure 6.1. A 2-to-1 multiplexer.
ECE 2372 Modern Digital System Design
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
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.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Use of HDLs in Teaching of Computer Hardware Courses Zvonko Vranesic and Stephen Brown University of Toronto.
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.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
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)
Verilog hdl – II.
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.
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.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Hardware Description Languages: Verilog
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
Behavioral Style Combinational Design with VHDL
Verilog Introduction Fall
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
Supplement on Verilog adder examples
‘if-else’ & ‘case’ Statements
Lecture 2 Supplement Verilog-01
Verilog-HDL-3 by Dr. Amin Danial Asham.
Behavioral Style Combinational Design with VHDL
Hardware Description Languages: Verilog
TODAY’S OUTLINE Procedural Assignments Verilog Coding Guidelines
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Introduction to Verilog
Behavioral Modeling in Verilog
Introduction to Verilog
IAS 0600 Digital Systems Design
332:437 Lecture 8 Verilog and Finite State Machines
Chapter 4: Behavioral Modeling
Lecture 2: Continuation of SystemVerilog
IAS 0600 Digital Systems Design
Introduction to Verilog
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
Dr. Tassadaq Hussain Verilog Dr. Tassadaq Hussain
Supplement on Verilog adder examples
Introduction to Verilog
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
Introduction to Digital IC Design
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Introduction to Verilog – Part-2 Procedural Statements Dr. Tassadaq Hussain www.tassadaq.ucerd.com

Verilog Procedural Statements always @(sensitivity_list) [begin] [procedural assignment statements] [if-else statements] [case statements] [while, repeat, and for loops] [task and function calls] [end] Verilog syntax requires that procedural statements be contained inside a construct called an always block.

About Always block An always block represents a hardware block in HW. A typical Verilog design module may include several always blocks each representing a part of the circuit being modeled. all the always blocks are concurrent with respect to one another. insert synthesis snapshot 3

Always block Sensitivity List The part of the always block after the @symbol, in parentheses, is called the sensitivity list. The sensitivity list simply tells the Verilog compiler which signals can directly affect the outputs produced by the always block. More simply can be written as, always @(*) Tells the compiler to include all input signals in the sensitivity list 4

Statement Order is IMPORTANT inside an Always Block An important property of the always block is that the statements it contains are evaluated in the order given in the code: This is in contrast to the continuous assignment statements, which are evaluated concurrently and hence have no meaningful order. Stay tuned for an example.

Procedural Assignment Statements Any signal assigned a value inside an always block has to be a variable of type reg or integer. There are two kinds of assignments in an Always block: Blocking assignments, denoted by the = symbol Non-blocking assignments, denoted by the <= symbol. Blocking procedural assignment “=“ The term blocking means that the assignment statement completes and updates its left-hand side before the subsequent statement is evaluated; e.g., Assume A holds the value 1 … A=2; B=A; A is left with 2, B with 2. Non-blocking procedural assignment “<=“ RHS is executed and assignment takes place at the end of the current time step e.g., Assume A holds the value 1 … A<=2; B<=A; A is left with 2, B with 1.

Blocking vs Non-Blocking: Avoid Confusion Notion of “current time step” is tricky in synthesis, so to guarantee that your simulation matches the behavior of the synthesized circuit, follow these rules: Use blocking assignments to model combinational logic within an always block. Use non-blocking assignments to implement sequential logic. Do not mix blocking and non-blocking assignments in the same always block. It is not possible to model both a combinational output and a sequential output in a single always block. Do not make assignments to the same variable from more than one always block

Procedural Statement: If-Else

Example: Statement Ordering inside an Always block module mux (w0, w1, s, f); input w0, w1, s; output reg f; always @(w0, w1, s) begin f = w0; if (s == 1) f = w1; end endmodule module mux (w0, w1, s, f); input w0, w1, s; output reg f; always @(w0, w1, s) begin if (s == 1) f = w1; f = w0; end endmodule Insert or show synthesis result here Still a MUX Not a MUX Anymore Verilog semantics specify that a signal assigned multiple values in an always construct retains the last assignment. 9

Procedural Statement: The Case (expression) The bits in expression, called the controlling expression, are checked for a match with each alternative. alternative1: begin statement; end alternative2: begin statement; end [default : begin statement; end] endcase

Case: Example module mux (w0, w1, s, f); input w0, w1, s; output reg f;   always @(w0, w1, s) case (s) 1’b0: f = w0; 1’b1: f = w1; endcase  endmodule

Using a Case to Specify a Truth-Table module fulladd (Cin, x, y, s, Cout); input Cin, x, y; output reg s, Cout;   always @(Cin, x, y) begin case ( {Cin, x, y} ) 3'b000: {Cout, s} = 'b00; 3'b001: {Cout, s} = 'b01; 3'b010: {Cout, s} = 'b01; 3'b011: {Cout, s} = 'b10; 3'b100: {Cout, s} = 'b01; 3'b101: {Cout, s} = 'b10; 3'b110: {Cout, s} = 'b10; 3'b111: {Cout, s} = 'b11; endcase end endmodule

Procedural Statement: Loop(s) Verilog includes four types of loop statements: for while repeat forever Synthesis tools typically support the for loop, which has the general form: for (initial_index; terminal_index; increment) begin statement; end

Example: for Loop x y x y x y c c c FA c c FA FA s s s MSB position 1 n – 1 1 1 c 1 c c FA c c n n ” 1 FA FA 2 s s s n – 1 1 MSB position LSB position

Example: for Loop module ripple (carryin, X, Y, S, carryout); parameter n = 4; input carryin; input [n-1:0] X, Y; output reg [n-1:0] S; output reg carryout; reg [n:0] C; integer k;   always @(X, Y, carryin) begin C[0] = carryin; for (k = 0; k <= n-1; k = k+1) S[k] = X[k] ^ Y[k] ^ C[k]; C[k+1] = (X[k] & Y[k]) | (C[k] & X[k]) | (C[k] & Y[k]); end carryout = C[n]; endmodule

Recommended Reading/Practice Stephen Brown - Fundamentals of Digital Logic with Verilog Design: Chapter-4: 4.6 – Verilog for Combinational Circuits Give practice labs, uploaded on LMS, a try to check out your skills.

THANK YOU 17