4#ifndef INDET_MODULEKEYHELPER_H
5#define INDET_MODULEKEYHELPER_H
16 template<
unsigned int bit,
unsigned int end,
typename T=
unsigned int>
18 if constexpr(bit>31u) {
19 return static_cast<T
>(0u);
21 else if constexpr(bit>=end) {
22 return static_cast<T
>(0u);
40 template <
typename T,
unsigned int T_ROW_BITS,
unsigned int T_COL_BITS,
unsigned int T_CHIP_BITS,
unsigned int T_TYPE_BITS=0u>
42 static constexpr unsigned int ROW_BITS = T_ROW_BITS;
43 static constexpr unsigned int COL_BITS = T_COL_BITS;
44 static constexpr unsigned int CHIP_BITS = T_CHIP_BITS;
46 static constexpr unsigned int TYPE_BITS = T_TYPE_BITS;
65 template <
unsigned int SHIFT, T MASK>
67 if constexpr(MASK==0) {
71 assert (((val << SHIFT) & MASK) == (val << SHIFT));
72 return (val << SHIFT);
85 static constexpr T
makeKey(
bool is_range,
unsigned int chip,
unsigned int col,
unsigned int row=0u) {
static consteval T createMask()
Convenience method to create a mask for which exactly one contiguous sequence of bits is set to 1.
Helper class to create keys for defects described by chip, column and row indices,...
static constexpr T COL_SHIFT
static constexpr T makeBaseKey(T key)
Return the key with the range flag removed.
static constexpr unsigned int ROW_BITS
static constexpr T makeKey(bool is_range, unsigned int chip, unsigned int col, unsigned int row=0u)
Create a key from mask, chip, column and row indices.
static constexpr unsigned int TYPE_BITS
static constexpr bool isMatchingDefect(T defect_key, T key)
Convenience method to check whether the key matches the defect.
static constexpr T getRow(T key)
Get the row index from a full key.
static constexpr std::pair< T, T > makeRangeForMask(T key, T mask)
Return a key pair marking the beginning and the end of the range for the given mask and key.
static constexpr bool isRangeKey(T key)
Test whether a key is a range key.
static constexpr unsigned int CHIP_BITS
static constexpr T CHIP_MASK
static constexpr T ROW_MASK
static constexpr T getChip(T key)
Get the column index from a full key.
static constexpr T getColumn(T key)
Get the column index from a full key.
static constexpr T CHIP_SHIFT
static constexpr T RANGE_FLAG_SHIFT
static constexpr unsigned int COL_BITS
static constexpr T makeRangeKey(T key)
Turn a key into a range key.
static constexpr T makeDefectTypeKey(unsigned int defect_type)
Make the key component representing the an associated defect type.
static constexpr unsigned int RANGE_FLAG_BITS
static constexpr T TYPE_MASK
static constexpr T RANGE_FLAG_MASK
static constexpr T getLimitColumnMax()
Get the maximum row value.
static constexpr T ROW_SHIFT
static constexpr T COL_MASK
static constexpr T getDefectType(T key)
Get an associated defect type.
static constexpr T makeKeyPart(T val)
Convenience method to create part of a key.
static constexpr T getLimitRowMax()
Get the maximum row value.
static constexpr T getDefectTypeComponent(T key)
Get key component of an associated defect type.
static constexpr T TYPE_SHIFT