Schemas
A schema declares shared state — attributes every agent can read and write — and invariants that must hold in every reachable state.
schema Name {
attributes {
attr1 : Type = initialValue ;
attr2 : Type ; // no initial value: unconstrained
}
invariants { // optional
<expression> ;
<expression> ;
}
}Parts#
attributes { }— global variables, each with a type and an optional initial value. The block is required; it may be empty.invariants { }— optional Boolean expressions, each ending in;, that must hold in every reachable state.
Known limitation
Schema invariants { } are parsed, but saple analyze does not check them today: the lowering of the schema drops them. Put formulas you want checked in the properties { } block of the system.
Compact attribute declarations#
Register files are declared in a few lines. These forms work in schemas and in agent attributes blocks alike:
| Form | Meaning |
|---|---|
N, Z, C, V : BV<1> = 0x0:BV<1> ; | One declaration per name, same type and initial value |
X0..X30 : BV<64> ; | A range: X0, X1, …, X30 (both ends included) |
X1 = 0x4a0080:BV<64> ; | Override: replaces the initial value of an attribute declared earlier in the block |
Names and ranges mix in one list: a, P1..P3, b : Int = 0 ;. Errors: declaring a name twice, overriding a name that is not declared yet, and a range whose ends do not share the same alphabetic prefix, whose first index exceeds the last, or that is longer than 65,536 names.
Example#
schema Env {
attributes {
X0..X30 : BV<64> = 0x0:BV<64> ;
SP : BV<64> = 0x7ffffff000:BV<64> ;
N, Z, C, V : BV<1> = 0x0:BV<1> ;
Memory : Array(BV<64>, BV<8>) ;
X1 = 0x4a0080:BV<64> ;
}
invariants {
SP != 0x0:BV<64> ;
}
}type LineState = { INVALID, SHARED, EXCLUSIVE, MODIFIED } ;
schema CacheEnv {
attributes {
numCores : Int = 4 ;
line : Array(LineState, 4) ;
}
invariants {
forall (i : Int) in [0..numCores) .
forall (j : Int) in [0..numCores) .
(i != j) => !(line[i] == MODIFIED && line[j] == MODIFIED) ;
}
}