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> - Creates a constant range based on a left / right value that is either indexed up or indexed down.
Public functions
-
auto width() const -> bitwidth_
t - Gets the width of the range, regardless of the order in which the bounds are specified.
-
auto fullWidth() const -> uint64_
t - Gets the full width of the range, which may not fit into a 32-bit integer.
-
auto lower() const -> int32_
t - Gets the lower bound of the range, regardless of the order in which the bounds are specified.
-
auto upper() const -> int32_
t - Gets the upper bound of the range, regardless of the order in which the bounds are specified.
- 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
- Selects a subrange of this range, correctly handling both forms of bit endianness.
- auto intersect(ConstantRange other) const -> ConstantRange
- Return the intersection range with other.
-
auto translateIndex(int32_
t index) const -> int32_ t - Translates the given index to be relative to the range.
-
auto containsPoint(int32_
t index) const -> bool - Determines whether the given point is within the range.
- auto contains(ConstantRange other) const -> bool
- Determines whether the given range is wholly contained within this one.
- auto overlaps(ConstantRange other) const -> bool
- 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.