Asynchronous FIFO Memory Array
The memory inside an async FIFO is an ordinary dual-port RAM with one clock per port. It needs no synchronizers of its own; the pointer logic around it makes sure the two ports never use the same entry at the same time.
The module acts as a simple dual-port RAM with independent clocks. The write port operates exclusively in the write clock domain, storing data into the memory array when enabled. The read port operates exclusively in the read clock domain, fetching data from the memory array into an output register when enabled.
Timing and reset behaviour must strictly follow these rules:
- Write clock edge:
posedge wclk - Read clock edge:
posedge rclk - Reset:
rst_nis an asynchronous active-low reset applied only to the read domain. - On reset, the output register
r_datamust go to 0. The internal memory array contents remain uninitialized and are completely unaffected by reset. - Write behaviour: Writes occur on
posedge wclkwhenw_enis 1. - Read behaviour: Reads occur on
posedge rclkwhenr_enis 1. The data atr_addris registered intor_data. Ifr_enis 0,r_dataholds its previous value.
Worked Trace:
Event 1: rst_n=0 asserted → r_data=8'h00
Event 2: posedge wclk (w_en=1, w_addr=4'h5, w_data=8'hFF) → mem[5]=8'hFF
Event 3: posedge rclk (rst_n=1, r_en=1, r_addr=4'h5) → r_data=8'hFF
Event 4: posedge rclk (r_en=0, r_addr=4'h0) → r_data=8'hFF (hold)
| Signal | Direction | Width | Description |
|---|---|---|---|
wclk |
input | 1 | Write domain clock; positive-edge triggered |
w_en |
input | 1 | Write enable; active-high |
w_addr |
input | ADDR_WIDTH |
Write address |
w_data |
input | DATA_WIDTH |
Write data |
rclk |
input | 1 | Read domain clock; positive-edge triggered |
rst_n |
input | 1 | Asynchronous active-low reset for the read data register |
r_en |
input | 1 | Read enable; active-high |
r_addr |
input | ADDR_WIDTH |
Read address |
r_data |
output | DATA_WIDTH |
Registered read data; resets to 0 |
Constraints
- The module must be parameterized with
DATA_WIDTH(default 8) andADDR_WIDTH(default 4). - The internal memory array must be sized to hold 2^{ADDR\_WIDTH} elements of
DATA_WIDTHbits. - Output
r_datamust be registered on the positive edge ofrclk. - Output
r_datamust reset to 0 asynchronously whenrst_nis 0. - The internal memory array must not be reset.
- Write operations must occur on the positive edge of
wclk.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Clock Domain Crossing and Synchronization
Problem 18 of 36 in the Clock Domain Crossing and Synchronization track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks