CIRCT 24.0.0git
Loading...
Searching...
No Matches
Structure.cpp File Reference
#include "ImportVerilogInternals.h"
#include "circt/Support/FVInt.h"
#include "slang/ast/Compilation.h"
#include "slang/ast/symbols/ClassSymbols.h"
#include "slang/ast/symbols/MemberSymbols.h"
#include "slang/syntax/AllSyntax.h"
#include "slang/syntax/SyntaxVisitor.h"
#include "llvm/ADT/STLFunctionalExtras.h"
#include "llvm/ADT/ScopeExit.h"
Include dependency graph for Structure.cpp:

Go to the source code of this file.

Functions

static void recordDPIExportDirectives (Context &context, const slang::ast::Scope &scope, const slang::syntax::SyntaxNode *syntax)
 Record export "DPI-C" directives in the given scope so that callable declarations can be tagged with the exported C name.
static void guessNamespacePrefix (const slang::ast::Symbol &symbol, SmallString< 64 > &prefix)
static moore::ProcedureKind convertProcedureKind (slang::ast::ProceduralBlockKind kind)
static moore::NetKind convertNetKind (slang::ast::NetType::NetKind kind)
static FunctionType getFunctionSignature (Context &context, const slang::ast::SubroutineSymbol &subroutine, ArrayRef< Type > prefixParams, ArrayRef< Type > suffixParams={})
 Helper function to generate the function signature from a SubroutineSymbol and optional extra arguments (used for this argument).
static FailureOr< SmallVector< moore::DPIArgInfo > > getDPISignature (Context &context, const slang::ast::SubroutineSymbol &subroutine)
static Value collapseZToX (OpBuilder &builder, Location loc, Value data, Type dstType)
 Yields data unless it is exactly Z, in which case yields X instead.
static void parseInputRow (StringRef inputs, SmallVectorImpl< char > &levels)
static bool skipUnsupportedRow (const slang::ast::PrimitiveSymbol::TableEntry &entry, ArrayRef< char > levels, size_t numInputs)
static Value buildProductiveTerm (OpBuilder &builder, Location loc, ArrayRef< char > levels, ValueRange inputVals, SmallVectorImpl< Value > &notVars)
 Build the productive AND-term for this row.

Variables

static constexpr StringLiteral dpiExportAttrName = "circt.dpi.export"

Function Documentation

◆ buildProductiveTerm()

Value buildProductiveTerm ( OpBuilder & builder,
Location loc,
ArrayRef< char > levels,
ValueRange inputVals,
SmallVectorImpl< Value > & notVars )
static

Build the productive AND-term for this row.

Returns nullptr if the row is unproductive (all don't cares).

Definition at line 2853 of file Structure.cpp.

Referenced by circt::ImportVerilog::Context::convertUserDefinedPrimitiveDef().

◆ collapseZToX()

Value collapseZToX ( OpBuilder & builder,
Location loc,
Value data,
Type dstType )
static

Yields data unless it is exactly Z, in which case yields X instead.

Per IEEE 1800-2023 Section 28.6's table 28-5 for three-state gates, a Z data input yields X on either the actively-driven or ambiguous-enable path. Known 0/1 data values pass through unchanged. For three-state gates this depends on the assumption that we collapse L to 0 and H to 1.

Definition at line 2535 of file Structure.cpp.

References circt::FVInt::getAllX(), and circt::FVInt::getAllZ().

Referenced by circt::ImportVerilog::Context::convertThreeStateGatePrimitive().

◆ convertNetKind()

moore::NetKind convertNetKind ( slang::ast::NetType::NetKind kind)
static

Definition at line 271 of file Structure.cpp.

◆ convertProcedureKind()

moore::ProcedureKind convertProcedureKind ( slang::ast::ProceduralBlockKind kind)
static

Definition at line 253 of file Structure.cpp.

◆ getDPISignature()

FailureOr< SmallVector< moore::DPIArgInfo > > getDPISignature ( Context & context,
const slang::ast::SubroutineSymbol & subroutine )
static

Definition at line 1969 of file Structure.cpp.

References context, and failure().

Referenced by circt::ImportVerilog::Context::declareCallableImpl().

◆ getFunctionSignature()

FunctionType getFunctionSignature ( Context & context,
const slang::ast::SubroutineSymbol & subroutine,
ArrayRef< Type > prefixParams,
ArrayRef< Type > suffixParams = {} )
static

Helper function to generate the function signature from a SubroutineSymbol and optional extra arguments (used for this argument).

Definition at line 1934 of file Structure.cpp.

References context.

Referenced by circt::ImportVerilog::Context::declareCallableImpl().

◆ guessNamespacePrefix()

void guessNamespacePrefix ( const slang::ast::Symbol & symbol,
SmallString< 64 > & prefix )
static

◆ parseInputRow()

void parseInputRow ( StringRef inputs,
SmallVectorImpl< char > & levels )
static

◆ recordDPIExportDirectives()

void recordDPIExportDirectives ( Context & context,
const slang::ast::Scope & scope,
const slang::syntax::SyntaxNode * syntax )
static

Record export "DPI-C" directives in the given scope so that callable declarations can be tagged with the exported C name.

Slang resolves the directives during elaboration but does not expose them on the subroutine symbols themselves, so walk the scope's syntax to recover them.

Definition at line 32 of file Structure.cpp.

References context.

Referenced by circt::ImportVerilog::Context::convertCompilation(), circt::ImportVerilog::Context::convertModuleBody(), and circt::ImportVerilog::Context::convertPackage().

◆ skipUnsupportedRow()

bool skipUnsupportedRow ( const slang::ast::PrimitiveSymbol::TableEntry & entry,
ArrayRef< char > levels,
size_t numInputs )
static

Variable Documentation

◆ dpiExportAttrName

StringLiteral dpiExportAttrName = "circt.dpi.export"
staticconstexpr

Definition at line 22 of file Structure.cpp.

Referenced by circt::ImportVerilog::Context::declareCallableImpl().