summaryrefslogtreecommitdiff
path: root/mips
diff options
context:
space:
mode:
Diffstat (limited to 'mips')
-rw-r--r--mips/main.sail14
-rw-r--r--mips/prelude.sail2
2 files changed, 13 insertions, 3 deletions
diff --git a/mips/main.sail b/mips/main.sail
index e3ffa262..2c4ee064 100644
--- a/mips/main.sail
+++ b/mips/main.sail
@@ -1,5 +1,5 @@
-
+register instCount : int
val fetch_and_execute : unit -> unit effect {barr, eamem, escape, rmem, rreg, wmv, wreg, undef, wmvt, rmemt}
function fetch_and_execute () = {
@@ -9,7 +9,7 @@ function fetch_and_execute () = {
branchPending = 0b0;
nextPC = if inBranchDelay then delayedPC else PC + 4;
cp2_next_pc();
-
+ instCount = instCount + 1;
print_bits("PC: ", PC);
try {
let pc_pa = TranslatePC(PC);
@@ -54,7 +54,15 @@ function main () = {
init_cp0_state();
init_cp2_state();
nextPC = to_bits(64, elf_entry());
+ startTime = get_time_ns();
fetch_and_execute();
+ endTime = get_time_ns();
+ elapsed = endTime - startTime;
+ inst_1e9 = instCount * 1000000000;
+ ips = inst_1e9 / elapsed;
dump_mips_state ();
- dump_cp2_state ()
+ dump_cp2_state ();
+ print_int("Executed instructions: ", instCount);
+ print_int("Nanoseconds elapsed: ", elapsed);
+ print_int("Instructions per second: ", ips);
}
diff --git a/mips/prelude.sail b/mips/prelude.sail
index 5a7f1351..cf44f6de 100644
--- a/mips/prelude.sail
+++ b/mips/prelude.sail
@@ -395,3 +395,5 @@ overload vector_update_subrange = {vector_update_subrange_dec, vector_update_sub
val mask : forall 'm 'n , 'm >= 'n > 0 . bits('m) -> bits('n)
function mask bs = bs['n - 1 .. 0]
+
+val "get_time_ns" : unit -> int