simx decode bug fix.

This commit is contained in:
Blaise Tine 2024-04-09 01:34:14 -07:00
parent 0e4501aecd
commit db35f5d768
2 changed files with 24 additions and 26 deletions

View file

@ -58,25 +58,22 @@ private:
ipdom_entry_t(const ThreadMask &tmask, Word PC);
ipdom_entry_t(const ThreadMask &tmask);
ThreadMask tmask;
Word PC;
bool fallthrough;
ThreadMask tmask;
Word PC;
bool fallthrough;
};
struct warp_t {
warp_t(const Arch& arch);
void clear(const Arch& arch, const DCRS &dcrs);
Word PC;
ThreadMask tmask;
std::vector<std::vector<Word>> ireg_file;
std::vector<std::vector<uint64_t>> freg_file;
std::stack<ipdom_entry_t> ipdom_stack;
Byte fcsr;
UUIDGenerator uui_gen;
Word PC;
ThreadMask tmask;
std::vector<std::vector<Word>> ireg_file;
std::vector<std::vector<uint64_t>>freg_file;
std::stack<ipdom_entry_t> ipdom_stack;
Byte fcsr;
UUIDGenerator uui_gen;
};
std::shared_ptr<Instr> decode(uint32_t code) const;
@ -99,9 +96,9 @@ private:
void cout_flush();
uint32_t get_csr(uint32_t addr, uint32_t tid, uint32_t wid);
Word get_csr(uint32_t addr, uint32_t tid, uint32_t wid);
void set_csr(uint32_t addr, uint32_t value, uint32_t tid, uint32_t wid);
void set_csr(uint32_t addr, Word value, uint32_t tid, uint32_t wid);
uint32_t get_fpu_rm(uint32_t func3, uint32_t tid, uint32_t wid);
@ -113,13 +110,14 @@ private:
const Arch& arch_;
const DCRS& dcrs_;
Core* core_;
Core* core_;
std::vector<warp_t> warps_;
WarpMask active_warps_;
WarpMask stalled_warps_;
WarpMask active_warps_;
WarpMask stalled_warps_;
std::vector<WarpMask> barriers_;
std::unordered_map<int, std::stringstream> print_bufs_;
MemoryUnit mmu_;
MemoryUnit mmu_;
Word csr_mscratch_;
};
}

View file

@ -256,7 +256,7 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
} else {
switch (func3) {
case 0: {
if (func7) {
if (func7 & 0x20) {
// RV32I: SUB
rddata[t].i = rsdata[t][0].i - rsdata[t][1].i;
} else {
@ -290,7 +290,7 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
case 5: {
Word shamt_mask = ((Word)1 << log2up(XLEN)) - 1;
Word shamt = rsdata[t][1].i & shamt_mask;
if (func7) {
if (func7 & 0x20) {
// RV32I: SRA
rddata[t].i = rsdata[t][0].i >> shamt;
} else {
@ -351,7 +351,7 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
break;
}
case 5: {
if (func7) {
if (func7 & 0x20) {
// RV32I: SRAI
Word result = rsdata[t][0].i >> immsrc;
rddata[t].i = result;
@ -462,7 +462,7 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
} else {
switch (func3) {
case 0: {
if (func7){
if (func7 & 0x20){
// RV64I: SUBW
uint32_t result = (uint32_t)rsdata[t][0].i - (uint32_t)rsdata[t][1].i;
rddata[t].i = sext((uint64_t)result, 32);
@ -486,7 +486,7 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
uint32_t shamt_mask = 0x1F;
uint32_t shamt = rsdata[t][1].i & shamt_mask;
uint32_t result;
if (func7) {
if (func7 & 0x20) {
// RV64I: SRAW
result = (int32_t)rsdata[t][0].i >> shamt;
} else {
@ -530,7 +530,7 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
uint32_t shamt_mask = 0x1F;
uint32_t shamt = immsrc & shamt_mask;
uint32_t result;
if (func7) {
if (func7 & 0x20) {
// RV64I: SRAIW
result = (int32_t)rsdata[t][0].i >> shamt;
} else {
@ -786,7 +786,7 @@ void Emulator::execute(const Instr &instr, uint32_t wid, instr_trace_t *trace) {
if (!warp.tmask.test(t))
continue;
uint32_t csr_addr = immsrc;
uint32_t csr_value;
Word csr_value;
if (func3 == 0) {
trace->fu_type = FUType::ALU;
trace->alu_type = AluType::SYSCALL;