# nasa/sil architecture

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

- Interactive diagram: https://gitdiagram.com/nasa/sil
- Repository: https://github.com/nasa/sil

## Overview

##### Main Components
- Simulink Model / Autocoding Environment: Represents the user’s model in Simulink that is the source for auto-code generation.
- SIL Code Generation Pipeline: The extension to Simulink’s tools (incorporating MATLAB classes, scripts, and TLC [Target Language Compiler] files) responsible for describing and configuring model interfaces.
- cFS ECI Integration Layer: This encapsulates the generic wrapper code that interfaces with the Core Flight System’s APIs (table services, time services, software bus, events, and fault reporting).
- Supporting Libraries and Utilities: Includes custom MATLAB packages (e.g., the +cfsPackage with its specialized classes like Parameter, Signal, customAttribs, etc.), mex functions (providing low-level integrations), and utility scripts that prepare and configure the environment.
- Testing Framework: Unit tests and ECI compatibility tests that exercise both the integration (by generating simulink models and verifying the output) and any code parser/analysis capabilities.

##### Relationships & Interactions
- Within the SIL Code Generation Pipeline, denote sub-components such as:
– MATLAB classes (from the +cfsPackage) that encapsulate parameters, signals, and other attributes.
– TLC files which are used to customize the code generation (for instance, cfsCmdMessage.tlc, cfsCriticalDataStorage.tlc, etc.).
– Utility scripts (e.g., in src/util and mex) that support the compilation process.
- Testing Framework interfacing with multiple components (SIL pipeline outputs, and directly with sections of the ECI integration) to validate functionality.

##### Architectural Patterns / Design Principles
- Modularity: The division into separate directories (src, tests, doc) and packages (e.g., +cfsPackage) implies a modular design where functionality is encapsulated into narrowly defined components.
- Layered Architecture: The structure (from Simulink model through SIL abstraction to the runtime integration with cFS) conforms to a layered design paradigm.
- Extensibility: The inclusion of custom attribute classes and code parser utilities (found in tests/unit/+cfetargettester) demonstrates a system designed with extensibility in mind.
- Code Generation & Automation: The heavy emphasis on TLC files, mex functions, and auto-generated code signals an architecture built around automated code generation pipelines.

##### Mention Relevant Technologies, Frameworks, and Libraries
- MATLAB & Simulink (with toolboxes such as Embedded Coder, Simulink Coder, and MATLAB Coder).
- Core Flight System (cFS) APIs – including table services, time services, software bus, event services, and fault reporting.
- TLC (Target Language Compiler) for customizing code generation.
- MEX functions: These are used for integration with low-level C code.
- Testing frameworks (unit tests as seen in tests/unit, ECI compatibility tests).

- Clear labels for each major component, such as:
– “Simulink Model / Autocoding Environment”
– “SIL Code Generation Pipeline” (with subcomponents: MATLAB Classes, TLC Files, Utilities, and MEX Functions)
– “cFS ECI Integration Layer”
– “Testing & Validation Framework”
– Data/code flow from Simulink to the SIL pipeline.
– Integration and interfacing from the SIL pipeline to the cFS system.
– Feedback loops from the testing components back to the SIL pipeline and possibly Simulink inputs.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Simulink Model / Autocoding Environment"]:::input

    subgraph "SIL Code Generation Pipeline"
        B1["MATLAB Packages (+cfsPackage)"]:::module
        B2["TLC Files"]:::module
        B3["Additional TLC Files"]:::module
        B4["MEX TLC Files"]:::module
        B5["Utility Scripts"]:::module
        B6["MEX Functions"]:::module
    end

    BP["Pipeline Output"]:::junction

    subgraph "cFS ECI Integration Layer"
        C1["Wrapper & Interface Code"]:::integration
        C2["Integration Scripts"]:::integration
    end

    subgraph "Testing & Validation Framework"
        D1["ECI Compatibility Tests"]:::test
        D2["Unit & Code Parser Tests"]:::test
    end

    A -->|"generate"| B1
    A --> B2
    A --> B3
    A --> B4
    A --> B5
    A --> B6

    B1 --> BP
    B2 --> BP
    B3 --> BP
    B4 --> BP
    B5 --> BP
    B6 --> BP

    BP -->|"integrate"| C1
    C1 --> C2

    C1 -->|"validation"| D1
    C2 --> D2

    D2 -- "feedback" --> B1

    click A "https://github.com/nasa/sil/tree/master/tests/eci_compatibility/model"
    click B1 "https://github.com/nasa/sil/tree/master/src/+cfsPackage"
    click B2 "https://github.com/nasa/sil/tree/master/src/+cfsPackage/tlc"
    click B3 "https://github.com/nasa/sil/blob/master/src/cfs_ert.tlc"
    click B4 "https://github.com/nasa/sil/tree/master/src/mex/tlc_c"
    click B5 "https://github.com/nasa/sil/tree/master/src/util"
    click B6 "https://github.com/nasa/sil/tree/master/src/mex"
    click C1 "https://github.com/nasa/sil/blob/master/src/cfs_interface.tlc"
    click C2 "https://github.com/nasa/sil/blob/master/src/cfs_selectcallback.m"
    click D1 "https://github.com/nasa/sil/tree/master/tests/eci_compatibility"
    click D2 "https://github.com/nasa/sil/tree/master/tests/unit"

    classDef input fill:#f9c,stroke:#333,stroke-width:2px;
    classDef module fill:#bbf,stroke:#333,stroke-width:2px;
    classDef junction fill:#eee,stroke:#333,stroke-dasharray: 5,5,stroke-width:2px;
    classDef integration fill:#fc9,stroke:#333,stroke-width:2px;
    classDef test fill:#cfc,stroke:#333,stroke-width:2px;
```
