Download presentation
Presentation is loading. Please wait.
1
CSE 370 – Winter 2002 - Sequential Logic-2 - 1
Overview Last lecture “Complex” counters Finite state machines Example: Parity checker Today Example: Ant in a maze More on Moore vs. Mealy 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 1
2
Example: ant brain (Ward, MIT)
Sensors: L and R antennae, 1 if in touching wall Actuators: F - forward step, TL/TR - turn left/right slightly Goal: find way out of maze Strategy: keep the wall on the right 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 2
3
CSE 370 – Winter 2002 - Sequential Logic-2 - 3
Ant behavior A: Following wall, touching Go forward, turning left slightly B: Following wall, not touching Go forward, turning right slightly D: Hit wall again Back to state A C: Break in wall Go forward, turning right slightly E: Wall in front Turn left until... F: ...we are here, same as state B G: Turn left until... LOST: Forward until we touch something 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 3
4
CSE 370 – Winter 2002 - Sequential Logic-2 - 4
Designing an ant brain State diagram L + R L’ R LOST (F) L’ R’ E/G (TL) L + R R A (TL, F) L L’ R’ B (TR, F) L’ R’ R C (TR, F) R’ R’ 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 4
5
Synthesizing the ant brain circuit
Encode states using a set of state variables arbitrary choice - may affect cost, speed Use transition truth table define next state function for each state variable define output function for each output Implement next state and output functions using combinational logic 2-level logic (ROM/PLA/PAL) multi-level logic next state and output functions can be optimized together 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 5
6
Transition truth table
Using symbolic states and outputs LOST (F) E/G (TL) A (TL, F) B (TR, F) C (TR, F) R’ L’ R’ R L L’ R L + R state L R next state outputs LOST 0 0 LOST F LOST – 1 E/G F LOST 1 – E/G F A 0 0 B TL, F A 0 1 A TL, F A 1 – E/G TL, F B – 0 C TR, F B – 1 A TR, F 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 6
7
CSE 370 – Winter 2002 - Sequential Logic-2 - 7
Synthesis 5 states : at least 3 state variables required (X, Y, Z) state assignment (in this case, arbitrarily chosen) LOST - 000 E/G - 001 A - 010 B - 011 C - 100 state L R next state outputs X,Y,Z X', Y', Z' F TR TL it now remains to synthesize these 6 functions 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 7
8
Synthesis of next state and output functions
state inputs next state outputs X,Y,Z L R X+,Y+,Z+ F TR TL e.g. TR = X + Y Z X+ = X R’ + Y Z R’ = R’ TR 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 8
9
Circuit implementation
Outputs are a function of the current state only - Moore machine L R F TR TL Next State Current State output logic next state logic X+ Y+ Z+ X Y Z 2/28/2019 CSE 370 – Winter Sequential Logic-2 - 9
10
Don’t cares in FSM synthesis
What happens to the "unused" states (101, 110, 111)? They were exploited as don't cares to minimize the logic if the states can't happen, then we don't care what the functions do if states do happen, we may be in trouble 000 (F) 001 (TL) 010 (TL, F) 011 (TR, F) 100 (TR, F) R’ L’ R’ R L L’ R L + R 111 101 110 Ant is in deep trouble if it gets in this state 2/28/2019 CSE 370 – Winter Sequential Logic
11
CSE 370 – Winter 2002 - Sequential Logic-2 - 11
State minimization Fewer states may mean fewer state variables High-level synthesis may generate many redundant states Two states are equivalent if they are impossible to distinguish from the outputs of the FSM, i. e., for any input sequence the outputs are the same Two conditions for two states to be equivalent: 1) output must be the same in both states 2) must transition to equivalent states for all input combinations 2/28/2019 CSE 370 – Winter Sequential Logic
12
CSE 370 – Winter 2002 - Sequential Logic-2 - 12
Ant brain revisited Any equivalent states? LOST (F) E/G (TL) A (TL, F) B (TR, F) C (TR, F) R’ L’ R’ R L L’ R L + R 2/28/2019 CSE 370 – Winter Sequential Logic
13
CSE 370 – Winter 2002 - Sequential Logic-2 - 13
New improved brain Merge equivalent B and C states Behavior is exactly the same as the 5-state brain We now need only 2 state variables rather than 3 LOST (F) E/G (TL) A (TL, F) B/C (TF, F) R’ L’ R’ R L L’ R L + R 2/28/2019 CSE 370 – Winter Sequential Logic
14
New brain implementation
state inputs next state outputs X,Y L R X',Y' F TR TL X X+ Y R L X Y+ Y R L X F Y R L X TR Y R L X TL Y R L 2/28/2019 CSE 370 – Winter Sequential Logic
15
Mealy vs. Moore machines
Moore: outputs depend on current state only Mealy: outputs may depend on current state and current inputs Our ant brain is a Moore machine output does not react immediately to input change We could have specified a Mealy FSM outputs have immediate reaction to inputs as inputs change, so does next state, doesn’t commit until clocking event A L’ R’ / TR, F L / TL L’ R / TL, F react right away to leaving the wall 2/28/2019 CSE 370 – Winter Sequential Logic
16
Specifying outputs for a Moore machine
Output is a function of state only Specify output in the state-diagram state bubble Example: Detector for 01 or 10 current next reset input state state output 1 – – A 0 0 0 A B 0 0 1 A C 0 0 0 B B 0 0 1 B D 1 0 0 C E 1 0 1 C C 0 0 0 D E 1 0 1 D C 0 0 0 E B 0 0 1 E D 1 D/1 E/1 B/0 A/0 C/0 1 reset 2/28/2019 CSE 370 – Winter Sequential Logic
17
Specifying outputs for a Mealy machine
Output is a function of state and of inputs Specify outputs on transition arcs Example: Detector for 01 or 10 B A C 0/1 0/0 1/1 1/0 reset/0 current next reset input state state output 1 – – A 0 0 0 A B 0 0 1 A C 0 0 0 B B 0 0 1 B C 1 0 0 C B 1 0 1 C C 0 2/28/2019 CSE 370 – Winter Sequential Logic
18
Comparing Moore and Mealy machines
Mealy machines usually have less states React faster to inputs – don't need to wait for clock Asynchronous outputs and asynchronous feedback are dangerous Moore machines are safer to use Outputs change at clock edge (always one cycle later) May need more logic to decode state into outputs 2/28/2019 CSE 370 – Winter Sequential Logic
19
CSE 370 – Winter 2002 - Sequential Logic-2 - 19
FSM design procedure FSM-design procedure 1. State diagram and state-transition table 2. State minimization 3. State assignment (or state encoding) 4. Next-state logic minimization 5. Implement the design 2/28/2019 CSE 370 – Winter Sequential Logic
20
Example: vending machine
Release item after 15 cents are deposited Single coin slot for dimes, nickels No change Reset N Vending Machine FSM Open Coin Sensor Release Mechanism D Clock 2/28/2019 CSE 370 – Winter Sequential Logic
21
Example: vending machine (cont’d)
Suitable abstract representation tabulate typical input sequences: 3 nickels nickel, dime dime, nickel two dimes draw state diagram: inputs: N, D, reset output: open chute assumptions: assume N and D asserted for one cycle each state has a self loop for N = D = 0 (no coin) S0 Reset S1 N S2 D S3 N S4 [open] D S5 [open] N S6 [open] D S7 [open] N 2/28/2019 CSE 370 – Winter Sequential Logic
22
Example: vending machine (cont’d)
Minimize number of states - reuse states whenever possible 0¢ Reset symbolic state table present inputs next output state D N state open 0¢ ¢ ¢ ¢ – – 5¢ ¢ ¢ ¢ – – 10¢ ¢ ¢ ¢ – – 15¢ – – 15¢ 1 10¢ D 5¢ N 15¢ [open] D N N + D 2/28/2019 CSE 370 – Winter Sequential Logic
23
Example: vending machine (cont’d)
Uniquely encode states present state inputs next state output Q1 Q0 D N D1 D0 open – – – – – – – – – – – 2/28/2019 CSE 370 – Winter Sequential Logic
24
Example: vending machine (cont’d)
Mapping to logic X X X X Q1 D1 Q0 N D D0 Open D1 = Q1 + D + Q0 N D0 = Q0’ N + Q0 N’ + Q1 N + Q1 D OPEN = Q1 Q0 2/28/2019 CSE 370 – Winter Sequential Logic
25
Equivalent Mealy and Moore state diagrams
Moore machine outputs associated with state Mealy machine outputs associated with transitions 0¢ [0] 10¢ 5¢ 15¢ [1] N’ D’ + Reset D N N+D N’ D’ Reset’ Reset 0¢ 10¢ 5¢ 15¢ (N’ D’ + Reset)/0 D/0 D/1 N/0 N+D/1 N’ D’/0 Reset’/1 Reset/0 2/28/2019 CSE 370 – Winter Sequential Logic
26
Example: vending machine (cont’d)
One-hot encoding (selecting state through a bit-vector process) present state inputs next state output Q3 Q2 Q1 Q0 D N D3 D2 D1 D0 open D0 = Q0 D’ N’ D1 = Q0 N + Q1 D’ N’ D2 = Q0 D + Q1 N + Q2 D’ N’ D3 = Q1 D + Q2 D + Q2 N + Q3 OPEN = Q3 2/28/2019 CSE 370 – Winter Sequential Logic
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.