Skip to content

Commit 6a45f8c

Browse files
hyperpolymathclaude
andcommitted
feat: implement Phase 1 — Lustre codegen pipeline with WCET analysis
Implement the full lustreiser code generation pipeline: - Manifest: [project], [[nodes]] with typed/rated signals, [target] (arm-cortex-m/riscv/x86 + DO-178C/IEC-61508/ISO-26262), [timing] - Codegen: parser.rs (validate node definitions), lustre_gen.rs (generate .lus files with pre/fby/when/merge clock operators), c_gen.rs (generate deterministic C with state structs and step functions) - ABI: LustreNode, Clock, TemporalOperator, Signal, SignalType, SafetyStandard, WCET, EmbeddedTarget — all with validation and Display - Tests: 36 unit tests + 8 integration tests covering flight controller, ABS controller, industrial safety interlock, multi-rate sensor fusion, manifest validation, init template, and x86 simulation - Example: flight-controller/ with multi-node avionics manifest Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f234dbc commit 6a45f8c

12 files changed

Lines changed: 3688 additions & 45 deletions

File tree

Cargo.lock

Lines changed: 906 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
= Flight Controller Example
2+
// SPDX-License-Identifier: PMPL-1.0-or-later
3+
4+
A simplified fixed-wing aircraft flight controller demonstrating lustreiser's
5+
core capabilities:
6+
7+
* **Multi-node decomposition**: attitude control + navigation filter
8+
* **Multi-rate signals**: GPS at 10Hz vs IMU at 200Hz (clock calculus)
9+
* **DO-178C compliance**: avionics safety standard with WCET analysis
10+
* **Deterministic C output**: suitable for ARM Cortex-M bare-metal
11+
12+
== Running
13+
14+
[source,bash]
15+
----
16+
# Validate the manifest
17+
lustreiser validate -m examples/flight-controller/lustreiser.toml
18+
19+
# Generate Lustre and C code
20+
lustreiser generate -m examples/flight-controller/lustreiser.toml \
21+
-o generated/flight-controller
22+
23+
# Inspect generated files
24+
ls generated/flight-controller/
25+
# attitude_ctrl.lus attitude_ctrl.h attitude_ctrl.c
26+
# nav_filter.lus nav_filter.h nav_filter.c
27+
# wcet_report.txt
28+
----
29+
30+
== Architecture
31+
32+
----
33+
IMU (200Hz) GPS (10Hz) Barometer (40Hz)
34+
| | |
35+
v v v
36+
+------------------+ +---------------------+
37+
| attitude_ctrl | | nav_filter |
38+
| (5ms period) | | (5ms period, |
39+
| | | multi-rate inputs) |
40+
| pitch_err -----> elevator_cmd | |
41+
| roll_err -----> aileron_cmd | |
42+
| yaw_err -----> rudder_cmd | |
43+
+------------------+ +---------------------+
44+
|
45+
est_lat, est_lon,
46+
est_alt, est_heading
47+
----
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# lustreiser manifest — Flight controller example
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
#
4+
# This manifest describes a simplified flight controller for a fixed-wing
5+
# aircraft. It demonstrates:
6+
# - Multi-node decomposition (attitude control + navigation filter)
7+
# - Multi-rate signals (GPS at 10Hz vs IMU at 200Hz)
8+
# - DO-178C avionics safety standard
9+
# - Tight WCET deadline (5ms)
10+
#
11+
# Usage:
12+
# lustreiser validate -m examples/flight-controller/lustreiser.toml
13+
# lustreiser generate -m examples/flight-controller/lustreiser.toml -o generated/flight-controller
14+
15+
[project]
16+
name = "flight-controller"
17+
version = "1.0.0"
18+
19+
# --- Attitude control node ---
20+
# Runs at 200Hz (5ms period). Takes Euler angle errors from the INS
21+
# and computes control surface deflection commands.
22+
[[nodes]]
23+
name = "attitude_ctrl"
24+
inputs = [
25+
"pitch_err:real",
26+
"roll_err:real",
27+
"yaw_err:real",
28+
"airspeed:real",
29+
]
30+
outputs = [
31+
"elevator_cmd:real",
32+
"aileron_cmd:real",
33+
"rudder_cmd:real",
34+
]
35+
36+
[nodes.clock]
37+
base-period-ms = 5
38+
39+
# --- Navigation filter node ---
40+
# Runs at 200Hz base clock, but GPS inputs are sampled at 10Hz (every 20 ticks).
41+
# This requires Lustre clock calculus (when/merge) to handle rate adaptation.
42+
[[nodes]]
43+
name = "nav_filter"
44+
inputs = [
45+
"imu_accel_x:real",
46+
"imu_accel_y:real",
47+
"imu_accel_z:real",
48+
"imu_gyro_x:real",
49+
"imu_gyro_y:real",
50+
"imu_gyro_z:real",
51+
"gps_lat:real@20",
52+
"gps_lon:real@20",
53+
"gps_alt:real@20",
54+
"baro_alt:real@5",
55+
]
56+
outputs = [
57+
"est_lat:real",
58+
"est_lon:real",
59+
"est_alt:real",
60+
"est_heading:real",
61+
]
62+
63+
[nodes.clock]
64+
base-period-ms = 5
65+
66+
# --- Target platform ---
67+
# ARM Cortex-M7 (e.g. STM32H743) with hardware FPU.
68+
# Certified to DO-178C Level A (catastrophic failure condition).
69+
[target]
70+
platform = "arm-cortex-m"
71+
safety-standard = "DO-178C"
72+
73+
# --- Timing constraints ---
74+
# 5ms period => 5000us deadline.
75+
# WCET analysis enabled: the generator will produce a static estimate
76+
# and flag any node that risks exceeding the deadline.
77+
[timing]
78+
deadline-us = 5000
79+
wcet-analysis = true

0 commit comments

Comments
 (0)