Two types of state machine as classified by output formation

Similar documents
EECS150 - Digital Design Lecture 19 - Finite State Machines Revisited

Sequential Circuits. Output depends only and immediately on the inputs Have no memory (dependence on past values of the inputs)

Combinational vs Sequential

Sequential Logic. E&CE 223 Digital Circuits and Systems (A. Kennings) Page 1

P U Q Q*

Asynchronous (Ripple) Counters

Digital Fundamentals: A Systems Approach

Note that none of the above MAY be a VALID ANSWER.

EITF35: Introduction to Structured VLSI Design

Digital Design, Kyung Hee Univ. Chapter 5. Synchronous Sequential Logic

Chapter 5. Introduction

Chapter 5 Synchronous Sequential Logic

Digital Logic Design Sequential Circuits. Dr. Basem ElHalawany

Counters

Modeling Latches and Flip-flops

Combinational / Sequential Logic

WEEK 10. Sequential Circuits: Analysis and Design. Page 1

P U Q Q*

Chapter 5: Synchronous Sequential Logic

Introduction to Sequential Circuits

Unit 11. Latches and Flip-Flops

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Practice Homework Problems for Module 3

Flip-Flops and Sequential Circuit Design

EECS150 - Digital Design Lecture 15 Finite State Machines. Announcements

2 Sequential Circuits

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

problem maximum score 1 28pts 2 10pts 3 10pts 4 15pts 5 14pts 6 12pts 7 11pts total 100pts

Sequential logic. Circuits with feedback. How to control feedback? Sequential circuits. Timing methodologies. Basic registers

D Latch (Transparent Latch)

Practice Homework Solution for Module 3

Finite State Machine Design

Review of digital electronics. Storage units Sequential circuits Counters Shifters

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Registers

CHAPTER 6 COUNTERS & REGISTERS

Digital Circuits ECS 371

ENGN3213 Digital Systems and Microprocessors Sequential Circuits

EET2411 DIGITAL ELECTRONICS

Counter dan Register

UNIT III. Combinational Circuit- Block Diagram. Sequential Circuit- Block Diagram

ASYNCHRONOUS COUNTER CIRCUITS

Advanced Digital Logic Design EECS 303

Final Exam review: chapter 4 and 5. Supplement 3 and 4

Chapter 5 Synchronous Sequential Logic

FPGA Implementation of Sequential Logic

FSM Implementations. TIE Logic Synthesis Arto Perttula Tampere University of Technology Fall Output. Input. Next. State.

Sequential Circuits. Sequential Logic. Circuits with Feedback. Simplest Circuits with Feedback. Memory with Cross-coupled Gates.

Digital Circuit And Logic Design I. Lecture 8

Digital Circuit And Logic Design I

IT T35 Digital system desigm y - ii /s - iii

Experiment 8 Introduction to Latches and Flip-Flops and registers

Software Engineering 2DA4. Slides 9: Asynchronous Sequential Circuits

CPS311 Lecture: Sequential Circuits

Logic and Computer Design Fundamentals. Chapter 7. Registers and Counters

Sequential Logic Circuits

Chapter 11 State Machine Design

More on Flip-Flops Digital Design and Computer Architecture: ARM Edition 2015 Chapter 3 <98> 98

Registers and Counters

Synchronous Sequential Logic

Section 6.8 Synthesis of Sequential Logic Page 1 of 8

The outputs are formed by a combinational logic function of the inputs to the circuit or the values stored in the flip-flops (or both).

Flip-Flops. Because of this the state of the latch may keep changing in circuits with feedback as long as the clock pulse remains active.

1. Convert the decimal number to binary, octal, and hexadecimal.

ELEN Electronique numérique

4 of 40. Multi-ASIC reset synchronization Good Multi-Flip-Flop. Synthesis issues with reset nets. 3 of 40. Synchronous Resets? Asynchronous Resets?

Level and edge-sensitive behaviour

! Two inverters form a static memory cell " Will hold value as long as it has power applied

Lecture 8: Sequential Logic

Figure 1 shows a simple implementation of a clock switch, using an AND-OR type multiplexer logic.

Sequential Logic. Sequential Circuits. ! Timing Methodologies " Cascading flip-flops for proper operation " Clock skew

Universal Asynchronous Receiver- Transmitter (UART)

Switching Circuits & Logic Design

Logic Design ( Part 3) Sequential Logic- Finite State Machines (Chapter 3)

Unit 9 Latches and Flip-Flops. Dept. of Electrical and Computer Eng., NCTU 1

CSE140: Components and Design Techniques for Digital Systems. More D-Flip-Flops. Tajana Simunic Rosing. Sources: TSR, Katz, Boriello & Vahid

Digital Logic Design I

Engr354: Digital Logic Circuits

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Digital Electronics II 2016 Imperial College London Page 1 of 8

L4: Sequential Building Blocks (Flip-flops, Latches and Registers)

Chapter. Synchronous Sequential Circuits

COE 202: Digital Logic Design Sequential Circuits Part 1. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Switching Circuits & Logic Design, Fall Final Examination (1/13/2012, 3:30pm~5:20pm)

CSCB58 - Lab 4. Prelab /3 Part I (in-lab) /1 Part II (in-lab) /1 Part III (in-lab) /2 TOTAL /8

Logic Design II (17.342) Spring Lecture Outline

CS8803: Advanced Digital Design for Embedded Hardware

DEDICATED TO EMBEDDED SOLUTIONS

Modeling Latches and Flip-flops

Flip-flop and Registers

Introduction. NAND Gate Latch. Digital Logic Design 1 FLIP-FLOP. Digital Logic Design 1

Analysis of Clocked Sequential Circuits

Universidad Carlos III de Madrid Digital Electronics Exercises

Unit-5 Sequential Circuits - 1

Chapter 2. Digital Circuits

2.6 Reset Design Strategy

Outline. CPE/EE 422/522 Advanced Logic Design L03. Review: Clocked D Flip-Flop with Rising-edge Trigger. Sequential Networks

The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

Sequential circuits. Same input can produce different output. Logic circuit. William Sandqvist

Chapter 7 Counters and Registers

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

Transcription:

Two types of state machine as classified by output formation Moore: outputs formed by present state only Mealy: outputs formed by present state and input Also classified by state encoding Binary : 000, 001, 010, 011, 100, 101,... Grey : 000, 001, 011, 010, 110, 100,... One Hot : 000001, 000010, 000100, 001000, 010000,... Random : 001000, 100010, 000110, 101000, 110110,...

A Moore-type state machine has the structure seen below Present state is typically held by D-type flip-flops The machine will transition to the next state as determined by the current inputs and the present state. The next state decoder is comprised entirely of combinatorial logic The outputs are a function of the present state only. The outputs may also simply be the state flip-flop outputs.

A Mealy-type state machine has the structure seen below Present state is typically held by D-type flip-flops The machine will transition to the next state as determined by the current inputs and the present state. The next state decoder is comprised entirely of combinatorial logic The outputs are a function of present state and current inputs.

State machine diagrams document how the state machine operates States are given names (enumerated types) inside the bubbles Transitions between states are indicated by arcs Conditions for taking the arc given by a logic equation Outputs asserted in states are given by a list beside the state Mealy outputs formed are described by a separate equation State machines with no explicit control outputs should state that it only has state only outputs.

Moore state machine coding - state encoding State encoding done with enumerated types Looking up state 01001 is inefficient and leads to errors Enumerated states show up in the simulator output Declare type of state vectors directly after defining the encoding arbiter ps, arbiter ns are the present and next state vectors These are defined directly after the type declaration //enumerated states enum logic [1:0]{ IDLE = 2 b00, BBUSY = 2 b01, BWAIT = 2 b10, BFREE = 2 b11, } arbiter_ps, arbiter_ns ;

Moore state machine coding - state storage State storage is implemented with one always ff clause Inferring rising edge triggered D-FFs to hold arbiter present state Asynchronous reset, active low Transitions between states occur only at the clock edge //infer the present state vector flip flops always_ff @(posedge clk, negedge rst_n) if (!rst_n) arbiter_ps <= IDLE; //at reset, go to idle state else arbiter_ps <= arbiter_ns; //otherwise, go to the next state

Moore state machine coding - next state decoder always_comb begin gnt = 1 b0; //default assignment, output signal unique case (arbiter_ps) IDLE : if (req) arbiter_ns = BBUSY; else arbiter_ns = IDLE; BBUSY: begin gnt = 1 b1; //assert gnt if (!done) arbiter_ns = BBUSY; else if (dly) arbiter_ns = BWAIT; else arbiter_ns = BFREE; BWAIT: begin gnt = 1 b1; //assert gnt if (!dly) arbiter_ns = BFREE; else arbiter_ns = BWAIT; BFREE: if (req) arbiter_ns = BBUSY; else arbiter_ns = IDLE; case //always

Arbiter synthesis results done done U16 req dly dly req U15 n10... n8 n9 U12...g[0] U11 clk...g[1] U17 U14 n11 n6 n7 rst_n rst_n clk arbiter_ns[1] gnt gnt

Arbiter operation

Moore state machine coding - the whole enchilada module arbiter0( output logic gnt, input clk, //clock input input rst_n, //asynchronous active low reset input dly, //delay input input done, //done input input req //request input ); //define enumerated types and vectors for ps, ns enum logic [1:0]{ IDLE = 2 b00, BBUSY = 2 b01, BWAIT = 2 b10, BFREE = 2 b11, } arbiter_ps, arbiter_ns; //infer the present state vector flip flops always_ff @(posedge clk, negedge rst_n) if (!rst_n) arbiter_ps <= IDLE; else arbiter_ps <= arbiter_ns; always_comb begin gnt = 1 b0; //default, output signal case (arbiter_ps) IDLE : if (req) arbiter_ns = BBUSY; else arbiter_ns = IDLE; BBUSY: begin gnt = 1 b1; //assert gnt if (!done) arbiter_ns = BBUSY; else if ( dly) arbiter_ns = BWAIT; else arbiter_ns = BFREE; BWAIT: begin gnt = 1 b1; //assert gnt if (!dly) arbiter_ns = BFREE; else arbiter_ns = BWAIT; BFREE: if (req) arbiter_ns = BBUSY; else arbiter_ns = IDLE; case //always module

Another state machine... module glitch(output logic rd, ds input go, ws, clk, reset_n); enum reg [1:0]{ IDLE = 2 b00, READ = 2 b01, DLY = 2 b10, DONE = 2 b11} glitch_ps, glitch_ns; always_ff @(posedge clk, negedge reset_n) if (!reset_n) glitch_ps <= IDLE; else glitch_ps <= glitch_ns; always_comb begin rd = 1 b0; //default state ds = 1 b0; //default state unique case (glitch_ps) IDLE : if (go) glitch_ns = READ; else glitch_ns = IDLE; READ : begin rd = 1 b1; glitch_ns = DLY; DLY : begin rd = 1 b1; if (!ws) glitch_ns = DONE; else glitch_ns = READ; DONE : begin ds = 1 b1; glitch_ns = IDLE; case module

How is the output rd formed? Which Q output changes first? Which flip flop gets the clock edge first? Where are the flip flops located relative to each other? Which is faster Q n or Q? Which inputs on the OR or OAI gate are faster? n5 U13 go go n8 n6 U12 U15 N13 ds..._reg[0] n4 U11 U14 U10 rd rd reset_n reset_n..._reg[1] clk clk n7 ws ws

What can happen... gate simulation BTW, the RTL simulation looks perfect Glitches formed when going between states 10 -> 01 Also note ns vector transitions

Anytime we decode FF outputs glitches could occur Unequal propagation times will create the glitches Grey encoding can prevent this, but requires care Do we care? In many cases, no. OK as long as inputs stabilize prior to (clock period + tsu) Deadly if output goes to edge sensitive circuitry, eg. FIFO, DRAM

To eliminate the possibility of glitches, force the outputs to come from flip-flop outputs. How about a clean-up flip-flop?

What else could we do? By looking at the inputs and the next state vector we know what the next state will be. We also know if an output should be asserted in that next state If we are going to transition to a state with an asserted output, set an output flip-flop to be one at that time. What would this look like?

Add an extra always block to make the output flip flops Note that the case is evaluating ns not ps always_ff @(posedge clk, negedge reset_n) if (!reset_n) begin rd <= 1 b0; ds <= 1 b0; else begin rd = 1 b0; ds = 1 b0; case (glitch_ns) READ : rd = 1 b1; DLY : rd = 1 b1; DONE : ds = 1 b1; case

Another clearer way using the same idea To the present state vector, add extra state bits that are actually outputs which are asserted in the correct state This eliminates the extra always block Outputs will only come from flip-flop outputs Strip off outputs from present state vector

Glitchless state machine code module no_glitch( output rd, ds, input go, ws, clk, reset_n); //state encoding outputs present state // ds rd ps[1] ps[0] enum reg [3:0]{ IDLE = 4 b00_00, READ = 4 b01_01, DLY = 4 b01_10, DONE = 4 b10_11, } no_glitch_ns, no_glitch_ps; always_ff @(posedge clk, negedge reset_n) if (!reset_n) no_glitch_ps <= IDLE; else no_glitch_ps <= no_glitch_ns; always_comb begin unique case (no_glitch_ps) IDLE : if (go) no_glitch_ns = READ; else no_glitch_ns = IDLE; READ : no_glitch_ns = DLY; DLY : if (!ws) no_glitch_ns = DONE; else no_glitch_ns = READ; DONE : no_glitch_ns = IDLE; case assign {ds,rd} = no_glitch_ps[3:2]; module

Synthesis output from glitchless state machine Outputs rd and ds come directly from flip-flop outputs Penalty is slight increase in gate count (ff vs gates) no_glitch_ns[3] U22 rd go go U25 U24...[0] U21 U20 n14...[1] n19 n13 U27 n18 no_glitch_ps[1] n20 U17 U19 n16 U18 n15...[2] rd U26 res... ws clk ws n17 n11 reset_n clk U23...[3] ds ds n12