# knguyen260404/cpu_32bit_verilog architecture

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

- Interactive diagram: https://gitdiagram.com/knguyen260404/cpu_32bit_verilog
- Repository: https://github.com/knguyen260404/cpu_32bit_verilog

## Overview

##### Project type and purpose
- This is a hardware‐IP project: a 32-bit RISC-V RV32I five-stage pipelined CPU targeting the Skywater 130 nm PDK via the OpenLane flow.
- It includes full RTL (cpu_core/ and src/), testbenches & simulation scripts (verify/), PnR configs (config.json, pin_order.cfg), and end-to-end documentation (documentation/).

##### File structure
- Top-level:
- cpu_core/: Modular RTL subcomponents for the final synthesized core.
- src/: Flat Verilog sources including the top-level riscv_5stage_cpu.v and SDC constraints.
- documentation/: Architecture, implementation guide, verification reports, deployment analysis.
- verify/: Testbench code, simulation harnesses, waveform analysis, and results.
- config.json & pin_order.cfg: OpenLane and I/O pin mapping for PnR.
- Patterns: A classic 5-stage pipeline (IF, ID, EX, MEM, WB) with hazard/forwarding units and Harvard memory separation.

##### README for additional insights
- Confirms a 5-stage Harvard RISC-V pipeline.

##### Detail
- Every pipeline boundary, hazard/forwarding path, and memory interface.
- SDC constraints feeding into the PnR block, and pin_order.cfg tying to the pad ring.
- Distinguish between RTL modules, testbench environment, and the OpenLane flow region.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Pipeline Stages
    subgraph "Instruction Fetch (IF)" 
        direction TB
        PC["PC Reg\n(npc_generator)"]:::compute
        IMEM["InstructionMemory"]:::memory
        IFID["IF/ID Register"]:::register
    end

    subgraph "Instruction Decode (ID)"
        direction TB
        RF["RegisterFile"]:::memory
        IMM["ImmediateGenerator"]:::compute
        HZ["HazardUnit"]:::control
        IDEX["ID/EX Register"]:::register
    end

    subgraph "Execute (EX)"
        direction TB
        ALUCTL["ALUControl"]:::control
        ALU["ALU / FastALU"]:::compute
        FU["ForwardingUnit"]:::control
        EXMEM["EX/MEM Register"]:::register
    end

    subgraph "Memory (MEM)"
        direction TB
        DMEM["DataMemory"]:::memory
        CTRL["ControlUnit"]:::control
        MEMWB["MEM/WB Register"]:::register
    end

    subgraph "Writeback (WB)"
        direction TB
        MUX["WB MUX & Write Enable"]:::compute
    end

    %% Core Integration
    subgraph "CPU Core"
        direction TB
        CORE["CPU_core.v"]:::external
    end

    %% Global Support
    subgraph "Global Support"
        direction TB
        RSYNC["ResetSynchronizer"]:::control
    end

    %% PnR Flow
    subgraph "OpenLane Flow & PDK"
        direction TB
        SDC["SDC Constraints"]:::pr
        CFG["config.json\npin_order.cfg"]:::pr
        PNR["Place & Route → GDSII"]:::pr
    end

    %% Verification
    subgraph "Verification & Simulation"
        direction TB
        TBENCH["Testbenches"]:::external
        SIM["Simulation Scripts"]:::external
        RES["Results & Waveforms"]:::external
    end

    %% Documentation
    subgraph "Documentation"
        direction TB
        ARCH["ARCHITECTURE.md"]:::doc
        IMP["IMPLEMENTATION_GUIDE.md"]:::doc
        VERIF["VERIFICATION_REPORT.md"]:::doc
        SIMREP["SIMULATION_RESULTS.md"]:::doc
        DEPLOY["DEPLOYMENT_ANALYSIS.md"]:::doc
        SYNOPSYS["SYNOPSYS_ANALYSIS.md"]:::doc
        STATUS["STATUS.md"]:::doc
    end

    %% Data Flow
    PC --> IMEM --> IFID --> RF --> IMM --> IDEX --> ALUCTL --> ALU --> EXMEM --> DMEM --> MEMWB --> MUX

    %% Control and Hazard
    HZ --> IDEX
    FU --> ALU

    %% Core Integration Edges
    IFID --> CORE
    IDEX --> CORE
    EXMEM --> CORE
    MEMWB --> CORE

    RSYNC --> IFID
    RSYNC --> IDEX
    RSYNC --> EXMEM
    RSYNC --> MEMWB

    %% PnR & Timing
    CORE --> SDC
    CORE --> CFG
    CORE --> PNR

    %% Verification connections
    CORE --> TBENCH --> SIM --> RES

    %% Documentation references
    CORE --> ARCH
    CORE --> IMP
    CORE --> VERIF
    CORE --> SIMREP
    CORE --> DEPLOY
    CORE --> SYNOPSYS
    CORE --> STATUS

    %% Click Events
    click PC "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/npc_generator.v"
    click IMEM "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/instruction_memory.v"
    click IFID "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/riscv_5stage_cpu.v"
    click RF "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/register_file.v"
    click IMM "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/immediate_generator.v"
    click HZ "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/hazard_unit.v"
    click IDEX "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/riscv_5stage_cpu.v"
    click ALUCTL "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/cpu_core/ALUControl_Fast.v"
    click ALU "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/cpu_core/FastALU.v"
    click FU "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/forwarding_unit.v"
    click EXMEM "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/riscv_5stage_cpu.v"
    click DMEM "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/data_memory.v"
    click CTRL "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/control_unit.v"
    click MEMWB "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/riscv_5stage_cpu.v"
    click MUX "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/riscv_5stage_cpu.v"
    click CORE "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/cpu_core/CPU_core.v"
    click RSYNC "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/reset_synchronizer.v"
    click SDC "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/src/riscv_5stage_cpu.sdc"
    click CFG "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/config.json"
    click PNR "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/pin_order.cfg"
    click TBENCH "https://github.com/knguyen260404/cpu_32bit_verilog/tree/main/verify/testbench/"
    click SIM "https://github.com/knguyen260404/cpu_32bit_verilog/tree/main/verify/simulation/"
    click RES "https://github.com/knguyen260404/cpu_32bit_verilog/tree/main/verify/results/"
    click ARCH "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/documentation/ARCHITECTURE.md"
    click IMP "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/documentation/IMPLEMENTATION_GUIDE.md"
    click VERIF "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/documentation/VERIFICATION_REPORT.md"
    click SIMREP "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/documentation/SIMULATION_RESULTS.md"
    click DEPLOY "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/documentation/DEPLOYMENT_ANALYSIS.md"
    click SYNOPSYS "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/documentation/SYNOPSYS_ANALYSIS.md"
    click STATUS "https://github.com/knguyen260404/cpu_32bit_verilog/blob/main/documentation/STATUS.md"

    %% Styles
    classDef compute fill:#f9f,stroke:#333,stroke-width:1px
    classDef register fill:#ffa,stroke:#333,stroke-width:1px
    classDef control fill:#9cf,stroke:#333,stroke-width:1px
    classDef memory fill:#afa,stroke:#333,stroke-width:1px
    classDef pr fill:#fcc,stroke:#333,stroke-width:1px
    classDef external fill:#eee,stroke:#333,stroke-width:1px
    classDef doc fill:#cdf,stroke:#333,stroke-width:1px
```
