Академический Документы
Профессиональный Документы
Культура Документы
8-1
Example: Odd Parity Checker Assert output whenever input bit stream has odd # of 1's
Present State Even Even Odd Odd Input 0 1 0 1 Next State Even Odd Odd Even Output 0 0 1 1
Reset 0
State Diagram
Present State 0 0 1 1
Input 0 1 0 1
Next State 0 1 1 0
Output 0 0 1 1
OUT = PS
Output
Input CLK
T R
Q Q
\Reset
T FF Implementation
D FF Implementation
Input Clk
Output
Basic Design Approach: Six Step Process 1. Understand the statement of the Specification 2. Obtain an abstract specification of the FSM 3. Perform a state mininimization 4. Perform state assignment 5. Choose FF types to implement FSM state register 6. Implement the FSM
1, 2 covered now; 3, 4, 5 covered later; 4, 5 generalized from the counter design procedure
8-4
Block Diagram
Open
8-5
Reset S0 N S1 D S2
Inputs: N, D, reset
S3
Output: open
8-6
Present State 0
Inputs D N 0 0 1 1 0 0 1 1 0 0 1 1 X 0 1 0 1 0 1 0 1 0 1 0 1 X
Next State 0 5 10 X 5 10 15 X 10 15 15 X 15
Output Open 0 0 0 X 0 0 0 X 0 0 0 X 1
N 5 D N 10 D N, D 15 [open]
10
15
8-7
8-8
N D Q0 K-map for D1
Q1 D Q0 N N \ Q0 Q0 \N Q1 N Q1 D D0 CLK \reset Q0 \ Q0
D1 CLK
D R
Q Q
Q1 \ Q1
D1 = Q1 + D + Q0 N
OPEN
\reset
D0 = N Q0 + Q0 N + Q1 N + Q1 D OPEN = Q1 Q0
Q RQ
8 Gates
8-9
J1 = D + Q0 N
Q1 Q0 DN Q1 Q1 Q0 DN Q1
K1 = 0
N
J0 = Q0 N + Q1 D K0 = Q1 N
Q1 \ Q1
KRQ
OPEN Q0 \ Q0
J K R
Q Q
7 Gates
8-11
Moore Machine
Xi Inputs Combinational Logic for Outputs and Next State Zk Outputs
Outputs are function solely of the current state Outputs change synchronously with state changes
State Register
Clock
State Feedback
State Register Xi Inputs Combinational Logic for Next State (Flip-flop Inputs) Clock Comb. Logic for Outputs Zk Outputs
Mealy Machine Outputs depend on state AND inputs Input change causes an immediate output change Asynchronous signals
8-12
state feedback
Reset/0 0
(N D + Reset)/0
Moore Machine
Reset
N/0
N 5
ND
Reset
8-13
States vs. Transitions Mealy Machine typically has fewer states than Moore Machine for same output sequence
0
0/0
1/0 1 1/1
8-14
X X \A
J Q C KR Q FFb \Reset
Z \B
Two Techniques for Reverse Engineering: Ad Hoc: Try input combinations to derive transition table Formal: Derive transition by analyzing the circuit
8-15
0 1 1 0 1 1
Clock
state feedback
Finite State Machine Word Problems Mapping English Language Description to Formal Specifications Four Case Studies: Finite String Pattern Recognizer Complex Counter with Decision Making Traffic Light Controller Digital Combination Lock We will use state diagrams and ASM Charts
8-18
Finite String Pattern Recognizer A finite string recognizer has one input (X) and one output (Z). The output is asserted whenever the input sequence 010 has been observed, as long as the sequence 100 has never been seen. Step 1. Understanding the problem statement Sample input/output behavior: X: 00101010010 Z: 00010101000 X: 11011010010 Z: 00000001000
8-19
Step 2. Draw State Diagrams/ASM Charts for the strings that must be recognized ( 010 , 100).
Reset
S0 [0] S1 [0]
S4 [0]
S2 [0]
S5 [0]
Outputs 1
S3 [1]
S6 [0]
Loops in State
8-20
Exit conditions from state S3: have recognized 010 if next input is 0 then have 0100! if next input is 1 then have 0101 = 01 (state S2)
S0 [0] S1 [0]
Reset
S4 [0]
S2 [0]
S5 [0]
S3 [1]
S6 [0]
8-21
Exit conditions from S1: recognizes strings of form 0 (no 1 seen) loop back to S1 if input is 0 Exit conditions from S4: recognizes strings of form 1 (no 0 seen) loop back to S4 if input is 1
Reset
S0 [0] S1 [0]
S4 [0]
S2 [0]
S5 [0]
S3 [1]
S6 [0]
8-22
S2, S5 with incomplete transitions S2 = 01; If next input is 1, then string could be prefix of (01)1(00) S4 handles just this case! S5 = 10; If next input is 1, then string could be prefix of (10)1(0) S2 handles just this case!
S0 [0] S1 [0] Reset
S4 [0]
S2 [0]
S5 [0]
S3 [1]
S6 [0]
8-23
Review of Process: Write down sample inputs and outputs to understand specification Write down sequences of states and transitions for the sequences to be recognized Add missing transitions; reuse states as much as possible Verify I/O behavior of your state diagram to insure it functions like the specification
8-24
Complex Counter A sync. 3 bit counter has a mode control M. if M = 0, the counter counts up in the binary sequence. if M = 1, the counter advances through the Gray code sequence. Binary: 000, 001, 010, 011, 100, 101, 110, 111 Gray: 000, 001, 011, 010, 110, 111, 101, 100 Valid I/O behavior:
Mode Input M 0 0 1 1 1 0 0 Current State 000 001 010 110 111 101 110 Next State (Z2 Z1 Z0) 001 010 110 111 101 110 111
8-25
One state for each output combination Add appropriate arcs for the mode control
S0 [000] Reset
S1 [001]
S2 [010]
S3 [011]
S4 [100]
S5 [101]
S6 [110]
S7 [111]
8-26
Digital Combination Lock "3 bit serial lock controls entry to locked room. Inputs are RESET, ENTER, 2 position switch for bit of key data. Locks generates an UNLOCK signal when key matches internal combination. ERROR light illuminated if key does not match combination. Sequence is: (1) Press RESET (2) enter key bit (3) Press ENTER (4) repeat (2) & (3) two more times.
8-27
Problem specification is incomplete: how do you set the internalcombination? exactly when is the ERROR light asserted?
Make reasonable assumptions: hardwired into next state logic vs. stored in internal register assert as soon as error is detected vs. wait until full combination has been entered
RESET
Operator Data
UNLOCK
ERROR
Internal Combination
L0 L1 L2
8-29
Reset + Enter
Reset
Reset Enter Comp0 KI = L0 Enter Idle0 Enter Comp1 KI = L1 Enter Idle1 Enter Comp2 KI = L2 Reset Done [Unlock] Reset Start KI L2 Error3 [Error] Reset Start Reset Idle1' Enter Error2 KI L1 Enter Idle0' Enter Error1 KI L0 Enter
8-30