Lecture 2 Logistics HW6 due Wednesday Lab 7 this week (Tuesday exception) Midterm 2 Friday (covers material up to simple FSM (today)) Review on Thursday Yoky office hour on Friday moved to Thursday 2-:2pm online Last lecture Counter design Finite state machine started vending machine example Today Continue on the vending machine example Moore/Mealy machines The WHY slide Finite State Machine (FSM) This is what we have been waiting for in this class. Using combinational and sequential logics, now you can design a lot of clever digital logic circuits for functional products. We will learn different steps you take to go from word problems to logic circuits. Moore/Mealy machines There are two different ways to express the FSMs with respect to the output. oth have different advantages so it is good to know them. 2
FSM design Counter-design procedure. State diagram 2. State-transition table 3. ext-state logic minimization 4. Implement the design FSM-design procedure. State diagram 2. state-transition table 3. State minimization 4. State encoding 5. ext-state logic minimization 6. Implement the design 3 Example: A vending machine 5 cents for a cup of coffee oesn t take pennies or quarters Reset oesn t provide any change Coin Sensor FSM-design procedure. State diagram 2. state-transition table 3. State minimization 4. State encoding 5. ext-state logic minimization 6. Implement the design Vending Machine FSM Clock Open Release Mechanism 4
A vending machine: (conceptual) state diagram Reset (from all states) S raw self-loops for for S to S3 S S2 Also draw self-loops for for S4 to S8 S3 S4 S5 S6 S7 S8 5 A vending machine: State transition table present inputs next output state state open S S S S2 X X S S S3 S4 X X S2 S2 S5 S6 X X S3 S3 S7 S8 X X S4 X X S4 S5 X X S5 S6 X X S6 S7 X X S7 S8 X X S8 6
A vending machine: State minimization Reset present inputs next output state state open 5 5 5 5 5 5 5 + 5 5 5 Reset symbolic state table 7 A vending machine: State encoding present state inputs next state output open 8
A vending machine: Logic minimization X X X X X X X X Open X X X = + + = + + + OPE = 9 A vending machine: Implementation
Generalized FSM model: Moore and Mealy Combinational logic computes next state and ext state is a function of current state and inputs Outputs are functions of Current state (Moore machine) Current state and inputs (Mealy machine) Inputs output logic ext-state logic ext State Outputs Current State Moore versus Mealy machines inputs combinational next state state feedback reg Moore machine Outputs are a function of current state t Outputs change synchronously with state changes inputs combinational next state state feedback reg Mealy machine Outputs depend on state and on inputs Input changes can cause immediate output changes (asynchronous) 2
Example -> : Moore or Mealy? Circuits recognize A= followed by A= What kinds of machines are they? out A clock Moore A clock Mealy out 3 Example / detector: a Moore machine Output is a function of state only Specify output in the state bubble / / reset A/ C/ E/ current next current reset input state state output A A A C C E C C E C E E 4
Example / detector: a Mealy machine Output is a function of state and inputs Specify on transition arcs reset/ / / A / / / C / current next current reset input state state output A A A C C C C C 5 Comparing Moore and Mealy machines Moore machines + Safer to use because change at clock edge May take additional logic to decode state into Mealy machines + Typically have fewer states + React faster to inputs don't wait for clock Asynchronous can be dangerous We often design synchronous Mealy machines esign a Mealy machine Then register the 6
Synchronous (registered) Mealy machine Registered state and registered o glitches on o race conditions between communicating machines inputs reg combinational next state reg state feedback 7 Example -> : Moore or Mealy? Recognize A, =, Mealy or Moore? A clock out Registered Mealy (actually Moore) A out clock Moore 8