arche-lang 0.16.2

Systems, written as code.

A textual language for embedded and complex systems: components, ports, messages, state machines, requirements and test plans. Check it as you type, simulate it, test it, and generate its code.

One file. The whole system.

A car that brakes for an obstacle: its messages, its parts and their links, a state machine, the requirement and the test that verifies it.

message POINT_CLOUD "Point cloud" { nearest: float32 }
message BRAKE_CMD "Brake command" { force: float32; emergency: bool }
message ENGAGE "Engage" { on: bool }

const MAX_SPEED = 40.0

requirement REQ-AEB "Emergency braking" {
  text "The car shall brake within 40 ms of an obstacle closer than 30 m."
}

component Lidar "Lidar" {
  out cloud: can sends POINT_CLOUD
}

component Hmi "Driver panel" {
  out bus: can sends ENGAGE
}

/// The driving computer: it brakes when an obstacle is close.
component Adcu "Driving computer" {
  satisfies REQ-AEB
  in sense:  can { handler POINT_CLOUD -> on_cloud }
  in hmi:    can receives ENGAGE
  out brake: can sends BRAKE_CMD
  var speed: float32 = 0 unit m/s

  fn on_cloud(nearest: float32) ```arche
    if state == Autonomous and nearest < 30.0 {
      send brake BRAKE_CMD { force: 8000.0, emergency: true }
    }
  ```

  states {
    state Manual
    state Autonomous
    Manual -> Autonomous on ENGAGE [self.speed < MAX_SPEED]
    Autonomous -> Manual on ENGAGE
  }
}

component Brakes "Brakes" {
  in cmd: can receives BRAKE_CMD
}

system Car "Car" {
  part lidar:  Lidar
  part hmi:    Hmi
  part adcu:   Adcu
  part brakes: Brakes
  lidar.cloud -> adcu.sense { latency 1ms }
  hmi.bus -> adcu.hmi
  adcu.brake -> brakes.cmd
}

test-plan TP-AEB "Emergency braking" {
  case TC-AEB-01 "Obstacle at 20 m" {
    verifies REQ-AEB
    at 0ms do send(hmi.bus, ENGAGE(on=True))
    at 10ms expect adcu.state == "Autonomous"
    at 10ms do send(lidar.cloud, POINT_CLOUD(nearest=20.0))
    within 40ms expect sent("BRAKE_CMD") >= 1
  }
}

Definitions and parts

A component is a definition; a part is one of it in a system. Ports send and receive messages; a link joins two ports.

Behaviour you can read

A function's body is written in the action language. archec checks it and translates it to the simulator's Python, and to C, Rust and Go.

The diagram, from the text

Three ways in.

The same compiler everywhere: in your editor, in your terminal and in this browser.

VS Code

Highlighting, diagnostics as you type, quick fixes, completion, a diagram beside the text and a simulation debugger.

code --install-extension arche-lang.vsix Get the extension

Command line

archec checks, builds, simulates, tests and generates. Node 18 or newer.

archec new my-robot && archec check main.arche Install archec

Playground

Write a model in the browser and see it checked, drawn, built and turned into code. Nothing to install; nothing leaves the page.

arche-lang.xyz/playground Open the Playground

From the model to the firmware.

Checked as you type

Names, types, ports and what they send, units, state machines: every mistake is a diagnostic at its line, most with a fix.

Requirements to tests

A requirement says who satisfies it and which test plan verifies it. The tests run in the simulator.

Simulated in the browser

State machines, bodies in the action language and links run in a page, with nothing installed.

Code from the model

C99 with no heap, Rust on Embassy, Go, C++, ROS 2, CAN DBC, AUTOSAR ARXML, devicetree, and generators of your own.

Verified

Formal checks of state machines with NuSMV, fault trees, STPA and TARA, test coverage, runtime checks of real logs.

An Arche project

The model compiles to an Arche project: open it in Arche to see the system on its canvas.

Follow the tutorial: a water pump, from model to firmware

The Arche Store

Architectures, drivers, boards and specifications to add to your model, signed. archec add brings one in.

Visit the Store