ISA Description Language (IDL)
This documentation is complete and ready to use.
The ISA Description Language (IDL) is a domain-specific language for formally specifying RISC-V instruction set architectures. IDL is designed to be:
- Human readable — serves as a reliable documentation source alongside the spec.
- Familiar — syntax resembles a mix of Verilog and C++, so hardware and software designers can read it with minimal ramp-up.
- Strongly typed — reduces ambiguity as a documentation source.
- Configurable — reflects RISC-V's configurable ISA structure. IDL can describe a wide range of devices, then be customized with configuration variables to generate an implementation-specific description.
IDL is used to describe the behavior of RISC-V instructions and (in cases where behavior is specialized) CSRs. Taken together, the IDL can be converted into a fully functioning Instruction Set Simulator (ISS) that is a golden model of execution.
- Hardware engineers — see IDL for Verilog Users
- Software engineers — see IDL for C Users
Use Cases
IDL specifications in the RISC-V Unified Database enable multiple workflows:
📚 Documentation generation
Generate comprehensive, accurate documentation directly from specifications:
- Instruction references with precise behavioral descriptions
- CSR field definitions with read/write semantics
- Extension documentation showing interactions and dependencies
- Configuration-specific manuals tailored to a specific implementation
🔍 Design verification
Ensure hardware implementations match specifications:
- Reference models for comparing against RTL simulations
- Test generation based on formal specifications
- Coverage analysis to identify untested corner cases
- Consistency checking across instruction set extensions
✅ Formal verification
Prove correctness properties mathematically:
- Configuration validation using constraint solvers
- Dead code detection for unreachable specifications
- Dependency analysis between extensions and parameters
💻 Software development
Enable software development before hardware availability:
- Instruction Set Simulators (ISS) generated from specifications
- Compiler testing against golden reference models
- OS development with accurate architectural behavior
Worked Example
The following example shows how the Branch if Less Than or Equal Unsigned (BLTU) instruction is specified in IDL. xs1, xs2, and imm are decode fields extracted automatically from the instruction encoding before execution.
Bits<MXLEN> src1 = X[xs1]; # (1) Read X[xs1]
Bits<MXLEN> src2 = X[xs2]; # (2) Read X[xs2]
if (src1 <= src2) { # (3) Unsigned comparison
jump($pc + $signed(imm)); # (4) Jump to target
}
# fall through: advance to next instruction
- Read general-purpose register
xs1into an MXLEN-bit variablesrc1.MXLENis a configuration parameter available as a global constant. - Read general-purpose register
xs2intosrc2. - Check if unsigned
src1is less than or equal to unsignedsrc2. - Call
jumpwith a target address formed by adding a signed immediate to the PC.
The jump function called above is itself defined in IDL:
function jump {
arguments XReg target_addr # (1)
description { # (2)
Jump to virtual address `target_addr`.
If target address is misaligned, raise a `MisalignedAddress` exception.
}
body { # (3)
# raise a misaligned exception if address is not aligned to IALIGN
if (implemented?(ExtensionName::C) && # C is implemented
(CSR[misa].C == 0x1) && # and C is enabled dynamically
((target_addr & 0x1) != 0)) { # and the target PC is odd
raise(ExceptionCode::InstructionAddressMisaligned); # (4)
} else if ((target_addr & 0x3) != 0) {
raise(ExceptionCode::InstructionAddressMisaligned);
}
PC = target_addr; # (5)
}
}
jumptakes a single argument of typeXReg(an alias ofBits<MXLEN>).- A textual description is mandatory — IDL is intended as executable documentation.
- Executable statements go inside
body { ... }. - Trigger a synchronous exception by calling
raise. - Set the new PC to the target address.
Basics
Comments
Comments start with # and run to the end of the line. There is no multi-line comment syntax.
# this is a comment
Boolean condition; # this is also a comment
Case sensitivity
IDL is case sensitive. Variable names must begin with a lowercase letter; constant names must begin with an uppercase letter — so a and A are different, and their case determines their mutability.
XReg a; # mutable variable
XReg A; # constant (uppercase)
Reserved keywords
function returns
arguments return
description builtin
body for
if else
enum bitfield
struct true
false
Learn More
- Data Types —
Bits<N>, enums, bitfields, structs, arrays - Operators — Full precedence table
- Functions — Declaring and calling functions
- Scope — How scoping works across instructions, CSRs, and functions
- Standard Library —
CSR[...]access,implemented?(),raise(), memory access - IDL in Instructions — How
operation()works - IDL in CSRs —
sw_read(),sw_write(), and field hooks - IDL for C Users — Side-by-side comparison
- IDL for Verilog Users — Side-by-side comparison
- Common Misunderstandings — Frequent points of confusion