Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.

Slides:



Advertisements
Similar presentations
Digital System Design-II (CSEB312)
Advertisements

FSM and Efficient Synthesizable FSM Design using Verilog
//HDL Example 8-2 // //RTL description of design example (Fig.8-9) module Example_RTL (S,CLK,Clr,E,F,A);
Counters Discussion D8.3.
Verilog in transistor level using Microwind
CDA 3100 Recitation Week 11.
//HDL Example 4-10 // //Gate-level description of circuit of Fig. 4-2 module analysis (A,B,C,F1,F2); input.
Verilog.
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Sequential Logic in Verilog
Synchronous Sequential Logic
EE 361 Fall 2003University of Hawaii1 Hardware Design Tips EE 361 University of Hawaii.
Combinational Logic.
Verilog Modules for Common Digital Functions
Review for Exam 2 Using MUXs to implement logic
Table 7.1 Verilog Operators.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
//HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input.
Analysis of Clocked Sequential Circuits
FSM Revisit Synchronous sequential circuit can be drawn like below  These are called FSMs  Super-important in digital circuit design FSM is composed.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
Digital Electronics Chapter 5 Synchronous Sequential Logic.
Latches and Flip-Flops Discussion D8.1 Section 13-9.
FSM examples.
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.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Arbitrary Waveform Discussion 12.2 Example 34. Recall Divide-by-8 Counter Use q2, q1, q0 as inputs to a combinational circuit to produce an arbitrary.
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.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
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.
Sequential Logic in Verilog
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
1 Chapter 5 Synchronous Sequential Logic 5-1 Sequential Circuits Every digital system is likely to have combinational circuits, most systems encountered.
Introduction Verilog is a HARDWARE DESCRIPTION LANGUAGE (HDL) A hardware description language is a language or means used to describe or model a digital.
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.
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 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
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.
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
 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.
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.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
Lecture 5. Verilog HDL #3 Prof. Taeweon Suh Computer Science & Engineering Korea University COSE221, COMP211 Logic Design.
1 Lecture 3: Modeling Sequential Logic in Verilog HDL.
Figure Implementation of an FSM in a CPLD..
Digital Design: With an Introduction to the Verilog HDL, 5e M. Morris Mano Michael D. Ciletti Copyright ©2013 by Pearson Education, Inc. All rights reserved.
Lecture 10 Flip-Flops/Latches
Supplement on Verilog FF circuit examples
Figure 8.1. The general form of a sequential circuit.
Last Lecture Talked about combinational logic always statements. e.g.,
EMT 351/4 DIGITAL IC DESIGN Week # Synthesis of Sequential Logic 10.
‘if-else’ & ‘case’ Statements
HDL for Sequential Circuits
FIGURE 5.1 Block diagram of sequential circuit
Chapter 5 Synchronous Sequential Logic 5-1 Sequential Circuits
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
Verilog.
332:437 Lecture 8 Verilog and Finite State Machines
COE 202 Introduction to Verilog
The Verilog Hardware Description Language
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
SYEN 3330 Digital Systems Chapter 6 – Part 3 SYEN 3330 Digital Systems.
332:437 Lecture 8 Verilog and Finite State Machines
Presentation transcript:

Verilog

2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.

3 Clock Generation initial begin clock = 1’b0; repeat (30) #10 clock = ~clock; end  Two methods: − 15 cycles of clock. − clock period = 20 time units. initial begin clock = 1’b0; #300 $finish; end always #10 clock = ~clock;

4 ? Description //HDL Example 5-1 // //Description of xxxx (See Fig.5-6) module xxxx (Q,D,control); output Q; input D,control; reg Q; (control or D) if (control = 1) Q = D; //Same as: if (control) endmodule  Output Q must be declared as reg.  Inside initial and always, if-else and case statements can be used.

5 D-Latch Description //HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input D,control; reg Q; (control or D) if (control = 1) Q = D; //Same as: if (control) endmodule  Output Q must be declared as reg.  Inside initial and always, if-else and case statements can be used.

6 D Flip-Flop Description //HDL Example 5-2 // //D flip-flop module D_FF (Q,D,CLK); output Q; input D,CLK; reg Q; (posedge CLK) Q = D; endmodule //D flip-flop with asynchronous reset. module DFF (Q,D,CLK,RST); output Q; input D,CLK,RST; reg Q; CLK or negedge RST) if (RST = 0) Q = 1'b0; // Same as: if (~RST) else Q = D; endmodule

7 T-FF Description (Structural) //HDL Example 5-3 // //T flip-flop from D flip-flop and gates module TFF (Q,T,CLK,RST); output Q; input T,CLK,RST; wire DT; assign DT = Q ^ T ; //Instantiate the D flip-flop DFF TF1 (Q,DT,CLK,RST); endmodule

8 JK-FF Description (Structural) //JK flip-flop from D flip-flop and gates module JKFF (Q,J,K,CLK,RST); output Q; input J,K,CLK,RST; wire JK; assign JK = (J & ~Q) | (~K & Q); //Instantiate D flipflop DFF JK1 (Q,JK,CLK,RST); endmodule

9 JK-FF Description (Behavioral) //HDL Example 5-4 // // Functional description of JK flip-flop module JK_FF (J,K,CLK,Q,Qnot); output Q,Qnot; input J,K,CLK; reg Q; assign Qnot = ~ Q ; (posedge CLK) case ({J,K}) 2'b00: Q = Q; 2'b01: Q = 1'b0; 2'b10: Q = 1'b1; 2'b11: Q = ~ Q; endcase endmodule  case executes one of the statements.

10 A Sequential Circuit: Schematic Diagram

11 State Diagram (Behavioral)

12 Mealy (Behavioral) module Mealy_mdl (x,y,CLK,RST); input x,CLK,RST; output y; reg y; reg [1:0] Prstate, Nxtstate; parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10, S3 = 2'b11; (posedge CLK or negedge RST) if (~RST) Prstate = S0; //Initialize to state S0 else Prstate = Nxtstate; //Clock operations (Prstate or x) //Determine next state case (Prstate) S0: if (x) Nxtstate = S1; S1: if (x) Nxtstate = S3; else Nxtstate = S0; S2: if (~x)Nxtstate = S0; S3: if (x) Nxtstate = S2; else Nxtstate = S0; endcase (Prstate or x) //Evaluate output case (Prstate) S0: y = 0; S1: if (x) y = 1'b0; else y = 1'b1; S2: if (x) y = 1'b0; else y = 1'b1; S3: if (x) y = 1'b0; else y = 1'b1; endcase endmodule  parameter defines constants.

13 Moore (Behavioral) (One always ) module Moore_mdl (x,AB,CLK,RST); input x,CLK,RST; output [1:0]AB; reg [1:0] state; parameter S0 = 2'b00, S1 = 2'b01, S2 = 2'b10, S3 = 2'b11; (posedge CLK or negedge RST) if (~RST) state = S0; //Initialize to state S0 else case (state) S0: if (~x) state = S1; S1: if (x) state = S2; else state = S3; S2: if (~x) state = S3; S3: if (~x) state = S0; endcase assign AB = state; //Output of flip-flops endmodule

14 Moore (Structural)

15 Moore (Structural) module Tcircuit (x,y,A,B,CLK,RST); input x,CLK,RST; output y,A,B; wire TA,TB; //Flip-flip input equations assign TB = x, TA = x & B; //Output equation assign y = A & B; //Instantiate T flip-flops T_FF BF (B,TB,CLK,RST); T_FF AF (A,TA,CLK,RST); endmodule //T flip-flop module T_FF (Q,T,CLK,RST); output Q; input T,CLK,RST; reg Q; (posedge CLK or negedge RST) if (~RST) Q = 1'b0; else Q = Q ^ T; endmodule

16 Testbench //Stimulus for testing sequential circuit module testTcircuit; reg x,CLK,RST; //inputs for circuit wire y,A,B; //output from circuit Tcircuit TC (x,y,A,B,CLK,RST); // instantiate circuit initial begin RST = 0; CLK = 0; #5 RST = 1; repeat (16) #5 CLK = ~CLK; end initial begin x = 0; #15 x = 1; repeat (8) #10 x = ~ x; end endmodule

17 Waveforms