slang::ConstantRange struct

Contents

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 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.

Function documentation

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.