Skip to content

Commit 89230cc

Browse files
committed
bug fix: rounding mode (rm) must be calculated again before executing FP instruction during simulation
1 parent 30d9e2b commit 89230cc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/riscvsim/core/inorder_backend.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ exec_insn_and_invalidate_rd(RISCVCPUState *s, INCore *core, InstructionLatch *e,
9191
}
9292

9393
e->elasped_clock_cycles = 1;
94+
e->ins.rm = get_insn_rm(s, (e->ins.binary >> 12) & 7);
9495
execute_riscv_instruction(&e->ins, &s->fflags);
9596
++s->simcpu->stats[s->priv].fu_access[fu_type];
9697
}

src/riscvsim/core/ooo_backend.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ oo_core_execute_non_pipe(OOCore *core, int fu_type, CPUStage *stage)
241241
e = get_insn_latch(s->simcpu->insn_latch_pool, stage->insn_latch_index);
242242
if (!stage->stage_exec_done)
243243
{
244+
e->ins.rm = get_insn_rm(s, (e->ins.binary >> 12) & 7);
244245
execute_riscv_instruction(&e->ins, &s->fflags);
245246

246247
/* Update FU stats */
@@ -310,6 +311,7 @@ oo_core_execute_pipe(OOCore *core, int cur_stage_id, int fu_type, CPUStage *stag
310311
e = get_insn_latch(s->simcpu->insn_latch_pool, stage->insn_latch_index);
311312
if (!stage->stage_exec_done)
312313
{
314+
e->ins.rm = get_insn_rm(s, (e->ins.binary >> 12) & 7);
313315
execute_riscv_instruction(&e->ins, &s->fflags);
314316

315317
/* Update FU stats */

0 commit comments

Comments
 (0)