aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam McSpaddden <bill@riscv.org>2023-06-23 17:28:06 -0500
committerWilliam McSpaddden <bill@riscv.org>2023-06-23 17:28:06 -0500
commit0f1577f8e066bb117d89d92c5bbb5feece128401 (patch)
treee25951d20d44f6da3e785e60a48abdf296290c20
parent3b67aea3f715cd1679c8ffbadff9337f16053709 (diff)
downloadsail-riscv-0f1577f8e066bb117d89d92c5bbb5feece128401.zip
sail-riscv-0f1577f8e066bb117d89d92c5bbb5feece128401.tar.gz
sail-riscv-0f1577f8e066bb117d89d92c5bbb5feece128401.tar.bz2
hpmcounters are counting the correct number of events, but they are in the wrong buckets. probable ordering issue.
-rw-r--r--c_emulator/riscv_sim.c24
-rw-r--r--model/riscv_step.sail8
2 files changed, 28 insertions, 4 deletions
diff --git a/c_emulator/riscv_sim.c b/c_emulator/riscv_sim.c
index 097e8b4..6b44975 100644
--- a/c_emulator/riscv_sim.c
+++ b/c_emulator/riscv_sim.c
@@ -78,6 +78,15 @@ bool config_print_mem_access = true;
bool config_print_platform = true;
bool config_print_rvfi = false;
+// TODO: Remove/replace the following code
+static bool enable_c_hpmcounters = false;
+bool c_hpmcounters_enabled(void);
+bool c_hpmcounters_enabled(void) {
+ return enable_c_hpmcounters;
+}
+// TODO: Remove/replace the above code
+
+
void set_config_print(char *var, bool val) {
if (var == NULL || strcmp("all", var) == 0) {
config_print_instr = val;
@@ -135,6 +144,8 @@ static struct option options[] = {
#ifdef SAILCOV
{"sailcov-file", required_argument, 0, 'c'},
#endif
+ // TODO: Remove/replace the following code
+ {"enable-hpmcounters-c", no_argument, 0, 'H'},
{0, 0, 0, 0}
};
@@ -236,6 +247,7 @@ char *process_args(int argc, char **argv)
"T:"
"g:"
"h"
+ "H"
#ifdef RVFI_DII
"r:"
#endif
@@ -320,6 +332,11 @@ char *process_args(int argc, char **argv)
case 'h':
print_usage(argv[0], 0);
break;
+ // TODO: Remove/replace the following code
+ case 'H':
+ enable_c_hpmcounters = true;
+ break;
+ // TODO: Remove/replace the above code
#ifdef RVFI_DII
case 'r':
rvfi_dii = true;
@@ -892,8 +909,11 @@ void run_sail(void)
KILL(sail_int)(&sail_step);
}
{ /* perform event processing */
- signal_platform_events();
-// process_hpm_events();
+ // TODO: Remove/replace the following code
+ if (c_hpmcounters_enabled() ) {
+ process_hpm_events();
+ signal_platform_events();
+ }
}
if (stepped) {
step_no++;
diff --git a/model/riscv_step.sail b/model/riscv_step.sail
index 61684b9..d8f026d 100644
--- a/model/riscv_step.sail
+++ b/model/riscv_step.sail
@@ -67,7 +67,8 @@
/*=======================================================================================*/
val signal_platform_events = {c: "signal_platform_events" } : unit -> unit
-val sail_process_hpm_events : (unit) -> unit
+val c_hpmcounters_enabled = {c: "c_hpmcounters_enabled" } : unit -> bool
+val sail_process_hpm_events : unit -> unit
val sail_init_platform_events : (unit) -> unit
/* The emulator fetch-execute-interrupt dispatch loop. */
@@ -145,7 +146,10 @@ function step(step_no : int) -> bool = {
ext_post_step_hook();
signal_platform_events();
- sail_process_hpm_events();
+ /* TODO: remove the conditional once the C implemnation of hpmcounters is removed */
+ if ( not (c_hpmcounters_enabled() )) then {
+ sail_process_hpm_events();
+ };
stepped
}