# lowrisc/ibex-demo-system architecture

> Architecture diagram of the GitHub repository lowrisc/ibex-demo-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lowrisc/ibex-demo-system
- Repository: https://github.com/lowrisc/ibex-demo-system

## Overview

Based on our analysis of the file tree and README, this project is a comprehensive demo system that showcases a RISC-V SoC built around the lowRISC Ibex core. The system is meant to run on several FPGA development boards (such as the Arty-A7, Arty S7, Nexys A7, Sonata, Blackboard, and Boolean boards) and demonstrates various peripherals (UART, GPIO, SPI, PWM, Timer, debug module, etc.). In addition, the project supports multiple software stacks (C and Rust) and includes simulation and build infrastructure using tools like FuseSoC, CMake, and Verilator. There’s also a containerized environment setup that ensures that all dependencies (Vivado, toolchains, etc.) are readily available to kickstart development.

##### Main Components
- Hardware/RTL: Show the FPGA’s main block with the Ibex processor at the center. Include the memory bus connecting to RAM and peripherals.
- Peripherals: List all peripherals explicitly described in the README and file structure. These include UART, GPIO, SPI (and by extension the LCD interface via SPI), PWM, Timer, and debug (JTAG) module.
- Board Interfaces: Note that external devices (switches, buttons, LEDs, LCD) connect to specific peripherals (GPIO for switches/LEDs, SPI for the LCD, etc.). Also indicate USB/serial access for debugging/programming.
- Software Stacks: Represent the firmware components. Separate out the C-based and Rust-based demo systems along with the support libraries (or Hardware Abstraction Layers) found in sw/c and sw/rust.

##### Relationships and Data Flow
- How the debug module interfaces with the JTAG port and how UART is used for serial-console communications.
- Link hardware simulation components (in dv) with the RTL design, indicating that the simulation model (Verilator-based, for example) takes software binaries (ELF/vmem) as input to emulate the system.

##### Architectural Patterns and Elements
- System-on-Chip (SoC) architecture pattern where a processing core is wired to multiple peripherals via a common bus.

##### Relevant Technologies, Frameworks, and Libraries
- LowRISC Ibex core and the PULP RISC-V Debug Module.
- Xilinx Vivado for synthesis and bitstream generation.
- Simulation tool – Verilator – as shown in the dv/ and simulation instructions.
- Software build tools: CMake for C stack and Cargo for Rust.
- Containerization with Docker/Podman and optionally Nix for environment management.
- OpenOCD for debugging and FPGA programming.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        H1["Ibex Core"]:::hardware
        H2["UART Peripheral"]:::hardware
        H3["GPIO Peripheral"]:::hardware
        H4["SPI Top"]:::hardware
        H5["SPI Host"]:::hardware
        H6["PWM Peripheral"]:::hardware
        H7["PWM Wrapper"]:::hardware
        H8["Debug Module (JTAG)"]:::hardware
        H9["FPGA Top Modules"]:::hardware
        H10["FPGA Constraints"]:::hardware
        subgraph "Board Interfaces"
            BI1["Switches/LEDs (via GPIO)"]:::external
            BI2["LCD (via SPI)"]:::external
            BI3["USB/Serial (via UART)"]:::external
            BI4["JTAG Port"]:::external
        end
    end

    %% Software & Build Layer
    subgraph "Software & Build Layer"
        S1["C-Based Demo & Drivers"]:::software
        S2["Rust-Based Demo & HAL"]:::software
        S3["Build & Container Environment"]:::build
    end

    %% Simulation & Debug Layer
    subgraph "Simulation & Debug Layer"
        SD1["Simulation Infrastructure"]:::simulation
        SD2["Debug Tools (OpenOCD/GDB)"]:::simulation
    end

    %% Relationships within Hardware Layer
    H1 -->|"bus"| H2
    H1 -->|"bus"| H3
    H1 -->|"bus"| H4
    H1 -->|"bus"| H5
    H1 -->|"bus"| H6
    H1 -->|"bus"| H7
    H1 -->|"bus"| H8

    H2 -->|"data"| BI3
    H3 -->|"control"| BI1
    H4 -->|"data"| BI2
    H8 -->|"debug"| BI4

    %% Connections from Build to Hardware (FPGA bitstream flow)
    S3 -->|"build_flow"| H9
    S3 -->|"build_flow"| H10

    %% Software to Simulation Flow
    S1 -->|"firmware"| SD1
    S2 -->|"firmware"| SD1
    S3 -->|"build_output"| SD1

    %% Simulation interacting with Hardware
    SD1 -->|"simulate"| H1

    %% Debug tools connecting to Hardware Debug Module
    SD2 -->|"control"| H8

    %% Styles for Diagram Components
    classDef hardware fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef software fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef build fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef simulation fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef external fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;

click H1 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/ibex_demo_system.sv"
click H2 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/uart.sv"
click H3 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/gpio.sv"
click H4 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/spi_top.sv"
click H5 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/spi_host.sv"
click H6 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/pwm.sv"
click H7 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/pwm_wrapper.sv"
click H8 "https://github.com/lowrisc/ibex-demo-system/blob/main/rtl/system/dm_top.sv"
click H9 "https://github.com/lowrisc/ibex-demo-system/tree/main/rtl/fpga"
click H10 "https://github.com/lowrisc/ibex-demo-system/tree/main/data"
click S1 "https://github.com/lowrisc/ibex-demo-system/tree/main/sw/c"
click S2 "https://github.com/lowrisc/ibex-demo-system/tree/main/sw/rust"
click S3 "https://github.com/lowrisc/ibex-demo-system/tree/main/container"
click SD1 "https://github.com/lowrisc/ibex-demo-system/tree/main/dv/verilator"
```
