Practice

Finite state machine design problems

State machines come up in almost every digital design course and interview. These problems cover them twice: as circuits built from flip flops and gates, and as Verilog written in one, two or three always blocks.

195 problems13 free to solve15 easy, 85 medium, 95 hard

In the RTL problems, the FSM tab draws the state diagram Yosys extracts from your code and traces the state register clock by clock, so you can see when your machine left the path you meant.

What these problems cover

  • Moore and Mealy machines and when their outputs change
  • Overlapping and non overlapping sequence detectors
  • Controllers: traffic lights, vending machines, arbiters
  • Binary, one hot and Gray state encoding
  • Unreachable states and safe recovery

Free to start

Solve these with a free account. Every other statement on this page is free to read.

Problems by track

Finite State Machines24

12 more in the Finite State Machines track

FSM Coding15

3 more in the FSM Coding track

Latches and Flip-Flops4

Counters57

45 more in the Counters track

Shift Registers10

Clocking and Synchronization9

Fault Testing and Verification2

Interface and Communication Circuits36

24 more in the Interface and Communication Circuits track

Interview Circuit2

Sequential RTL1

Synthesis Intuition4

Datapath Design2

Memory and Storage2

Pipelining2

Interfaces and Protocols10

Clock Domain Crossing and Synchronization6

Debug and Verification2

Interview Circuit2

More problems5

How your answer is checked

RTL machines are simulated against the problem's testbench, and the FSM tab shows the extracted state diagram with a per clock trace. Circuit machines are clocked through the test sequence and checked on every cycle.

Questions

Moore or Mealy: which do the problems want?
Each problem says which one, because the two put their outputs on different cycles and the testbench checks the cycle.
Can I see my state machine as a diagram?
Yes, for RTL problems. Yosys extracts the machine from your code and the FSM tab draws it, with the state names from your source.