L15 – Specification of State Machines

Slides:



Advertisements
Similar presentations
VHDL 5 FINITE STATE MACHINES (FSM) Some pictures are obtained from FPGA Express VHDL Reference Manual, it is accessible from the machines in the lab at.
Advertisements

©2004 Brooks/Cole FIGURES FOR CHAPTER 16 SEQUENTIAL CIRCUIT DESIGN Click the mouse to move to the next page. Use the ESC key to exit this chapter. This.
9/15/09 - L6 Other Gate typesCopyright Joanne DeGroat, ECE, OSU1 Other gate types.
Tutorial 2 Sequential Logic. Registers A register is basically a D Flip-Flop A D Flip Flop has 3 basic ports. D, Q, and Clock.
9/15/09 - L23 More Sequential Circuits Copyright Joanne DeGroat, ECE, OSU1 More Sequential Circuits.
L8 – Reduction of State Tables. Reduction of states  Given a state table reduce the number of states.  Eliminate redundant states  Ref: text Unit 15.
L23 – Adder Architectures. Adders  Carry Lookahead adder  Carry select adder (staged)  Carry Multiplexed Adder  Ref: text Unit 15 9/2/2012 – ECE 3561.
L9 – State Assignment and gate implementation. States Assignment  Rules for State Assignment  Application of rule  Gate Implementation  Ref: text.
STATE DIAGRAM AND STATE TABLES
VHDL Lecture 1 Megan Peck EECS 443 Spring 08.
Lecture #24 Page 1 EE 367 – Logic Design Lecture #24 Agenda 1.State Machines Review Announcements 1.n/a.
Sequential Circuits Storage elements
CDA 3100 Recitation Week 11.
State-machine structure (Mealy)
Synchronous Sequential Logic
Review for Exam 2 Using MUXs to implement logic
CS 140 Lecture 10 Sequential Networks: Implementation Professor CK Cheng CSE Dept. UC San Diego 1.
L7 – Derivation of State Graphs and Tables – Moore Machines.
Analysis of Clocked Sequential Circuits
Registers and Counters. Register Register is built with gates, but has memory. The only type of flip-flop required in this class – the D flip-flop – Has.
9/15/09 - L20 Flip FlopsCopyright Joanne DeGroat, ECE, OSU1 Flip Flops Not a gymnastic movement.
L18 – VHDL for other counters and controllers. Other counters  More examples Gray Code counter Controlled counters  Up down counter  Ref: text Unit.
6/12/20151 Sequence Detectors Lecture Notes – Lab 4 Sequence detection is the act of recognizing a predefined series of inputs A sequence detector is a.
Lab 10 RT methodology (cont’d) Example 1 – a counter Example 2 – a repetitive-adder multiplier.
9/15/09 - L22 Sequential Circuit Design Copyright Joanne DeGroat, ECE, OSU1 Sequential Circuit Design Creating a sequential circuit to address a.
9/15/09 - L25 Registers & Load Enable Copyright Joanne DeGroat, ECE, OSU1 Registers & Load Enable.
ECE/CS 352 Digital System Fundamentals© T. Kaminski & C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapter 4 – Part 3 Tom Kaminski & Charles.
L5 – Sequential Circuit Design
State Machines.
L16 – Testbenches for state machines. VHDL Language Elements  More examples HDL coding of class examples Testbench for example  Testing of examples.
Lecture 4 – State Machine Design 9/26/20081ECE Lecture 4.
L10 – State Machine Design Topics. States Machine Design  Other topics on state machine design Equivalent sequential machines Incompletely specified.
Chapter 10 State Machine Design. 2 State Machine Definitions State Machine: A synchronous sequential circuit consisting of a sequential logic section.
1/8/ L20 Project Step 8 - Data Path Copyright Joanne DeGroat, ECE, OSU1 State Machine Design with an HDL A methodology that works for documenting.
9/15/09 - L15 Decoders, Multiplexers Copyright Joanne DeGroat, ECE, OSU1 Decoders and Multiplexer Circuits.
L6 – Derivation of State Graphs and Tables. State Graphs and Tables  Problem Statement translation To State Graphs To State Tables  Ref: text : Unit.
Chapter 8 -- Analysis and Synthesis of Synchronous Sequential Circuits.
L16 – VHDL for State Machines with binary encoding.
Sequential Design Basics. Lecture 2 topics  A review of devices that hold state A review of Latches A review of Flip-Flops 8/22/2012 – ECE 3561 Lect.
9/15/09 - L21 Sequential Circuit Analaysis Copyright Joanne DeGroat, ECE, OSU1 Sequential Circuit Analysis.
9/15/09 - L13 Technology Mapping & Verificaiton Copyright Joanne DeGroat, ECE, OSU1 Technology Mapping and Verification.
Hardware languages "Programming"-language for modelling of (digital) hardware 1 Two main languages: VHDL (Very High Speed Integrated Circuit Hardware Description.
Analysis and Synthesis of Synchronous Sequential Circuits A “synchronizing” pulse/edge signal (clock) controls the operation of the memory portion of the.
CEC 220 Digital Circuit Design Timing Analysis of State Machines
Digital System Design using VHDL
9/15/09 - L19 Sequential CircuitsCopyright Joanne DeGroat, ECE, OSU1 Sequential Cirucits.
Project 1.  Two parts Implement a 3 bit Gray Code Counter Implement a 4-to-1 muxtiplexer  Can be done on Altera (Quartis) or Xilinx 8/22/2012 – ECE.
Common Elements in Sequential Design. Lecture 3 topics  Registers and Register Transfer  Shift Registers  Counters Basic Counter Partial sequence counters.
State Machine Design with an HDL
LAB #6 Sequential Logic Design (Flip Flops, Shift Registers)
Week #7 Sequential Circuits (Part B)
L5 – Sequential Circuit Design
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
FIGURE 5.1 Block diagram of sequential circuit
Digital Design Lecture 9
ECE 4110–5110 Digital System Design
Using CAD Tools to implement Digital Circuits
ECE 3130 – Digital Electronics and Design
Recap D flip-flop based counter Flip-flop transition table
CSE 370 – Winter Sequential Logic-2 - 1
L10 – additional State Machine examples
State Machine Design with an HDL
L11 – Midterm Review.
SYEN 3330 Digital Systems Chapter 6 – Part 3 SYEN 3330 Digital Systems.
L7s Multiple Output example
L11 – State Machine Analysis
Advanced Computer Architecture Lecture 1
L4 – An overview of Quartis
L25 – Final Review AU 15 Final Exam – Classroom – Journalism 300
Copyright Joanne DeGroat, ECE, OSU
Presentation transcript:

L15 – Specification of State Machines

Copyright 2012 - Joanne DeGroat, ECE, OSU VHDL State Machines State Machine Basics VHDL for sequential elements VHDL for state machines Example – Tail light controller Example – counter Example – gray code counter Ref: text Unit 10, 17, 20 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU State Machine Basics Mealy machine – outputs are a function of current state and current inputs. Moore machine – outputs are a function of the current state only. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU State machine design To implement the state machine have option to use Traditional methodology – state graph, state table, state assignment, K-maps, implementation HDL methodology HDL description directly from word description State graph and then the HDL description 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

In HDLs need state elements HDL code for the F/Fs A simple rising edge D Flip Flop ARCHITECTURE xxx OF yyy IS BEGIN PROCESS WAIT UNTIL clk=‘1’ AND clk’event; state <= next_state; END PROCESS; Semantics : Process runs at time 0 and then holds for clock to have an event (change value) and the new value is a ‘1’. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU Another Form This is an alternative to the previous HDL ARCHITECTURE xxx OF yyy IS BEGIN PROCESS (clk) IF (clk=‘1’ AND clk’event) THEN state <= next_state; END IF; END PROCESS; Semantics – Process runs once at time 0 and then holds until signal clk has an event. It then executes the IF statement. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU D F/F with reset ENTITY dff IS PORT (clk,reset,din : IN bit; qout : OUT bit); END dff; ARCHITECTURE one of dff IS -- Entity had sig clk,reset,din: IN and qout:OUT -- td_reset and td_in are constants. BEGIN PROCESS (clk) IF (clk=‘0’ AND clk’event) THEN IF (reset =‘1’) THEN qout <=‘0’ AFTER td_reset; ELSE qout <= din AFTER td_in; END IF; END PROCESS; END one; 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU More complete D F/F PROCESS (clk,preset,clear,next_state) BEGIN -- active low preset and clear IF (preset = ‘0’) THEN state <= pr_state; --preset state ELSIF (clear = ‘0’) THEN state <= clr_state; --clear state ELSIF (clk = ‘1’ AND clk’event) THEN --rising edge state <= next_state; END IF; END PROCESS; Semantics – runs once at startup. Then whenever any of the signals in the sensitivity list change value. Asynchronous preset has priority over clear and a clock edge. clear has priority over a clock edge. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

VHDL for finite state machines Use a process to describe the next state logic, often in a case statement used for determination of the next state. Will see this in the example. Use a process to represent the latching/loading of the calculated next_state such that it becomes the current_state. This is the only process that generates sequential elements (F/Fs). The other processes represent combinational logic. Use a third process to represent the generation of the outputs from the current state and possibly the inputs. This process will have as its inputs, the current state and, depending on the type of state machine, the state machine inputs. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU Notes on VHDL style The style applies to any HDL – VHDL, Verilog, System C Documents well Easily maintainable – excellent during development as changes are easily made Style maps to physical logic – using this style can predict the number of state elements (~) that should be produced by synthesis All three styles on the last slide simulate equally well, but this style also synthesizes well. Works in XILINX and Altera tools. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU Example The T-Bird tail light problem The turn signal indicator had a light sequence on each lamp. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

State machine description State Diagram and Transition Table Output is associated with state – a Moore machine 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Goal is a HDL description Often you still start with a state diagram and state table Where to start with the code? As with all HDL – start with the interface WHAT ARE THE INPUTS AND OUTPUTS? 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

ENTITY for the controller Inputs are a signal for Right turn signal Left turn signal Hazard Clock Outputs are signals for the taillights lc, lb, la rc, rb, ra HDL code for the entity ENTITY t_bird IS PORT(rts,lts,haz : IN bit; clk : IN bit; lc,lb,la : OUT bit; ra,rb,rc : OUT bit); END t_bird; 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

For the tail light controller Inputs are signals for Right Turn Signal Left Turn Signal Hazard Clock Outputs are the signals for the lights la,lb,la ra,rb,rc 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU The ARCHITECTURE Will use 3 processes In declarative region of ARCHITECTURE will declare the state_type for the states. ARCHITECTURE state_machine OF t_bird IS TYPE state_type IS (idle,l1,l2,l3,r1,r2,r3,lr3); SIGNAL state,next_state : state_type; BEGIN 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

1st Process – sequential elements Use a process to specify the sequential elements Here need only simple D F/Fs -- Process to specify F/Fs PROCESS BEGIN WAIT UNTIL clk=‘1’ AND clk’event; state <= next_state; END PROCESS; This is the only part of the description that should result in state elements from synthesis. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

2nd Process – next state generation What is the next state given the current state and the value present on the inputs? This process can be of considerable size. Work well using a case statement. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU Next State Process Code continued A separate action for each state that based on the inputs directs the value assigned to next_state. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

3rd Process – Output signals A separate process is used to generate the final outputs. Works great for Moore type implementations. Outputs are directly assigned to. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Complete VHDL code (no output) ENTITY t_bird IS PORT(rts,lts,haz, : IN bit; clk : IN bit; lc,lb,la : OUT bit; ra,rb,rc : OUT bit); END t_bird; ARCHITECTURE state_mach OF t_bird IS TYPE state_type IS (idle,l1,l2,l3,r1,r2,r3,lr3); SIGNAL state,next_state : state_type; BEGIN -- Process to specify F/Fs PROCESS WAIT UNTIL clk=‘1’ AND clk’event; state <= next_state; END PROCESS; -- next state logic PROCESS BEGIN CASE state IS WHEN idle => IF(haz=‘1’ OR (lts=‘1’ AND rts =‘1’) THEN next_state <= lr3; ELSIF (haz=‘0’ AND (lts=‘0’ AND rts=‘1’) THEN next_state<=r1; ELSIF (haz=‘0’ AND (lts=‘’1’ AND rts=‘0’) THEN next_state<=l1; ELSE next_state <= idle; END IF: WHEN l1 => IF (haz=‘1’) THEN next_state <= lr3; ELSE next_state <= l2; END IF; WHEN l2 => IF (haz=‘1’) THEN next_state <= lr3; ELSE next_state <= l3; WHEN l3 => next_state <= idle; WHEN r1 => IF (haz=‘1’) THEN next_state <= lr3; ELSE next_state <= r2; WHEN r2 => IF (haz=‘1’) THEN next_state <= lr3; ELSE next_state <= r3; WHEN r3 => next_state <= idle; WHEN lr3 => next_state <= idle; END CASE; END PROCESS; 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Having HDL description Simulate it in a test suite to verify the design meets specifications. This is the HDL topic of verification. For this course will construct simple testbenches to do simple check. HDL code can also be synthesized. 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU Results of synthesis From a Mentor graphics tool (several years back) 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU From FPGA tools When done in Quartis – ALTERA FPGA tool Use the state machine VHDL code for synthesis 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU FPGA results From the report Combination LUTs – 15 Dedicated logic registers – 8 (did a one hot encoding) Total pins 10 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU The schematic Big block for state elements 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU The implementation The one hot state machine state diagram 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU

Copyright 2012 - Joanne DeGroat, ECE, OSU Lecture summary VHDL for state machines T_bird tail light controller example VHDL Synthesis results 9/2/2012 – ECE 3561 Lect 9 Copyright 2012 - Joanne DeGroat, ECE, OSU