diff options
Diffstat (limited to 'riscv')
| -rw-r--r-- | riscv/riscv_step.sail | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/riscv/riscv_step.sail b/riscv/riscv_step.sail index 49f8e51c..2ac80cc6 100644 --- a/riscv/riscv_step.sail +++ b/riscv/riscv_step.sail @@ -41,32 +41,32 @@ function fetch() -> FetchResult = { } } -/* returns whether an instruction was retired */ -val step : int -> bool effect {barr, eamem, escape, exmem, rmem, rreg, wmv, wreg} +/* returns whether an instruction was retired, and whether to increment the step count in the trace */ +val step : int -> (bool, bool) effect {barr, eamem, escape, exmem, rmem, rreg, wmv, wreg} function step(step_no) = { match curInterrupt(cur_privilege, mip, mie, mideleg) { Some(intr, priv) => { print_bits("Handling interrupt: ", intr); handle_interrupt(intr, priv); - false + (false, false) }, None() => { match fetch() { F_Error(e, addr) => { handle_mem_exception(addr, e); - false + (false, false) }, F_RVC(h) => { match decodeCompressed(h) { None() => { print("[" ^ string_of_int(step_no) ^ "] [" ^ cur_privilege ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(h) ^ ") <no-decode>"); handle_decode_exception(EXTZ(h)); - false + (false, true) }, Some(ast) => { print("[" ^ string_of_int(step_no) ^ "] [" ^ cur_privilege ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(h) ^ ") " ^ ast); nextPC = PC + 2; - execute(ast) + (execute(ast), true) } } }, @@ -75,12 +75,12 @@ function step(step_no) = { None() => { print("[" ^ string_of_int(step_no) ^ "] [" ^ cur_privilege ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(w) ^ ") <no-decode>"); handle_decode_exception(EXTZ(w)); - false + (false, true) }, Some(ast) => { print("[" ^ string_of_int(step_no) ^ "] [" ^ cur_privilege ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(w) ^ ") " ^ ast); nextPC = PC + 4; - execute(ast) + (execute(ast), true) } } } @@ -96,11 +96,11 @@ function loop () = { step_no : int = 0; while true do { minstret_written = false; /* see note for minstret */ - let retired = step(step_no); + let (retired, stepped) = step(step_no); PC = nextPC; if retired then retire_instruction(); - step_no = step_no + 1; + if stepped then step_no = step_no + 1; /* check htif exit */ if htif_done then { |
