Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.

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);
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Combinational Logic.
//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.
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.
Give qualifications of instructors: DAP
Finite State Machine Chapter 10 RTL Hardware Design by P. Chu.
CSE Spring Verilog for Sequential Systems - 1 Today: Verilog and Sequential Logic zFlip-flops yrepresentation of clocks - timing of state.
FSM examples.
ELEN468 Lecture 101 ELEN 468 Advanced Logic Design Lecture 10 Behavioral Descriptions IV.
CS 151 Digital Systems Design Lecture 37 Register Transfer Level
Digital System Design by Verilog University of Maryland ENEE408C.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
Dr. Turki F. Al-Somani VHDL synthesis and simulation – Part 3 Microcomputer Systems Design (Embedded Systems)
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
FPGA-Based System Design: Chapter 5 Copyright  2004 Prentice Hall PTR Topics n Basics of sequential machines. n Sequential machine specification. n Sequential.
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.
ECE 551 Digital Design And Synthesis
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.
Register Transfer Level & Design with ASM
Verilog for Synthesis Ing. Pullini Antonio
Workshop Topics - Outline
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.
Introduction to ASIC flow and Verilog HDL
1 COMP541 State Machines – 2 Registers and Counters Montek Singh Feb 11, 2010.
Digital System Design using VHDL
Verilog hdl – II.
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:
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 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.
Figure Implementation of an FSM in a CPLD..
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Hardware Description Languages: Verilog
Finite State Machines (part 1)
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
Supplement on Verilog Sequential circuit examples: FSM
Hardware Description Languages: Verilog
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
Finite State Machines (part 1)
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
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
Presentation transcript:

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve Verilog ile Modelleme

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-2 Finite-State Machines (FSMs)  A finite-state machine (FSM) M is a quintuple M = (I, O, S, , ) where I, O, and S are finite, nonempty sets of inputs, outputs, and states, respectively.  S  S is the state transition function;   is the output function such that   : I  S  O for Mealy machine;   : S  O for Moore machine.  The design issues of a finite-state machine used in digital systems are to compute both the state transition and output functions from inputs and (present) states.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-3 Types of Sequential Circuits Mealy machine Moore machine

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-4 State Encoding  Common FSM encoding options:  One-hot code  Binary code  Gray code  Random code One-hot encoding is usually used in FPGA-based design, because there are a lot of registers in theses devices.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-5 How to Realize an FSM?  Explicit fsm: States are declared explicitly.  It is so easy to write clearly and correctly.  Every synthesis tool supports this type FSM.  Almost all FSMs are written in this type.  Implicit fsm: States are not declared explicitly. The synthesis tools infer the state from the activity within a cyclic (always …) behavior.  It is so hard to write clearly and correctly.  Not every synthesis tool supports this type FSM.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-6 (Explicit) FSM Realization  An explicit fsm is usually called FSM for short.  Two major realization issues: state-register declaration and update the computation of both next-state and output functions  State register can be declared as  one register: harder to follow and model.  two registers: easier to follow and model.  Output and next state functions:  continuous assignment  function  always block  a combination of the above

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-7 FSM Modeling Styles  Style 1: one state register  part 1: initialize and update the state register clk or negedge reset_n) if (!reset_n) state <= A; else state <= next_state (state, x) ;  part 2: determine next state using function function next_state (input present_state, x) case (present_state ) … endcase endfunction  part 3: determine output function or x) case (state) … or assignment statements

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-8 FSM Modeling Styles  Style 2: two state registers  part 1: initialize and update the state register clk or negedge reset_n) if (!reset_n) present_state <= A; else present_state <= next_state;  part 2: determine next state or x) case (present_state ) … or assignment statements  part 3: determine output function or x) case (present_state ) … or assignment statements

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-9 An FSM Example --- A 0101 Sequence Detector  Design a finite-state machine to detect the pattern 0101 in the input sequence x. Assume that overlapping pattern is allowed. State diagramTiming chart Block diagram

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-10 An FSM Example --- The Sequence Detector: Style 1a // a behavioral description of 0101 sequence detector – style 1a // Mealy machine example --- Using only state register and one always block. module sequence_detector_mealy (clk, reset_n, x, z); input x, clk, reset_n; output wire z; reg [1:0] state; // Use for both ps and ns parameter A = 2'b00, B = 2'b01, C = 2'b10, D = 2'b11; // the body of sequence detector --- Using only one always block. clk or negedge reset_n) begin if (!reset_n) state <= A; else state <= fsm_next_state(state, x); end function [1:0] fsm_next_state (input [1:0] present_state, input x); reg [1:0] next_state; begin case (present_state) A: if (x) next_state = A; else next_state = B; B: if (x) next_state = C; else next_state = B; C: if (x) next_state = A; else next_state = D; D: if (x) next_state = C; else next_state = B; endcase fsm_next_state = next_state; end endfunction assign z = (x == 1 && state == D); endmodule

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-11 An FSM Example --- The Sequence Detector: style 1b // a b ehavioral description of 0101 sequence detector: style 1b // Mealy machine example --- Using only one state register and two always blocks. module sequence_detector_mealy (clk, reset_n, x, z); input x, clk, reset_n; output reg z; // Local declaration reg [1:0] state; // Use for both ps and ns parameter A = 2'b00, B = 2'b01, C = 2'b10, D = 2'b11; // the body of sequence detector --- Using two always blocks. clk or negedge reset_n) begin if (!reset_n) state <= A; else state <= fsm_next_state(state, x); end function [1:0] fsm_next_state (input [1:0] present_state, input x); …. Same as that of style 1a end endfunction // evaluate output function z or x) case (state) A: if (x) z = 1'b0; else z = 1'b0; B: if (x) z = 1'b0; else z = 1'b0; C: if (x) z = 1'b0; else z = 1'b0; D: if (x) z = 1'b1; else z = 1'b0; endcase endmodule

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-12 An FSM Example --- The Sequence Detector: style 2 // a behavioral description of 0101 sequence detector: style 2 // Mealy machine example --- using two state registers and three always blocks. module sequence_detector_mealy (clk, reset_n, x, z); input x, clk, reset_n; output z; // local declaration reg [1:0] present_state, next_state; // present state and next state reg z; parameter A = 2'b00, B = 2'b01, C = 2'b10, D = 2'b11; // initialize to state A and update state register clk or negedge reset_n) if (!reset_n) present_state <= A; else present_state <= next_state; // update present state

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-13 An FSM Example --- The Sequence Detector: style 2 // determine next state or x) case (present_state) A: if (x) next_state = A; else next_state = B; B: if (x) next_state = C; else next_state = B; C: if (x) next_state = A; else next_state = D; D: if (x) next_state = C; else next_state = B; endcase // evaluate output function z or x) case (present_state) A: if (x) z = 1'b0; else z = 1'b0; B: if (x) z = 1'b0; else z = 1'b0; C: if (x) z = 1'b0; else z = 1'b0; D: if (x) z = 1'b1; else z = 1'b0; endcase endmodule

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-14 An FSM Example --- The Sequence Detector  Both modeling styles, using one state register or two state registers, yield the same circuit as shown below.  Gate-level result RTL result Although we declare two state registers, the synthesis tool only yields one state register. Use Synplify with FSM compiler option.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-15 Coding Style  State name should be described using parameters: parameter or localparam.  Combinational logic for computing the next state should be separated from the state registers, i.e., using its own always block or a function.  The combinational logic of next state function should be implemented with a case statement.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-16 Explicit vs. Implicit FSMs // an implicit FSM example module sum_3data_implicit(clk, data, total); parameter N = 8; input clk; input [N-1:0] data; output [N-1:0] total; reg [N-1:0] total; // we do not declare state registers. always clk) total <= clk) total <= total + data; end endmodule Both implicit and explicit fsm have the same synthesized results.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-17 Explicit vs. Implicit FSMs // an explicit FSM example module sum_3data_explicit(clk, reset, data, total); parameter N = 8; input clk, reset; input [N-1:0] data; output [N-1:0] total; reg [N-1:0] total; reg [1:0] state; // declare state registers explicitly parameter A = 2'b00, B =2'b01, C = 2'b10; clk) if (reset) state <= A; else case (state) A: begin total <= data; state <= B; end B: begin total <= total + data; state <= C; end C: begin total <= total + data; state <= A; end endcase endmodule Both implicit and explicit fsm have the same synthesized results.