# nuand/bladerf architecture

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

- Interactive diagram: https://gitdiagram.com/nuand/bladerf
- Repository: https://github.com/nuand/bladerf

## Overview

This project is a mixed-hardware and software system that targets a bladeRF radio platform. Its purpose is to implement all the necessary components that allow communication between the host computer and the bladeRF board’s FPGA and USB controller (the Cypress FX3). The repository is split into clearly defined components:
- The FX3 firmware, which runs on the Cypress FX3 USB controller and handles the USB communication with the host.
- The FPGA HDL, which is the code for the Cyclone IV FPGA responsible for handling radio signal processing.
- The host-side libraries, drivers, utilities, and command line tools (bladeRF-cli) that interact with the hardware via the USB interface.
- A common firmware component (firmware_common) used by both FX3 firmware and host code for shared functionality.

##### Host Application Layer
– Include the host-side components such as:
- The libbladeRF library (drivers, libraries, and common utilities).
- The bladeRF-cli utility, examples, and any other host utilities.
– Represent the use of CMake build scripts, source files in the “host” directory, and supportive third-party libraries.
– Indicate that these components ultimately issue commands and receive data via a USB interface.

##### FX3 Firmware Layer
– Show the fx3_firmware component (firmware for the Cypress FX3 USB controller).
– Note how this module contains USB protocol handling, interfaces to the FPGA, and common utility code (from firmware_common).

##### FPGA HDL Layer
– Represent the FPGA block based on Cyclone IV with its HDL code (from the “hdl” directory).
– Indicate that this component is responsible for radio signal processing and low-level hardware functionality.
– Include subcomponents if desired: for example, IP blocks for clock control, data formatting, and digital signal processing modules (e.g., those imported from third-party sources or created in-house).

##### Shared/Supporting Components
– Reference the firmware_common directory which supplies headers and source files shared between the FX3 firmware and host-side utilities.
– Optionally include build/configuration files (CMakeLists.txt, debian packaging, etc.) which show how the system is assembled.

##### Interactions and Data Flow
– Connect FX3 Firmware to the FPGA (HDL) block, showing that commands and data pass from the controller to the FPGA.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Host Application Layer
    subgraph "Host Application Layer"
        host1["libbladeRF"]:::software
        host2["bladeRF-cli"]:::software
        host3["Build Config (CMake & Makefiles)"]:::software
    end

    %% FX3 Firmware Layer
    subgraph "FX3 Firmware Layer"
        fx3["FX3 Firmware"]:::firmware
    end

    %% FPGA HDL Layer
    subgraph "FPGA HDL Layer"
        fpga["Cyclone IV FPGA HDL"]:::hardware
        ip["IP Blocks (Clock, DSP, Data Formatting)"]:::hardware
    end

    %% Shared/Supporting Components
    shared["Firmware Common"]:::shared

    %% Interactions and Data Flow
    host2 -->|"USB_Interface"| fx3
    fx3 -->|"Control/Commands"| fpga
    fpga -->|"Processed_Data/IQ_Samples"| fx3
    fx3 -->|"USB_Response"| host2

    %% Shared Component Usage (dashed lines indicate shared utility)
    host1 -.->|"uses_shared"| shared
    fx3 -.->|"uses_shared"| shared

    %% Click Events
    click host1 "https://github.com/nuand/bladerf/tree/master/host/libraries/libbladeRF"
    click host2 "https://github.com/nuand/bladerf/tree/master/host/utilities/bladeRF-cli"
    click fx3 "https://github.com/nuand/bladerf/tree/master/fx3_firmware/"
    click fpga "https://github.com/nuand/bladerf/tree/master/hdl/"
    click shared "https://github.com/nuand/bladerf/tree/master/firmware_common/"

    %% Styling / Colors
    classDef software fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef firmware fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef hardware fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef shared fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
