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
- Moore FSM Output Delay Analysis
- Moore vs Mealy Output Area
- Mealy Output Glitch Detection
- Explicit vs Implicit FSMs
- Mod-6 Counter: Next-State Table
- Mod-7 Counter: Full Next-State Table Design
- BCD Counter: Next-State Table Derivation
- Counter from State Diagram: Implementation
- ROM Based State Machine Next State Logic
- One Hot Enum Encoding Verification
- Priority Encoder vs One Hot Leading Zero
- Ring Counter: One-Hot Outputs as Decoder Replacement
FSM Coding15
- Three-Process Moore FSM
- The Default Assignment Trick
- Typedef Enum State Machine
- Explicit One Hot Encoding
- Overlapping Sequence Detector Checker
- Nonoverlapping Sequence Detector with Abort
- Sequence Detector: 101
- Vending Machine Accumulator FSM
- Traffic Light Controller with Timer
- Serial Adder Mealy Machine
- Valid and Ready Handshake Transmitter
- Valid and Ready Handshake Receiver
Latches and Flip-Flops4
Counters57
- Synchronous Counter: Count Sequence Verification
- Mod-6 Counter: Synchronous Reset
- Mod-3 Counter
- Mod-6 Counter: Self-Correcting (No Don't-Cares)
- Mod-6 Counter Reset Decode Wrong Bit Debug
- Mod-9 Counter: 4-Bit Design with Multiple Don't-Cares
- Mod-N Counter: Two Approaches Compared
- Up/Down Counter: Overflow and Underflow Detection
- Up/Down Counter: Direction Change at Terminal Count
- Decade Up/Down Counter
- Bidirectional Ring Counter
- Up/Down Counter with 7-Segment Display
Shift Registers10
- SIPO with Start Bit Detection
- PISO: Programmable Start Position
- Ring Counter: Self-Correction for All-Zeros Lockup
- Johnson Counter: 5-Bit for 10-Phase Generation
- Johnson vs. Ring Counter: Period and State Comparison
- Serial Link with Start and Stop Bits
- Start Bit Detection Waveform
- UART-Style 10-Bit Frame: Full Transmit and Receive
- PISO: Parallel-to-Serial Conversion for SPI Transmission
- Serial Link: Framing Error Detection
Clocking and Synchronization9
Fault Testing and Verification2
Interface and Communication Circuits36
- Shift Register Debouncer
- Counter Based Debouncer
- Glitch Rejector
- Edge Aligned Clock Divider
- Period Measurement
- Maximum Pulse Width Timeout
- Minimum Pulse Width Validator
- Phase Difference Measurement
- Pulse Train Counter
- Frequency Limit Detector
- Byte Serializer with Busy Flag
- Valid Data Serializer
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.