# magnmaeh/programming-pret-machines architecture

> Architecture diagram of the GitHub repository magnmaeh/programming-pret-machines, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/magnmaeh/programming-pret-machines
- Repository: https://github.com/magnmaeh/programming-pret-machines

## Overview

This repository is a reproducibility suite for evaluating timing jitter and interrupt robustness across four embedded platforms. The principal workflow runs either a Lingua Franca or C benchmark on a target, optionally with periodic and sporadic interrupts, records timestamp data, and analyzes it into plots. The README also documents a parallel-reaction benchmark and a C interrupt-robustness experiment. Shared timing/workload logic and platform-specific interrupt handlers form the main internal layer. Unsampled Lingua Franca sources are represented at their existing directory; their internal wiring is not inferred.

Main entry points: [`experiments/lib/common.h`](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/common.h) (Work and interrupt logic), [`experiments/C/RP2040/app/main.c`](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/RP2040/app/main.c) (RP2040 C run), [`experiments/C/FlexPRET/main.c`](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/FlexPRET/main.c) (FlexPRET C run), [`experiments/C/nrf52/src/main.c`](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/nrf52/src/main.c) (nRF52 C run)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_benchmarks["Benchmark workloads"]
  node_lf_workloads["LF workloads"]
  node_c_flexpret["FlexPRET C run<br/>[main.c]"]
  node_c_rp2040["RP2040 C run<br/>[main.c]"]
  node_c_nrf52["nRF52 C run<br/>[main.c]"]
  node_c_rpi["RPi C run<br/>[main.c]"]
end

subgraph group_platforms["Platform runtimes"]
  node_shared_core["Work and interrupt logic<br/>[common.h]"]
  node_lf_logging["LF logging helpers<br/>[lf_common.h]"]
  node_flexpret_irq["FlexPRET IRQ backend<br/>[interrupt.c]"]
  node_rp2040_irq["RP2040 IRQ backend<br/>[interrupt.c]"]
  node_nrf52_irq["nRF52 IRQ backend<br/>[interrupt.c]"]
  node_rpi_irq["RPi IRQ backend<br/>[interrupt.c]"]
  node_rp2040_uart["RP2040 UART output<br/>[printf_custom.c]"]
end

subgraph group_analysis["Signal and analysis"]
  node_wave_generator["Waveform generator"]
  node_wave_script["Waveform generation<br/>[genwaves.py]"]
  node_timestamp_data["Timestamp data"]
  node_control_plot["Control-loop analysis<br/>[plot-control.py]"]
  node_parallel_plot["Parallel comparison<br/>[plot-seqvspar.py]"]
  node_normalization["Data normalization<br/>[normal.py]"]
  node_figures["Result figures"]
end

node_engineer(("Experiment operator"))

node_engineer -->|"selects benchmark"| node_lf_workloads
node_engineer -->|"runs benchmark"| node_c_flexpret
node_engineer -->|"runs benchmark"| node_c_rp2040
node_engineer -->|"runs benchmark"| node_c_nrf52
node_engineer -->|"runs benchmark"| node_c_rpi
node_engineer -.->|"generates signals"| node_wave_script
node_wave_script -.->|"configures waveforms"| node_wave_generator
node_wave_generator -.->|"triggers interrupts"| node_flexpret_irq
node_wave_generator -.->|"triggers interrupts"| node_rp2040_irq
node_wave_generator -.->|"triggers interrupts"| node_nrf52_irq
node_wave_generator -.->|"triggers interrupts"| node_rpi_irq
node_c_flexpret -->|"runs workload"| node_shared_core
node_c_rp2040 -->|"runs workload"| node_shared_core
node_c_nrf52 -->|"runs workload"| node_shared_core
node_c_rpi -->|"runs workload"| node_shared_core
node_c_flexpret -.->|"configures pins"| node_flexpret_irq
node_c_rp2040 -.->|"configures pins"| node_rp2040_irq
node_c_nrf52 -.->|"configures pins"| node_nrf52_irq
node_c_rpi -.->|"configures pins"| node_rpi_irq
node_flexpret_irq -->|"handles interrupts"| node_shared_core
node_rp2040_irq -->|"handles interrupts"| node_shared_core
node_nrf52_irq -->|"handles interrupts"| node_shared_core
node_rpi_irq -->|"handles interrupts"| node_shared_core
node_lf_workloads -.->|"uses logging"| node_lf_logging
node_c_rp2040 -->|"prints results"| node_rp2040_uart
node_c_flexpret -->|"emits timestamps"| node_timestamp_data
node_c_rp2040 -->|"emits timestamps"| node_timestamp_data
node_c_nrf52 -->|"emits timestamps"| node_timestamp_data
node_c_rpi -->|"emits timestamps"| node_timestamp_data
node_timestamp_data -.->|"analyzes data"| node_control_plot
node_timestamp_data -.->|"compares results"| node_parallel_plot
node_timestamp_data -.->|"normalizes data"| node_normalization
node_control_plot -->|"creates plots"| node_figures
node_parallel_plot -->|"creates plots"| node_figures

click node_lf_workloads "https://github.com/magnmaeh/programming-pret-machines/tree/master/experiments/lf/src"
click node_c_flexpret "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/FlexPRET/main.c"
click node_c_rp2040 "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/RP2040/app/main.c"
click node_c_nrf52 "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/nrf52/src/main.c"
click node_c_rpi "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/RPi/main.c"
click node_shared_core "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/common.h"
click node_lf_logging "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/lf_common.h"
click node_flexpret_irq "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/FlexPRET/interrupt.c"
click node_rp2040_irq "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/RP2040/interrupt.c"
click node_nrf52_irq "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/nrf52/interrupt.c"
click node_rpi_irq "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/RPi/interrupt.c"
click node_rp2040_uart "https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/RP2040/printf_custom.c"
click node_wave_script "https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/genwaves.py"
click node_control_plot "https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/plot-control.py"
click node_parallel_plot "https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/plot-seqvspar.py"
click node_normalization "https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/normal.py"
click node_figures "https://github.com/magnmaeh/programming-pret-machines/tree/master/figs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_lf_workloads,node_c_flexpret,node_c_rp2040,node_c_nrf52,node_c_rpi toneBlue
class node_shared_core,node_lf_logging,node_flexpret_irq,node_rp2040_irq,node_nrf52_irq,node_rpi_irq,node_rp2040_uart toneAmber
class node_wave_generator,node_wave_script,node_timestamp_data,node_control_plot,node_parallel_plot,node_normalization,node_figures toneMint
class node_engineer toneIndigo
```

## Components

### Benchmark workloads

- [LF workloads](https://github.com/magnmaeh/programming-pret-machines/tree/master/experiments/lf/src): `experiments/lf/src`
- [FlexPRET C run](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/FlexPRET/main.c): `experiments/C/FlexPRET/main.c`
- [RP2040 C run](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/RP2040/app/main.c): `experiments/C/RP2040/app/main.c`
- [nRF52 C run](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/nrf52/src/main.c): `experiments/C/nrf52/src/main.c`
- [RPi C run](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/C/RPi/main.c): `experiments/C/RPi/main.c`

### Platform runtimes

- [Work and interrupt logic](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/common.h): `experiments/lib/common.h`
- [LF logging helpers](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/lf_common.h): `experiments/lib/lf_common.h`
- [FlexPRET IRQ backend](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/FlexPRET/interrupt.c): `experiments/lib/FlexPRET/interrupt.c`
- [RP2040 IRQ backend](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/RP2040/interrupt.c): `experiments/lib/RP2040/interrupt.c`
- [nRF52 IRQ backend](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/nrf52/interrupt.c): `experiments/lib/nrf52/interrupt.c`
- [RPi IRQ backend](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/RPi/interrupt.c): `experiments/lib/RPi/interrupt.c`
- [RP2040 UART output](https://github.com/magnmaeh/programming-pret-machines/blob/master/experiments/lib/RP2040/printf_custom.c): `experiments/lib/RP2040/printf_custom.c`

### Signal and analysis

- **Waveform generator**
- [Waveform generation](https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/genwaves.py): `scripts/genwaves.py`
- **Timestamp data**
- [Control-loop analysis](https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/plot-control.py): `scripts/plot-control.py`
- [Parallel comparison](https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/plot-seqvspar.py): `scripts/plot-seqvspar.py`
- [Data normalization](https://github.com/magnmaeh/programming-pret-machines/blob/master/scripts/normal.py): `scripts/normal.py`
- [Result figures](https://github.com/magnmaeh/programming-pret-machines/tree/master/figs): `figs`

### Other components

- **Experiment operator**

## Connections

- Experiment operator → LF workloads: selects benchmark (evidence: `README.md`)
- Experiment operator → FlexPRET C run: runs benchmark (evidence: `README.md`)
- Experiment operator → RP2040 C run: runs benchmark (evidence: `README.md`)
- Experiment operator → nRF52 C run: runs benchmark (evidence: `README.md`)
- Experiment operator → RPi C run: runs benchmark (evidence: `README.md`)
- Experiment operator → Waveform generation: generates signals
- Waveform generation → Waveform generator: configures waveforms
- Waveform generator → FlexPRET IRQ backend: triggers interrupts (evidence: `README.md`)
- Waveform generator → RP2040 IRQ backend: triggers interrupts (evidence: `README.md`)
- Waveform generator → nRF52 IRQ backend: triggers interrupts (evidence: `README.md`)
- Waveform generator → RPi IRQ backend: triggers interrupts (evidence: `README.md`)
- FlexPRET C run → Work and interrupt logic: runs workload (evidence: `experiments/C/FlexPRET/main.c`)
- RP2040 C run → Work and interrupt logic: runs workload (evidence: `experiments/C/RP2040/app/main.c`)
- nRF52 C run → Work and interrupt logic: runs workload (evidence: `experiments/C/nrf52/src/main.c`)
- RPi C run → Work and interrupt logic: runs workload (evidence: `experiments/C/RPi/main.c`)
- FlexPRET C run → FlexPRET IRQ backend: configures pins
- RP2040 C run → RP2040 IRQ backend: configures pins
- nRF52 C run → nRF52 IRQ backend: configures pins
- RPi C run → RPi IRQ backend: configures pins
- FlexPRET IRQ backend → Work and interrupt logic: handles interrupts (evidence: `experiments/lib/FlexPRET/interrupt.c`)
- RP2040 IRQ backend → Work and interrupt logic: handles interrupts (evidence: `experiments/lib/RP2040/interrupt.c`)
- nRF52 IRQ backend → Work and interrupt logic: handles interrupts (evidence: `experiments/lib/nrf52/interrupt.c`)
- RPi IRQ backend → Work and interrupt logic: handles interrupts (evidence: `experiments/lib/RPi/interrupt.c`)
- LF workloads → LF logging helpers: uses logging
- RP2040 C run → RP2040 UART output: prints results (evidence: `experiments/C/RP2040/app/main.c`)
- FlexPRET C run → Timestamp data: emits timestamps (evidence: `experiments/C/FlexPRET/main.c`)
- RP2040 C run → Timestamp data: emits timestamps (evidence: `experiments/C/RP2040/app/main.c`)
- nRF52 C run → Timestamp data: emits timestamps (evidence: `experiments/C/nrf52/src/main.c`)
- RPi C run → Timestamp data: emits timestamps (evidence: `experiments/C/RPi/main.c`)
- Timestamp data → Control-loop analysis: analyzes data
- Timestamp data → Parallel comparison: compares results
- Timestamp data → Data normalization: normalizes data
- Control-loop analysis → Result figures: creates plots (evidence: `README.md`)
- Parallel comparison → Result figures: creates plots (evidence: `README.md`)
