Sequential Logic in Verilog

Slides:



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

Sequential Logic in Verilog
Synchronous Sequential Logic
Table 7.1 Verilog Operators.
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
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.
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
Digital Electronics Chapter 5 Synchronous Sequential Logic.
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
FSM examples.
Spring 20067W. Rhett Davis with minor modifications by Dean Brock ECE 406 at UNASlide 1 ECE 406 Design of Complex Digital Systems Lecture 10: 9: State.
Digital System Design by Verilog University of Maryland ENEE408C.
Copyright © 2007 Elsevier4- Chapter 4 :: Hardware Description Languages Digital Design and Computer Architecture David Money Harris and Sarah L. Harris.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Senior Design I Lecture 4 - Verilog 2 (Sequential.
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
ELEN 468 Advanced Logic Design
Advanced Verilog EECS 270 v10/23/06.
ECE 301 – Digital Electronics Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #17)
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
1 COMP541 State Machines Montek Singh Feb 8, 2012.
Sequential Logic Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer Organization and.
Lecture 6. Verilog HDL – Sequential Logic
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 551 Digital Design And Synthesis
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.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Lecture 5. Sequential Logic 2 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education & Research.
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.
Finite State Machine (FSM) Nattha Jindapetch December 2008.
VHDL Discussion Finite State Machines
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL State Machines Anselmo Lastra.
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 11, 2010.
Digital System Design using VHDL
Chapter 3 Computer System Architectures Based on
Chapter 4 Computer System Architectures Chapter 4 Based on Digital Design and Computer Architecture, 2 nd Edition David Money Harris and Sarah L. Harris.
1 COMP541 State Machines - II Montek Singh Feb 13, 2012.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU 99-1 Under-Graduate Project Design of Datapath Controllers Speaker: Shao-Wei Feng Adviser:
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 9: State Machines & Reset Behavior Spring.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 Modeling of Finite State Machines Debdeep Mukhopadhyay Associate Professor Dept of Computer Science and Engineering NYU Shanghai and IIT Kharagpur.
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Finite State Machine -Moore & Mealy Machine -State Encoding Techniques.
Pusat Pengajian Kejuruteraan Mikroelektronik EMT 351/4 DIGITAL IC DESIGN Verilog Behavioural Modeling (Part 4) Week #
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.
Chapter 4 Digital Design and Computer Architecture: ARM® Edition
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.,
Chapter 4 Digital Design and Computer Architecture, 2nd Edition
Chapter 4 Digital Design and Computer Architecture, 2nd Edition
Supplement on Verilog Sequential circuit examples: FSM
HDL Compiler Unsupport (Do NOT use in your verilog code)
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
COE 202 Introduction to Verilog
Supplement on Verilog Sequential circuit examples: FSM
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
Design of Digital Circuits Lecture 7: Sequential Logic Design
Lecture 4: Finite State Machines
Lecture 7: Verilog Part II
Presentation transcript:

Sequential Logic in Verilog Taken From Digital Design and Computer Architecture David Money Harris and Sarah L. Harris Copyright © 2007 Elsevier

Sequential Logic Verilog uses certain idioms to describe latches, flip-flops and FSMs Other coding styles may simulate correctly but produce incorrect hardware Copyright © 2007 Elsevier

Always Statement General Structure: always @ (sensitivity list) statement; Whenever the event in the sensitivity list occurs, the statement is executed Copyright © 2007 Elsevier

D Flip-Flop module flop(input clk, input [3:0] d, output reg [3:0] q); always @ (posedge clk) q <= d; // pronounced “q gets d” endmodule Any signal assigned in an always statement must be declared reg. In this case q is declared as reg Beware: A variable declared reg is not necessarily a registered output. We will show examples of this later. Copyright © 2007 Elsevier

Resettable D Flip-Flop module flopr(input clk, input reset, input [3:0] d, output reg [3:0] q); // synchronous reset always @ (posedge clk) if (reset) q <= 4'b0; else q <= d; endmodule Copyright © 2007 Elsevier

Resettable D Flip-Flop module flopr(input clk, input reset, input [3:0] d, output reg [3:0] q); // asynchronous reset always @ (posedge clk, posedge reset) if (reset) q <= 4'b0; else q <= d; endmodule Copyright © 2007 Elsevier

D Flip-Flop with Enable module flopren(input clk, input reset, input en, input [3:0] d, output reg [3:0] q); // asynchronous reset and enable always @ (posedge clk, posedge reset) if (reset) q <= 4'b0; else if (en) q <= d; endmodule Copyright © 2007 Elsevier

Latch module latch(input clk, input [3:0] d, output reg [3:0] q); always @ (clk, d) if (clk) q <= d; endmodule Warning: We won’t use latches in this course, but you might write code that inadvertently implies a latch. So if your synthesized hardware has latches in it, this indicates an error. Copyright © 2007 Elsevier

Finite State Machines (FSMs) Three blocks: next state logic state register output logic Copyright © 2007 Elsevier

FSM Example: Divide by 3 The double circle indicates the reset state Copyright © 2007 Elsevier

FSM in Verilog: Divide by 3 module divideby3FSM (input clk, input reset, output q); reg [1:0] state, nextstate; parameter S0 = 2'b00; parameter S1 = 2'b01; parameter S2 = 2'b10; // state register always @ (posedge clk, posedge reset) if (reset) state <= S0; else state <= nextstate; // next state logic always @ (*) case (state) S0: nextstate = S1; S1: nextstate = S2; S2: nextstate = S0; default: nextstate = S0; endcase // output logic assign q = (state == S0); endmodule Copyright © 2007 Elsevier

Moore vs. Mealy FSM Alyssa P. Hacker has a snail that crawls down a paper tape with 1’s and 0’s on it. The snail smiles whenever the last four digits it has crawled over are 1101. Design Moore and Mealy FSMs of the snail’s brain. Copyright © 2007 Elsevier

Snail Moore Machine snailMoore.v Copyright © 2007 Elsevier

JK Moore Machine Example 110 Detector designed with JK flip-flops Design a machine with input A and output Y Y should be one whenever the sequence 1 1 0 has been detected on A on the last 3 consecutive rising clock edges or ticks. Otherwise Y = 0 Timing diagram interpretation of word description Copyright © 2007 Elsevier

State Diagram S A NS Y 00 (S0) 1 01 (S1) 10 (S2) 11 (S3) 1 01 (S1) 10 (S2) 11 (S3) Copyright © 2007 Elsevier

Transition Tables S1 S0 A S1+S0+ J1 K1 J0 K0 Y 0 0 (S0) 0 0 (S0) x 1 0 0 (S0) x 1 0 1 (S1) 0 1 (S1) 1 0 (S2) 1 0 (S2) 1 1 (S3) 1 1 (S3) J K Q+ Q 1 ~Q Transition J K 0 => 0 x 0 => 1 1 1 => 0 1 => 1 Copyright © 2007 Elsevier

Verilog Implementation 1 Copyright © 2007 Elsevier

Verilog Implementation 2 JK FlipFlop in Verilog testBench in Verilog Copyright © 2007 Elsevier