# dadongshangu/async_fifo architecture

> Architecture diagram of the GitHub repository dadongshangu/async_fifo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dadongshangu/async_fifo
- Repository: https://github.com/dadongshangu/async_fifo

## Overview

##### Project type and purpose
- This is a hardware IP project implementing an Asynchronous FIFO in Verilog.
- It provides:
– RTL sources (src/)
– Two verification flows: simple Verilog TB (sim/) and UVM environment (sim_uvm/)
– Static linting/quality checks (spyglass/)
– Synthesis scripts (synthesis/)

##### File structure
- src/: Core RTL modules – async_fifo.v, fifo_mem.v, gray_sync2d.v, rptr_empty.v, wptr_full.v
- sim/: Basic Verilog testbench (top_tb.v + makefile)
- sim_uvm/: UVM testbench components – interfaces, agents, drivers, sequencer, scoreboard, environment, tests, sequences
- spyglass/: Project file, Tcl scripts to run Synopsys SpyGlass linting
- synthesis/: Synopsys DC scripts (Tcl + timing) and makefile

##### README insights
- Design based on Cummings’ asynchronous FIFO paper.
- Three phases implemented: RTL, basic TB, UVM TB.
- UVM environment follows standard agent/driver/monitor/scoreboard/model pattern.

##### Main components
a. DUT (src/)
– async_fifo top
– Internal sub-blocks: dual-port memory, gray-code pointer synchronizers, pointer arithmetic & status (full/empty) logic
b. Verification
– Simple Verilog TB (sim/top_tb.v)
– UVM environment (sim_uvm/)
- Interface block (asyncf_if)
- Upstream & downstream agents: driver, sequencer, monitor, transaction
- Scoreboard + reference model
- Virtual sequencer to coordinate sequences
- Test cases (case0, case1, base_test)
c. Static analysis
– SpyGlass flow (spyglass/run_sg.tcl)
d. Synthesis flow
– Synopsys DC scripts (synthesis/main.tcl, synopsys.tcl, timing.tcl)

##### Relationships and interactions
- DUT <> Testbench
– Clock & reset domains (src/ gray_sync2d handles crossing)
– FIFO interface signals (write_data, write_en, read_data, read_en, full, empty)
- UVM environment <> DUT
– Virtual interface bound to DUT’s ports
– Drivers generate transactions, monitors capture response
– Scoreboard compares DUT output vs reference model
- Tools flows
– SpyGlass reads src/ + sim_uvm/ for lint checks
– DC reads src/ + constraints for synthesis & timing analysis

##### Architectural patterns & design principles
- Dual-clock FIFO with pointer synchronization (Gray code)
- Modular UVM agent/driver/monitor/scoreboard/test hierarchy
- Separation of concerns: RTL vs verification vs lint vs synthesis

##### Detailed elements to capture
- Internal FIFO memory and pointer sync blocks inside DUT
- UVM hierarchy: environment → agents → drivers/monitors → sequencer → sequences
- Reference model path feeding scoreboard
- Top-level scripts invoking each flow (Makefiles, Tcl)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "RTL Design"
        subgraph "DUT (async_fifo.v)"
            async_fifo["async_fifo.v"]:::rtl
            fifo_mem["fifo_mem.v"]:::rtl
            gray_sync2d["gray_sync2d.v"]:::rtl
            rptr_empty["rptr_empty.v"]:::rtl
            wptr_full["wptr_full.v"]:::rtl
        end
    end

    subgraph "Verification"
        subgraph "Simple Verilog TB"
            tb_top["top_tb.v"]:::uvm
            tb_make["makefile"]:::uvm
        end
        subgraph "UVM Environment"
            iface["asyncf_if.sv"]:::uvm
            env["asyncf_env.sv"]:::uvm
            agent_up["asyncf_up_agent.sv"]:::uvm
            agent_down["asyncf_down_agent.sv"]:::uvm
            driver_up["asyncf_driver.sv"]:::uvm
            driver_down["asyncf_down_driver.sv"]:::uvm
            mon_up["asyncf_up_monitor.sv"]:::uvm
            mon_down["asyncf_down_monitor.sv"]:::uvm
            seqr_up["asyncf_up_sequencer.sv"]:::uvm
            seqr_down["asyncf_down_sequencer.sv"]:::uvm
            trans_up["asyncf_transaction.sv"]:::uvm
            trans_down["asyncf_down_transaction.sv"]:::uvm
            seq0["asyncf_case0_seq.sv"]:::uvm
            seq1["asyncf_case1_seq.sv"]:::uvm
            seqd["asyncf_down_seq.sv"]:::uvm
            scoreboard["asyncf_scoreboard.sv"]:::uvm
            model["asyncf_model.sv"]:::uvm
            virt_seq["asyncf_virtual_sequencer.sv"]:::uvm
            testcase_base["base_test.sv"]:::uvm
            testcase0["asyncf_case0.sv"]:::uvm
            testcase1["asyncf_case1.sv"]:::uvm
            testcase_top["top_tb.sv"]:::uvm
            uvmmake["makefile"]:::uvm
            uvmreadme["README.md"]:::uvm
            debug["debug.rc"]:::uvm
        end
    end

    subgraph "Static Checking"
        spyglass["run_sg.tcl"]:::tool
        sg_proj["async_fifo.prj"]:::tool
        sg_make["makefile"]:::tool
        sg_readme["README"]:::tool
    end

    subgraph "Synthesis"
        dc_main["main.tcl"]:::tool
        dc_syn["synopsys.tcl"]:::tool
        dc_time["timing.tcl"]:::tool
        dc_make["makefile"]:::tool
        dc_readme["README"]:::tool
    end

    driver_up -->|"drive"| async_fifo
    driver_down -->|"drive"| async_fifo
    async_fifo -->|"response"| mon_up
    async_fifo -->|"response"| mon_down
    mon_up -->|"collect"| scoreboard
    mon_down -->|"collect"| scoreboard
    model -->|"reference"| scoreboard
    seqr_up -->|"request"| driver_up
    seqr_down -->|"request"| driver_down
    seq0 -->|"sequence"| seqr_up
    seq1 -->|"sequence"| seqr_up
    seqd -->|"sequence"| seqr_down
    virt_seq -->|"control"| seqr_up
    virt_seq -->|"control"| seqr_down
    iface -->|"bind"| async_fifo
    tb_top -->|"stimulus"| async_fifo
    tb_top -->|"invoke"| tb_make

    spyglass -->|"lint"| async_fifo
    spyglass -->|"lint"| iface
    dc_main -->|"synthesize"| async_fifo

    click async_fifo "https://github.com/dadongshangu/async_fifo/blob/master/src/async_fifo.v"
    click fifo_mem "https://github.com/dadongshangu/async_fifo/blob/master/src/fifo_mem.v"
    click gray_sync2d "https://github.com/dadongshangu/async_fifo/blob/master/src/gray_sync2d.v"
    click rptr_empty "https://github.com/dadongshangu/async_fifo/blob/master/src/rptr_empty.v"
    click wptr_full "https://github.com/dadongshangu/async_fifo/blob/master/src/wptr_full.v"
    click tb_top "https://github.com/dadongshangu/async_fifo/blob/master/sim/top_tb.v"
    click tb_make "https://github.com/dadongshangu/async_fifo/tree/master/sim/makefile"
    click iface "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_if.sv"
    click env "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_env.sv"
    click agent_up "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_up_agent.sv"
    click agent_down "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_down_agent.sv"
    click driver_up "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_driver.sv"
    click driver_down "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_down_driver.sv"
    click mon_up "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_up_monitor.sv"
    click mon_down "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_down_monitor.sv"
    click seqr_up "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_up_sequencer.sv"
    click seqr_down "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_down_sequencer.sv"
    click trans_up "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_transaction.sv"
    click trans_down "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_down_transaction.sv"
    click seq0 "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_case0_seq.sv"
    click seq1 "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_case1_seq.sv"
    click seqd "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_down_seq.sv"
    click scoreboard "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_scoreboard.sv"
    click model "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_model.sv"
    click virt_seq "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_virtual_sequencer.sv"
    click testcase_base "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/base_test.sv"
    click testcase0 "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_case0.sv"
    click testcase1 "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/asyncf_case1.sv"
    click testcase_top "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/top_tb.sv"
    click uvmmake "https://github.com/dadongshangu/async_fifo/tree/master/sim_uvm/makefile"
    click uvmreadme "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/README.md"
    click debug "https://github.com/dadongshangu/async_fifo/blob/master/sim_uvm/debug.rc"
    click spyglass "https://github.com/dadongshangu/async_fifo/blob/master/spyglass/run_sg.tcl"
    click sg_proj "https://github.com/dadongshangu/async_fifo/blob/master/spyglass/async_fifo.prj"
    click sg_make "https://github.com/dadongshangu/async_fifo/tree/master/spyglass/makefile"
    click sg_readme "https://github.com/dadongshangu/async_fifo/tree/master/spyglass/README"
    click dc_main "https://github.com/dadongshangu/async_fifo/blob/master/synthesis/main.tcl"
    click dc_syn "https://github.com/dadongshangu/async_fifo/blob/master/synthesis/synopsys.tcl"
    click dc_time "https://github.com/dadongshangu/async_fifo/blob/master/synthesis/timing.tcl"
    click dc_make "https://github.com/dadongshangu/async_fifo/tree/master/synthesis/makefile"
    click dc_readme "https://github.com/dadongshangu/async_fifo/tree/master/synthesis/README"

    classDef rtl fill:#add8e6,stroke:#000
    classDef uvm fill:#90ee90,stroke:#000
    classDef tool fill:#ffcc99,stroke:#000
```
