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 std::
optional<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.
Public functions
-
bitwidth_
t width() const - Gets the width of the range, regardless of the order in which the bounds are specified.
-
uint64_
t fullWidth() const - Gets the full width of the range, which may not fit into a 32-bit integer.
-
int32_
t lower() const - Gets the lower bound of the range, regardless of the order in which the bounds are specified.
-
int32_
t upper() const - Gets the upper bound of the range, regardless of the order in which the bounds are specified.
- bool isLittleEndian() const
- "Little endian" bit order is when the msb is >= the lsb.
- ConstantRange reverse() const
- Reverses the bit ordering of the range.
- ConstantRange subrange(ConstantRange select) const
- Selects a subrange of this range, correctly handling both forms of bit endianness.
- ConstantRange intersect(ConstantRange other) const
- Return the intersection range with other.
-
int32_
t translateIndex(int32_ t index) const - Translates the given index to be relative to the range.
-
bool containsPoint(int32_
t index) const - Determines whether the given point is within the range.
- bool contains(ConstantRange other) const
- Determines whether the given range is wholly contained within this one.
- bool overlaps(ConstantRange other) const
- Determines whether the given range overlaps with this one (including cases where one is wholly contained in the other).
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.
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.