let state = reg r_sync enable 2 in
let a = wire 8 in
compile [
if_ (a.value ==:. 4) [
a <-- of_int ~width:8 2
] [
switch state.value [
(of_int ~width:2 0) [
a <--. 3;
state <-- of_int ~width:2 1;
];
(of_int ~width:2 1) [
a <--. 2;
state <-- of_int ~width:2 2;
];
(of_int ~width:2 2) [
a <--. 1;
state <-- of_int ~width:2 3;
];
(of_int ~width:2 3) [
a <--. 0;
state <-- of_int ~width:2 4;
]
]
];
let state = state.value in
let a = a.value in
....
The type of variables in guarded assignments. Variables may be asychronous wires, or synchronous regs. The current value of the variable may be accessed through the value field below.