Finite State Machines Mealy machine current state inputs

  • Slides: 14
Download presentation
Finite State Machines Mealy machine current state inputs next state function clock Outputs output

Finite State Machines Mealy machine current state inputs next state function clock Outputs output function next state function: output function: 1 Fnext state ( I, S(i) ) S(i+1) Foutput ( I, S(i) ) O(i) S(i) - Cu rren t st ate

Example -- Traffic Lights Controller l The controller operates the traffic lights at one

Example -- Traffic Lights Controller l The controller operates the traffic lights at one intersection. Detectors in both directions provide input signals to controllers: car approaching NS / car approaching EW. Outputs control the traffic light: set to green / set to red. When cars approach in both directions, toggle the light. l The controller l l l needs two states, green/red. A state/output table is used to construct the controller state(i) NSgo EWgo 2 car. NS no no yes yes car. EW no yes state(i+1) NSgo EWgo NSgo

State Diagram car. EW or both directions NSgo car. NS or both directions EWgo

State Diagram car. EW or both directions NSgo car. NS or both directions EWgo car. NS or nothing car. EW or nothing Calculate next state transitions using the table and Boolean identities This example is a Moore machine the outputs are a function only of the state. In this case the output function is trivial: In state NSgo we want a signal for a NS green light. In state EWgo we want a signal for an EW green light. 3

Moore and Mealy Machines l l l 4 Both these machine types follow the

Moore and Mealy Machines l l l 4 Both these machine types follow the basic characteristics of state machines, but differ in the way that outputs (not next state) are produced. Moore Machine: – Outputs are independent of the inputs, i. e. outputs are effectively produced from within only the state of the state machine. Mealy Machine: – Outputs can be determined by the present state alone, or by the present state and the present inputs, i. e. outputs are produced as the machine makes a transition from one state to another.

Machine Models Inputs Combinatorial Logic to Determine State Present State Register Bank Combinatorial Logic

Machine Models Inputs Combinatorial Logic to Determine State Present State Register Bank Combinatorial Logic to Determine Output Based on: Present State w Present Inputsw Moore Machine Output 5 Mealy Machine Output

Advantages of Mealy FSM l l Moore and Mealy FSMs Can Be Functionally Equivalent.

Advantages of Mealy FSM l l Moore and Mealy FSMs Can Be Functionally Equivalent. Mealy FSM Has a Richer Description and Usually Requires Smaller Number of States – Smaller circuit area. l Mealy FSM Computes Outputs as soon as Inputs Change – Mealy FSM responds one clock cycle sooner than equivalent Moore FSM. 6

Advantages of Moore FSM l Moore FSM Has No Combinational Path Between Inputs and

Advantages of Moore FSM l Moore FSM Has No Combinational Path Between Inputs and Outputs. – output changes only when clock ends short inputs that temporarily generated during the clock cycles will be ignored. 7

Moore FSM that Recognizes Sequence 10 0 1 S 0 / 0 reset Meaning

Moore FSM that Recognizes Sequence 10 0 1 S 0 / 0 reset Meaning : of states 8 S 1 / 0 1 S 2 / 1 0 S 0: No elements of the sequence observed ”S 1: “ 10 observed

Mealy FSM that Recognizes Sequence 10 0/1 S 0 reset Meaning : of states

Mealy FSM that Recognizes Sequence 10 0/1 S 0 reset Meaning : of states 9 0/1 S 1 1/0 S 0: No elements of the sequence observed ”S 1: “ 1 observed

Moore & Mealy Time Line clock input Moore Mealy 10 0 1 0 S

Moore & Mealy Time Line clock input Moore Mealy 10 0 1 0 S 1 S 2 S 0 S 0 S 1 S 0 S 0

Finite State Machine l Any circuit with memory is a Finite State Machine –

Finite State Machine l Any circuit with memory is a Finite State Machine – Even computers can be viewed as huge FSMs l Design of FSMs Involves – Defining states – Defining transitions between states – Optimization / minimization 11

Implementation Finite state machine with a state variable Outputs Combinational Logic State Register inputs

Implementation Finite state machine with a state variable Outputs Combinational Logic State Register inputs 12

General Digital System Control Combinational Logic control lines Architecture State Register CLOCK Opcode 13

General Digital System Control Combinational Logic control lines Architecture State Register CLOCK Opcode 13

Finite State Machine: Conclusion State Diagram – Illustrates the form and function of a

Finite State Machine: Conclusion State Diagram – Illustrates the form and function of a state machine. Usually drawn as a bubble-and-arrow diagram. l. State – A uniquely identifiable set of values measured at various points in a digital system. l. Next State – The state to which the state machine makes the next transition, determined by the inputs present when the device is clocked. l. Mealy Machine – A state machine that determines its outputs from the present state and from the inputs. l. Moore Machine – A state machine that determines its outputs from the present state only. l 14