-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,25 +4,23 @@ | |
// | ||
// Authors: Samuel Riedel, ETH Zurich <[email protected]> | ||
// Viviane Potocnik, ETH Zurich <[email protected]> | ||
// Luca Colagrande, ETH Zurich <[email protected]> | ||
|
||
// Dump a value via CSR | ||
// !!! Careful: This is only supported in simulation and an experimental | ||
// feature. All writes to unimplemented CSR registers will be dumped by Snitch. | ||
// 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)); \ | ||
} | ||
// TODO(colluca): do not hardcode the CSR address | ||
#define DUMP(val) ({ asm volatile("csrw 0x7C3, %0" ::"rK"(val)); }) |