slang::ast::Definition class

Represents a module, interface, or program definition.

Public types

struct ParameterDecl
Information about a single parameter declaration.

Constructors, destructors, conversion operators

Definition(const Scope& scope, LookupLocation lookupLocation, const syntax::ModuleDeclarationSyntax& syntax, const NetType& defaultNetType, UnconnectedDrive unconnectedDrive, std::optional<TimeScale> directiveTimeScale, const syntax::SyntaxTree* syntaxTree, const SourceLibrary* sourceLibrary)
Constructs a new instance of the Definition class.

Public functions

auto getKindString() const -> std::string_view
Returns a string description of the definition kind, such as "module", "interface", or "program".
auto getArticleKindString() const -> std::string_view
Returns a string description of the definition kind, including an indefinite article.
auto isInstantiated() const -> bool
Returns true if the definition has been instantiated anywhere in the design.
void noteInstantiated() const
Notes that the definition has been instantiated.
void getHierarchicalPath(std::string& buffer) const
Gets the hierarchical path to the definition, appending it to the provided string.

Public variables

std::string_view name
The name of the definition.
SourceLocation location
The source location where the definition is declared.
const syntax::ModuleDeclarationSyntax& syntax
The syntax node describing the definition.
const NetType& defaultNetType
The default nettype for implicit nets within this definition.
const Scope& scope
The scope containing the definition.
SymbolIndex indexInScope
The index of this definition within its parent scope.
DefinitionKind definitionKind
The kind of definition (module, interface, or program).
VariableLifetime defaultLifetime
The default lifetime for variables declared within this definition.
UnconnectedDrive unconnectedDrive
The drive setting to use for unconnected nets within this definition.
std::optional<TimeScale> timeScale
The timescale specified for this definition, or nullopt if none is explicitly specified.
SmallVector<ParameterDecl, 8> parameters
A list of parameters declared by this definition.
const syntax::PortListSyntax* portList
A list of ports declared by this definition.
flat_hash_set<std::string_view> modports
A set of modport names declared by this definition.
std::span<const AttributeSymbol*const > attributes
A set of attributes associated with this definition.
std::vector<const syntax::BindDirectiveSyntax*> bindDirectives
A set of bind directives that apply to all instances of this definition.
const syntax::SyntaxTree* syntaxTree
The syntax tree that contains this definition, or nullptr if constructed outside of any specific syntax tree.
const SourceLibrary* sourceLibrary
The source library that contains the definition, or nullptr for the default library.
bool hasNonAnsiPorts
Indicates whether this definition has non-ansi port declarations.

Function documentation

std::string_view slang::ast::Definition::getArticleKindString() const

Returns a string description of the definition kind, including an indefinite article.

e.g. "a module", "an interface".