How jonathanjing/asynchronous-fifo works
Project type and purpose
• This is a hardware design project written in Verilog for implementing and optimizing both synchronous and asynchronous FIFOs (First-In-First-Out queues).
• The README makes clear the focus is on clock-domain crossing, metastability safety via Gray-coded pointers, and FIFO depth/width conversion.
File structure
• Top-level Verilog modules:
• asy_fifo.v – asynchronous FIFO implementation
• Syn_FIFO.v – synchronous FIFO implementation (for comparison/benchmark)
• Gray-code utilities (under Gray_code/):
• Binary_2_gray.v, Gray_2_binary.v – pointer Gray-encoding and decoding
• Gray code.md – background on Gray code use for metastability mitigation
• Documentation:
• README.md – project overview, theory, references
• New function.md – notes on additional features (e.g. width conversion)
Key architectural insights from the README
• FIFO consists of separate write and read pointer controllers, a dual‐port memory array, and control logic generating full/empty flags.
• Asynchronous design requires two‐stage synchronizers for cross‐domain pointer sampling and Gray‐code conversion to avoid multiple‐bit flips.
• Supports optional data‐width conversion (e.g. 32-bit write into 16-bit read).
Main components
a. Write‐domain block (clock A)
• Write pointer (binary + Gray encoder)
• Write data input interface
• Write‐side full‐flag logic
• Synchronizer to receive read pointer from read domain
b. Read‐domain block (clock B)
• Read pointer (binary + Gray encoder)
• Read data output interface
• Read‐side empty‐flag logic
• Synchronizer to receive write pointer from write domain
c. Dual‐port memory array
• One port clocked by write clock, one by read clock
• Data‐width conversion logic (optional)
d. Cross‐domain synchronizers
• Gray-coded pointer signals passed through two‐stage flip-flop synchronizers
Relationships and interactions
• Data flows from the write‐domain interface → memory → read‐domain interface.
• Each domain’s pointer controller drives one memory port.
• Full flag: write pointer compares (after synchronizer) to read pointer Gray code.
• Empty flag: read pointer compares (after synchronizer) to write pointer Gray code.
Architectural patterns & design principles
• Clock-domain crossing using two-stage synchronizers.
• Gray-code encoding of pointers to ensure single-bit transitions.
• Separation of control logic from data storage (clean RTL modularity).
• Optional width conversion stage decoupled from pointer/control logic.
Technologies/frameworks/libraries
• Pure Verilog (no external IP).
• Use of simple two‐flip‐flop synchronizer primitives.
• Dual-port RAM can be inferred or mapped to FPGA block RAM.