# agalimberti/nocrouter architecture

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

- Interactive diagram: https://gitdiagram.com/agalimberti/nocrouter
- Repository: https://github.com/agalimberti/nocrouter

## Overview

##### Project type and purpose
- This is an RTL‐level hardware design in SystemVerilog implementing a Network‐on‐Chip (NoC) router with wormhole switching, multiple virtual channels (VCs), and a 2D mesh topology.
- Its goal is to route flit‐granular packets through a mesh of routers using Dimension Order Routing (DOR), VC allocation, switch allocation, and On/Off flow control.

##### File structure
- Top level:
- src/if – contains SystemVerilog interface definitions (decouples I/O from behavior)
- src/rtl – implements the functional blocks:
– allocators (round‐robin arbiter, VC allocator, separable‐input‐first, switch allocator)
– crossbar (crossbar switch)
– input_port (input buffer, circular buffer, resource control unit)
– noc (mesh, noc top, links between routers)
– router (top‐level router integrating all submodules)
- src/tb – testbenches for each module and for top‐level interactions
- src/discarded – older/alternative implementations (ignore for current architecture)
- Other artifacts:
- doc/Project Documentation.pdf – high‐level design rationale
- _config.yml, README.md, LICENSE, .gitignore

##### Key insights from README
- Bottom‐up development: each submodule built & tested before composition
- Interfaces heavily used to simplify wiring between submodules
- Wormhole switching with multiple VCs to avoid head‐of‐line blocking
- Dimension Order Routing computed locally in each router
- On/Off flow control in switch allocator
- Verification by self‐checking testbenches in Vivado HL WebPack 2016.4

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mesh Level
    subgraph "NoC Mesh Top (src/rtl/noc/noc.sv)"
        Mesh["NoC Top"]:::block
        click Mesh "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/noc/noc.sv"
        Mesh -->|instantiates| MeshGrid["Mesh (M×N grid)"]:::block
        click MeshGrid "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/noc/mesh.sv"
    end

    %% Node Links
    MeshGrid -->|to local node| NL["Node Link"]:::data
    click NL "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/noc/node_link.sv"
    MeshGrid -->|to neighbor router| RL["Router Link"]:::data
    click RL "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/noc/router_link.sv"

    %% Router Instance
    MeshGrid -->|contains| RouterNode["Router Instance"]:::block
    click RouterNode "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/router/router.sv"

    %% Router Internals
    subgraph "Router Internals"
        direction TB
        subgraph "Input Port Block"
            IB["Input Block"]:::block
            click IB "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/input_port/input_block.sv"
            IB --> CB["Circular Buffer"]:::block
            click CB "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/input_port/circular_buffer.sv"
            IB --> IBUF["Input Buffer"]:::block
            click IBUF "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/input_port/input_buffer.sv"
            IB --> RC["RC Unit"]:::control
            click RC "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/input_port/rc_unit.sv"
        end

        %% Interfaces
        subgraph "Interfaces"
            IF1["Input→VC Intf"]:::interface
            click IF1 "https://github.com/agalimberti/nocrouter/blob/master/src/if/input_block2vc_allocator.sv"
            IF2["Input→Switch Intf"]:::interface
            click IF2 "https://github.com/agalimberti/nocrouter/blob/master/src/if/input_block2switch_allocator.sv"
            IF3["Input→Crossbar Intf"]:::interface
            click IF3 "https://github.com/agalimberti/nocrouter/blob/master/src/if/input_block2crossbar.sv"
            IF4["SA→Crossbar Intf"]:::interface
            click IF4 "https://github.com/agalimberti/nocrouter/blob/master/src/if/switch_allocator2crossbar.sv"
            IF5["Router→Router Intf"]:::interface
            click IF5 "https://github.com/agalimberti/nocrouter/blob/master/src/if/router2router.sv"
        end

        %% Allocation and Crossbar
        IB -->|flit data| IF1 --> VC["VC Allocator"]:::control
        click VC "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/allocators/vc_allocator.sv"

        VC -->|vc grant| IF2 --> SA["Switch Allocator"]:::control
        click SA "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/allocators/switch_allocator.sv"

        subgraph "Arbiter Modules"
            RRA["Round-Robin Arbiter"]:::control
            click RRA "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/allocators/round_robin_arbiter.sv"
            SIFA["Separable-Input-First Arbiter"]:::control
            click SIFA "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/allocators/separable_input_first_allocator.sv"
        end
        SA --> RRA
        SA --> SIFA

        SA -->|grant| IF4 --> CBx["Crossbar Switch"]:::block
        click CBx "https://github.com/agalimberti/nocrouter/blob/master/src/rtl/crossbar/crossbar.sv"

        DOR["DOR Logic"]:::control
        IB --> DOR
        DOR --> SA

        CBx -->|flit data| IF5 --> RL
        CBx -->|flit data| NL
    end

    classDef block fill:#f9f,stroke:#333,stroke-width:1px;
    classDef data stroke:#0000ff,fill:#eef,stroke-width:2px;
    classDef control stroke:#ff0000,fill:#fee,stroke-width:2px;
    classDef interface stroke-dasharray:5 5,stroke:#999;
```
