summaryrefslogtreecommitdiff
path: root/riscv/tracecmp.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-07-24 18:09:18 +0100
committerAlasdair Armstrong2018-07-24 18:09:18 +0100
commit6b4f407ad34ca7d4d8a89a5a4d401ac80c7413b0 (patch)
treeed09b22b7ea4ca20fbcc89b761f1955caea85041 /riscv/tracecmp.ml
parentdafb09e7c26840dce3d522fef3cf359729ca5b61 (diff)
parent8114501b7b956ee4a98fa8599c7efee62fc19206 (diff)
Merge remote-tracking branch 'origin/sail2' into c_fixes
Diffstat (limited to 'riscv/tracecmp.ml')
-rw-r--r--riscv/tracecmp.ml69
1 files changed, 67 insertions, 2 deletions
diff --git a/riscv/tracecmp.ml b/riscv/tracecmp.ml
index c4f718a2..64a918d5 100644
--- a/riscv/tracecmp.ml
+++ b/riscv/tracecmp.ml
@@ -27,6 +27,15 @@ type tick = {
time : int64
}
+type htif = {
+ tohost : int64
+}
+
+type ld_res =
+ | Res_make of int64
+ | Res_match of int64 * int64
+ | Res_cancel
+
type line =
| L_none
| L_inst of inst
@@ -34,6 +43,8 @@ type line =
| L_csr_read of csr_read
| L_csr_write of csr_write
| L_tick of tick
+ | L_htif of htif
+ | L_ld_res of ld_res
let inst_count = ref 0
@@ -123,6 +134,57 @@ let parse_tick l =
let sprint_tick t =
Printf.sprintf "clint::tick mtime <- 0x%Lx" t.time
+(* htif tick
+ htif::tick 0x1
+ *)
+
+let parse_htif l =
+ try Scanf.sscanf l " htif::tick 0x%Lx"
+ (fun tohost -> L_htif { tohost })
+ with
+ | Scanf.Scan_failure _ -> L_none
+ | End_of_file -> L_none
+
+let sprint_htif t =
+ Printf.sprintf "htif::tick 0x%Lx" t.tohost
+
+(* Load reservations:
+ make: reservation <- 0x80002008
+ match: reservation: 0xffffffffffffffff, key=0x80002008
+ cancel: reservation <- none
+
+ *)
+let parse_ldres_match l =
+ try Scanf.sscanf
+ l " reservation: 0x%Lx, key=0x%Lx"
+ (fun res key -> L_ld_res (Res_match (res, key)))
+ with
+ | Scanf.Scan_failure _ -> L_none
+ | End_of_file -> L_none
+
+let parse_ldres_match_sail l =
+ try Scanf.sscanf
+ l " reservation: none, key=0x%Lx"
+ (fun key -> L_ld_res (Res_match (Int64.minus_one, key)))
+ with
+ | Scanf.Scan_failure _ -> L_none
+ | End_of_file -> L_none
+
+let parse_ldres_change l =
+ try if l = "reservation <- none"
+ then L_ld_res Res_cancel
+ else Scanf.sscanf
+ l " reservation <- 0x%Lx"
+ (fun res -> L_ld_res (Res_make res))
+ with
+ | Scanf.Scan_failure _ -> L_none
+ | End_of_file -> L_none
+
+let sprint_ldres = function
+ | Res_make res -> Printf.sprintf "reservation <- 0x%Lx" res
+ | Res_match (res, key) -> Printf.sprintf "reservation: 0x%Lx, key=0x%Lx" res key
+ | Res_cancel -> Printf.sprintf "reservation <- none"
+
(* scanners *)
let popt p l = function
@@ -131,10 +193,11 @@ let popt p l = function
let parse_line l =
parse_csr_read l |> popt parse_csr_write l
- |> popt parse_reg_write l |> popt parse_tick l
+ |> popt parse_reg_write l |> popt parse_tick l |> popt parse_htif l
+ |> popt parse_ldres_change l |> popt parse_ldres_match l
let parse_sail_line l =
- parse_line l |> popt parse_sail_inst l
+ parse_line l |> popt parse_sail_inst l |> popt parse_ldres_match_sail l
let parse_spike_line l =
parse_line l |> popt parse_spike_inst l
@@ -147,6 +210,8 @@ let sprint_line = function
| L_csr_read r -> Printf.sprintf "<%d> %s" !inst_count (sprint_csr_read r)
| L_csr_write r -> Printf.sprintf "<%d> %s" !inst_count (sprint_csr_write r)
| L_tick t -> Printf.sprintf "<%d> %s" !inst_count (sprint_tick t)
+ | L_htif t -> Printf.sprintf "<%d> %s" !inst_count (sprint_htif t)
+ | L_ld_res r -> Printf.sprintf "<%d> %s" !inst_count (sprint_ldres r)
(* file processing *)