This repository contains Verilog-based RTL implementations of both Synchronous and Asynchronous (Dual-Clock) FIFO (First-In First-Out) buffers, widely used in digital systems for temporary data storage, clock domain crossing, and communication between different subsystems.
π’ Synchronous FIFO β Uses a single clock for both read and write operations.
π΅ Asynchronous FIFO β Uses separate, independent clocks for write and read operations.
Both modules are essential components in digital design, especially in System-on-Chip (SoC) architectures where data needs to be buffered, streamed, or transferred safely across different modules or clock domains.
These FIFO designs include complete pointer management, flag generation (full, empty, overflow, underflow), and simulation testbenches with waveform outputs.
A FIFO (First-In First-Out) is a hardware buffer that stores data in the order it was written and ensures it is read out in the same sequence. It is widely used in scenarios like:
- Data streaming between producer and consumer
- Temporary data storage in pipelined systems
- Bridging between two clock domains (asynchronous FIFOs)
- Operates on a single clock domain.
- Uses binary counters for read and write pointers.
fullflag is raised when the write pointer catches up to the read pointer (with offset).emptyflag is raised when both pointers are equal.- Simpler and faster than asynchronous FIFO but limited to systems where both ends share the same clock.
- Operates on two independent clocks (
wr_clkandrd_clk). - Uses Gray code conversion for pointer synchronization across clock domains.
- Synchronizers (
sync_w2r,sync_r2w) are used to safely pass pointers between domains. - Handles clock domain crossing (CDC) using safe techniques to prevent metastability.
- More complex, but essential when interfacing modules running on different clocks.
fullis asserted when the next write would overwrite unread data.emptyis asserted when there is no data left to read.overflowandunderfloware optional flags for debug or protection logic.- Pointers are compared using binary or Gray-coded values depending on FIFO type.
These designs are built for clarity, modularity, and synthesis compatibility for FPGA/ASIC workflows.
-
β Synchronous FIFO
- Single-clock domain read/write
- Parameterizable data width and depth
- Clean flag logic (
full,empty) - Pipelined read/write pointers
- Testbench and waveform simulation
-
β Asynchronous FIFO
- Dual-clock domain (independent write and read clocks)
- Gray code pointer synchronization
full,empty,overflow,underflow,validflag generation- Safe and robust cross-domain design
- Integrated modules like
convert_b2g,convert_g2b, and synchronizers
full: Write pointer is one step behind the (inverted MSBs of) synchronized read pointerempty: Read pointer matches the synchronized write pointer- Flags are computed using either binary or Gray-coded comparison logic depending on the architecture
| Feature | Synchronous FIFO | Asynchronous FIFO |
|---|---|---|
| Clock Domains | Single clock (clk) |
Dual clocks (w_clk, r_clk) |
| Pointer Format | Binary | Gray code |
| Synchronization | Not required | Required (sync_r2w, sync_w2r) |
| Use Case | Same-clock systems | CDC (Clock Domain Crossing) |
| Status Flags | full, empty |
full, empty |
| Extras | Registered output, clean counters | Gray code + synchronizers |
| Testbench | Included | Included |
| Waveform | GTKWave compatible | GTKWave compatible |
Both designs are fully testbench-driven.
The testbenches include:
- Reset and initialization sequences
- Data push into FIFO (
wr_en) - Data read from FIFO (
rd_en) - Observation of status flags under different scenarios
Use GTKWave to inspect vcd waveform outputs.
rtl-fifo-designs/
β
βββ synchronous-fifo-verilog/
β βββ fifo_sync.v
β βββ tb_fifo_sync.v
β βββ images/
β βββ Sync_FIFO_RTL.png
β βββ Sync_FIFO_waveform.png
β
βββ asynchronous-dual-clock-fifo/
β βββ async_fifo.v
β βββ fifo_mem.v
β βββ full.v
β βββ empty.v
β βββ sync_r2w.v
β βββ sync_w2r.v
β βββ tb_async_fifo.v
β βββ sim/
β βββ Async_FIFO_RTL.png
β βββ Async_FIFO_waveform.png
