Behaviour
What the parts do: functions, variables, memory maps and state machines.
On this page: fn · var · memory · states · state · transition · event
Functions, data, memory maps and state machines, and the events a machine reacts to that are not messages. Code blocks are Python, as Arche runs it.
fn#
A function the component exposes. private fn hides it. main runs at t=0 as the component's thread. An array parameter (a: int32[], a: int32[8]) is the caller's array, which the function may change; -> (int32, int32) gives several results (docs/spec.md, Arrays, Several results).
- Keywords:
fn(old spellings:function,operation) - Set: the model
- Where: inside
component, insidesystem, insideinterface - Syntax:
fn name ["Label"] ([in|out|inout] arg: Type, …) [-> Type | -> (Type, Type, …)] [raises E, …] ```arche … ``` | fn name { calls …; ```arche … ``` } | oneway fn name(…) (```python for Python)
| Property | Value | Meaning |
|---|---|---|
source |
text | Where it is implemented (repeatable): a file, a folder, a glob, path:line. Arche sources. For archec conform, its files are its component's. |
description |
text | Prose description. $…$ and $$…$$ are LaTeX math; a ```latex block is kept as LaTeX. |
tags |
list of tag names | Tags from the tag catalog. |
calls |
list of function names | Functions it calls: own (f) or a direct child's (child.f). With a ```arche body, expand reads the body's own calls, so calls only needs a child's. |
parallel |
bool | Its calls run at the same time (a manager that starts every child at once): a step that expands it draws them as the branches of a par. |
in-states |
list of state names | States it may be called in (default: all). |
visibility |
public | private |
public (default) or private. |
body |
code | What it does: a arche block (the action language, checked and translated to Python, Rust, C and Go), a python block, or the name of a def in a code .py file. |
wcet |
duration | Worst-case execution time. |
pip |
text | The Python packages its Python bodies import, as pip takes them (repeatable, or a list): pip "numpy>=1.26", "sympy". archec sim checks them in the Python it runs and prints the pip command for what is missing; it installs nothing. |
simulation-only |
bool | This function runs only in simulation (archec sim, Arche's simulator) and in host processes: its bodies are Python the action language cannot say (lists, dicts, big ints, libraries). The embedded generators (c, embassy, go, cpp on a microcontroller) refuse to deploy its component to a microcontroller (simulation-only); the Python and TypeScript targets keep it. |
oneway |
bool | An operation with no result, which the caller does not wait for: written before it, oneway fn notify(t: Track). It has no out or inout argument and no -> Type (oneway-result). |
raises |
list of type names | The exceptions an operation may raise, after its result: fn lookup(id: uint32) -> Track raises NotFound, Busy. |
satisfies |
list of requirement names | Requirements this element satisfies (emitted to traces.yaml). |
verifies |
list of requirement names | Requirements this element verifies. |
refines |
list of element names | Elements this one refines. |
realizes |
list of element names | Elements (one layer up) this one realizes. |
allocated-to |
list of element names | Elements this one is allocated to. |
deploys |
list of element names | Elements this one deploys. |
traces |
list of element names | Generic trace to other elements. |
fn apply_brake(force: float32) ```arche
pressure = force * GAIN
```
fn actuate(p: *Valve) -> bool {
calls apply_brake
```arche
return true
```
}
var#
A component variable; its value is the initial value. In an interface, attribute x: T is a value its provider holds and a client may read (and write, unless readonly attribute): IDL's attribute.
- Keywords:
var·attribute(old spellings:variable,let) - Set: the model
- Where: inside
component, insidesystem, insideinterface - Syntax:
var name[: Type[n]] [= value] [unit u] (no type: any type, written as none in Arche) | [readonly] attribute name: Type (in an interface)
| Property | Value | Meaning |
|---|---|---|
readonly |
bool | An interface attribute a client reads and does not write: written before it, readonly attribute id: uint32. |
tbc |
bool | To be confirmed: the value is not final. |
description |
text | Prose description. $…$ and $$…$$ are LaTeX math; a ```latex block is kept as LaTeX. |
unit |
string | Physical unit, written as it is (unit km/h, unit m/s², unit °C); one with a space is quoted. |
range |
range | Allowed range. |
initial |
string | Its starting value as Arche text, not as an expression: Arche starts it as this word (initial "BOOT"), or as a number or a list when the text reads as one. = "BOOT" is the Python string "BOOT", quotes included. |
parameter |
configuration | internal |
In an algorithm (kind algorithm): a configuration parameter, set again when it is configured, or an internal one, its own. Its instantiation parameters are the component's parameters (component Filter(taps: int32 = 16)). |
var retries: uint8 = 3
var thresholds: float32[4] = [0.1, 0.2, 0.4, 0.8]
memory#
A memory block / register map: size × count at an address, optionally a record of bitfields. On a processor, a memory with no type and no address is one of its memories: memory ddr { size 2GiB } (shared when other processors reach it, else local) — what a deployment's allocators are in.
- Keywords:
memory(old spellings:register,regs) - Set: the model
- Where: inside
component, insidesystem - Syntax:
memory NAME @ 0x4000_0000 : uint32[8] rw { field: uint8 bits "7:0" }
| Property | Value | Meaning |
|---|---|---|
size |
any | Bytes of one element, as written (instead of the size of its type or fields); on a processor's memory, its size (size 1GiB). |
count |
number | Number of elements, as written. |
reset |
any | Value at reset. |
description |
text | Prose description. $…$ and $$…$$ are LaTeX math; a ```latex block is kept as LaTeX. |
on-write |
code | Python run when another component writes the block. A ``` block, or the name of a def in a code .py file. |
shared |
bool | Reachable from peers over a memory-mapped link. |
memory CTRL @ 0x4000_0000 : uint32 rw {
enable: uint8 bits "0:0"
mode: uint8 bits "3:1"
}
states#
The component's state machine. It starts in its first state (initial X starts it elsewhere); A -> B on trig [guard] / action are transitions. The linter walks it: a state nothing reaches (unreachable-state), a state with no way out that is not pseudo final (deadlock-state; a state every state falls into, * -> Fault, is a safe state and may be one), a transition on a message no input port receives or with a guard that is false (dead-transition), one that an earlier unguarded one on the same trigger always beats (shadowed-transition), and two guarded ones whose guards may hold together (nondeterministic). archec gen --target uppaal (or nusmv) hands it to a model checker.
- Keywords:
states(old spellings:statemachine,machine) - Set: the model
- Where: inside
component, insidesystem - Syntax:
states { state A; state B { state B1 }; A -> B on go [ready] / start() }
| Property | Value | Meaning |
|---|---|---|
initial |
state name | State entered at start. |
states {
state Off "Powered off"
state On { state Idle; state Driving }
Off -> Idle on power_on
Idle -> Driving on go [speed_ok] / engage()
}
state#
A state. Nest states for a statechart; pseudo makes a pseudo-state.
- Keywords:
state(old spelling:mode) - Set: the model
- Where: inside
states, insidestate - Syntax:
state id ["Name"] { on-enter ```arche …```; state child … }
| Property | Value | Meaning |
|---|---|---|
description |
text | Prose description. $…$ and $$…$$ are LaTeX math; a ```latex block is kept as LaTeX. |
pseudo |
state | mode | initial | final | choice | fork | join | history | deep-history | terminate | entry | exit |
A pseudo-state: what it is instead of a state (pseudo initial, pseudo choice…). |
kind |
state | mode | initial | final | choice | fork | join | history | deep-history | terminate | entry | exit |
Old name of pseudo (kind names a catalog kind elsewhere): still read, archec fmt --simplify renames it. |
on-enter |
code | What runs on entering: a arche block, a python block, or the name of a def in a code .py file. |
on-exit |
code | What runs on leaving: a arche block, a python block, or the name of a def in a code .py file. |
do |
list of function names | Functions active while in the state (doActivity) — or what it does, as text (do "CBIT of every tile"). |
entry-activity |
list of function names | What it does on entering, as text (UML entry activity; repeatable). on-enter is the Python that does it. |
exit-activity |
list of function names | What it does on leaving, as text (UML exit activity; repeatable). |
region |
any | Orthogonal region name: a name, or a quoted label. |
state Driving "Autonomous driving" {
on-enter ```arche
log "engaged"
```
}
transition#
A transition A -> B on trigger [guard] / action. With a deadline, a trigger the part starts on too late (a message later than that after it was sent, a timer later than that after it ran out) runs on-deadline instead of the transition — as Lingua Franca's deadlines.
- Keywords: (no keyword)
- Where: inside
states, insidestate - Syntax:
A -> B [as id] [on trigger] [[guard] | when "guard"] [/ action] [{ deadline 10ms; on-deadline ```arche … ``` }]
| Property | Value | Meaning |
|---|---|---|
deadline |
duration | The latest the part may start on the trigger after it was sent (or the timer ran out). |
on-deadline |
code | What runs instead of the transition when the trigger comes too late: a ```arche block. The guard is checked first; the transition is then not taken. |
Idle -> Driving on go [speed_ok] / engage()
event#
An event a state machine reacts to that is not a message: Idle -> Run on dry_run. Declared, a trigger that names it is not a typo (the linter warns on a trigger that is neither a message, nor an event, nor a member of its part — unknown-trigger). It has no payload and is not sent on a port: the generated C machine takes it as one of its events (…_fire(self, CTRL_EV_DRY_RUN)); the simulation fires only messages, so a test or a panel raises it. Declared in a component, it is that component's.
- Keywords:
event - Set: functional analysis & scenarios
- Where: top level, inside
component, insidesystem - Syntax:
event id ["Name"] [{ description "…" }]
| Property | Value | Meaning |
|---|---|---|
description |
text | Prose description. $…$ and $$…$$ are LaTeX math; a ```latex block is kept as LaTeX. |
event dry_run "Dry run" { description "The operator asks for a run without water." }