# xuantie-rv/openc906 architecture

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

- Interactive diagram: https://gitdiagram.com/xuantie-rv/openc906
- Repository: https://github.com/xuantie-rv/openc906

## Overview

##### Project type and purpose
- This is an open-source hardware RTL project implementing the “C906” RISC-V CPU core plus a small SoC test environment.
- The `C906_RTL_FACTORY/gen_rtl/…` directory contains all the Verilog RTL modules of the CPU’s functional units and system coprocessors (IFU, IDU, IU, LSU, BIU, MMU, PLIC, CLINT, CP0, PMU, DTU, RTU, DSP/FP units, etc.).
- The `smart_run/` directory is the simulation/test-bench environment: bus fabrics (AXI, AHB, APB), on-chip peripherals (UART, GPIO, timer), memory models, SDC for synthesis/timing, and test suites.

##### File structure
- Top-level split:
- C906_RTL_FACTORY/gen_rtl – CPU core RTL
- C906_RTL_FACTORY/setup – environment setup scripts
- smart_run – simulation “SoC” wrapper and test infrastructure
– impl – timing constraint (SDC) files
– logical – bus interconnects, SoC glue, memory/pseudo-RAM models, peripherals, testbench top
– tests – C and assembly test suites, linker scripts, boot code
– setup – toolchain environment scripts
– work – simulation output (waveforms)
- The CPU modules follow an organized pipeline structure:
IFU → IDU → IU / LSU / BIU with cross-cutting agents for CSR (CP0), debug (DTU/TDMI), traps (RTU), interrupts (PLIC), timer (CLINT).
- Bus fabrics in `smart_run/logical`:
AXI interconnect → AHB → APB bridge → APB peripherals.

##### README for additional insights
- The README confirms this is a CPU-centric IP with a “smart” testbench.
- It details usage: environment setup, dependencies on an external RISC-V toolchain, supported simulators (iverilog, vcs, irun).

##### Elements
– Clear labels for each block (e.g., “aq_ifu_top”, “aq_lsu_top”, “AXI Interconnect”, “UART_APB”)
- Bus fabrics (another)
- Peripherals (distinct)
- Debug/Test harness (distinct)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% SoC Wrapper
    soc["SoC Top / Testbench Wrapper"]:::wrapper

    %% CPU Core Node and Submodules
    cpu["CPU Core"]:::core
    soc --> cpu

    subgraph "CPU Core"
        ifu["Instruction Fetch Unit (IFU)"]:::core
        idu["Instruction Decode Unit (IDU)"]:::core
        iu["Integer Unit (IU)"]:::core
        lsu["Load-Store Unit (LSU)"]:::core
        biu["Bus Interface Unit (BIU)"]:::core

        cp0["Control & Status Coprocessor (CP0)"]:::coproc
        pmu["Performance Monitoring Unit (PMU)"]:::coproc
        mmu["Memory Management Unit (MMU)"]:::coproc
        rtu["Retire/Trap Unit (RTU)"]:::coproc
        dtu["Debug/Test Unit (DTU)"]:::coproc
        plic["Platform-Level Interrupt Controller (PLIC)"]:::coproc
        clint["Core Local Interruptor/Timer (CLINT)"]:::coproc
        tdt["Debug Transport Module (TDT/TDMI)"]:::coproc

        %% Pipeline flow
        ifu --> idu
        idu --> iu
        iu --> lsu
        lsu --> biu

        %% CSR & Coprocessor links
        iu --> cp0
        rtu --> cp0
        plic --> cp0
        clint --> cp0

        %% Debug flow
        dtu --> tdt
    end

    %% Bus Fabric
    subgraph "Bus Fabric"
        axi["AXI Interconnect"]:::bus
        ahb["AHB Bus"]:::bus
        apb["APB Bridge"]:::bus
        cpu --> axi
        axi --> ahb
        ahb --> apb
    end

    %% Memory
    mem["On-chip Memory Model (RAM)"]:::mem
    axi --> mem

    %% Peripherals
    subgraph "Peripherals"
        uart["UART"]:::periph
        gpio["GPIO"]:::periph
        timer["Timer"]:::periph
        apb --> uart
        apb --> gpio
        apb --> timer
    end

    %% Testbench
    tb["Testbench Top Module"]:::tb
    tb --> soc

    %% Click Events
    click cpu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/cpu/rtl/aq_top.v"
    click ifu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/ifu/rtl/aq_ifu_top.v"
    click idu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/idu/rtl/aq_idu_top.v"
    click iu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/iu/rtl/aq_iu_top.v"
    click lsu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/lsu/rtl/aq_lsu_top.v"
    click biu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/biu/rtl/aq_biu_top.v"
    click cp0 "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/cp0/rtl/aq_cp0_top.v"
    click pmu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v"
    click mmu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/mmu/rtl/aq_mmu_top.v"
    click rtu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/rtu/rtl/aq_rtu_top.v"
    click dtu "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/dtu/rtl/aq_dtu_top.v"
    click plic "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/plic/rtl/plic_top.v"
    click clint "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/clint/rtl/clint_top.v"
    click tdt "https://github.com/xuantie-rv/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/tdt/rtl/top/tdt_top.v"
    click axi "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/axi/axi_interconnect128.v"
    click ahb "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/ahb/ahb.v"
    click apb "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/apb/apb_bridge.v"
    click uart "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/uart/uart.v"
    click gpio "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/gpio/gpio.v"
    click timer "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/common/timer.v"
    click mem "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/mem/ram.v"
    click soc "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/common/soc.v"
    click tb "https://github.com/xuantie-rv/openc906/blob/main/smart_run/logical/tb/tb.v"

    %% Styles
    classDef core fill:#AEDFF7,stroke:#0366D6,color:#0366D6;
    classDef coproc fill:#D4F1C5,stroke:#2C662D,color:#2C662D;
    classDef bus fill:#FFF3CD,stroke:#856404,color:#856404;
    classDef periph fill:#FDE2E1,stroke:#C82333,color:#C82333;
    classDef mem fill:#E2E8F0,stroke:#1F2A37,color:#1F2A37;
    classDef tb fill:#E8DAEF,stroke:#6F42C1,color:#6F42C1;
    classDef wrapper fill:#F0F4C3,stroke:#827717,color:#827717;
```
