Skip to content
STIMSMITH

decode macro

CodeArtifact WIKI v1 · 5/29/2026

The decode macro is an ISA-description macro used in generated instruction-set simulators to split an instruction word into decoded bit fields. Its result is stored as an instruction record and can be cached so the simulator avoids repeatedly decoding the same instruction during execution.

Overview

The decode macro decomposes an instruction word into several bit fields according to the instruction-set specification. The decoded fields of the current instruction are kept in an instruction_t record-like data type, where they can be used by the ISA transition logic.

In the architectural-style ISA property, the decoded instruction is bound with a freeze expression such as:

instr = decode(instruction) @ t

The resulting instr value is then passed to next_state, which computes the architectural state after executing the current instruction.

Role in ISS generation

When generating the C++ instruction set simulator (ISS), decode is one of the public functions emitted for the simulator class, alongside next_state and the interface macros. The generated simulator class contains the code for instruction execution and holds the architectural state.

Performance use: cached decoding

The decoded fields can be cached in the simulator. Because software often has locality, for example due to loops, this avoids repeated decoding of the same instruction and reduces simulation run time. The cited ISS-generation approach explicitly uses caching of the decode function result as an optimization analogous in spirit to just-in-time compiled simulation.

LINKED ENTITIES

1 links

CITATIONS

5 sources
5 citations
[1] The decode macro decomposes an instruction word into bit fields according to the specification. Generating an Efficient Instruction Set Simulator from a Complete Property Suite
[2] Decoded fields of the current instruction are kept in an instruction_t record-like data type and can be used to avoid repeated decoding. Generating an Efficient Instruction Set Simulator from a Complete Property Suite
[3] The ISA property uses decode(instruction) at time t and passes the resulting instruction to next_state. Generating an Efficient Instruction Set Simulator from a Complete Property Suite
[4] ISS generation emits public functions for next_state, decode, and interface macros. Generating an Efficient Instruction Set Simulator from a Complete Property Suite
[5] Caching the result of the decode function avoids repeated instruction decoding and can decrease simulation run time due to software locality. Generating an Efficient Instruction Set Simulator from a Complete Property Suite