RTL Problems / Level 3 · Queues & Buffers
What You Will Learn
By solving FIFO Full and Empty Detection — Pointer Logic, you will acquire core industry skills:
- Synthesizable hardware modeling in standard Verilog-2001 / SystemVerilog.
- Correct handling of interface port contracts, edge-triggered clocks, and active-low/high resets.
- Simulation waveform interpretation and debugging using timing diagrams (VCD traces).
- Architectural avoidance of timing violations, glitching hazards, and synthesis warnings.
Problem Statement & Requirements
Generate full and empty flags for an 8-entry circular FIFO using 4-bit pointers (3-bit address + 1 MSB wrap bit) without an occupancy counter.
Hardware design teams at leading semiconductor firms evaluate these exact port contracts, race-condition assertions, and corner cases during technical design reviews and ASIC engineer interviews.
Prerequisites: FIFO architecture, circular buffer pointers, binary wrap bits.
Port List & Interface Timing
The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:
| Name | Dir | Width | Description |
|---|---|---|---|
wr_ptr | input | 4 | 4-bit write pointer with MSB wrap bit |
rd_ptr | input | 4 | 4-bit read pointer with MSB wrap bit |
full | output | 1 | Full flag (identical address, inverted MSB) |
empty | output | 1 | Empty flag (identical address and MSB) |
Timing Constraints & Synthesizable RTL Rules
Timing Contract: Combinational flag evaluation from pointers.
Synthesis Constraints: FIFO depth = 8 ($2^3$). Pointers are 4-bit vectors `[3:0]`.
Architectural Deep Dive & Implementation Walkthrough
Common RTL Designer Pitfalls
['Checking `wr_ptr - rd_ptr == 8` using subtraction without properly sizing operands.', 'Applying binary pointer comparison across clock domains without Gray coding (in asynchronous FIFOs).']
Silicon & Hardware Engineering Notes
This MSB-wrap method is the foundational algorithm required for Asynchronous FIFO design, because Gray-coded pointers can be compared across clock domains without arithmetic counters.
Starter RTL Code
module top_module(
input [3:0] wr_ptr,
input [3:0] rd_ptr,
output full,
output empty
);
// Compute full and empty from pointers
endmodule
Verified Reference Solution
🔒 Reveal Verified Reference RTL Solution
module top_module(
input [3:0] wr_ptr,
input [3:0] rd_ptr,
output full,
output empty
);
// Empty: all 4 bits match
assign empty = (wr_ptr == rd_ptr);
// Full: LSBs match (same memory slot) but MSBs differ (wr_ptr has wrapped around once more)
assign full = (wr_ptr[2:0] == rd_ptr[2:0]) && (wr_ptr[3] != rd_ptr[3]);
endmodule
Related RTL Problems in Level 3
- Synchronous RAM — Memory Read/Write — Design a 16-word by 8-bit synchronous RAM (16x8) with synchronous write and synchronous read.
- Single-Port RAM with Write Enable — Memory Control — Implement a 32-word x 8-bit single-port synchronous RAM with read-first (read-during-write) behavior.
- Synchronous FIFO — FIFO Architecture — Design an 8-entry by 8-bit synchronous First-In First-Out (FIFO) buffer with write enable (wr_en), read enable (rd_en), full, and empty flags.
Connected EcrioniX Learning Resources
Accelerate your VLSI engineering knowledge with these curated learning materials:
Progress through step-by-step verified modules from fundamentals to advanced silicon design.
Benchmark your hardware knowledge across 10 semiconductor domains and receive study roadmaps.
Explore foundational circuit theory, waveform timing, and physical hardware implementation.
Frequently Asked Questions
What does FIFO Full and Empty Detection — Pointer Logic require?
Generate full and empty flags for an 8-entry circular FIFO using 4-bit pointers (3-bit address + 1 MSB wrap bit) without an occupancy counter. Implement it as Verilog module top_module matching the listed ports.
Is this design combinational or sequential?
Tags: memory, fifo, protocols, apb, uart, hard, fifo-pointers. If a clock signal is present in the port table, implement it as sequential logic; otherwise, use continuous assignments or combinational blocks.
How is my solution graded?
A hidden SystemVerilog testbench simulates your module in the cloud judge. You pass when all directed corner cases match the golden model and the VCD timing waveform matches the contract.
How does this challenge help with semiconductor interviews?
Technical interviewers at NVIDIA, Qualcomm, Apple, and Intel routinely ask candidates to code, debug, and explain the timing waveforms of FIFO Full and Empty Detection — Pointer Logic to assess real-world synthesizability and race-condition awareness.