# jiteshnayak2004/flame_thrower architecture

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

- Interactive diagram: https://gitdiagram.com/jiteshnayak2004/flame_thrower
- Repository: https://github.com/jiteshnayak2004/flame_thrower

## Overview

##### Project type and purpose
- This is a hardware-design project: an On-Chip Network (OCN) router written in Bluespec SystemVerilog (BSC).
- The router implements a 5-port (north, south, east, west, local) 2D-mesh network interface with virtual channels, a crossbar switch, round-robin arbitration, and an XY routing algorithm.

##### File structure
- Top-level source directory:
- src/router.bsv ‑ likely the top-level router module that instantiates submodules and exposes the five network ports.
- src/router_core.bsv ‑ contains the crossbar, routing logic, and arbiters.
- src/buffer.bsv ‑ implements the statically allocated multi-queue buffers (SAMQs) that provide virtual channels for each incoming direction.
- src/tb_router.bsv ‑ testbench that drives and observes the router.
- Build scripts and configs:
- Makefile with a rule “generate_verilog” that runs `bsc` to compile all .bsv files into Verilog.
- README.adoc, CHANGELOG.md, docs/ folder for specification details.

##### README for additional insights
- The router supplies:
- 4 SAMQs (one per compass direction) + 1 for the attached PE (processing element).
- 4×4×1 crossbar switch—to multiplex any of the five input ports onto any of four compass outputs.
- A round-robin arbiter per output port (no priority scheme yet).
- An XY routing scheme (first route along X, then along Y, since each router’s coordinates are known).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top-Level Router
    subgraph "Top-Level Router"
        direction TB
        TL["Router"]:::control
        %% Input Buffers
        subgraph "Input Buffer Bank"
            direction TB
            B_N["Buffer N"]:::storage
            B_S["Buffer S"]:::storage
            B_E["Buffer E"]:::storage
            B_W["Buffer W"]:::storage
            B_L["Buffer Local"]:::storage
        end
        %% Routing Logic
        RL["Routing Logic"]:::control
        %% Router Core Components
        subgraph "Router Core"
            direction TB
            XBAR["Crossbar Switch"]:::datapath
            ARB_N["Arbiter North"]:::control
            ARB_S["Arbiter South"]:::control
            ARB_E["Arbiter East"]:::control
            ARB_W["Arbiter West"]:::control
        end
    end

    %% External Mesh Interfaces
    NorthPort["North Port"]:::external
    SouthPort["South Port"]:::external
    EastPort["East Port"]:::external
    WestPort["West Port"]:::external
    LocalPort["Local Port"]:::external

    %% Data Flow: Inputs to Buffers
    NorthPort -->|"flit_in"| B_N
    SouthPort -->|"flit_in"| B_S
    EastPort  -->|"flit_in"| B_E
    WestPort  -->|"flit_in"| B_W
    LocalPort -->|"flit_in"| B_L

    %% Control Flow: Header inspection
    B_N -->|"header"| RL
    B_S -->|"header"| RL
    B_E -->|"header"| RL
    B_W -->|"header"| RL
    B_L -->|"header"| RL

    %% Routing requests to arbiters
    RL -.->|"route_req"| ARB_N
    RL -.->|"route_req"| ARB_S
    RL -.->|"route_req"| ARB_E
    RL -.->|"route_req"| ARB_W

    %% Arbitration grants to crossbar
    ARB_N -->|"grant"| XBAR
    ARB_S -->|"grant"| XBAR
    ARB_E -->|"grant"| XBAR
    ARB_W -->|"grant"| XBAR

    %% Data through crossbar to outputs
    B_N -->|"flit_data"| XBAR
    B_S -->|"flit_data"| XBAR
    B_E -->|"flit_data"| XBAR
    B_W -->|"flit_data"| XBAR
    B_L -->|"flit_data"| XBAR

    XBAR -->|"flit_out"| NorthPort
    XBAR -->|"flit_out"| SouthPort
    XBAR -->|"flit_out"| EastPort
    XBAR -->|"flit_out"| WestPort

    %% Documentation and Scripts
    subgraph "Project Files"
        direction TB
        TBMod["tb_router.bsv"]:::external
        RouterMod["router.bsv"]:::control
        BufferMod["buffer.bsv"]:::storage
        CoreMod["router_core.bsv"]:::control
        Make["Makefile"]:::external
        Readme["README.adoc"]:::external
        Changelog["CHANGELOG.md"]:::external
        Docs["docs/"]:::external
    end

    %% Click Events
    click RouterMod "https://github.com/jiteshnayak2004/flame_thrower/blob/main/src/router.bsv"
    click BufferMod "https://github.com/jiteshnayak2004/flame_thrower/blob/main/src/buffer.bsv"
    click CoreMod "https://github.com/jiteshnayak2004/flame_thrower/blob/main/src/router_core.bsv"
    click TBMod "https://github.com/jiteshnayak2004/flame_thrower/blob/main/src/tb_router.bsv"
    click Make "https://github.com/jiteshnayak2004/flame_thrower/tree/main/Makefile"
    click Readme "https://github.com/jiteshnayak2004/flame_thrower/blob/main/README.adoc"
    click Changelog "https://github.com/jiteshnayak2004/flame_thrower/blob/main/CHANGELOG.md"
    click Docs "https://github.com/jiteshnayak2004/flame_thrower/tree/main/docs/"

    %% Styles
    classDef storage fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
    classDef control fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20
    classDef datapath fill:#ffe0b2,stroke:#e65100,color:#e65100
    classDef external fill:#e0e0e0,stroke:#424242,color:#424242
```
