slang::ast::Bitstream class

Provides utility methods for working with bitstream operations.

Public static functions

template<typename T1, typename T2>
static auto dynamicSizesMatch(const T1& destination, const T2& source) -> bool
Compile-time check that the source and destination types have the same dynamic bitstream sizes.
static auto evaluateCast(const Type& type, ConstantValue&& value, SourceRange sourceRange, EvalContext& context, bool isImplicit = false) -> ConstantValue
Performs a bit-stream cast of value to type.
static auto canBeTarget(const StreamingConcatenationExpression& lhs, const Expression& rhs, SourceLocation assignLoc, const ASTContext& context) -> bool
Compile-time check that streaming concatenation target has a bit-stream type source with enough bits.
static auto canBeSource(const Type& target, const StreamingConcatenationExpression& rhs, SourceLocation assignLoc, const ASTContext& context) -> bool
Compile-time check that streaming concatenation source has a bit-stream target type with enough bits.
static auto isBitstreamCast(const Type& type, const StreamingConcatenationExpression& arg) -> bool
Compile-time check that bit-streaming cast on a streaming operator is valid.
static auto checkClassAccess(const Type& type, const ASTContext& context, SourceRange sourceRange) -> bool
Checks that the given type is accessible for bit-stream casting from the provided scope.
static auto reOrder(ConstantValue&& value, uint64_t sliceSize, uint64_t unpackWidth = 0) -> ConstantValue
Re-ordering of the generic stream.
static auto evaluateTarget(const StreamingConcatenationExpression& lhs, const Expression& rhs, EvalContext& context) -> ConstantValue
Performs constant evaluation of an assignment with a streaming concatenation as the target.
static auto resizeToRange(ConstantValue&& value, ConstantRange range, ConstantValue defaultValue, bool keepArray = false) -> ConstantValue
Resize a constant array value from [0:size-1] to [lower:upper].
static auto convertToBitVector(ConstantValue&& value, SourceRange sourceRange, EvalContext& context) -> ConstantValue
Converts a bitstream value into a corresponding bit vector of the same width.

Function documentation

template<typename T1, typename T2>
static bool slang::ast::Bitstream::dynamicSizesMatch(const T1& destination, const T2& source)

Compile-time check that the source and destination types have the same dynamic bitstream sizes.

note: only Type and StreamingConcatenationExpression are allowed for T1/T2

static ConstantValue slang::ast::Bitstream::evaluateCast(const Type& type, ConstantValue&& value, SourceRange sourceRange, EvalContext& context, bool isImplicit = false)

Performs a bit-stream cast of value to type.

If the conversion is not valid, returns nullptr (invalid value).

static bool slang::ast::Bitstream::canBeTarget(const StreamingConcatenationExpression& lhs, const Expression& rhs, SourceLocation assignLoc, const ASTContext& context)

Compile-time check that streaming concatenation target has a bit-stream type source with enough bits.

If the target is definitely invalid, a diagnostic will be issued.

static bool slang::ast::Bitstream::canBeSource(const Type& target, const StreamingConcatenationExpression& rhs, SourceLocation assignLoc, const ASTContext& context)

Compile-time check that streaming concatenation source has a bit-stream target type with enough bits.

If the source is definitely invalid, a diagnostic will be issued.

static bool slang::ast::Bitstream::checkClassAccess(const Type& type, const ASTContext& context, SourceRange sourceRange)

Checks that the given type is accessible for bit-stream casting from the provided scope.

This is always true unless the type is a class type with private or protected members that are not visible from the given scope. If false, a diagnostic will be issued using the provided context.

static ConstantValue slang::ast::Bitstream::reOrder(ConstantValue&& value, uint64_t sliceSize, uint64_t unpackWidth = 0)

Re-ordering of the generic stream.

For source/packed concatenation, unpackWidth = 0. For target/unpacked concatenation, unpackWidth is the total width of target.