forked from pulp-platform/snitch_cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* snitch: add csr dump for single cycle printf (works only in sim!!!) * snitch: add macro for csr dump --------- Co-authored-by: Viviane Potocnik <vivianep@iis.ee.ethz.ch>
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2020 ETH Zurich and University of Bologna. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Authors: Samuel Riedel, ETH Zurich <sriedel@iis.ee.ethz.ch> | ||
// Viviane Potocnik, ETH Zurich <vivianep@iis.ee.ethz.ch> | ||
|
||
// 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. | ||
|
||
#define dump_float(name, reg) \ | ||
static __attribute__((always_inline)) inline void dump_##name(float 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)); \ | ||
} |
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