Snitch Runtime
Loading...
Searching...
No Matches
perf_cnt.h
1// Copyright 2023 ETH Zurich and University of Bologna.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5#define SNRT_NUM_PERF_CNTS \
6 (sizeof(((perf_regs_t){}).perf_cnt) / sizeof(((perf_regs_t){}).perf_cnt[0]))
7
15typedef snitch_cluster_peripheral_reg__perf_regs_t perf_regs_t;
16
22inline volatile perf_regs_t* snrt_perf_counters() {
23 return (volatile perf_regs_t*)snrt_cluster_perf_counters_addr();
24}
25
33inline void snrt_cfg_perf_counter(uint32_t perf_cnt, uint16_t metric,
34 uint16_t hart) {
35 snrt_perf_counters()->perf_cnt_sel[perf_cnt].f.hart = hart;
36 snrt_perf_counters()->perf_cnt_sel[perf_cnt].f.metric = metric;
37}
38
44inline void snrt_start_perf_counter(uint32_t perf_cnt) {
45 snrt_perf_counters()->perf_cnt_en[perf_cnt].f.enable = 0x1;
46}
47
53inline void snrt_stop_perf_counter(uint32_t perf_cnt) {
54 snrt_perf_counters()->perf_cnt_en[perf_cnt].f.enable = 0x0;
55}
56
62inline void snrt_reset_perf_counter(uint32_t perf_cnt) {
63 snrt_perf_counters()->perf_cnt[perf_cnt].f.perf_counter = 0x0;
64}
65
73inline uint32_t snrt_get_perf_counter(uint32_t perf_cnt) {
74 return snrt_perf_counters()->perf_cnt[perf_cnt].f.perf_counter;
75}