This project implements a Parameterized Asynchronous FIFO (First-In First-Out) buffer using Gray-code pointer synchronization to enable reliable Clock Domain Crossing (CDC) between two independent clock domains.
The design ensures safe data transfer between modules operating at different clock frequencies, which is a common requirement in System-on-Chip (SoC) architectures, communication interfaces, and digital hardware systems.
β Parameterized FIFO depth and data width
β Independent read and write clocks
β Gray-code pointer synchronization
β Full and Empty detection
β Almost Full and Almost Empty flags
β Dual-port FIFO memory
β Safe clock domain crossing design
When two modules operate on different clocks, direct data transfer can lead to:
- Metastability
- Data corruption
- Timing hazards
Asynchronous FIFOs solve this problem by acting as a buffer between clock domains.
The architecture contains the following modules:
- Write Pointer Logic
- Read Pointer Logic
- FIFO Memory (Dual-Port)
- Gray Code Pointer Synchronization
- Full & Almost Full Detection
- Empty & Almost Empty Detection
Maintains the write address inside the write clock domain.
Features:
- Binary write pointer
- Gray-code conversion
- Write address generation
- Overflow protection
Maintains the read address inside the read clock domain.
Features:
- Binary read pointer
- Gray-code conversion
- Safe pointer synchronization
- Underflow protection
The memory block is implemented as a dual-port memory.
| Port | Function |
|---|---|
| Write Port | Data written using write clock |
| Read Port | Data read using read clock |
Advantages:
- Simultaneous read and write
- Efficient buffering
- Prevents overflow/underflow
Binary counters can change multiple bits simultaneously, which can cause synchronization errors across clock domains.
Gray-code solves this problem because:
β Only one bit changes at a time
β Reduced metastability risk
β Reliable pointer synchronization
Two-stage flip-flop synchronizers are used for safe CDC transfer.
The FIFO becomes FULL when the write pointer catches the read pointer after wrap-around.
Next Gray Write Pointer == Inverted MSB of Read Pointer
Provides early warning before FIFO overflow.
Used Entries >= DEPTH - ALMOST_FULL_MARGIN
The FIFO becomes EMPTY when:
Read Pointer == Synchronized Write Pointer
Indicates the buffer is close to empty.
Used Entries <= ALMOST_EMPTY_MARGIN
The FIFO was verified using a multi-clock testbench.
Verified conditions:
β Correct data ordering
β Proper flag generation
β Stable clock domain crossing
The RTL view shows:
- Synchronizer modules
- FIFO memory block
- Pointer generation logic
- Flag detection modules
Asynchronous-FIFO
β
βββ rtl
β βββ asynchronous_fifo.v
β βββ sync_w2r.v
β βββ sync_r2w.v
β βββ fifo_mem.v
β βββ full_with_almost.v
β βββ empty_with_almost.v
β
βββ testbench
β βββ fifo_tb.v
β
βββ docs
β βββ architecture.png
β βββ pointer_logic.png
β βββ synchronizer.png
β
βββ images
β βββ simulation_output.png
β βββ rtl_schematic.png
β
βββ README.md
| Parameter | Description |
|---|---|
| WIDTH | Data width |
| DEPTH | FIFO depth |
| ALMOST_FULL_MARGIN | Threshold for Almost Full |
| ALMOST_EMPTY_MARGIN | Threshold for Almost Empty |
This FIFO can be used in:
- SoC Interconnect Systems
- Communication Interfaces
- Bus Bridges
- Network Routers
- Processor Pipelines
- DMA Controllers
Possible extensions include:
- AXI / AHB FIFO integration
- Formal CDC verification
- FPGA implementation
- ASIC optimization
- Multi-channel FIFO architecture
Raviranjan Kumar
M.Tech β Embedded System Design
National Institute of Technology Kurukshetra
If you find this project useful, please β star the repository.











