Verilog and VHDL Interview Problems
RTL and VLSI interview problems in SystemVerilog and VHDL: FSMs, FIFOs, arbiters, CDC and more, solved in your browser against a real testbench.
-
Binary to Thermometer
Easy · Combinational · SystemVerilog · VHDL
Design a binary-to-thermometer decoder. A thermometer (unary) code writes a number m as a word whose lowest m bits are 1 and the rest 0, like mercury ri…
-
Edge Detector
Easy · Sequential · SystemVerilog · VHDL
Design a rising-edge detector. dout is high for one cycle, the cycle after one in which din is high and was low in the cycle before. In every other cycl…
-
Sequence Detector
Easy · Sequential · SystemVerilog · VHDL
Design an overlapping sequence detector for the target sequence 1010. Whenever the target sequence is detected on the serial input stream din, dout shou…
-
Elevator Controller
Medium · Sequential · SystemVerilog · VHDL
Design an elevator controller FSM with states IDLE, MOVING_UP, and MOVING_DOWN, reported on state as 00, 01, and 10. up_request is high while there is d…
-
Synchronous FIFO
Medium · Sequential · SystemVerilog · VHDL
Design a synchronous FIFO storing up to DEPTH words of DATA_WIDTH bits. On each rising edge: a write (wr_en high, not full) stores wr_data at the tail;…
-
Asynchronous FIFO
Hard · Sequential · SystemVerilog · VHDL
Design an asynchronous (dual-clock) first-in-first-out buffer that stores up to DEPTH entries of DATA_WIDTH bits each, safely transferring data from an…
-
Thermometer Code Detector
Easy · Combinational · SystemVerilog · VHDL
Design a thermometer code detector. A thermometer (unary) code writes a number m as a word whose lowest m bits are 1 and the rest 0, like mercury rising…
-
Second Largest
Easy · Sequential · SystemVerilog · VHDL
Design a module that tracks the second-largest of a sequence of unsigned values. Each cycle without a reset, din is the next value of the sequence. dout…
-
Vector Sort
Hard · Sequential · SystemVerilog · VHDL
Design a sorter that holds eight unsigned BITWIDTH-bit words and outputs them sorted. Each cycle with sortit low loads din: the module stores the last e…
-
Round-Robin Arbiter
Medium · Sequential · SystemVerilog · VHDL
Design a round-robin arbiter for N requesters. req[i] is high while requester i asks for access. Each cycle the arbiter grants at most one asking reques…
-
Register File
Easy · Sequential · SystemVerilog · VHDL
Design an 8-entry register file of 8-bit words with a single port shared by reads and writes. wr is a synchronous write of din into entry addr, and rd i…
-
MIPS ALU
Medium · Combinational · SystemVerilog · VHDL
Design a 32-bit MIPS ALU. aluc selects the operation, and r is its result: Any other aluc gives r = 0. zero is high when r is 0, and negative is r[31],…
-
Direct-Mapped Cache
Hard · Sequential · SystemVerilog · VHDL
Design a direct-mapped, write-back cache between a CPU and a memory. A cache keeps copies of recently used memory words so that most accesses never wait…
-
Dot Product
Easy · Sequential · SystemVerilog · VHDL
Design a module that computes the dot product of two length-3 vectors, A = [a_1, a_2, a_3] and B = [b_1, b_2, b_3], whose elements arrive one per cycle…
-
Multiply-Accumulate
Medium · Sequential · SystemVerilog · VHDL
Design a pipelined multiply-accumulate (MAC) unit. A MAC unit multiplies a pair of operands each cycle and adds the product to a running sum; it is the…
-
FIR Filter
Hard · Sequential · SystemVerilog
Design a direct-form FIR filter. A finite impulse response (FIR) filter's output is a weighted sum of the most recent input samples, y[n] = Σ_k h[k] · x…
-
Median Filter
Hard · Sequential · SystemVerilog · VHDL
Design a sliding-window median filter. A median filter replaces each sample of a stream with the median of the last few samples. Unlike an average, a me…
-
Serial to Parallel Converter
Easy · Sequential · SystemVerilog · VHDL
Design a serial-to-parallel converter. Each cycle din_valid is high, one bit is accepted from din_serial. After 8 valid bits, the assembled byte appears…
-
Parallel to Serial Converter
Easy · Sequential · SystemVerilog · VHDL
Design a module that takes the input din and shifts its LSB to the output dout one bit at a time. The module should begin shifting the input’s LSB when…
-
UART Receiver
Medium · Sequential · SystemVerilog
Design a UART receiver that deserializes the serial stream on rx. A frame is a low start bit, DATA_BITS data bits LSB first, then a high stop bit; rx id…
-
LFSR
Medium · Sequential · SystemVerilog · VHDL
Design a Fibonacci LFSR pseudo-random number generator. A linear feedback shift register (LFSR) is a shift register whose next input bit is the XOR of a…
-
UART Transmitter
Hard · Sequential · SystemVerilog
Design a UART transmitter. A UART sends words over a single wire with no clock beside it. The line idles high, and each word goes out as a frame: a low…
-
Fixed Point Adder
Easy · Combinational · SystemVerilog · VHDL
Design a parameterized fixed-point adder for sign-magnitude operands. a, b and c are N-bit sign-magnitude values: bit N-1 is the sign (1 for negative) a…
-
Square Root
Medium · Combinational · SystemVerilog · VHDL
Design a module that computes the integer square root of the signed input in_0: the largest root such that root^2 ≤ in_0. If in_0 is negative, root is 0.
-
Fixed Point Multiplier
Medium · Combinational · SystemVerilog · VHDL
Design a signed fixed-point multiplier. A QM.N fixed-point number is an M+N-bit two's-complement integer read with the binary point N bits from the righ…
-
Modular Exponentiation
Medium · Combinational · SystemVerilog · VHDL
Design a module that computes modular exponentiation. y is a^b mod m, with a, b and m read as unsigned integers. When m is 0, y is 0. The module is comb…
-
Galois Field Multiplier
Medium · Combinational · SystemVerilog · VHDL
Design a multiplier for the finite field GF(2^8) defined by the AES polynomial. An element of GF(2^8) is an 8-bit value read as a polynomial with one-bi…
-
Floating Point Multiplier
Hard · Combinational · SystemVerilog · VHDL
Design a combinational module that multiplies two IEEE 754 single-precision (32-bit) floating-point numbers a and b and produces their product result, a…
-
Fibonacci Generator
Easy · Sequential · SystemVerilog · VHDL
Design a Fibonacci sequence generator. The sequence starts F_0 = 1, F_1 = 1, and each later term is the sum of the two before it (1, 1, 2, 3, 5, 8, 13,…
-
Binary to BCD
Medium · Sequential · SystemVerilog · VHDL
Design a sequential binary-to-BCD converter. Binary-coded decimal (BCD) writes a number one decimal digit at a time, four bits per digit, so 8'd123 beco…
-
Clock Divider
Easy · Sequential · SystemVerilog · VHDL
Design a clock divider that produces clocks with 2, 4 and 6 times the period of clk and a 50% duty cycle. resetn is a synchronous, active-low reset that…
-
Fractional Clock Divider
Easy · Sequential · SystemVerilog · VHDL
Design a fractional clock divider that divides clk by MUL2_DIV_CLK/2, a half-integer ratio such as 3.5 for the default MUL2_DIV_CLK = 7. clk_div has a p…
-
PWM Controller
Medium · Sequential · SystemVerilog · VHDL
Design a PWM controller for a half-bridge, with a high-side and a low-side output separated by a programmable dead time. A half-bridge is two switches i…
-
Stopwatch
Easy · Sequential · SystemVerilog · VHDL
Design a stopwatch that counts hours, minutes, and seconds. secs increments every cycle and wraps from 59 to 0. mins increments each time secs wraps and…
-
Rate Limiter
Medium · Sequential · SystemVerilog · VHDL
Design a token bucket rate limiter. A token bucket admits requests at an average rate set by its refills while still allowing bursts up to its size: eve…
-
Carry Look-Ahead Adder
Medium · Combinational · SystemVerilog · VHDL
Design a parameterized carry look-ahead adder that also exposes its generate, propagate, and carry signals. cout and sum together form the (N+1)-bit val…
-
Prefix Sum
Medium · Combinational · SystemVerilog · VHDL
Design a parallel prefix sum module. A prefix sum, or scan, gives for every element of a sequence the total of the elements up to and including it. Comp…
-
Priority Encoder
Medium · Combinational · SystemVerilog · VHDL
Design a priority encoder that grants the three highest-priority requests out of sixteen. Bit 15 of req has the highest priority and bit 0 the lowest. g…
-
Divisible by 3
Easy · Sequential · SystemVerilog · VHDL
Design a serial checker for divisibility by three. The bits of an unsigned number of any length arrive on din, one per cycle, most-significant bit first…
-
SPI Master
Medium · Sequential · SystemVerilog · VHDL
Design an SPI mode 0 master that sends tx_data on mosi while it receives a byte from miso into rx_data, both most significant bit first. In SPI mode 0 t…
-
Skid Buffer
Medium · Sequential · SystemVerilog · VHDL
Design a skid buffer: a valid/ready register slice whose outputs, s_ready included, are all registered. A pipeline stage that registers its ready signal…
-
Hamming Decoder
Easy · Combinational · SystemVerilog · VHDL
Design a Hamming(7,4) decoder that corrects a single-bit error. A Hamming(7,4) codeword carries four data bits and three parity bits. Numbering its bits…
-
Ping-Pong Buffer
Medium · Sequential · SystemVerilog · VHDL
Design a ping-pong buffer: two banks of DEPTH words of DATA_W bits, one written while the other is read. A ping-pong (double) buffer lets a producer fil…
-
Reciprocal
Hard · Sequential · SystemVerilog · VHDL
Design a fixed-point reciprocal unit that computes 1/d by Newton-Raphson iteration. Newton-Raphson finds a reciprocal without dividing: from an estimate…