From 35fbc722781d1685108818ca3454a07a51f783f6 Mon Sep 17 00:00:00 2001 From: Luca Colagrande Date: Wed, 25 Oct 2023 11:53:55 +0200 Subject: [PATCH] snRuntime: Update `dump.h` routines --- sw/snRuntime/src/dump.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sw/snRuntime/src/dump.h b/sw/snRuntime/src/dump.h index 8f24cc1b92..d07200d378 100644 --- a/sw/snRuntime/src/dump.h +++ b/sw/snRuntime/src/dump.h @@ -4,6 +4,7 @@ // // Authors: Samuel Riedel, ETH Zurich // Viviane Potocnik, ETH Zurich +// Luca Colagrande, ETH Zurich // Dump a value via CSR // !!! Careful: This is only supported in simulation and an experimental @@ -11,18 +12,15 @@ // This can be exploited to quickly print measurement values from all cores // simultaneously without the hassle of printf. To specify multiple metrics, // different CSRs can be used. The macro will define a function that will then -// always print via the same CSR. E.g., `dump(errors, 8)` will define a function -// with the following signature: `dump_errors(uint32_t val)`, which will print -// the given value via the 8th register. Alternatively, the `write_csr(reg, -// val)` macro can be used directly. +// always print via the same CSR. E.g., `dump(uint32_t, errors, 8)` will define +// a function with the following signature: `dump_errors(uint32_t val)`, which +// will print the given value via the 8th register. Alternatively, the +// `write_csr(reg, val)` macro can be used directly. -#define dump_float(name, reg) \ - static __attribute__((always_inline)) inline void dump_##name(float val) { \ - asm volatile("csrw " #reg ", %0" ::"rK"(val)); \ +#define NAMED_DUMP(type, name, reg) \ + static __attribute__((always_inline)) inline void dump_##name(type val) { \ + asm volatile("csrw " #reg ", %0" ::"rK"(val)); \ } -#define dump_uint(name, reg) \ - static \ - __attribute__((always_inline)) inline void dump_##name(uint32_t val) { \ - asm volatile("csrw " #reg ", %0" ::"rK"(val)); \ - } \ No newline at end of file +// TODO(colluca): do not hardcode the CSR address +#define DUMP(val) ({ asm volatile("csrw 0x7C3, %0" ::"rK"(val)); })