struct
#include <slang/numeric/ConstantValue.h>
ConstantRange Represents a simple constant range, fully inclusive. SystemVerilog allows negative indices, and for the left side to be less, equal, or greater than the right.
Note that this class makes no attempt to handle overflow of the underlying integer; SystemVerilog places tighter bounds on possible ranges anyway so it shouldn't be an issue.
Public static functions
- static auto getIndexedRange(int32_t l, int32_t r, bool littleEndian, bool indexedUp) -> std::optional<ConstantRange>
Public functions
-
auto width() const -> bitwidth_
t - auto lower() const -> int32_t
- auto upper() const -> int32_t
- auto isLittleEndian() const -> bool
- "Little endian" bit order is when the msb is >= the lsb.
- auto reverse() const -> ConstantRange
- Reverses the bit ordering of the range.
- auto subrange(ConstantRange select) const -> ConstantRange
- auto translateIndex(int32_t index) const -> int32_t
- auto containsPoint(int32_t index) const -> bool
- Determines whether the given point is within the range.
- auto overlaps(ConstantRange other) const -> bool
Function documentation
static std::optional<ConstantRange> slang:: ConstantRange:: getIndexedRange(int32_t l,
int32_t r,
bool littleEndian,
bool indexedUp)
Creates a constant range based on a left / right value that is either indexed up or indexed down. This implements the SystemVerilog range operators of '+:' and '-:'
bitwidth_ t slang:: ConstantRange:: width() const
Gets the width of the range, regardless of the order in which the bounds are specified.
int32_t slang:: ConstantRange:: lower() const
Gets the lower bound of the range, regardless of the order in which the bounds are specified.
int32_t slang:: ConstantRange:: upper() const
Gets the upper bound of the range, regardless of the order in which the bounds are specified.
ConstantRange slang:: ConstantRange:: subrange(ConstantRange select) const
Selects a subrange of this range, correctly handling both forms of bit endianness. This will assert that the given subrange is not wider.
int32_t slang:: ConstantRange:: translateIndex(int32_t index) const
Translates the given index to be relative to the range. For example, if the range is [7:2] and you pass in 3, the result will be 1. If the range is [2:7] and you pass in 3, the result will be 4.
bool slang:: ConstantRange:: overlaps(ConstantRange other) const
Determines whether the given range overlaps with this one (including cases where one is wholly contained in the other).