diff --git a/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv b/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv index 772a6a0a0a..e6a06f70a9 100644 --- a/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv +++ b/hw/snitch_cluster/src/snitch_cluster_peripheral/snitch_cluster_peripheral.sv @@ -60,10 +60,10 @@ module snitch_cluster_peripheral .hw2reg (hw2reg) ); - // As defined in the `.hjson` file. Unforunately, + // As defined in the `.hjson` file. Unfortunately, // The regtool does not generate enums for SV, // only for C. So we have to define them here. - typedef enum logic[9:0] { + typedef enum logic[4:0] { Cycle = 10'd0, TcdmAccessed = 10'd1, TcdmCongested = 10'd2, @@ -195,7 +195,7 @@ module snitch_cluster_peripheral end end - // Actual performance counters. + // Performance counter FFs. for (genvar i = 0; i < NumPerfCounters; i++) begin : gen_perf_cnt `FFLARNC(perf_cnt_q[i], perf_cnt_d[i], reg2hw.perf_cnt_en[i], reg2hw.perf_cnt[i].qe, '0, clk_i, rst_ni) diff --git a/sw/snRuntime/src/perf_cnt.h b/sw/snRuntime/src/perf_cnt.h index 297673a637..474e10ab79 100644 --- a/sw/snRuntime/src/perf_cnt.h +++ b/sw/snRuntime/src/perf_cnt.h @@ -20,12 +20,13 @@ typedef struct { volatile perf_reg32_t perf_counter[SNRT_NUM_PERF_CNTS]; } perf_regs_t; -// Return the pointer to the perf_counters +// Return the pointer to the performance counter cfg registers inline perf_regs_t* snrt_perf_counters() { return (perf_regs_t*)snrt_cluster_perf_counters_addr(); } -// Configure a specific perf_counter +// Configure a perf_counter, the metrics which can be set +// are defined in `snitch_cluster_peripheral.h` inline void snrt_cfg_perf_counter(uint32_t perf_cnt, uint16_t metric, uint16_t hart) { // Make sure the configuration is written in a single write @@ -34,7 +35,7 @@ inline void snrt_cfg_perf_counter(uint32_t perf_cnt, uint16_t metric, snrt_perf_counters()->select[perf_cnt].value = cfg_reg.value; } -// Enable a specific perf_counter +// Enable a performance counter inline void snrt_start_perf_counter(uint32_t perf_cnt) { snrt_perf_counters()->enable[perf_cnt].value = 0x1; } @@ -44,12 +45,12 @@ inline void snrt_stop_perf_counter(uint32_t perf_cnt) { snrt_perf_counters()->enable[perf_cnt].value = 0x0; } -// Resets the counter completely +// Resets the counter to zero inline void snrt_reset_perf_counter(uint32_t perf_cnt) { snrt_perf_counters()->perf_counter[perf_cnt].value = 0x0; } -// Get counter of specified perf_counter +// Get counter value of a perf_counter inline uint32_t snrt_get_perf_counter(uint32_t perf_cnt) { return snrt_perf_counters()->perf_counter[perf_cnt].value; }