Conditional Statements  if and else if statements if (expression) if (expression) statements statements { else if (expression) { else if (expression)

Slides:



Advertisements
Similar presentations
//HDL Example 8-2 // //RTL description of design example (Fig.8-9) module Example_RTL (S,CLK,Clr,E,F,A);
Advertisements

Counters Discussion D8.3.
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Synchronous Sequential Logic
Combinational Logic.
Verilog Modules for Common Digital Functions
Table 7.1 Verilog Operators.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
//HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
FSM examples.
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
Design at the Register Transfer Level
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Counters Discussion 12.1 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Design example Binary Multiplier.
D Flip-Flops in Verilog Discussion 10.3 Example 27.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior : initial blocks execute.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Verilog Descriptions of Digital Systems. Electronic Lock // // Electronic combinational lock // module lock(seg7,key, valid_key, col, row, mclk, resetL)
Overview Logistics Last lecture Today HW5 due today
Sequential Logic in Verilog
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.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
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.
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.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Final Project. System Overview Description of Inputs reset: When LOW, a power on reset is performed. mode: When LOW, NORMal mode selected When HIGH,
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.
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:
Finite State Machine (FSM) Nattha Jindapetch December 2008.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
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.
 A test bench is an HDL program used for applying stimulus to an HDL design in order to test it and observe its response during simulation.  In addition.
National Taiwan University Verilog HDL Overview Prof. An-Yeu Wu Date:2002/05/17 For NTUEE Undergraduate VLSI Design Course.
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.
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
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.
Figure Implementation of an FSM in a CPLD..
Overview Logistics Last lecture Today HW5 due today
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
HDL for Sequential Circuits
Verilog-HDL-3 by Dr. Amin Danial Asham.
For NTUEE Undergraduate
Digital Logic Design Digital Design, M. Morris Mano and Michael D
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
Chapter 4: Behavioral Modeling
The Verilog Hardware Description Language
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Lecture 4: Continuation of SystemVerilog
332:437 Lecture 9 Verilog Example
332:437 Lecture 9 Verilog Example
332:437 Lecture 9 Verilog Example
Presentation transcript:

Conditional Statements  if and else if statements if (expression) if (expression) statements statements { else if (expression) { else if (expression) statements } statements } [ else [ else statements ] statements ] if (total < 60) begin if (total < 60) begin grade = C; grade = C; total_C = total_C + 1; total_C = total_C + 1; end end else if (sum < 75) begin else if (sum < 75) begin grade = B; grade = B; total_B = total_B + 1; total_B = total_B + 1; end end else grade = A; else grade = A;

Conditional Statements  case statement case (case_expression) case (case_expression) case_item_expression {, case_item_expression }: statements case_item_expression {, case_item_expression }: statements …… …… [ default: statements ] [ default: statements ] endcase endcase case (OP_CODE) case (OP_CODE) 2`b10: Z = A + B; 2`b10: Z = A + B; 2`b11: Z = A – B; 2`b11: Z = A – B; 2`b01: Z = A * B; 2`b01: Z = A * B; 2`b00: Z = A / B; 2`b00: Z = A / B; default: Z = 2`bx; default: Z = 2`bx; endcase endcase

Loop Statements  Four loop statements are supported –The for loop –The while loop –The repeat loop –The forever loop  The syntax of loop statements is very similar to that in C language  Most of the loop statements are not synthesizable in current commercial synthesizers

for loop  for (initial condition; terminating condition; increment) begin ….. end  for (i=0;i<32;i=i+1) state[i]=0;  for (i=0;i<32;i=i+2) beginstate[i]=1; state[i+32]=0; state[i+32]=0;end

repeat loop  repeat(constant number)  connot be used to loop on a general logical expression  repeat(128) begin $display( “ count=%d ”,count); count=count+1;end

forever loop  execute forever until the $finish task is encountered.  clock=1 ’ b0; forever #10 clock=~clock;

while loop  while (logical expression) begin ……. ……. end end  while ((i<128) && continue) begin $display( “ count=%d ”, count); i=i+1;end  while ((i<128) && continue) i=i+1;

Example -- ASM designed by HDL This example is referred from “ Digital Design “, M. Morris Mano

Example -- ASM designed by HDL

//RTL description of design example (Fig.8-11) module Example_RTL (S,CLK,Clr,E,F,A); //Specify inputs and outputs //See block diagram Fig input S,CLK,Clr; output E, F; output [4:1] A; //Specify system registers reg [4:1] A; //A register reg E, F; //E and F flip-flops reg [1:0] pstate, nstate; //control register //Encode the states parameter T0 = 2'b00, T1= 2'b01, T2 = 2'b11; //State transition for control logic //See state diagram Fig. 8-11(a) CLK or negedge Clr) if (~Clr) pstate = T0; //Initial state else pstate <= nstate; //Clocked operations (S or A or pstate) case (pstate) T0: if (S) nstate = T1; else nstate = T0; T1: if (A[3] & A[4]) nstate = T2; else nstate = T1; T2: nstate = T0; endcase //Register transfer operations //See list of operation Fig.8-11(b) (posedge CLK) case (pstate) T0: if (S) begin A <= 4'b0000; F <= 1'b0; end T1: begin A <= A + 1'b1; if (A[3]) E <= 1'b1; else E <= 1'b0; end T2: F <= 1'b1; endcase endmodule

Example -- ASM designed by HDL //Test bench for design example module test_design_example; reg S, CLK, Clr; wire [4:1] A; wire [4:1] A; wire E, F; wire E, F; //Instantiate design example Example_RTL dsexp (S,CLK.Clr,E,F,A); initial begin Clr = 0; S = 0; CLK = 0; #5 Clr = 1; S = 1; repeat (32) begin #5 CLK = ~ CLK; end initial $monitor("A = %b E = %b F = %b time = %0d”, A.E.F,$time); endmodule

Simulation results Table 8-2