Expand description
This module implement an interpreter for the RISCV32 IM instruction set architecture.
The implementation mostly follows (and copy) code from the MIPS interpreter available here.
§Credits
We would like to thank the authors of the following documentations:
- https://msyksphinz-self.github.io/riscv-isadoc/html/rvm.html (CC BY 4.0) from msyksphinz-self
- https://www.cs.cornell.edu/courses/cs3410/2024fa/assignments/cpusim/riscv-instructions.pdf from the course CS 3410: Computer System Organization and Programming at Cornell University.
The format and description of each instruction is taken from these sources, and copied in this file for offline reference. If you are the author of the above documentations and would like to add or modify the credits, please open a pull request.
For each instruction, we provide the format, description, and the
semantic in pseudo-code of the instruction.
When signed
is mentioned in the pseudo-code, it means that the
operation is performed as a signed operation (i.e. signed(v) where v
is a
32 bits value means that v
must be interpreted as a i32 value in Rust, the
most significant bit being the sign - 1 for negative, 0 for positive).
By default, unsigned operations are performed.
Structs§
- IInstruction
Iter - An iterator over the variants of IInstruction
- Instruction
Iter - An iterator over the variants of Instruction
- MInstruction
Iter - An iterator over the variants of MInstruction
- RInstruction
Iter - An iterator over the variants of RInstruction
- SBInstruction
Iter - An iterator over the variants of SBInstruction
- SInstruction
Iter - An iterator over the variants of SInstruction
- Syscall
Instruction Iter - An iterator over the variants of SyscallInstruction
- UInstruction
Iter - An iterator over the variants of UInstruction
- UJInstruction
Iter - An iterator over the variants of UJInstruction
Enums§
- IInstruction
- Instruction
- MInstruction
- M extension instructions Following https://msyksphinz-self.github.io/riscv-isadoc/html/rvm.html
- RInstruction
- SBInstruction
- SInstruction
- Syscall
Instruction - UInstruction
- UJInstruction
Traits§
Functions§
- interpret_
instruction - interpret_
itype - Interpret an I-type instruction. The encoding of an I-type instruction is as follows:
- interpret_
mtype - Interpret an M-type instruction. The encoding of an M-type instruction is as follows:
- interpret_
rtype - Interpret an R-type instruction. The encoding of an R-type instruction is as follows:
- interpret_
sbtype - Interpret an SB-type instruction. The encoding of an SB-type instruction is as follows:
- interpret_
stype - Interpret an S-type instruction. The encoding of an S-type instruction is as follows:
- interpret_
syscall - interpret_
ujtype - Interpret an UJ-type instruction. The encoding of an UJ-type instruction is as follows:
- interpret_
utype - Interpret an U-type instruction. The encoding of an U-type instruction is as follows: