General C, C++ and CUDA helpers from axi-pcie-devel: memory dumps, raw register access, a monotonic clock and min, max and clamp.
More...
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <type_traits>
|
| namespace | util |
| | Small generic helpers that return the common type of their arguments.
|
| |
|
| void | putByte (uint8_t byte) |
| |
| template<typename T , int COLS = 16> |
| static void | dumpMem (T *ptr, size_t sizeInBytes) |
| | Dump memory to stdout, in a (kinda) pretty format However, the code is far from pretty.
|
| |
| template<typename T > |
| static void | writeRegister (void *fpgaRegs, uintptr_t reg, const T &value) |
| | Stupid wrapper for writing to FPGA registers.
|
| |
| template<typename T > |
| static T | readRegister (void *fpgaRegs, uintptr_t reg) |
| | Stupid wrapper for reading FPGA registers mapped via DMA.
|
| |
| static double | curTime () |
| | Return the CLOCK_MONOTONIC time in seconds.
|
| |
| template<typename A , typename B > |
| std::common_type< A, B >::type | util::min (const A &a, const B &b) |
| | Return the smaller of a and b (b if they compare equal), as their common type.
|
| |
| template<typename A , typename B > |
| std::common_type< A, B >::type | util::max (const A &a, const B &b) |
| | Return the larger of a and b (b if they compare equal), as their common type.
|
| |
| template<typename A , typename B , typename C > |
| std::common_type< A, B, C >::type | util::clamp (const A &val, const B &lower, const C &upper) |
| | Return val limited to the range from lower to upper, as the common type of the three arguments.
|
| |
General C, C++ and CUDA helpers from axi-pcie-devel: memory dumps, raw register access, a monotonic clock and min, max and clamp.
Used in psdaq through GpuAsyncLib.hh by the pgpread_gpu tool.
◆ curTime()
| static double curTime |
( |
| ) |
|
|
inlinestatic |
Return the CLOCK_MONOTONIC time in seconds.
◆ dumpMem()
template<typename T , int COLS = 16>
| static void dumpMem |
( |
T * |
ptr, |
|
|
size_t |
sizeInBytes |
|
) |
| |
|
inlinestatic |
Dump memory to stdout, in a (kinda) pretty format However, the code is far from pretty.
◆ putByte()
| void putByte |
( |
uint8_t |
byte | ) |
|
|
inline |
Company : SLAC National Accelerator Laboratory
Description: General utilities for C/C++/CUDA code
This file is part of 'axi-pcie-devel'. It is subject to the license terms in the LICENSE.txt file found in the top-level directory of this distribution and at: https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. No part of 'axi-pcie-devel', including this file, may be copied, modified, propagated, or distributed except according to the terms contained in
the LICENSE.txt file.
◆ readRegister()
template<typename T >
| static T readRegister |
( |
void * |
fpgaRegs, |
|
|
uintptr_t |
reg |
|
) |
| |
|
inlinestatic |
Stupid wrapper for reading FPGA registers mapped via DMA.
◆ writeRegister()
template<typename T >
| static void writeRegister |
( |
void * |
fpgaRegs, |
|
|
uintptr_t |
reg, |
|
|
const T & |
value |
|
) |
| |
|
inlinestatic |
Stupid wrapper for writing to FPGA registers.
- Parameters
-
| fpgaRegs | Pointer to DMA space |
| reg | Register offset |