DescriptionQ071
Q071DesignAMDASIC interview problem
Implement an Eight-Entry Synchronous FIFO
TechniquesDesignFIFOClocking
DifficultyMedium
TopicTiming
LanguageSystemVerilog
Requirements4 checkpoints
01
Problem
A single-clock datapath needs an eight-entry, 16-bit FIFO with ready/valid interfaces on both sides. Implement the FIFO with deterministic boundary and simultaneous-transfer behavior.
Module declarationSystemVerilog
module sync_fifo8x16(input logic clk,rst_n,
input logic in_valid, output logic in_ready, input logic [15:0] in_data,
output logic out_valid, input logic out_ready, output logic [15:0] out_data,
output logic [3:0] occupancy);Example input and output
Use this case to check your interpretationInput
Case 1: After reset, accept 16'h0011 then 16'h0022
Case 2: At occupancy 8, assert out_ready and in_valid
Case 3: At occupancy 0, assert in_valid and out_readyOutput
Case 1: the next two pop handshakes return 0011 then 0022
Case 2: one old item pops, one new item writes, occupancy stays 8, and both pointers advance
Case 3: only a push occurs; out_valid rises after the edge and the item is not consumed on that edgeExplanation
The shown result follows by applying this rule: Use three-bit read/write pointers with natural modulo-eight wrap and a four-bit occupancy counter that represents zero through eight. The cases also demonstrate this requirement: Present the oldest entry on out_data and keep it stable while out_valid&& !out_ready; at empty there is no combinational pass-through, so a pushed item becomes valid after the accepting edge.
02
Requirements (4)
- Active-low synchronous reset sets both pointers and occupancy to zero; memory contents need not be reset, and out_valid must be zero after reset.
- Define pop as out_valid&&out_ready and push as in_valid&&in_ready; out_valid is occupancy!=0, and in_ready is occupancy<8 or pop, allowing a full FIFO to pop and replace one item on the same edge.
- Increment occupancy for push without pop, decrement for pop without push, and hold it for neither or both; advance only the pointer belonging to an accepted operation.
- Present the oldest entry on out_data and keep it stable while out_valid&& !out_ready; at empty there is no combinational pass-through, so a pushed item becomes valid after the accepting edge.
