IDL in Instructions
Instruction definitions in spec/std/isa/inst/ use IDL to formally specify execution behavior via the operation() key. See also IDL in CSRs and Scope for how IDL source is organized across .idl files.
Instruction operation()
Instruction definitions in spec/std/isa/inst/ use IDL to formally specify execution behavior via the operation() key. The IDL executes at Instruction scope when the instruction executes on a hart.
operation() has no arguments and no return value, though decode variables are automatically populated from the encoding before execution begins.
Example instruction operation (add.yaml)
add:
# ...
encoding:
# ...
variables:
- name: xs2
location: 24-20
- name: xs1
location: 19-15
- name: xd
location: 11-7
operation(): |
X[xd] = X[xs1] + X[xs2];
In the operation() body, the decoded fields (xs1, xs2, xd) are automatically available as variables. The $encoding and $pc builtins are also available.