# jankae/librevna architecture

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

- Interactive diagram: https://gitdiagram.com/jankae/librevna
- Repository: https://github.com/jankae/librevna

## Overview

##### Main System Components

The system should be divided into three major sections:
a) Hardware Layer
b) Firmware/FPGA Layer
c) Software Layer

##### Hardware Layer Components
- RF Frontend
- Signal Generation (Si5351C clock source, MAX2871 source)
- Power Control (RFSA3714 attenuator)
- Port Switching and Routing
- Receiver Paths (mixers, ADCs)
- Digital Control
- Spartan6 FPGA
- STM32G4 Microcontroller
- Flash Memory
- Power Management
- USB Power Input
- Multiple Voltage Regulators

##### Firmware/FPGA Layer Components
- FPGA Functionality
- ADC Sampling Control
- RF Block Communication
- Frequency Control
- Data Acquisition
- Embedded Software
- USB Communication
- FPGA Configuration
- Measurement Control
- Data Preprocessing

##### Software Layer Components
- GUI Application
- Measurement Modes (VNA, Generator, Spectrum Analyzer)
- Calibration System
- Data Visualization
- Device Control
- Data Processing
- Mathematical Operations
- Calibration Algorithms
- Trace Processing
- External Interfaces
- SCPI Interface
- File Import/Export
- TCP/IP Communication

##### Additional Elements

- Frequency ranges (100kHz to 6GHz)
- Power specifications
- Key performance parameters
- Calibration requirements
- Operating modes

##### Critical Paths to Highlight

- RF signal path through the system
- Data acquisition chain
- Control signal distribution
- Calibration signal flow
- Power distribution network

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef hardware fill:#d0e0ff,stroke:#333
    classDef firmware fill:#d0ffd0,stroke:#333
    classDef software fill:#ffd0b0,stroke:#333
    classDef interface fill:#e0e0e0,stroke:#333

    subgraph Hardware
        RF["RF Frontend"]:::hardware
        FPGA["Spartan6 FPGA"]:::hardware
        MCU["STM32G4 MCU"]:::hardware
        PWR["Power Management"]:::hardware
        
        subgraph RF_Components
            SRC["Signal Generation<br/>(Si5351C, MAX2871)"]:::hardware
            ATT["Power Control<br/>(RFSA3714)"]:::hardware
            SWITCH["Port Switching"]:::hardware
            RX["Receiver Paths<br/>(Mixers, ADCs)"]:::hardware
        end
    end

    subgraph Firmware
        FPGA_FW["FPGA Implementation"]:::firmware
        EMB["Embedded Firmware"]:::firmware
        USB_FW["USB Communication"]:::firmware
    end

    subgraph Software
        GUI["GUI Application"]:::software
        DATA["Data Processing"]:::software
        CAL["Calibration System"]:::software
        DEV["Device Control"]:::software
        
        subgraph External
            SCPI["SCPI Interface"]:::interface
            TCP["TCP/IP Server"]:::interface
        end
    end

    %% Connections
    RF --> FPGA
    FPGA --> MCU
    MCU --> USB_FW
    USB_FW --> DEV
    DEV --> GUI
    GUI --> DATA
    GUI --> CAL
    GUI --> SCPI
    GUI --> TCP
    
    SRC --> SWITCH
    SWITCH --> RX
    ATT --> SWITCH

    %% Click events
    click RF "https://github.com/jankae/LibreVNA/blob/master/Hardware/VNA.sch"
    click FPGA_FW "https://github.com/jankae/LibreVNA/tree/master/FPGA/VNA/"
    click EMB "https://github.com/jankae/LibreVNA/tree/master/Software/VNA_embedded/"
    click USB_FW "https://github.com/jankae/LibreVNA/tree/master/Software/VNA_embedded/Application/Drivers/USB/"
    click GUI "https://github.com/jankae/LibreVNA/tree/master/Software/PC_Application/LibreVNA-GUI/"
    click DATA "https://github.com/jankae/LibreVNA/tree/master/Software/PC_Application/LibreVNA-GUI/Traces/"
    click CAL "https://github.com/jankae/LibreVNA/blob/master/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.*"
    click DEV "https://github.com/jankae/LibreVNA/tree/master/Software/PC_Application/LibreVNA-GUI/Device/"
    click SCPI "https://github.com/jankae/LibreVNA/blob/master/Software/PC_Application/LibreVNA-GUI/scpi.*"
    click TCP "https://github.com/jankae/LibreVNA/blob/master/Software/PC_Application/LibreVNA-GUI/tcpserver.*"
```
