# bsc-loca/sauria architecture

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

- Interactive diagram: https://gitdiagram.com/bsc-loca/sauria
- Repository: https://github.com/bsc-loca/sauria

## Overview

SAURIA is a configurable SystemVerilog CNN convolution/GEMM accelerator, with Python tools for preparing workloads and generating stimuli, running simulations, and checking results. The main workflow starts with a user workload, creates convolution and hardware configuration, prepares tensor and memory data, then runs the RTL accelerator and reads simulation outputs. The README also identifies on-the-fly convolution lowering and configurable arithmetic/array shapes as core capabilities. RTL relationships are shown only where documented; sampled evidence focuses on the Python tools, so uncertain internal RTL connections are omitted.

Main entry points: [`Python/src/sauria_lib.py`](https://github.com/bsc-loca/sauria/blob/main/Python/src/sauria_lib.py) (Simulation API), [`Python/src/approx_comp/multipliers.py`](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/multipliers.py) (Multiplier selection), [`RTL/src/sauria_core/sauria_core.sv`](https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/sauria_core.sv) (Accelerator core), [`Python/src/file_helper.py`](https://github.com/bsc-loca/sauria/blob/main/Python/src/file_helper.py) (Stimuli and results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python["Python workload tools"]
  node_api["Simulation API<br/>[sauria_lib.py]"]
  node_convolution["Convolution mapping<br/>[sauria_lib.py]"]
  node_config["Hardware configuration<br/>[config_helper.py]"]
  node_data["Tensor and DRAM data<br/>[data_helper.py]"]
  node_files["Stimuli and results<br/>[file_helper.py]"]
  node_execution["Execution model<br/>[execution_model.py]"]
  node_approx_float["Approximate FP arithmetic<br/>[fp.py]"]
  node_mul_dispatch["Multiplier selection<br/>[multipliers.py]"]
  node_booth["Booth multiplier<br/>[abm.py]"]
  node_broken_array["Broken array multiplier<br/>[bam.py]"]
  node_logarithmic["Log multiplier<br/>[lm.py]"]
  node_udm["UDM multiplier<br/>[udm.py]"]
  node_adders["Approximate adders<br/>[adders.py]"]
end

subgraph group_rtl_control["RTL control and dataflow"]
  node_rtl_top["SAURIA subsystem"]
  node_df_controller["Dataflow controller"]
  node_dma["DMA engine<br/>[dma_top.sv]"]
end

subgraph group_rtl_compute["RTL compute and memory"]
  node_core["Accelerator core<br/>[sauria_core.sv]"]
  node_array["Systolic array<br/>[sa_array.sv]"]
  node_feeders["Operand feeders<br/>[ifmap_feeder.sv]"]
  node_local_memory[("Local SRAM<br/>[sram_top.sv]")]
  node_psm["Partial-sum manager<br/>[psm_top.sv]"]
end

node_user(("Workload user"))
node_simulator["RTL simulator"]

node_user -->|"configures"| node_api
node_api -->|"maps workload"| node_convolution
node_api -->|"builds registers"| node_config
node_api -->|"prepares tensors"| node_data
node_api -->|"models execution"| node_execution
node_api -->|"generates stimuli"| node_files
node_files -->|"packs commands"| node_config
node_files -->|"converts data"| node_data
node_execution -->|"evaluates arithmetic"| node_approx_float
node_approx_float -->|"uses multipliers"| node_mul_dispatch
node_approx_float -.->|"uses adders"| node_adders
node_mul_dispatch -->|"dispatches"| node_booth
node_mul_dispatch -->|"dispatches"| node_broken_array
node_mul_dispatch -->|"dispatches"| node_logarithmic
node_mul_dispatch -->|"dispatches"| node_udm
node_files -->|"provides stimuli"| node_simulator
node_simulator -->|"runs design"| node_rtl_top
node_rtl_top -.->|"coordinates"| node_df_controller
node_rtl_top -.->|"transfers memory"| node_dma
node_rtl_top -.->|"connects accelerator"| node_core
node_core -.->|"computes GEMM"| node_array
node_core -.->|"supplies operands"| node_feeders
node_core -.->|"uses SRAM"| node_local_memory
node_core -.->|"manages sums"| node_psm
node_simulator -.->|"writes outputs"| node_files

click node_api "https://github.com/bsc-loca/sauria/blob/main/Python/src/sauria_lib.py"
click node_convolution "https://github.com/bsc-loca/sauria/blob/main/Python/src/sauria_lib.py"
click node_config "https://github.com/bsc-loca/sauria/blob/main/Python/src/config_helper.py"
click node_data "https://github.com/bsc-loca/sauria/blob/main/Python/src/data_helper.py"
click node_files "https://github.com/bsc-loca/sauria/blob/main/Python/src/file_helper.py"
click node_execution "https://github.com/bsc-loca/sauria/blob/main/Python/src/execution_model.py"
click node_approx_float "https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/fp.py"
click node_mul_dispatch "https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/multipliers.py"
click node_booth "https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/abm.py"
click node_broken_array "https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/bam.py"
click node_logarithmic "https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/lm.py"
click node_udm "https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/udm.py"
click node_adders "https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/adders.py"
click node_rtl_top "https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_subsystem.sv"
click node_df_controller "https://github.com/bsc-loca/sauria/blob/main/RTL/src/df_controller/df_controller_top.sv"
click node_dma "https://github.com/bsc-loca/sauria/blob/main/RTL/src/dma/dma_top.sv"
click node_core "https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/sauria_core.sv"
click node_array "https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/systolic_array/sa_array.sv"
click node_feeders "https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/data_feeder/ifmap_feeder.sv"
click node_local_memory "https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/sram/sram_top.sv"
click node_psm "https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/psm/psm_top.sv"

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_api,node_convolution,node_config,node_data,node_files,node_execution,node_approx_float,node_mul_dispatch,node_booth,node_broken_array,node_logarithmic,node_udm,node_adders,node_user toneBlue
class node_rtl_top,node_df_controller,node_dma toneAmber
class node_core,node_array,node_feeders,node_local_memory,node_psm toneMint
class node_simulator toneIndigo
```

## Components

### Python workload tools

- [Simulation API](https://github.com/bsc-loca/sauria/blob/main/Python/src/sauria_lib.py): `Python/src/sauria_lib.py`
- [Convolution mapping](https://github.com/bsc-loca/sauria/blob/main/Python/src/sauria_lib.py): `Python/src/sauria_lib.py`
- [Hardware configuration](https://github.com/bsc-loca/sauria/blob/main/Python/src/config_helper.py): `Python/src/config_helper.py`
- [Tensor and DRAM data](https://github.com/bsc-loca/sauria/blob/main/Python/src/data_helper.py): `Python/src/data_helper.py`
- [Stimuli and results](https://github.com/bsc-loca/sauria/blob/main/Python/src/file_helper.py): `Python/src/file_helper.py`
- [Execution model](https://github.com/bsc-loca/sauria/blob/main/Python/src/execution_model.py): `Python/src/execution_model.py`
- [Approximate FP arithmetic](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/fp.py): `Python/src/approx_comp/fp.py`
- [Multiplier selection](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/multipliers.py): `Python/src/approx_comp/multipliers.py`
- [Booth multiplier](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/abm.py): `Python/src/approx_comp/abm.py`
- [Broken array multiplier](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/bam.py): `Python/src/approx_comp/bam.py`
- [Log multiplier](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/lm.py): `Python/src/approx_comp/lm.py`
- [UDM multiplier](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/udm.py): `Python/src/approx_comp/udm.py`
- [Approximate adders](https://github.com/bsc-loca/sauria/blob/main/Python/src/approx_comp/adders.py): `Python/src/approx_comp/adders.py`

### RTL control and dataflow

- [SAURIA subsystem](https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_subsystem.sv): `RTL/src/sauria_subsystem.sv`
- [Dataflow controller](https://github.com/bsc-loca/sauria/blob/main/RTL/src/df_controller/df_controller_top.sv): `RTL/src/df_controller/df_controller_top.sv`
- [DMA engine](https://github.com/bsc-loca/sauria/blob/main/RTL/src/dma/dma_top.sv): `RTL/src/dma/dma_top.sv`

### RTL compute and memory

- [Accelerator core](https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/sauria_core.sv): `RTL/src/sauria_core/sauria_core.sv`
- [Systolic array](https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/systolic_array/sa_array.sv): `RTL/src/sauria_core/systolic_array/sa_array.sv`
- [Operand feeders](https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/data_feeder/ifmap_feeder.sv): `RTL/src/sauria_core/data_feeder/ifmap_feeder.sv`
- [Local SRAM](https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/sram/sram_top.sv): `RTL/src/sauria_core/sram/sram_top.sv`
- [Partial-sum manager](https://github.com/bsc-loca/sauria/blob/main/RTL/src/sauria_core/psm/psm_top.sv): `RTL/src/sauria_core/psm/psm_top.sv`

### Other components

- **Workload user**
- **RTL simulator**

## Connections

- Workload user → Simulation API: configures (evidence: `README.md`)
- Simulation API → Convolution mapping: maps workload (evidence: `Python/src/sauria_lib.py`)
- Simulation API → Hardware configuration: builds registers (evidence: `Python/src/sauria_lib.py`)
- Simulation API → Tensor and DRAM data: prepares tensors (evidence: `Python/src/sauria_lib.py`)
- Simulation API → Execution model: models execution (evidence: `Python/src/sauria_lib.py`)
- Simulation API → Stimuli and results: generates stimuli (evidence: `Python/src/sauria_lib.py`)
- Stimuli and results → Hardware configuration: packs commands (evidence: `Python/src/file_helper.py`)
- Stimuli and results → Tensor and DRAM data: converts data (evidence: `Python/src/file_helper.py`)
- Execution model → Approximate FP arithmetic: evaluates arithmetic (evidence: `Python/src/execution_model.py`)
- Approximate FP arithmetic → Multiplier selection: uses multipliers (evidence: `Python/src/approx_comp/fp.py`)
- Approximate FP arithmetic → Approximate adders: uses adders (evidence: `Python/src/approx_comp/fp.py`)
- Multiplier selection → Booth multiplier: dispatches (evidence: `Python/src/approx_comp/multipliers.py`)
- Multiplier selection → Broken array multiplier: dispatches (evidence: `Python/src/approx_comp/multipliers.py`)
- Multiplier selection → Log multiplier: dispatches (evidence: `Python/src/approx_comp/multipliers.py`)
- Multiplier selection → UDM multiplier: dispatches (evidence: `Python/src/approx_comp/multipliers.py`)
- Stimuli and results → RTL simulator: provides stimuli (evidence: `README.md`)
- RTL simulator → SAURIA subsystem: runs design (evidence: `README.md`)
- SAURIA subsystem → Dataflow controller: coordinates
- SAURIA subsystem → DMA engine: transfers memory
- SAURIA subsystem → Accelerator core: connects accelerator
- Accelerator core → Systolic array: computes GEMM
- Accelerator core → Operand feeders: supplies operands
- Accelerator core → Local SRAM: uses SRAM
- Accelerator core → Partial-sum manager: manages sums
- RTL simulator → Stimuli and results: writes outputs
