Verilog practice problems
Every problem here is a module to write: a port list, a spec and a testbench that checks it. You write the RTL in the browser and it runs on a real simulator, the same way it would on your own machine.
240 problems53 free to solve53 easy, 118 medium, 69 hard
The problems are grouped by track and ordered the way the track teaches them, from continuous assignments and always blocks to FSMs, pipelines and clock domain crossing.
What these problems cover
- Module structure, ports, vectors, concatenation and parameters
- Combinational always blocks and avoiding inferred latches
- Flip flops, resets, counters and shift registers with nonblocking assignments
- FSMs in one, two and three always block styles
- Datapaths, memories, FIFOs and pipelines
- Synchronizers and async FIFOs across clock domains
Free to start
Solve these with a free account. Every other statement on this page is free to read.
Problems by track
Verilog Syntax and Language Basics25
- Basic Module Ports
- Vector Port Endianness
- Inout Port Mechanics
- Port Width Mismatch
- Wire versus Reg in Continuous Assignment
- Parameterized Module Width
- Parameterized Vector Slicing
- Overriding Parameters via Hash Parentheses
- Bitwise versus Logical Negation
- Reduction AND and NAND
- Reduction XOR Parity Generator
- Addition with Carry Out
Combinational RTL14
- The Incomplete Sensitivity List Fallback
- Intermediate Variables in Combinational Blocks
- Priority Routing via If Else
- Tristate Bus Driver
- Instruction Decoder using Casez
- Parameterized Equality Comparator
- Decoder with Enable Logic
- Binary to Gray Code Datapath
- Find First One Priority Encoder
- Variable Indexed Part Select
- Signed Arithmetic and Sign Extension
- 8-to-1 Multiplexer via Case Statement
Sequential RTL26
- Basic D Flip Flop
- Four Stage Shift Register
- Debug: Blocking Assignment Race Condition
- Variable Swap Without Temporary Storage
- Asynchronous Active Low Reset
- Synchronous Active High Reset
- Debug: Missing Edge in Sensitivity List
- Dual Reset: Async Hard Clear and Sync Soft Clear
- Basic Clock Enable Register
- Register with Byte Enables
- Priority Control: Reset Overrides Enable Overrides Load
- Parameterized Serial In Parallel Out
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
Synthesis Intuition17
- The Incomplete Case Latch
- Ternary Operator Safety
- The Variable Loop Bound
- If Else Priority Encoder
- Parameterized Sign Extension Unit
- Four Stage Pipelined Multiplier
- ROM Inference via Case
- Power of Two Alignment
- Tapped Delay Line
- Up Down Counter with Dynamic Step
- Registered vs Combinational Output
- The Implicit State Machine
Datapath Design25
- 8-bit ALU with Flags
- Signed versus Unsigned Comparison ALU
- 8-bit Logical Barrel Shifter
- 16-bit Arithmetic Barrel Shifter
- 4x4 Array Multiplier from Gates
- 16-bit Sequential Multiplier
- Signed Sequential Multiplier
- 8-bit Signed Accumulator
- Saturating Subtractor
- Absolute Value with Bit Growth
- 16-bit Leading Zero Counter Loop
- 32-bit Leading Zero Counter Tree
Memory and Storage24
- Combinational ROM Initialization
- Synchronous Single Port RAM
- Write First Single Port RAM
- Read First Single Port RAM
- Read After Write Hazard Detection
- Simple Dual Port RAM 1R1W
- True Dual Port RAM 2RW
- True Dual Port RAM Collision Resolution
- Register File with Hardwired Zero
- CPU Register File 2R1W
- Shift Register Based FIFO
- Circular Buffer Pointer Math
Pipelining18
- Two Stage Datapath
- Valid Data Propagation
- Reconvergent Paths with Different Latencies
- Global Pipeline Stall
- Valid Bubble Insertion
- Upstream vs Downstream Stall Backpressure
- Branch Flush Mechanism
- Simultaneous Stall and Flush Priority
- Parameterized Pipeline Delay Line
- Parameterized Pipeline with Valid Signals
- Parameterized Pipelined Reduction OR
- Pipeline Interlock on Data Hazard
Interfaces and Protocols19
- Synchronous Rising Edge Detector
- Continuous Counter Debounce
- Basic Pulse Width Modulator
- Glitch Free PWM with Shadow Register
- Basic Fibonacci LFSR
- Serial CRC-8 Generator
- Valid Ready Pipeline Stage
- The Skid Buffer
- Baud Rate Pulse Generator
- UART Transmitter FSM
- UART Receiver Oversampling Counter
- UART Receiver Data Shifter
SystemVerilog RTL14
- Packed Array Endianness Extraction
- Unpacked Array Memory Initialization
- Mixed Array Memory Mapping
- Packed Struct Instruction Decoder
- Struct Field Updating and Assignment
- Basic Interface Grouping
- Bit Stream Cast to Packed Struct
- Localparam Derivation with Clog2
- Parameterized Struct Widths
- Generate If Optional Pipeline Stage
- Recursive Generate Reduction Tree
- Bypassable Register with Generate If
Clock Domain Crossing and Synchronization33
- Two-Flop Synchronizer
- Asynchronous Assertion and Synchronous Deassertion
- Reset Synchronizer Tree
- Coordinated Reset Sequence
- Divide by Two Clock Generator
- Divide by Three with 50% Duty Cycle
- Divide by Even N with 50% Duty Cycle
- Latch-Based Clock Gating Cell
- Glitch Free Clock Multiplexer
- The Glitchy Clock Multiplexer
- Clock Enable Generator
- Full Four Phase Handshake Protocol
Debug and Verification5
Interview Circuit5
How your answer is checked
Your module is compiled with Icarus Verilog and simulated against the problem's testbench. The result lists every test with the value you produced and the value expected, and the waveform shows where they part. Yosys synthesizes the same code, so you can see the schematic and the cell count of what you wrote.
Questions
- Do I need to install a simulator?
- No. The editor, the simulator and the synthesis view run on Codiode. You need a laptop or desktop browser; on a phone you can read a problem but not solve it.
- Which Verilog standard is used?
- Verilog submissions compile as Verilog 2005. You can switch the editor to SystemVerilog on any problem, and to VHDL on the problems that offer it.
- Are these problems free?
- The first problems of every track are free with an account, and every problem statement is free to read. The rest of the catalog is part of Codiode Pro.