# skpro-glitch/riscv-processor-asic architecture

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

- Interactive diagram: https://gitdiagram.com/skpro-glitch/riscv-processor-asic
- Repository: https://github.com/skpro-glitch/riscv-processor-asic

## Overview

##### Project type and purpose
- From the file tree and README, this is an HDL-based RISC-V processor design (ASIC/FPGA prototype) implementing the 32-bit integer ISA. The Verilog files correspond to the main processor datapath, control logic, memories, and submodules (ALU, Branch unit, Fetch, Decode, Execute, Load/Store, program/data memories).

##### File structure
- Top-level file: Processor.v (with a compiled version Processor_Compiled.v)
- Instruction memory: Prog_Mem.v
- Data memory: RAM.v and Data_RAM.v
- Datapath stages / control modules: Fetch.v, Decode.v, Execute.v, Loadstore.v, Branch.v, ALU.v
- Auxiliary modules: Prog_Count.v (program counter)

##### Key insights from README
- “Basic RISC-V based processor under development”
- Implements 32-bit integer ISA
- Single‐chip design with separate instruction and data memories

##### Main components
a. Program Counter (Prog_Count)
b. Instruction Memory (Prog_Mem)
c. Fetch stage (Fetch)
d. Decode stage (Decode) – includes register file and control signal generation
e. Execute stage (Execute) – orchestrates ALU and Branch modules
f. ALU (ALU) and Branch unit (Branch)
g. Memory access (Loadstore + Data_RAM)
h. Data memory (RAM) if used separately
i. Write-back path back into the register file inside Decode
j. Control signals and multiplexers

##### Relationships and data flows
- PC → instruction memory → fetched instruction → Decode
- Decode outputs register operands & control signals → Execute
- Execute drives ALU operations or Branch decisions
- Branch unit may override PC update
- Loadstore & Data_RAM modules handle memory reads/writes → result to write-back
- Write-back bus returns register data
- PC is updated each cycle by Prog_Count, based on branch/jump signals

##### Architectural patterns & design principles
- 5-stage pipeline (Fetch, Decode, Execute, Memory, Write-back)
- Harvard architecture (separate instruction and data memories)
- Modular design: each stage in its own .v file
- Clear separation of control (Decode, Branch) and datapath (ALU, memories)

##### Technologies, frameworks, libraries
- Verilog HDL modules
- ASIC synthesis flow implied by naming (*.v and *_Compiled.v)

- Clear labels: e.g., “PC (Prog_Count)”, “IMEM (Prog_Mem)”, “Fetch”, “Decode (RegFile+Control)”, “ALU”, “Branch Unit”, “Data Memory”
- A note on “5-stage pipeline” and “Harvard memory separation”

##### Final recommendation
- Be exhaustive: represent every .v module as a block or sub-block
- Inter-module wiring (control buses vs. data buses) clearly
- Don’t overcomplicate: align stages linearly and group related modules (e.g., decode+register file)
- This will give a precise, accurate view for implementation reviews, timing analysis, and ASIC synthesis planning.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Pipeline stages and components
    PC["PC (Prog_Count)"]:::pc
    IMEM["IMEM (Prog_Mem)"]:::mem
    Fetch["Fetch Stage"]:::pc
    Decode["Decode (RegFile+Control)"]:::control
    Execute["Execute Stage"]:::dp
    ALU["ALU Unit"]:::dp
    Branch["Branch Unit"]:::control
    MemAcc["Mem Access (Load/Store)"]:::dp
    DMEM["Data Memory (Data_RAM)"]:::mem
    WB["Write-Back Path"]:::control

    %% Main data/control flow
    PC -->|"Instr Addr"| IMEM
    IMEM -->|"Instr[31:0]"| Fetch
    Fetch -->|"Instr"| Decode
    Decode -->|"rs1_data, rs2_data, ctrl_signals"| Execute
    Execute -->|"alu_op, operands"| ALU
    ALU -->|"alu_result"| Execute
    Execute -->|"branch_ctrl"| Branch
    Branch -->|"branch_decision"| PC
    Execute -->|"mem_addr, write_data, mem_ctrl"| MemAcc
    MemAcc -->|"mem_data"| WB
    ALU -->|"alu_result"| WB
    WB -->|"reg_write_data"| Decode

    %% Memory connection
    MemAcc -.-> DMEM
    DMEM -.-> MemAcc

    %% Click events
    click PC "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Prog_Count.v"
    click IMEM "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Prog_Mem.v"
    click Fetch "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Fetch.v"
    click Decode "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Decode.v"
    click Execute "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Execute.v"
    click ALU "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/ALU.v"
    click Branch "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Branch.v"
    click MemAcc "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Loadstore.v"
    click DMEM "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Data_RAM.v"
    click PC "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Prog_Count.v"
    click IMEM "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Prog_Mem.v"
    click DMEM "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/RAM.v"
    click WB "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Processor.v"
    click WB "https://github.com/skpro-glitch/riscv-processor-asic/blob/main/Processor_Compiled.v"

    %% Styles
    classDef pc fill:#ccffcc,stroke:#006600,color:#003300
    classDef control fill:#cce0ff,stroke:#003366,color:#001933
    classDef dp fill:#ffe0b3,stroke:#cc8400,color:#663d00
    classDef mem fill:#e0e0e0,stroke:#666666,color:#333333
```
