# lofaldli/gr-ccsds architecture

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

- Interactive diagram: https://gitdiagram.com/lofaldli/gr-ccsds
- Repository: https://github.com/lofaldli/gr-ccsds

## Overview

##### Project type and purpose
- This is a GNU Radio out-of-tree module (“gr-ccsds”) that implements CCSDS 131.0-B encoding/decoding (Reed-Solomon, interleaving, scrambling) as radio signal processing blocks. It’s a C++ core library plus a SWIG/Python wrapper, a set of GRC (GNU Radio Companion) flow-graph definitions, example flows, docs, and unit tests.

##### File structure
- Top-level build (CMakeLists.txt, cmake/Modules)
- apps/: any standalone executables that consume the library
- /ccsds/: public C++ API headers
- lib/: core C++ implementation, plus the bundled fec-3.0.1 Reed-Solomon library, plus unit tests (qa_*.cc)
- swig/: SWIG interface file for binding C++ to Python
- python/: generated Python modules, build utilities, and Python‐side unit tests (qa_*.py)
- grc/: XML definitions for the custom GNU Radio Companion blocks
- examples/: GRC flow-graphs demonstrating use cases
- docs/: Doxygen configuration and scripts

##### README for additional insights
- Confirms this is a plugin for GNU Radio, depends on GNURadio runtime, built via CMake and SWIG.

- Python/SWIG components in another
- GRC/XML in a third
- External dependencies (GNU Radio runtime, fec-3.0.1) as shaded clouds

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build System
    subgraph "Build System"
        CMake["CMakeLists.txt"]:::build
        cmakeMod["cmake/Modules/"]:::build
        swigCMake["swig/CMakeLists.txt"]:::build
    end

    %% External Dependencies
    subgraph "External Dependencies"
        fec["lib/fec-3.0.1/"]:::external
        gnuradioFind["FindGnuradioRuntime.cmake"]:::external
    end

    %% Core C++ Library
    subgraph "Core C++ Library" 
        decImpl["ccsds_decoder_impl.cc/.h"]:::cpp
        encImpl["ccsds_encoder_impl.cc/.h"]:::cpp
        corrImpl["correlator_impl.cc/.h"]:::cpp
        rsLib["reed_solomon.cc/.h"]:::cpp
        rsTables["rs_tables.cc"]:::cpp
    end

    %% Public C++ API
    subgraph "Public C++ API"
        apiH["api.h"]:::cpp
        decH["ccsds_decoder.h"]:::cpp
        encH["ccsds_encoder.h"]:::cpp
        corrH["correlator.h"]:::cpp
    end

    %% SWIG Interface
    swigI["swig/ccsds_swig.i"]:::swig

    %% Python Module
    subgraph "Python Module"
        pyInit["__init__.py"]:::py
        buildUtils["build_utils.py"]:::py
        buildUtilsCodes["build_utils_codes.py"]:::py
    end

    %% GRC Block Definitions
    subgraph "GRC Block Definitions"
        grcDec["ccsds_ccsds_decoder.xml"]:::grc
        grcEnc["ccsds_ccsds_encoder.xml"]:::grc
        grcCorr["ccsds_correlator.xml"]:::grc
    end

    %% Example Flows
    subgraph "Example Flows"
        ex1["dbpsk_downlink.grc"]:::example
        ex2["dbpsk_uplink.grc"]:::example
        ex3["simulation.grc"]:::example
    end

    %% Unit Tests
    subgraph "Unit Tests"
        utLib1["qa_ccsds.cc"]:::test
        utLib2["test_ccsds.cc"]:::test
        utPy1["qa_ccsds_decoder.py"]:::test
        utPy2["qa_ccsds_encoder.py"]:::test
        utPy3["qa_correlator.py"]:::test
    end

    %% Documentation Generation
    subgraph "Documentation Generation"
        doxyIn["Doxyfile.in"]:::doc
        doxySwig["Doxyfile.swig_doc.in"]:::doc
        doxyCMake["CMakeLists.txt"]:::doc
    end

    %% Build relationships
    CMake -->|compiles| decImpl
    CMake -->|compiles| encImpl
    CMake -->|compiles| corrImpl
    CMake -->|compiles| rsLib
    CMake -->|compiles| rsTables
    CMake -->|includes headers| apiH
    cmakeMod -->|finds| gnuradioFind
    fec -->|linked by| decImpl
    fec -->|linked by| encImpl
    fec -->|linked by| corrImpl
    gnuradioFind -->|provides| decImpl
    gnuradioFind -->|provides| encImpl
    gnuradioFind -->|provides| corrImpl

    swigCMake -->|invokes| swigI
    swigI -->|generates| pyInit
    swigI -->|generates| buildUtils
    swigI -->|generates| buildUtilsCodes

    %% Runtime pipeline
    pyInit -->|"loads at runtime"| grcDec
    pyInit -->|"loads at runtime"| grcEnc
    pyInit -->|"loads at runtime"| grcCorr
    grcDec -->|instantiates| decImpl
    grcEnc -->|instantiates| encImpl
    grcCorr -->|instantiates| corrImpl

    ex1 -->|uses blocks| grcDec
    ex2 -->|uses blocks| grcEnc
    ex3 -->|uses blocks| grcCorr

    %% Unit Tests execution
    utLib1 -->|runs via| CMake
    utLib2 -->|runs via| CMake
    utPy1 -->|runs via| swigCMake
    utPy2 -->|runs via| swigCMake
    utPy3 -->|runs via| swigCMake

    %% Documentation
    doxyIn -->|parsed by| CMake
    doxySwig -->|parsed by| CMake
    doxyCMake -->|orchestrates| docs

    %% Click Events
    click CMake "https://github.com/lofaldli/gr-ccsds/blob/master/CMakeLists.txt"
    click cmakeMod "https://github.com/lofaldli/gr-ccsds/tree/master/cmake/Modules/"
    click swigCMake "https://github.com/lofaldli/gr-ccsds/blob/master/swig/CMakeLists.txt"
    click fec "https://github.com/lofaldli/gr-ccsds/tree/master/lib/fec-3.0.1/"
    click gnuradioFind "https://github.com/lofaldli/gr-ccsds/blob/master/cmake/Modules/FindGnuradioRuntime.cmake"
    click swigI "https://github.com/lofaldli/gr-ccsds/blob/master/swig/ccsds_swig.i"
    click decImpl "https://github.com/lofaldli/gr-ccsds/blob/master/lib/ccsds_decoder_impl.cc"
    click encImpl "https://github.com/lofaldli/gr-ccsds/blob/master/lib/ccsds_encoder_impl.cc"
    click corrImpl "https://github.com/lofaldli/gr-ccsds/blob/master/lib/correlator_impl.cc"
    click rsLib "https://github.com/lofaldli/gr-ccsds/blob/master/lib/reed_solomon.cc"
    click rsTables "https://github.com/lofaldli/gr-ccsds/blob/master/lib/rs_tables.cc"
    click apiH "https://github.com/lofaldli/gr-ccsds/blob/master/include/ccsds/api.h"
    click decH "https://github.com/lofaldli/gr-ccsds/blob/master/include/ccsds/ccsds_decoder.h"
    click encH "https://github.com/lofaldli/gr-ccsds/blob/master/include/ccsds/ccsds_encoder.h"
    click corrH "https://github.com/lofaldli/gr-ccsds/blob/master/include/ccsds/correlator.h"
    click pyInit "https://github.com/lofaldli/gr-ccsds/blob/master/python/__init__.py"
    click buildUtils "https://github.com/lofaldli/gr-ccsds/blob/master/python/build_utils.py"
    click buildUtilsCodes "https://github.com/lofaldli/gr-ccsds/blob/master/python/build_utils_codes.py"
    click grcDec "https://github.com/lofaldli/gr-ccsds/blob/master/grc/ccsds_ccsds_decoder.xml"
    click grcEnc "https://github.com/lofaldli/gr-ccsds/blob/master/grc/ccsds_ccsds_encoder.xml"
    click grcCorr "https://github.com/lofaldli/gr-ccsds/blob/master/grc/ccsds_correlator.xml"
    click ex1 "https://github.com/lofaldli/gr-ccsds/blob/master/examples/dbpsk_downlink.grc"
    click ex2 "https://github.com/lofaldli/gr-ccsds/blob/master/examples/dbpsk_uplink.grc"
    click ex3 "https://github.com/lofaldli/gr-ccsds/blob/master/examples/simulation.grc"
    click utLib1 "https://github.com/lofaldli/gr-ccsds/blob/master/lib/qa_ccsds.cc"
    click utLib2 "https://github.com/lofaldli/gr-ccsds/blob/master/lib/test_ccsds.cc"
    click utPy1 "https://github.com/lofaldli/gr-ccsds/blob/master/python/qa_ccsds_decoder.py"
    click utPy2 "https://github.com/lofaldli/gr-ccsds/blob/master/python/qa_ccsds_encoder.py"
    click utPy3 "https://github.com/lofaldli/gr-ccsds/blob/master/python/qa_correlator.py"
    click doxyIn "https://github.com/lofaldli/gr-ccsds/blob/master/docs/doxygen/Doxyfile.in"
    click doxySwig "https://github.com/lofaldli/gr-ccsds/blob/master/docs/doxygen/Doxyfile.swig_doc.in"
    click doxyCMake "https://github.com/lofaldli/gr-ccsds/blob/master/docs/doxygen/CMakeLists.txt"

    %% Styles
    classDef build fill:#f9f,stroke:#333,stroke-width:1px
    classDef external fill:#ccf,stroke:#333,stroke-width:1px
    classDef cpp fill:#cfc,stroke:#333,stroke-width:1px
    classDef swig fill:#fcf,stroke:#333,stroke-width:1px
    classDef py fill:#cff,stroke:#333,stroke-width:1px
    classDef grc fill:#ffc,stroke:#333,stroke-width:1px
    classDef example fill:#eef,stroke:#333,stroke-width:1px
    classDef test fill:#fdd,stroke:#333,stroke-width:1px
    classDef doc fill:#ddd,stroke:#333,stroke-width:1px
```
