Finite State Machines - Analysis
In questa pagina 5
Analysis starts from a synchronous sequential circuit (flip-flops and gates, Sequential Systems - State, Latches and Flip-FlopsA sequential circuit has outputs that depend on the inputs and on the state held in memory elements; it is a combinational network with flip-flops in a feedback loop, where present state is the flip-flop outputs and next state is their inputs. Synchronous circuits update only on the clock edge. The SR latch (NOR) sets, resets, holds, and forbids S=R=1; the D latch is transparent while C=1; the edge-triggered D flip-flop is two D latches in cascade (master-slave) and samples D only on the active clock edge, with Q(t+1)=D(t).Sequential Systems - State, Latches and Flip-Flops →) and derives its behaviour. It is the inverse of synthesis (Finite State Machines - SynthesisSynthesis of a synchronous sequential circuit follows specifications, state diagram, state table (merging equivalent states), binary state encoding, choice of D flip-flop, flip-flop input and output equations, minimisation, circuit and verification. A state summarises the useful part of history; a sequence recogniser has one state per recognised prefix, reusing states for overlaps. A reset gives a known initial state. Gray encoding (minimum flip-flops) versus one-hot (one flip-flop per state, simpler logic): for the 1101 recogniser Gray costs about half.Finite State Machines - Synthesis →).
Analysis procedure
- Flip-flop input equations: they compute the next state (for a D flip-flop, ). The subscript names the state variable; the equations contain state variables and inputs.
- Output equations.
- State table: for each combination of present state and inputs, gives next state and output.
- State diagram: the same data in graphical form.
- Simulation (timing diagram) to check the operation.
Definition (state table). With flip-flops (state variables) and inputs the table has rows: columns for present state and inputs, for the next state, plus the output columns. A two-dimensional state table has one row per state and separate columns for each input value (next state/output).
Example. With flip-flops and input: rows.
State diagram. States are circles; transitions are arrows, one for each input combination; next to the arrow write input/output. A reset signal brings the circuit to a known initial state (arrow entering the initial state).
Mealy and Moore models
Definition (Mealy and Moore).
- Mealy: outputs depend on the present state and the inputs. In the diagram the output is next to each arrow (
input/output).- Moore: outputs depend only on the present state. The output is written inside the circle; arrows carry only the input.
- A Mealy machine may need fewer states and less logic, and reacts faster: the output may change between two clock edges, as soon as the input changes (it depends on it combinationally).
- In a Moore machine the output depends on the state, held in flip-flops that change only on the active edge: the output changes only at clock edges and is more stable; it usually needs one more state.
Counting example. Detecting the sequence with output 1: 2 states in Mealy, 3 states in Moore (the third means " recognised" and carries the output in the circle).
Example 1: a Moore machine
Two D flip-flops , input , output , reset to :
| (next state) | |||
|---|---|---|---|
| 00 | 0 | 00 | 1 |
| 00 | 1 | 11 | 1 |
| 01 | 0 | 10 | 1 |
| 01 | 1 | 11 | 1 |
| 10 | 0 | 00 | 0 |
| 10 | 1 | 10 | 0 |
| 11 | 0 | 10 | 1 |
| 11 | 1 | 10 | 1 |
does not depend on : a Moore machine. State diagram (output in the circle):
- state : stays in ; goes to ;
- state : both and go to ;
- state : goes to ; stays in ;
- state : goes to ; goes to .
From reset , state is unreachable.
Simulation with (one value per cycle, reset to first):
| cycle | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| present state | 00 | 11 | 10 | 00 | 11 | 10 | 00 | 11 |
| input | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| output | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
| next state | 11 | 10 | 00 | 11 | 10 | 00 | 11 | 10 |
The output of cycle is determined by the present state.
Example 2: a Mealy machine
Two D flip-flops , input , output , reset to :
| 00 | 0 | 01 | 0 |
| 00 | 1 | 00 | 1 |
| 01 | 0 | 11 | 1 |
| 01 | 1 | 10 | 0 |
| 10 | 0 | 00 | 1 |
| 10 | 1 | 01 | 0 |
| 11 | 0 | 10 | 0 |
| 11 | 1 | 11 | 1 |
Here depends also on in every state: a Mealy machine. Diagram (arrows X/Y): , , , , , , , .
With from reset: states and outputs .
States can be given symbolic names: , , , .
Equivalent states
Definition (equivalent states). Two states are equivalent if, for every input value, they give the same output and lead to equal or equivalent next states. Equivalent states can be merged, giving a simpler circuit with fewer states and flip-flops. Reduction does not always lower the cost: the cost also depends on the combinational network, not only on the flip-flops.
Example (Mealy, input , output 1 when goes from 1 to 0):
| state | ||
|---|---|---|
and have the same outputs ( for , for ) and the same destinations ( for ; for , which itself merges with ): they are equivalent. Merged into the machine has 2 states (: last input 0; : last input 1), i.e. 1 flip-flop instead of 2. The systematic method is partition refinement: start by grouping states with the same output row and split those that, for the same input, go to different groups, until the partition no longer changes.
Versione ripasso
- Steps: (1) FF input equations ( for D FFs); (2) output equations; (3) state table, rows for FFs and inputs; (4) state diagram (circles = states, arrows
input/output); (5) simulation from reset. Two-dimensional table: one row per state. - Mealy: output , on the arrows, may change between clock edges, fewer states. Moore: output , in the circle, changes only at edges. Detecting : 2 states Mealy, 3 Moore.
- Moore example: , , . : , ; ; : , ; unreachable. With : .
- Mealy example: , , . With : states , outputs . Table: : , ; : , ; : , ; : , .
- Equivalent states: same output for every input and equal or equivalent next states, so merge (partition refinement). In the example , giving 2 states and 1 FF. Cost also depends on the combinational network.
- Mistakes: calling a machine Mealy because it has an input (what counts is whether the output depends on it); Moore output on the arrows; reading next state as present state in the simulation; not checking reachability from reset.