Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Chapter 11: System Design.

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);
Sequential Logic in Verilog
Synchronous Sequential Logic
Combinational Logic.
Register Transfer Level
Hardware Description Language (HDL)
Verilog. 2 Behavioral Description initial:  is executed once at the beginning. always:  is repeated until the end of simulation.
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
FPGA-Based System Design: Chapter 6 Copyright  2004 Prentice Hall PTR Register-transfer Design n Basics of register-transfer design: –data paths and controllers.
Finite State Machine Chapter 10 RTL Hardware Design by P. Chu.
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
3/20/20091 More State Machines. Multiple processes.
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)
ENEE 408C Lab Capstone Project: Digital System Design Fall 2005 Sequential Circuit Design.
55:035 Computer Architecture and Organization
ELEN 468 Advanced Logic Design
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 9: RTL Design.
Overview Logistics Last lecture Today HW5 due today
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.
Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 Ders 8: FSM Gerçekleme ve.
George Mason University ECE 545 – Introduction to VHDL ECE 545 Lecture 5 Finite State Machines.
EEE2243 Digital System Design Chapter 4: Verilog HDL (Sequential) by Muhazam Mustapha, January 2011.
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
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
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
Algorithmic state machines
VHDL Discussion Finite State Machines IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
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
Modern VLSI Design 3e: Chapter 8 Copyright  1998, 2002 Prentice Hall PTR Topics n Basics of register-transfer design: –data paths and controllers; –ASM.
Verilog hdl – II.
ECE DIGITAL LOGIC LECTURE 21: FINITE STATE MACHINE Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 11/24/2015.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
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 #
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
Overview Logistics Last lecture Today HW5 due today
Finite State Machines (part 1)
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
332:437 Lecture 8 Verilog and Finite State Machines
COE 202 Introduction to Verilog
Finite State Machines (part 1)
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
Dr. Tassadaq Hussain Introduction to Verilog – Part-4 Expressing FSM in Verilog (contd) and FSM State Encoding Dr. Tassadaq Hussain.
ECE 448 Lecture 6 Finite State Machines State Diagrams vs. Algorithmic State Machine (ASM) Charts.
Presentation transcript:

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-1 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 Register-Transfer-Level Design  Features of register-transfer-level (RTL) designs  are sequential machines.  are structural.  concentrate on functionality, not details of logic design.  Two types of register-transfer-level design are  ASM (algorithmic-state machine) chart  Datapath and controller

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-15 ASM Charts  ASM (algorithmic state machine) charts  specify RTL operations on the per-cycle basis.  show clearly the flow of control from state to state.  are very suitable for data path-controller architectures.  An ASM chart is composed of  State block  Decision block  Conditional output block

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-16 ASM State Blocks  A state block  specifies a machine state and a set of unconditional RTL operations associated with the state.  may execute as many actions as you want and all actions in a state block occur in parallel.  occupies a clock period along with its related operations.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-17 Decision Blocks  A decision block  describes the condition under which ASM will execute specific actions.  selects the next state based on the value of primary input or present state.  can be drawn in either two-way selection or multi-way selection. Two-way selectionMulti-way selection

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-18 Conditional Output Blocks  A conditional output block  describes the RTL operations executed under conditions specified by one or more decision blocks.  receives signals from the output of a decision block or the other conditional output block.  can only evaluate present state or primary input value on present cycle.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-19 ASM Blocks  An ASM block has exactly one entrance path and one or more exit paths. Serial testingParallel testing

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-20 ASM Charts --- ASM Blocks  ASM blocks  An ASM block contains one state block and a serial- parallel network of decision blocks and conditional output blocks.  Each ASM block describes the operations executed in one state.  The basic rules for constructing an ASM chart  Each state and its associated set of conditions must define a unique next state.  Every path of the network of conditions must terminate at a next state.  There cannot exist any loop in the network of conditions.

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-21 Invalid ASM Blocks  Undefined next state: why? Try to explain it! Undefined exit path: why? Try to explain it!

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-22 ASM Modeling Styles  Style 1a: one state register and one always block. (Not a good style!!!)  part 1: initialize, determine, update the state register, and determine RTL operations. clk or negedge start_n) if (!start_n) state <= A; else state <= …;  Style 1b: one state register and two always blocks  part 1: initialize, determine, and update the state register. clk or negedge start_n) if (!start_n) state <= A; else state <= …;  part2: determine RTL operations clk) case (state ) … or assignment statements

Chapter 11: System Design Methodology Digital System Designs and Practices Using Verilog HDL and 2008, John Wiley11-23 ASM Modeling Styles  Style 2: two state registers and three always blocks (the best style !!!!)  part 1: initialize and update the state register clk or negedge start_n) if (!start_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 RTL operations clk) case (present_state ) … Or assignment statements