RTL Problems / Level 8 · Advanced RTL & Protocol Design
What You Will Learn
By solving Parameterized Synchronous FIFO with Simultaneous Read/Write, 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
Design a parameterized synchronous FIFO supporting simultaneous read and write operations without underflow or overflow hazards.
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: Synchronous FIFO architectures, circular buffers, pointer arithmetic, Verilog parameters.
Port List & Interface Timing
The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:
| Port | Dir | Width | Description |
|---|---|---|---|
clk, rst_n | input | 1 | Clock and active-low synchronous reset |
wr_en, wr_data[31:0] | input | 1, 32 | Push enable strobe and incoming data |
rd_en, rd_data[31:0] | in/out | 1, 32 | Pop enable strobe and outgoing read data |
full, empty | output | 1, 1 | Status flags for full and empty capacity |
count[3:0] | output | 4 | Current entry count (0 to 8) |
Timing Constraints & Synthesizable RTL Rules
Timing Contract: Clocked on rising edge of clk with active-low rst_n. Write updates on posedge clk when wr_en && !full (or wr_en && rd_en when full). Read data presents registered or cut-through.
Synthesis Constraints: No underflow or memory corruption. Parameterized DATA_WIDTH and DEPTH. Synthesizable Verilog-2001.
Architectural Deep Dive & Implementation Walkthrough
Single-Clock FIFO Architecture
Synchronous FIFOs decouple data rate mismatches between modules running in the same clock domain.
Corner-Case Handling
- Simultaneous Read/Write when Full: A well-designed FIFO allows a write when full if a read is concurrently popping an entry. The write overwrites the slot being freed, maintaining
count = DEPTHwithout dropping data. - Underflow Protection: If
rd_enis asserted whenempty = 1, read pointer advancement must be suppressed.
Common RTL Designer Pitfalls
Allowing count to overflow beyond DEPTH or underflow below 0 on invalid enable strobes.
Silicon & Hardware Engineering Notes
For small depths (DEPTH <= 32), synthesize to distributed flip-flops; for larger depths (DEPTH >= 64), infer block RAMs (BRAMs).
Starter RTL Code
module top_module #(
parameter DATA_WIDTH = 32,
parameter DEPTH = 8
)(
input wire clk,
input wire rst_n,
input wire wr_en,
input wire [DATA_WIDTH-1:0] wr_data,
input wire rd_en,
output reg [DATA_WIDTH-1:0] rd_data,
output wire full,
output wire empty,
output reg [3:0] count
);
// Implement parameterized synchronous FIFO:
// 1. circular write and read pointers.
// 2. count tracks number of valid items in FIFO (0 to DEPTH).
Verified Reference Solution
🔒 Reveal Verified Reference RTL Solution
module top_module #(
parameter DATA_WIDTH = 32,
parameter DEPTH = 8
)(
input wire clk,
input wire rst_n,
input wire wr_en,
input wire [DATA_WIDTH-1:0] wr_data,
input wire rd_en,
output reg [DATA_WIDTH-1:0] rd_data,
output wire full,
output wire empty,
output reg [3:0] count
);
reg [DATA_WIDTH-1:0] mem [0:DEPTH-1];
reg [2:0] wr_ptr, rd_ptr;
assign full = (count == DEPTH);
assign empty = (count == 4'd0);
wire valid_wr = wr_en && (!full || rd_en);
wire valid_rd = rd_en && !empty;
always @(posedge clk or negedge rst_n) begin
if (!rst_n) begin
wr_ptr <= 3'd0;
rd_ptr <= 3'd0;
count <= 4'd0;
rd_data <= {DATA_WIDTH{1'b0}};
end else begin
if (valid_wr) begin
mem[wr_ptr] <= wr_data;
wr_ptr <= (wr_ptr + 3'd1) % DEPTH;
end
if (valid_rd) begin
rd_data <= mem[rd_ptr];
rd_ptr <= (rd_ptr + 3'd1) % DEPTH;
end
case ({valid_wr, valid_rd})
2'b10: count <= count + 4'd1;
2'b01: count <= count - 4'd1;
default: ; // 2'b00 or 2'b11 -> hold count
endcase
end
end
endmodule
Related RTL Problems in Level 8
- Watchdog Timer — A timeout that fires unless it keeps getting "kicked" — the safety-net circuit that resets a hung system when its heartbeat stops arriving.
- Fixed-Priority Arbiter — Grant exactly one of four requesters at a time, always favoring the highest-index request when several arrive together.
- CRC-4 Generator — Compute the 4-bit CRC remainder of an 8-bit message using the CRC-4 (poly x⁴+x+1) bit-serial algorithm, entirely in combinational logic.
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 Parameterized Synchronous FIFO with Simultaneous Read/Write require?
Design a parameterized synchronous FIFO supporting simultaneous read and write operations without underflow or overflow hazards. Implement it as Verilog module top_module matching the listed ports.
Is this design combinational or sequential?
Tags: advanced-rtl, fifo-and-buffer-architecture, systemverilog, asic, fpga. 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 Parameterized Synchronous FIFO with Simultaneous Read/Write to assess real-world synthesizability and race-condition awareness.