Skip to content

Commit 5d7e53f

Browse files
authoredOct 15, 2024
Merge pull request #194 from MichaelJSr/add-back-ecall-ebreak-traps
Add back the "ecall" and "ebreak" instruction traps for riscv-vector test functionality
2 parents 91c135a + 0d04423 commit 5d7e53f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
 

‎sim/simx/emulator.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,15 @@ void Emulator::update_fcrs(uint32_t fflags, uint32_t tid, uint32_t wid) {
625625
this->set_csr(VX_CSR_FFLAGS, this->get_csr(VX_CSR_FFLAGS, tid, wid) | fflags, tid, wid);
626626
}
627627
}
628+
629+
// For riscv-vector test functionality, ecall and ebreak must trap
630+
// These instructions are used in the vector tests to stop execution of the test
631+
// Therefore, without these instructions, undefined and incorrect behavior happens
632+
//
633+
// For now, we need these instructions to trap for testing the riscv-vector isa
634+
void Emulator::trigger_ecall() {
635+
active_warps_.reset();
636+
}
637+
void Emulator::trigger_ebreak() {
638+
active_warps_.reset();
639+
}

‎sim/simx/emulator.h

+4
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ class Emulator {
122122

123123
void update_fcrs(uint32_t fflags, uint32_t tid, uint32_t wid);
124124

125+
void trigger_ecall(); // Re-added for riscv-vector test functionality
126+
127+
void trigger_ebreak(); // Re-added for riscv-vector test functionality
128+
125129
const Arch& arch_;
126130
const DCRS& dcrs_;
127131
Core* core_;

‎sim/simx/execute.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,11 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
830830
trace->fetch_stall = true;
831831
switch (csr_addr) {
832832
case 0x000: // RV32I: ECALL
833+
this->trigger_ecall(); // Re-added for riscv-vector test functionality
834+
break;
833835
case 0x001: // RV32I: EBREAK
836+
this->trigger_ebreak(); // Re-added for riscv-vector test functionality
837+
break;
834838
case 0x002: // RV32I: URET
835839
case 0x102: // RV32I: SRET
836840
case 0x302: // RV32I: MRET

0 commit comments

Comments
 (0)