fix(mpact): fix vector instruction bugs and refine trap logic Refine RVV implementation in mpact simulator to address several instruction bugs and trap handling mismatches: 1. Trap Handling: Append "&& is_interrupt" to existing trap conditions to resolve PC mismatch in ecall. 2. Mask Search: Correct the implementation for Vmsbf, Vmsif, and Vmsof mask search instructions. 3. Bitwise Ops: Update BitwiseMaskBinaryOp for vmand, vmnor, and vmxor. 4. vsetvli: Fix x0, x0 logic to preserve current_vl when max_vector_length remains unchanged. 5. Reduction: Fix data truncation in Vwredsum/u by aligning the accumulator with the destination's widening width. 6. Vslide: - Introduced is_down flag and corrected Vslideup/down logic. - Refined execution logic for Vslide1up/down single-element slide. (Backported from mpact-riscv-vsi commit 6dac0e2a09d0845f1499f46ca2d05d24e1306605) Note: The VlIndexed fix was omitted from this backport as it was natively fixed in google3 already. PiperOrigin-RevId: 975873345
MPACT-RiscV is an implementation of an instruction set simulator for the RiscV instruction set architecture created using the MPACT-Sim simulator tools and framework, for which there are tutorials at Google for Developers.
The instruction set is described in a set of .isa files, and the instruction encoding in a corresponding set of .bin_fmt files. The instruction semantics are implemented in a set of of functions distributed over a large set of C++ files *_instructions.{cc,h}.
The top level simulator control is implemented in riscv_top.{cc,h}, and the simulators are instantiated from main in rv{32,64}g_sim.cc.
MPACT-Sim utilizes the Bazel build system. The easiest way to install bazel is to use Bazelisk, a wrapper for Bazel that automates selecting and downloading the right version of bazel. Use brew install bazelisk on macOS, choco install bazelisk on Windows, and on linux, download the Bazelisk binary, add it to your PATH, then alias bazel to the bazelisk binary.
MPACT-Sim depends on Java, so a reasonable JRE has to be installed. For macOS, run brew install java, on linux sudo apt install default-jre, and on Windows follow the appropriate instructions at java.com.
To build the mpact-sim libraries for x86 based processors, use the command bazel build ...:all from the top level directory. To run the tests, use the command bazel test ...:all.
For Apple computers with Arm64 M series chips, use bazel build --cpu=darwin_arm64 ...:all and bazel test --cpu=darwin_arm64 ...:all.
The build targets rv32g_sim and rv64g_sim provide RiscV simulators for the 32 bit and 64 bit variants of RiscV scalar architectures respectively. Decoding and execution support for vector instructions is included, but has not been built into these targets, though adding them to these simulators is not particularly daunting.