pld state machine design - welcome to matcecampus.matc.edu/lokkenr/elctec-131/pp...
TRANSCRIPT
![Page 1: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/1.jpg)
PLD State Machine DesignELCTEC-131
![Page 2: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/2.jpg)
State Machine Definitions State Machine:
◦ A synchronous sequential circuit consisting of a sequential logic section and a combinational logic section.
The outputs and internal flip flops (FF) progress through a predictable sequence of states in response to a clock and other control inputs.
22/15/2010 © 2009 Richard Lokken
![Page 3: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/3.jpg)
State Machine Types Moore Machine:
◦ A Finite State Machine (FSM) whose outputs are determined only by the Sequential Logic (FF) of the FSM.
Mealy Machine:
◦ An FSM whose outputs are determined by both the sequential logic and combinational logic of the FSM.
32/15/2010 © 2009 Richard Lokken
![Page 4: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/4.jpg)
State Machine Basics State Variable:
◦ The variable held in the SM (FF) that determines its present state.
A basic FSM has a memory section that holds the present state of the machine (stored in FF) and a control section that controls the next state of the machine (by clocks, inputs, and present state).
42/15/2010 © 2009 Richard Lokken
![Page 5: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/5.jpg)
Basic Block Diagram
2/15/2010 © 2009 Richard Lokken 5
![Page 6: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/6.jpg)
FSM Design Techniques Classical Design:
◦ Makes use of state tables, FF excitation tables, and Karnaugh Mapping to find FF input control logic.
VHDL Design:
◦ Uses case statements or IF THEN ELSE statements to set the design and the logic synthesis tools to define equations.
62/15/2010 © 2009 Richard Lokken
![Page 7: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/7.jpg)
Classical Design Approach Define the actual problem.
Draw a state diagram (bubble) to implement the problem.
Make a state table.
◦ Define all present states and inputs in a binary sequence.
◦ Then define the next states and outputs from the state diagram.
72/15/2010 © 2009 Richard Lokken
![Page 8: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/8.jpg)
Classical Design Approach Use FF excitation tables to determine in
what states the FF inputs must be to cause a present state to next state transition.
Find the output values for each present state/input combination.
Simplify Boolean logic for each FF input and output equations and design logic.
82/15/2010 © 2009 Richard Lokken
![Page 9: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/9.jpg)
FSM Design Example 1
Gray Code Counter that sequences
◦ {000, 001, 011, 010, 110, 111, 101, 100, 000}.
From this the state and excitation table is developed for D flip flops (see Table 10.2 in the textbook).
92/15/2010 © 2009 Richard Lokken
![Page 10: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/10.jpg)
State Diagram
2/15/2010 © 2009 Richard Lokken 10
![Page 11: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/11.jpg)
State Table
2/15/2010 © 2009 Richard Lokken 11
![Page 12: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/12.jpg)
K-Maps
2/15/2010 © 2009 Richard Lokken 12
![Page 13: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/13.jpg)
FSM Design Example 2
From the K-Maps for the inputs D0, D1, and D2, the following equations are developed:
13
12120
02011
02012
QQ QQ D
QQ QQ D
QQ QQ D
+=
+=
+=
2/15/2010 © 2009 Richard Lokken
![Page 14: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/14.jpg)
Simulation
2/15/2010 © 2009 Richard Lokken 14
![Page 15: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/15.jpg)
VHDL FSM Design Uses an enumerated type to declare state
variables.
Enumerated Type: A user-defined type in which all possible values of a named identifier are listed in a type definition.
An FSM uses a CASE statement on the enumerated type state variable.
152/15/2010 © 2009 Richard Lokken
![Page 16: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/16.jpg)
FSM VHDL Example
16
-- gray_ct1.vhd
-- 3-bit Gray code counter
-- (state machine with decoded outputs)
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
2/15/2010 © 2009 Richard Lokken
![Page 17: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/17.jpg)
FSM VHDL Entity
17
ENTITY gray_ct1 IS
PORT(
clk : IN STD_LOGIC;
q : OUT STD_LOGIC_VECTOR(2 downto 0));
END gray_ct1;
2/15/2010 © 2009 Richard Lokken
![Page 18: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/18.jpg)
FSM VHDL Architecture
18
ARCHITECTURE a OF gray_ct1 IS
TYPE STATE_TYPE IS (s0,s1,s2,s3,s4,s5,s6,s7);
SIGNAL state :STATE_TYPE;
BEGIN
PROCESS(clk)
BEGIN
2/15/2010 © 2009 Richard Lokken
![Page 19: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/19.jpg)
FSM VHDL Architecture
19
IF (clk’EVENT AND clk = ‘1’) THEN
CASE state IS
WHEN s0 => state <= s1;
WHEN s1 => state <= s2;
WHEN s2 => state <= s3;
WHEN s3 => state <= s4;
WHEN s4 => state <= s5;
2/15/2010 © 2009 Richard Lokken
![Page 20: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/20.jpg)
FSM VHDL Architecture
20
WHEN s5 => state <= s6;
WHEN s6 => state <= s7;
WHEN s7 => state <= s0;
END CASE;
END IF;
END PROCESS;
2/15/2010 © 2009 Richard Lokken
![Page 21: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/21.jpg)
FSM VHDL Architecture
21
WITH state SELECT
q <= “000” WHEN s0,
“001” WHEN s1,
“011” WHEN s2
“010” WHEN s3,
“110” WHEN s4,
“111” WHEN s5,
“101” WHEN s6,
“100” WHEN s7;
END a;2/15/2010 © 2009 Richard Lokken
![Page 22: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/22.jpg)
VHDL Output Assignment
The output assignment for the following example could have also been in the CASE test statements (in the process).
22
WHEN s0 => state <= s1;
q <= “001”;
WHEN s1 => state <= s2;
q <= “011”;
2/15/2010 © 2009 Richard Lokken
![Page 23: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/23.jpg)
FSM with Control Inputs
Same design approach used for FSM such as counters.
Uses the control inputs and clock to control the sequencing from state to state.
Inputs can also cause output changes not just FF outputs.
232/15/2010 © 2009 Richard Lokken
![Page 24: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/24.jpg)
FSM with Control Inputs
2/15/2010 © 2009 Richard Lokken 24
![Page 25: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/25.jpg)
SM Diagram Notation Bubbles contain the state name and
value (StateName/Value), such as Start/000.
Transitions between states are designated with arrows from one bubble to another.
Each transition has an ordered Input/Output, such as in1/out1.
252/15/2010 © 2009 Richard Lokken
![Page 26: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/26.jpg)
SM Diagram Notation For example, if SM is at State = Start and
if in1 = 0, it then transitions to State = Continue and out1 = 1, out2 = 0.
The arrow is drawn from start bubble to continue bubble.
On the arrow the value 0/10 is given to represent the in1/out1,out2.
262/15/2010 © 2009 Richard Lokken
![Page 27: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/27.jpg)
SM Design
State Table for the State Diagram
27
Present Status Input Next State Sync. InputsQ in1 Q JK out1 out20 0 1 1X 1 00 1 0 0X 0 01 0 0 X1 0 11 1 0 X1 0 1
Outputs
2/15/2010 © 2009 Richard Lokken
![Page 28: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/28.jpg)
SM Design
The State Excitation Tables for the JKInputs
28
Transition JK
0 to 0 0X
0 to 1 1X
1 to 0 X1
1 to 1 X0
2/15/2010 © 2009 Richard Lokken
![Page 29: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/29.jpg)
SM Design
The following equation represents the next state and output logic of the state machine.
29
Qin1Qin1Q out2
in1Q out1
1 Kin1 in1Q in1Q J
=•+•=
•=
==•+•=
2/15/2010 © 2009 Richard Lokken
![Page 30: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/30.jpg)
SM Design
The pulser SM has two outputs that are not always synchronized to clock.
The pulse out2 is always synched to a change in clock, but out1 could change if in1 changes.
The following slides show a BDF implementation of the Pulser SM.
302/15/2010 © 2009 Richard Lokken
![Page 31: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/31.jpg)
SM Design
312/15/2010 © 2009 Richard Lokken
![Page 32: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/32.jpg)
Simluation Results
2/15/2010 © 2009 Richard Lokken 32
![Page 33: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/33.jpg)
SM Pulser Architecture
Uses an enumerated type state listing of start and continue.
33
ARCHITECTURE a OF state_x1 IS
TYPE PULSER IS (start, continue);
SIGNAL sequence : PULSER;
BEGIN
PROCESS(clk)
BEGIN
2/15/2010 © 2009 Richard Lokken
![Page 34: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/34.jpg)
SM Pulser Architecture
A portion of the case statement:
34
IF(clk’EVENT AND clk = ‘1’) THEN
CASE sequence IS
WHEN start =>
IF in1 = ‘1’ THEN
sequence <= start;
out1 <= ‘0’;
out2 <= ‘0’;
2/15/2010 © 2009 Richard Lokken
![Page 35: PLD State Machine Design - Welcome to MATCecampus.matc.edu/lokkenr/elctec-131/pp lectures/pld_state_machine... · State Machine Definitions State Machine: A synchronous sequential](https://reader033.vdocument.in/reader033/viewer/2022051601/5ac31bbc7f8b9af91c8ba2f1/html5/thumbnails/35.jpg)
SM Pulser Architecture In the VHDL case statement, an IF
conditional test statement was used to check the Input Signal (in1) for State = Start.
IF in1 = 1, stay at State = Start; IF in1 = 0, then move to State = Continue (next clk).
If the present state was continue, the next state is always start, so an IF statement is not required.
352/15/2010 © 2009 Richard Lokken