# sergeykhbr/riscv_vhdl architecture

> Architecture diagram of the GitHub repository sergeykhbr/riscv_vhdl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sergeykhbr/riscv_vhdl
- Repository: https://github.com/sergeykhbr/riscv_vhdl

## Overview

This repository combines a RISC-V SoC design with a C++ debugger and simulation ecosystem. The principal workflow is firmware execution on the River processor and SoC peripherals, with the debugger providing command, inspection, and visualization facilities against simulated or FPGA targets. The graph preserves documented CPU models, debugging and bus capabilities, and major peripheral areas. Some subsystem connections are documented only at a high level; unsampled source is not treated as inspected, and unverified links are omitted.

Main entry points: [`sc/prj/impl/asic_gencpu64/asic_gencpu64_top.cpp`](https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/prj/impl/asic_gencpu64/asic_gencpu64_top.cpp) (SoC top), [`debugger/src/appdbg64g/main.cpp`](https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/appdbg64g/main.cpp) (Debugger application), [`debugger/src/socsim_plugin`](https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/socsim_plugin) (SoC simulator), [`sc/rtl/internal/riverlib/core`](https://github.com/sergeykhbr/riscv_vhdl/tree/master/sc/rtl/internal/riverlib/core) (River CPU)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_soc["SoC implementation"]
  node_river_cpu["River CPU"]
  node_river_cache["River cache<br/>[dcache_lru.cpp]"]
  node_river_csr["River CSR<br/>[csr.cpp]"]
  node_soc_top["SoC top"]
  node_soc_fabric["AMBA fabric"]
end

subgraph group_peripherals["SoC peripherals"]
  node_uart["UART peripheral<br/>[apb_uart.h]"]
  node_sd_controller["SD controller<br/>[sdctrl.cpp]"]
end

subgraph group_debugger["Debugger runtime"]
  node_debug_app["Debugger application<br/>[main.cpp]"]
  node_debug_services["Debugger services"]
  node_service_api["Service API<br/>[iservice.h]"]
  node_dpi_client["DPI client<br/>[dpiclient.cpp]"]
end

subgraph group_ui["Debugger UI"]
  node_debug_gui["Debugger GUI<br/>[gui_plugin.cpp]"]
  node_coverage_ui["Coverage view"]
end

subgraph group_simulation["Simulation models"]
  node_soc_sim["SoC simulator"]
  node_systemc_cpu["SystemC CPU"]
  node_functional_cpu["Functional CPU"]
end

node_engineer(("Firmware engineer"))
node_fpga_target["FPGA target"]
node_ethernet["Ethernet EDCL"]

node_engineer -.->|"starts debugger"| node_debug_app
node_debug_app -->|"configures services"| node_service_api
node_service_api -.->|"registers services"| node_debug_services
node_debug_gui -.->|"hosts view"| node_coverage_ui
node_debug_services -.->|"includes remote access"| node_dpi_client
node_dpi_client -.->|"exchanges DPI requests"| node_fpga_target
node_engineer -.->|"runs firmware"| node_soc_top
node_soc_top -->|"instantiates SoC"| node_soc_fabric
node_soc_top -.->|"runs processor"| node_river_cpu
node_soc_top -.->|"integrates peripheral"| node_uart
node_soc_top -.->|"integrates peripheral"| node_sd_controller
node_river_cpu -.->|"uses cache"| node_river_cache
node_river_cpu -.->|"uses control registers"| node_river_csr
node_engineer -.->|"runs simulation"| node_soc_sim
node_soc_sim -.->|"supports functional model"| node_functional_cpu
node_soc_sim -.->|"supports precise model"| node_systemc_cpu
node_debug_app -.->|"loads simulator plugin"| node_soc_sim
node_debug_app -.->|"debugs target"| node_fpga_target
node_debug_app -.->|"uses EDCL transport"| node_ethernet
node_ethernet -.->|"connects to target"| node_fpga_target

click node_river_cpu "https://github.com/sergeykhbr/riscv_vhdl/tree/master/sc/rtl/internal/riverlib/core"
click node_river_cache "https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/riverlib/cache/dcache_lru.cpp"
click node_river_csr "https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/riverlib/core/csr.cpp"
click node_soc_top "https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/prj/impl/asic_gencpu64/asic_gencpu64_top.cpp"
click node_soc_fabric "https://github.com/sergeykhbr/riscv_vhdl/tree/master/sc/rtl/internal/ambalib"
click node_uart "https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/misclib/apb_uart.h"
click node_sd_controller "https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/sdctrl/sdctrl.cpp"
click node_soc_sim "https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/socsim_plugin"
click node_systemc_cpu "https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/cpu_sysc_plugin"
click node_functional_cpu "https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/cpu_fnc_plugin"
click node_debug_app "https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/appdbg64g/main.cpp"
click node_debug_services "https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/libdbg64g/services"
click node_service_api "https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/common/iservice.h"
click node_debug_gui "https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/gui_plugin/gui_plugin.cpp"
click node_coverage_ui "https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/gui_plugin/CpuWidgets/CodeCoverage/CodeCoverageWidget.cpp"
click node_dpi_client "https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/libdbg64g/services/remote/dpiclient.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_river_cpu,node_river_cache,node_river_csr,node_soc_top,node_soc_fabric toneBlue
class node_uart,node_sd_controller toneAmber
class node_debug_app,node_debug_services,node_service_api,node_dpi_client toneMint
class node_debug_gui,node_coverage_ui toneRose
class node_soc_sim,node_systemc_cpu,node_functional_cpu,node_engineer,node_fpga_target,node_ethernet toneIndigo
```

## Components

### SoC implementation

- [River CPU](https://github.com/sergeykhbr/riscv_vhdl/tree/master/sc/rtl/internal/riverlib/core): `sc/rtl/internal/riverlib/core`
- [River cache](https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/riverlib/cache/dcache_lru.cpp): `sc/rtl/internal/riverlib/cache/dcache_lru.cpp`
- [River CSR](https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/riverlib/core/csr.cpp): `sc/rtl/internal/riverlib/core/csr.cpp`
- [SoC top](https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/prj/impl/asic_gencpu64/asic_gencpu64_top.cpp): `sc/prj/impl/asic_gencpu64/asic_gencpu64_top.cpp`
- [AMBA fabric](https://github.com/sergeykhbr/riscv_vhdl/tree/master/sc/rtl/internal/ambalib): `sc/rtl/internal/ambalib`

### SoC peripherals

- [UART peripheral](https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/misclib/apb_uart.h): `sc/rtl/internal/misclib/apb_uart.h`
- [SD controller](https://github.com/sergeykhbr/riscv_vhdl/blob/master/sc/rtl/internal/sdctrl/sdctrl.cpp): `sc/rtl/internal/sdctrl/sdctrl.cpp`

### Debugger runtime

- [Debugger application](https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/appdbg64g/main.cpp): `debugger/src/appdbg64g/main.cpp`
- [Debugger services](https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/libdbg64g/services): `debugger/src/libdbg64g/services`
- [Service API](https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/common/iservice.h): `debugger/src/common/iservice.h`
- [DPI client](https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/libdbg64g/services/remote/dpiclient.cpp): `debugger/src/libdbg64g/services/remote/dpiclient.cpp`

### Debugger UI

- [Debugger GUI](https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/gui_plugin/gui_plugin.cpp): `debugger/src/gui_plugin/gui_plugin.cpp`
- [Coverage view](https://github.com/sergeykhbr/riscv_vhdl/blob/master/debugger/src/gui_plugin/CpuWidgets/CodeCoverage/CodeCoverageWidget.cpp): `debugger/src/gui_plugin/CpuWidgets/CodeCoverage/CodeCoverageWidget.cpp`

### Simulation models

- [SoC simulator](https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/socsim_plugin): `debugger/src/socsim_plugin`
- [SystemC CPU](https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/cpu_sysc_plugin): `debugger/src/cpu_sysc_plugin`
- [Functional CPU](https://github.com/sergeykhbr/riscv_vhdl/tree/master/debugger/src/cpu_fnc_plugin): `debugger/src/cpu_fnc_plugin`

### Other components

- **Firmware engineer**
- **FPGA target**
- **Ethernet EDCL**

## Connections

- Firmware engineer → Debugger application: starts debugger
- Debugger application → Service API: configures services (evidence: `debugger/src/appdbg64g/main.cpp`)
- Service API → Debugger services: registers services
- Debugger GUI → Coverage view: hosts view
- Debugger services → DPI client: includes remote access (evidence: `debugger/src/libdbg64g/services/remote/dpiclient.cpp`)
- DPI client → FPGA target: exchanges DPI requests
- Firmware engineer → SoC top: runs firmware
- SoC top → AMBA fabric: instantiates SoC
- SoC top → River CPU: runs processor
- SoC top → UART peripheral: integrates peripheral
- SoC top → SD controller: integrates peripheral
- River CPU → River cache: uses cache
- River CPU → River CSR: uses control registers (evidence: `sc/rtl/internal/riverlib/core/csr.cpp`)
- Firmware engineer → SoC simulator: runs simulation
- SoC simulator → Functional CPU: supports functional model
- SoC simulator → SystemC CPU: supports precise model
- Debugger application → SoC simulator: loads simulator plugin
- Debugger application → FPGA target: debugs target
- Debugger application → Ethernet EDCL: uses EDCL transport
- Ethernet EDCL → FPGA target: connects to target
