Skip to main content

Crate ab_riscv_interpreter

Crate ab_riscv_interpreter 

Source
Expand description

Composable and generic RISC-V interpreter.

This interpreter is designed to work with abstractions from ab-riscv-primitives crate and is similarly composable with a powerful macro system and trait abstractions over handling of memory, syscalls, etc.

The immediate needs dictate the current set of available instructions and extensions. Consider contributing if you need something not yet available.

ab-riscv-act4-runner crate in the repository contains a complementary RISC-V Architectural Certification Tests runner for https://github.com/riscv-non-isa/riscv-arch-test that ensures correct implementation.

Does not require a standard library (no_std) or an allocator.

§Supported ISA variants and extensions

ISA variants:

  • RV32I (version 2.1)
  • RV32E (version 2.0)
  • RV64I (version 2.1)
  • RV64E (version 2.0)

Extensions:

  • M (version 2.0)
  • B (version 1.0.0)
  • Zba (version 1.0.0)
  • Zbb (version 1.0.0)
  • Zbc (version 1.0.0)
  • Zbkc (version 1.0.0)
  • Zbs (version 1.0.0)
  • Zknh (version 1.0.0)
  • Zicsr (version 2.0)
  • (experimental) Zve32x (version 1.0.0)
  • (experimental) Zve64x (version 1.0.0)
  • (experimental) Zvl*b (version 1.0.0), where * is anything allowed by the specification

All extensions except experimental pass all relevant RISC-V Architectural Certification Tests (ACTs) using the ACT4 framework.

Any permutation of compatible extensions is supported.

Experimental extensions are known to have bugs and need more work. They are not tested against ACTs yet.

Modules§

rv32
Part of the interpreter responsible for RISC-V RV32 base instruction set
rv64
Part of the interpreter responsible for RISC-V RV64 base instruction set
v
V extension
zicsr
Zicsr extension

Structs§

BasicInstructionFetcher
Basic instruction fetcher implementation
CustomErrorPlaceholder
Placeholder for custom errors in ExecutionError
InterpreterState
Base interpreter state

Enums§

CsrError
CSR error
ExecutionError
Execution errors
FetchInstructionResult
Result of InstructionFetcher::fetch_instruction() call
ProgramCounterError
Program counter errors
VirtualMemoryError
Errors for VirtualMemory

Traits§

BasicInt
Basic integer types that can be read and written to/from memory freely
Csrs
CSRs (Control and Status Registers)
ExecutableInstruction
Trait for executable instructions.
InstructionFetcher
Generic instruction fetcher
ProgramCounter
Generic program counter
SystemInstructionHandler
Custom handler for system instructions ecall and ebreak
VirtualMemory
Virtual memory interface