slang::ast::Constraint class

The base class for all constraints in SystemVerilog.

Derived classes

class ConditionalConstraint
Represents a constraint defined by an if-else condition.
class ConstraintList
Represents a list of constraints.
class DisableSoftConstraint
Represents a constraint that disables a soft random variable.
class ExpressionConstraint
Represents a constraint defined by a logical expression.
class ForeachConstraint
Represents a constraint that iterates over the elements of an array.
class ImplicationConstraint
Represents a constraint defined by an implication.
class InvalidConstraint
Represents an invalid constraint.
class SolveBeforeConstraint
Represents a constraint that enforces ordering of solving variables.
class UniquenessConstraint
Represents a constraint that enforces uniqueness of variables.

Public static functions

static auto bind(const syntax::ConstraintItemSyntax& syntax, const ASTContext& context) -> const Constraint&
Binds a constraint tree from the given syntax node.

Public functions

auto bad() const -> bool
Indicates whether the constraint is invalid.
template<typename T>
auto as() -> T&
Casts this constraint to the given concrete derived type.
template<typename T>
auto as() const -> const T&
Casts this constraint to the given concrete derived type.
template<typename T>
auto as_if() -> T*
Tries to cast this constraint to the given concrete derived type.
template<typename T>
auto as_if() const -> const T*
Tries to cast this constraint to the given concrete derived type.
template<typename TVisitor, typename... Args>
auto visit(TVisitor& visitor, Args && ... args) const -> decltype(auto)
Visits this constraint's concrete derived type via the provided visitor object.

Public variables

ConstraintKind kind
The kind of constraint; indicates the type of derived class.
const syntax::ConstraintItemSyntax* syntax
The syntax used to create the constraint, if any.

Function documentation

template<typename T>
T& slang::ast::Constraint::as()

Casts this constraint to the given concrete derived type.

Asserts that the type is appropriate given this constraint's kind.

template<typename T>
const T& slang::ast::Constraint::as() const

Casts this constraint to the given concrete derived type.

Asserts that the type is appropriate given this constraint's kind.

template<typename T>
T* slang::ast::Constraint::as_if()

Tries to cast this constraint to the given concrete derived type.

If the type is not appropriate given this constraint's kind, returns nullptr.

template<typename T>
const T* slang::ast::Constraint::as_if() const

Tries to cast this constraint to the given concrete derived type.

If the type is not appropriate given this constraint's kind, returns nullptr.

Variable documentation

const syntax::ConstraintItemSyntax* slang::ast::Constraint::syntax

The syntax used to create the constraint, if any.

A constraint tree can be created manually in which case it may not have a syntax representation.