CIRCT 24.0.0git
Loading...
Searching...
No Matches
Functions | Variables
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.
 

Variables

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

Function Documentation

◆ collapseZToX()

static 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 2505 of file Structure.cpp.

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

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

◆ convertNetKind()

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

Definition at line 266 of file Structure.cpp.

◆ convertProcedureKind()

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

Definition at line 248 of file Structure.cpp.

◆ getDPISignature()

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

Definition at line 1942 of file Structure.cpp.

References context.

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

◆ getFunctionSignature()

static 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 1907 of file Structure.cpp.

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

◆ guessNamespacePrefix()

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

◆ recordDPIExportDirectives()

static 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().

Variable Documentation

◆ dpiExportAttrName

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

Definition at line 22 of file Structure.cpp.

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