Skip to content
Tactiverge
  1. Stage 1
  2. Stage 2
  3. Stage 3
  4. Stage 4
  5. Stage 5
  6. Stage 6
  7. Stage 7
  8. Stage 8
  9. Stage 9
  10. Stage 10 (this one)
  11. Stage 11
  12. Stage 12
  13. Stage 13
  14. Stage 14
  15. Stage 15

Explanation

A finite state machine is a register holding the current state plus combinational logic that computes the next state from the current state and the inputs. Each clock edge moves it one step.

A pattern detector that spots 1, 0, 1 in a stream of bits needs four states: nothing yet, saw 1, saw 1 0, saw 1 0 1. A traffic light controller is another. A processor's control unit is a state machine too: its states are fetch, decode and execute.

Clock a state machine

S0out 0S1out 0S10out 0S101out 1

NowS0: nothing useful seen yet

input
History, one column per clock edge
input–
stateS0
output0

State S0, output 0

Check yourself

Marked instantly in your browser. Use the interactive above to work it out.

  1. 1. What is the fewest flip-flops needed to store one of 4 states?
  2. 2. The 1-0-1 detector starts in S0 and receives 1, 0, 1, 0, 1. How many times does it output 1?