Skip to content

SayantanMandal2000/rtl-fifo-designs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

49 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RTL FIFO Designs in Verilog

License: MIT Language: Verilog Build: Simulated Waveform: Vivado

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.


πŸ“˜ Description

🟒 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.


πŸ“– Theory

▢️ What is a FIFO?

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)

🟒 Synchronous FIFO

  • Operates on a single clock domain.
  • Uses binary counters for read and write pointers.
  • full flag is raised when the write pointer catches up to the read pointer (with offset).
  • empty flag is raised when both pointers are equal.
  • Simpler and faster than asynchronous FIFO but limited to systems where both ends share the same clock.

πŸ”΅ Asynchronous FIFO (Dual Clock)

  • Operates on two independent clocks (wr_clk and rd_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.

⏱️ Flag Logic

  • full is asserted when the next write would overwrite unread data.
  • empty is asserted when there is no data left to read.
  • overflow and underflow are 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.

πŸ“Œ Project Highlights

  • βœ… 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, valid flag generation
    • Safe and robust cross-domain design
    • Integrated modules like convert_b2g, convert_g2b, and synchronizers

⏱️ Flag Logic

  • full: Write pointer is one step behind the (inverted MSBs of) synchronized read pointer
  • empty: Read pointer matches the synchronized write pointer
  • Flags are computed using either binary or Gray-coded comparison logic depending on the architecture

πŸ“Œ Project Highlights

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

πŸ”§ RTL Block Diagrams

Synchronous FIFO

Synchronous FIFO RTL Diagram

Asynchronous FIFO (Dual Clock)

Asynchronous FIFO RTL Diagram


πŸ§ͺ Testbench Support

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.


πŸ“ Folder Structure

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

About

πŸš€ RTL design of synchronous and dual-clock asynchronous FIFO buffers in Verilog, featuring flow control, pointer logic, and waveform-based validation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors