|
CIRCT 24.0.0git
|
#include "ImportVerilogInternals.h"#include "circt/Dialect/SV/SVAttributes.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/SyntaxKind.h"#include "slang/syntax/SyntaxVisitor.h"#include "llvm/ADT/STLFunctionalExtras.h"#include "llvm/ADT/ScopeExit.h"
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 std::optional< UdpLevel > | decodeUdpLevel (char c) |
| Decode a single UDP level character (0, 1, x, ?, or b, case-insensitive). | |
| static bool | parseInputRow (StringRef inputs, SmallVectorImpl< UdpLevel > &levels) |
| Parse a level-only UDP input row string into UdpLevel entries. | |
| static bool | skipUnsupportedCombinationalRow (const slang::ast::PrimitiveSymbol::TableEntry &entry, ArrayRef< UdpLevel > levels, size_t numInputs) |
| Skip unsupported or non-productive combinational table rows. | |
| static Value | buildLevelLiteral (OpBuilder &builder, Location loc, UdpLevel level, Value val, Value ¬Val) |
| Materialize a 2-state literal (val for One, ~val for Zero) or null for DontCare, caching the negation in notVal. | |
| static Value | buildProductiveTerm (OpBuilder &builder, Location loc, ArrayRef< UdpLevel > inputs, ValueRange inputVals, SmallVectorImpl< Value > ¬Vars) |
| Build the productive AND-term for this row. | |
| static LogicalResult | classifySequentialTableRows (const slang::ast::PrimitiveSymbol &primitiveType, size_t numInputs, Location loc, SequentialTableInfo &info) |
| Classify sequential UDP truth table rows into synchronous (edge-sensitive) transitions and asynchronous (level-sensitive) transitions. | |
| static AsyncConditions | buildAsyncConditions (OpBuilder &builder, Location loc, ArrayRef< AsyncRow > asyncRows, ArrayRef< Value > inputVals, Value qVal, moore::IntType i1Ty) |
| Construct boolean conditions from level-sensitive (AsyncRow) rows by partitioning them into rows driving '0' (clearCond) and rows driving '1' (presetCond). | |
| static void | emitSequentialLevelSensitiveProcedure (Context &context, OpBuilder &builder, Location loc, Value asyncCond, Value asyncVal, Value qVar) |
| Emit a level-sensitive moore.procedure always_latch for a latch UDP. | |
Variables | |
| static constexpr StringLiteral | dpiExportAttrName = "circt.dpi.export" |
|
static |
Construct boolean conditions from level-sensitive (AsyncRow) rows by partitioning them into rows driving '0' (clearCond) and rows driving '1' (presetCond).
Because Slang's table conflict check (BitTrie) guarantees that '0'-output and '1'-output rows are mutually exclusive for any 2-state input/state combination, when both '0' and '1' rows exist (e.g. D or SR latches), they combine into a single enable condition (asyncCond = clearCond | presetCond) with dynamic value (asyncVal = presetCond). When only '0' or only '1' rows exist, asyncVal is a constant 0 or 1.
Definition at line 3272 of file Structure.cpp.
References buildLevelLiteral(), and buildProductiveTerm().
Referenced by circt::ImportVerilog::Context::convertSequentialUserDefinedPrimitiveDef().
|
static |
Materialize a 2-state literal (val for One, ~val for Zero) or null for DontCare, caching the negation in notVal.
Definition at line 2958 of file Structure.cpp.
Referenced by buildAsyncConditions(), and buildProductiveTerm().
|
static |
Build the productive AND-term for this row.
Returns nullptr if the row is unproductive (all don't cares).
Definition at line 2976 of file Structure.cpp.
References buildLevelLiteral().
Referenced by buildAsyncConditions(), and circt::ImportVerilog::Context::convertUserDefinedPrimitiveDef().
|
static |
Classify sequential UDP truth table rows into synchronous (edge-sensitive) transitions and asynchronous (level-sensitive) transitions.
Sequential UDPs in hardware are modeled either as edge-triggered flip-flops (where edge-sensitive rows syncRows describe clocked transitions on the edge-sensitive port and level-sensitive rows asyncRows describe asynchronous clear/preset overrides on asynchronous control ports) or as level-sensitive latches (where only asyncRows are present).
Safe Filtering and Benign Hold Rules: Truth tables may include entries that do not produce active 2-state transitions and are skipped before lowering:
Structural Lowering Requirements: Pure level-sensitive UDPs (latches) have no structural restrictions beyond Slang's table validation. For edge-triggered UDPs, while IEEE 1800-2017 Section 29.6 syntactically permits arbitrary combinations of level-sensitive and edge-sensitive rows, lowering to a structured flip-flop procedure (with outer asynchronous clear/preset priority branches and an inner clocked data branch) requires surviving active transitions to satisfy:
Definition at line 3045 of file Structure.cpp.
References assert(), decodeUdpLevel(), parseInputRow(), and success().
Referenced by circt::ImportVerilog::Context::convertSequentialUserDefinedPrimitiveDef().
|
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 2545 of file Structure.cpp.
References circt::FVInt::getAllX(), and circt::FVInt::getAllZ().
Referenced by circt::ImportVerilog::Context::convertThreeStateGatePrimitive().
|
static |
Definition at line 273 of file Structure.cpp.
|
static |
Definition at line 255 of file Structure.cpp.
|
static |
Decode a single UDP level character (0, 1, x, ?, or b, case-insensitive).
Returns std::nullopt for non-level characters such as edge specifiers (r, f, p, n, *, (, )).
Definition at line 2900 of file Structure.cpp.
Referenced by classifySequentialTableRows(), and parseInputRow().
|
static |
Emit a level-sensitive moore.procedure always_latch for a latch UDP.
Definition at line 3316 of file Structure.cpp.
References context.
Referenced by circt::ImportVerilog::Context::convertSequentialUserDefinedPrimitiveDef().
|
static |
Definition at line 1979 of file Structure.cpp.
References context, and failure().
Referenced by circt::ImportVerilog::Context::declareCallableImpl().
|
static |
Helper function to generate the function signature from a SubroutineSymbol and optional extra arguments (used for this argument).
Definition at line 1944 of file Structure.cpp.
References context.
Referenced by circt::ImportVerilog::Context::declareCallableImpl().
|
static |
Definition at line 63 of file Structure.cpp.
References guessNamespacePrefix().
Referenced by circt::ImportVerilog::Context::convertGlobalVariable(), circt::ImportVerilog::Context::declareFunction(), and guessNamespacePrefix().
|
static |
Parse a level-only UDP input row string into UdpLevel entries.
Returns false if any character is not a recognized UDP level symbol.
Definition at line 2920 of file Structure.cpp.
References decodeUdpLevel().
Referenced by classifySequentialTableRows(), and circt::ImportVerilog::Context::convertUserDefinedPrimitiveDef().
|
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 34 of file Structure.cpp.
References context.
Referenced by circt::ImportVerilog::Context::convertCompilation(), circt::ImportVerilog::Context::convertModuleBody(), and circt::ImportVerilog::Context::convertPackage().
|
static |
Skip unsupported or non-productive combinational table rows.
Currently, only combinational UDPs with 0/1/?/b inputs are supported.
Definition at line 2934 of file Structure.cpp.
Referenced by circt::ImportVerilog::Context::convertUserDefinedPrimitiveDef().
|
staticconstexpr |
Definition at line 24 of file Structure.cpp.
Referenced by circt::ImportVerilog::Context::declareCallableImpl().