summaryrefslogtreecommitdiff
path: root/riscv
diff options
context:
space:
mode:
authorPrashanth Mundkur2018-06-25 15:44:46 -0700
committerPrashanth Mundkur2018-06-25 15:44:53 -0700
commit768728bc21bb45b39494443f81f3e9de65f94fe1 (patch)
treedf981b54410bc3949cffe0f754c0620999ebb49b /riscv
parent07d0c0c72c0430a69552edcfb64d7640774c262b (diff)
Increment the riscv trace step counter only when instructions are executed.
Diffstat (limited to 'riscv')
-rw-r--r--riscv/riscv_step.sail20
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 {