Skip to content

Commit

Permalink
misc: Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fischeti committed Jul 19, 2024
1 parent c380d2b commit 333ee0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions sw/snRuntime/src/perf_cnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
}

0 comments on commit 333ee0d

Please sign in to comment.