2012-04-12 21:08:20 -04:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2006-08-26 11:35:28 +00:00
|
|
|
//*************************************************************************
|
|
|
|
|
// DESCRIPTION: Verilator: Removal of named begin blocks
|
|
|
|
|
//
|
2019-11-07 22:33:59 -05:00
|
|
|
// Code available from: https://verilator.org
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
//
|
2022-01-01 08:26:40 -05:00
|
|
|
// Copyright 2003-2022 by Wilson Snyder. This program is free software; you
|
2020-03-21 11:24:24 -04:00
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2009-05-04 17:07:57 -04:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
|
// Version 2.0.
|
2020-03-21 11:24:24 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
|
//*************************************************************************
|
|
|
|
|
// V3Begin's Transformations:
|
2008-06-09 21:25:10 -04:00
|
|
|
//
|
2006-08-26 11:35:28 +00:00
|
|
|
// Each module:
|
2019-05-19 16:13:13 -04:00
|
|
|
// Look for BEGINs
|
|
|
|
|
// BEGIN(VAR...) -> VAR ... {renamed}
|
|
|
|
|
// FOR -> WHILEs
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
2009-10-11 20:50:31 -04:00
|
|
|
// There are two scopes; named BEGINs change %m and variable scopes.
|
|
|
|
|
// Unnamed BEGINs change only variable, not $display("%m") scope.
|
|
|
|
|
//
|
2006-08-26 11:35:28 +00:00
|
|
|
//*************************************************************************
|
2019-10-04 20:17:11 -04:00
|
|
|
|
2006-12-18 19:20:45 +00:00
|
|
|
#include "config_build.h"
|
|
|
|
|
#include "verilatedos.h"
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
|
#include "V3Begin.h"
|
2022-08-05 10:56:57 +01:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
#include "V3Ast.h"
|
2022-08-05 10:56:57 +01:00
|
|
|
#include "V3Global.h"
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2018-10-14 13:43:24 -04:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2022-09-18 20:53:42 +01:00
|
|
|
VL_DEFINE_DEBUG_FUNCTIONS;
|
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
//######################################################################
|
|
|
|
|
|
2020-11-18 21:32:16 -05:00
|
|
|
class BeginState final {
|
2012-02-21 22:23:06 -05:00
|
|
|
private:
|
|
|
|
|
// NODE STATE
|
2020-04-15 07:58:34 -04:00
|
|
|
// Entire netlist:
|
2019-05-19 16:13:13 -04:00
|
|
|
// AstNodeFTask::user1 -> bool, 1=processed
|
2022-01-02 13:56:40 -05:00
|
|
|
const VNUser1InUse m_inuser1;
|
2020-08-15 13:11:27 -04:00
|
|
|
bool m_anyFuncInBegin = false;
|
2020-04-15 07:58:34 -04:00
|
|
|
|
2012-02-21 22:23:06 -05:00
|
|
|
public:
|
2020-11-16 19:56:16 -05:00
|
|
|
BeginState() = default;
|
|
|
|
|
~BeginState() = default;
|
2015-11-14 09:06:09 -05:00
|
|
|
void userMarkChanged(AstNode* nodep) {
|
2019-05-19 16:13:13 -04:00
|
|
|
nodep->user1(true);
|
|
|
|
|
m_anyFuncInBegin = true;
|
2012-02-21 22:23:06 -05:00
|
|
|
}
|
|
|
|
|
bool anyFuncInBegin() const { return m_anyFuncInBegin; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
|
2022-01-02 13:56:40 -05:00
|
|
|
class BeginVisitor final : public VNVisitor {
|
2006-08-26 11:35:28 +00:00
|
|
|
private:
|
|
|
|
|
// STATE
|
2021-11-13 13:50:44 -05:00
|
|
|
BeginState* const m_statep; // Current global state
|
2020-08-15 13:11:27 -04:00
|
|
|
AstNodeModule* m_modp = nullptr; // Current module
|
2021-11-26 17:55:36 -05:00
|
|
|
const AstNodeFTask* m_ftaskp = nullptr; // Current function/task
|
2021-07-08 14:58:57 +01:00
|
|
|
AstNode* m_liftedp = nullptr; // Local nodes we are lifting into m_ftaskp
|
2021-11-26 20:38:48 -05:00
|
|
|
string m_displayScope; // Name of %m in $display/AstScopeName
|
2020-04-15 07:58:34 -04:00
|
|
|
string m_namedScope; // Name of begin blocks above us
|
|
|
|
|
string m_unnamedScope; // Name of begin blocks, including unnamed blocks
|
2020-08-15 13:11:27 -04:00
|
|
|
int m_ifDepth = 0; // Current if depth
|
2009-01-21 16:56:50 -05:00
|
|
|
|
|
|
|
|
// METHODS
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2020-10-27 22:35:29 -04:00
|
|
|
string dot(const string& a, const string& b) {
|
|
|
|
|
if (a == "") return b;
|
|
|
|
|
return a + "__DOT__" + b;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-16 21:45:33 +02:00
|
|
|
void dotNames(const AstNodeBlock* const nodep, const char* const blockName) {
|
|
|
|
|
UINFO(8, "nname " << m_namedScope << endl);
|
|
|
|
|
if (nodep->name() != "") { // Else unneeded unnamed block
|
|
|
|
|
// Create data for dotted variable resolution
|
|
|
|
|
string dottedname = nodep->name() + "__DOT__"; // So always found
|
|
|
|
|
string::size_type pos;
|
|
|
|
|
while ((pos = dottedname.find("__DOT__")) != string::npos) {
|
|
|
|
|
const string ident = dottedname.substr(0, pos);
|
2022-09-14 21:10:19 -04:00
|
|
|
dottedname = dottedname.substr(pos + std::strlen("__DOT__"));
|
2022-05-16 21:45:33 +02:00
|
|
|
if (nodep->name() != "") {
|
|
|
|
|
m_displayScope = dot(m_displayScope, ident);
|
|
|
|
|
m_namedScope = dot(m_namedScope, ident);
|
|
|
|
|
}
|
|
|
|
|
m_unnamedScope = dot(m_unnamedScope, ident);
|
|
|
|
|
// Create CellInline for dotted var resolution
|
|
|
|
|
if (!m_ftaskp) {
|
|
|
|
|
AstCellInline* const inlinep = new AstCellInline(
|
|
|
|
|
nodep->fileline(), m_unnamedScope, blockName, m_modp->timeunit());
|
|
|
|
|
m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remap var names and replace lower Begins
|
|
|
|
|
iterateAndNextNull(nodep->stmtsp());
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-08 14:58:57 +01:00
|
|
|
void liftNode(AstNode* nodep) {
|
|
|
|
|
nodep->unlinkFrBack();
|
|
|
|
|
if (m_ftaskp) {
|
|
|
|
|
// AstBegin under ftask, just move into the ftask
|
|
|
|
|
if (!m_liftedp) {
|
|
|
|
|
m_liftedp = nodep;
|
|
|
|
|
} else {
|
|
|
|
|
m_liftedp->addNext(nodep);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Move to module
|
2022-09-15 19:43:56 +01:00
|
|
|
m_modp->addStmtsp(nodep);
|
2021-07-08 14:58:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
// VISITORS
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstNodeModule* nodep) override {
|
2020-08-24 21:10:43 -04:00
|
|
|
VL_RESTORER(m_modp);
|
2020-01-20 13:27:27 -05:00
|
|
|
{
|
|
|
|
|
m_modp = nodep;
|
|
|
|
|
iterateChildren(nodep);
|
|
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstNodeFTask* nodep) override {
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(8, " " << nodep << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
// Rename it
|
|
|
|
|
if (m_unnamedScope != "") {
|
2020-10-27 22:35:29 -04:00
|
|
|
nodep->name(dot(m_unnamedScope, nodep->name()));
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(8, " rename to " << nodep->name() << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
m_statep->userMarkChanged(nodep);
|
|
|
|
|
}
|
|
|
|
|
// BEGIN wrapping a function rename that function, but don't affect
|
|
|
|
|
// the inside function's variables. We then restart with empty
|
|
|
|
|
// naming; so that any begin's inside the function will rename
|
|
|
|
|
// inside the function.
|
|
|
|
|
// Process children
|
2021-11-26 20:38:48 -05:00
|
|
|
VL_RESTORER(m_displayScope);
|
2020-08-24 21:10:43 -04:00
|
|
|
VL_RESTORER(m_namedScope);
|
|
|
|
|
VL_RESTORER(m_unnamedScope);
|
2019-05-19 16:13:13 -04:00
|
|
|
{
|
2021-11-26 20:38:48 -05:00
|
|
|
m_displayScope = dot(m_displayScope, nodep->name());
|
2019-05-19 16:13:13 -04:00
|
|
|
m_namedScope = "";
|
|
|
|
|
m_unnamedScope = "";
|
|
|
|
|
m_ftaskp = nodep;
|
2021-07-08 14:58:57 +01:00
|
|
|
m_liftedp = nullptr;
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2021-07-08 14:58:57 +01:00
|
|
|
if (m_liftedp) {
|
|
|
|
|
// Place lifted nodes at beginning of stmtsp, so Var nodes appear before referenced
|
|
|
|
|
if (AstNode* const stmtsp = nodep->stmtsp()) {
|
|
|
|
|
stmtsp->unlinkFrBackWithNext();
|
|
|
|
|
m_liftedp->addNext(stmtsp);
|
|
|
|
|
}
|
|
|
|
|
nodep->addStmtsp(m_liftedp);
|
|
|
|
|
m_liftedp = nullptr;
|
|
|
|
|
}
|
2020-08-15 10:12:55 -04:00
|
|
|
m_ftaskp = nullptr;
|
2019-05-19 16:13:13 -04:00
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstBegin* nodep) override {
|
2019-05-19 16:13:13 -04:00
|
|
|
// Begin blocks were only useful in variable creation, change names and delete
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(8, " " << nodep << endl);
|
2021-11-26 20:38:48 -05:00
|
|
|
VL_RESTORER(m_displayScope);
|
2020-10-27 22:35:29 -04:00
|
|
|
VL_RESTORER(m_namedScope);
|
|
|
|
|
VL_RESTORER(m_unnamedScope);
|
2019-05-19 16:13:13 -04:00
|
|
|
{
|
2022-05-16 21:45:33 +02:00
|
|
|
dotNames(nodep, "__BEGIN__");
|
2006-08-26 11:35:28 +00:00
|
|
|
|
2019-07-06 12:57:50 -04:00
|
|
|
UASSERT_OBJ(!nodep->genforp(), nodep, "GENFORs should have been expanded earlier");
|
2011-11-29 18:23:18 -05:00
|
|
|
|
2020-10-27 22:35:29 -04:00
|
|
|
// Cleanup
|
|
|
|
|
AstNode* addsp = nullptr;
|
2021-11-26 17:55:36 -05:00
|
|
|
if (AstNode* const stmtsp = nodep->stmtsp()) {
|
2020-10-27 22:35:29 -04:00
|
|
|
stmtsp->unlinkFrBackWithNext();
|
2022-09-17 13:48:51 +01:00
|
|
|
addsp = AstNode::addNext(addsp, stmtsp);
|
2020-10-27 22:35:29 -04:00
|
|
|
}
|
2020-04-15 07:58:34 -04:00
|
|
|
if (addsp) {
|
2020-10-27 22:35:29 -04:00
|
|
|
nodep->replaceWith(addsp);
|
2020-04-15 07:58:34 -04:00
|
|
|
} else {
|
2020-10-27 22:35:29 -04:00
|
|
|
nodep->unlinkFrBack();
|
2020-04-15 07:58:34 -04:00
|
|
|
}
|
2020-10-27 22:35:29 -04:00
|
|
|
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
2019-05-19 16:13:13 -04:00
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstVar* nodep) override {
|
2019-05-19 16:13:13 -04:00
|
|
|
if (m_unnamedScope != "") {
|
|
|
|
|
// Rename it
|
2020-10-27 22:35:29 -04:00
|
|
|
nodep->name(dot(m_unnamedScope, nodep->name()));
|
2019-05-19 16:13:13 -04:00
|
|
|
m_statep->userMarkChanged(nodep);
|
2021-07-08 14:58:57 +01:00
|
|
|
// Move it under enclosing tree
|
|
|
|
|
liftNode(nodep);
|
2019-05-19 16:13:13 -04:00
|
|
|
}
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstTypedef* nodep) override {
|
2020-03-26 18:10:20 -04:00
|
|
|
if (m_unnamedScope != "") {
|
|
|
|
|
// Rename it
|
2020-10-27 22:35:29 -04:00
|
|
|
nodep->name(dot(m_unnamedScope, nodep->name()));
|
2020-03-26 18:10:20 -04:00
|
|
|
m_statep->userMarkChanged(nodep);
|
2021-07-08 14:58:57 +01:00
|
|
|
// Move it under enclosing tree
|
|
|
|
|
liftNode(nodep);
|
2020-03-26 18:10:20 -04:00
|
|
|
}
|
|
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstCell* nodep) override {
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(8, " CELL " << nodep << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
if (m_namedScope != "") {
|
|
|
|
|
m_statep->userMarkChanged(nodep);
|
|
|
|
|
// Rename it
|
2020-10-27 22:35:29 -04:00
|
|
|
nodep->name(dot(m_namedScope, nodep->name()));
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(8, " rename to " << nodep->name() << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
// Move to module
|
|
|
|
|
nodep->unlinkFrBack();
|
2022-09-15 19:43:56 +01:00
|
|
|
m_modp->addStmtsp(nodep);
|
2019-05-19 16:13:13 -04:00
|
|
|
}
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstVarXRef* nodep) override {
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(9, " VARXREF " << nodep << endl);
|
2020-09-27 15:10:44 +01:00
|
|
|
if (m_namedScope != "" && nodep->inlinedDots() == "" && !m_ftaskp) {
|
2019-05-19 16:13:13 -04:00
|
|
|
nodep->inlinedDots(m_namedScope);
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(9, " rescope to " << nodep << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
}
|
2015-12-05 19:39:40 -05:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstScopeName* nodep) override {
|
2019-05-19 16:13:13 -04:00
|
|
|
// If there's a %m in the display text, we add a special node that will contain the name()
|
|
|
|
|
// Similar code in V3Inline
|
|
|
|
|
if (nodep->user1SetOnce()) return; // Don't double-add text's
|
2021-11-26 20:38:48 -05:00
|
|
|
// DPI svGetScope doesn't include function name, but %m does
|
|
|
|
|
const string scname = nodep->forFormat() ? m_displayScope : m_namedScope;
|
|
|
|
|
if (!scname.empty()) {
|
2019-05-19 16:13:13 -04:00
|
|
|
// To keep correct visual order, must add before other Text's
|
2022-09-15 19:43:56 +01:00
|
|
|
AstText* const afterp = nodep->scopeAttrp();
|
2019-05-19 16:13:13 -04:00
|
|
|
if (afterp) afterp->unlinkFrBackWithNext();
|
2022-09-15 19:43:56 +01:00
|
|
|
nodep->addScopeAttrp(new AstText{nodep->fileline(), string("__DOT__") + scname});
|
|
|
|
|
if (afterp) nodep->addScopeAttrp(afterp);
|
2019-05-19 16:13:13 -04:00
|
|
|
}
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2007-03-06 18:53:24 +00:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstCoverDecl* nodep) override {
|
2019-05-19 16:13:13 -04:00
|
|
|
// Don't need to fix path in coverage statements, they're not under
|
|
|
|
|
// any BEGINs, but V3Coverage adds them all under the module itself.
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2008-11-05 10:23:03 -05:00
|
|
|
}
|
2010-12-26 09:31:09 -05:00
|
|
|
// VISITORS - LINT CHECK
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstIf* nodep) override { // not AstNodeIf; other types not covered
|
2019-05-19 16:13:13 -04:00
|
|
|
// Check IFDEPTH warning - could be in other transform files if desire
|
2020-08-24 21:10:43 -04:00
|
|
|
VL_RESTORER(m_ifDepth);
|
2020-04-15 07:58:34 -04:00
|
|
|
if (m_ifDepth == -1 || v3Global.opt.ifDepth() < 1) { // Turned off
|
2019-05-19 16:13:13 -04:00
|
|
|
} else if (nodep->uniquePragma() || nodep->unique0Pragma() || nodep->priorityPragma()) {
|
|
|
|
|
m_ifDepth = -1;
|
|
|
|
|
} else if (++m_ifDepth > v3Global.opt.ifDepth()) {
|
2020-04-15 07:58:34 -04:00
|
|
|
nodep->v3warn(IFDEPTH,
|
|
|
|
|
"Deep 'if' statement; suggest unique/priority to avoid slow logic");
|
2019-05-19 16:13:13 -04:00
|
|
|
nodep->fileline()->modifyWarnOff(V3ErrorCode::IFDEPTH, true); // Warn only once
|
|
|
|
|
m_ifDepth = -1;
|
|
|
|
|
}
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2015-12-05 19:39:40 -05:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
2020-04-04 08:31:14 -04:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
public:
|
2019-09-12 07:22:22 -04:00
|
|
|
// CONSTRUCTORS
|
2020-08-15 13:11:27 -04:00
|
|
|
BeginVisitor(AstNetlist* nodep, BeginState* statep)
|
2020-08-16 09:55:36 -04:00
|
|
|
: m_statep{statep} {
|
2018-05-10 20:55:37 -04:00
|
|
|
iterate(nodep);
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
~BeginVisitor() override = default;
|
2006-08-26 11:35:28 +00:00
|
|
|
};
|
|
|
|
|
|
2012-02-21 22:23:06 -05:00
|
|
|
//######################################################################
|
|
|
|
|
|
2022-01-02 13:56:40 -05:00
|
|
|
class BeginRelinkVisitor final : public VNVisitor {
|
2012-02-21 22:23:06 -05:00
|
|
|
// Replace tasks with new pointer
|
|
|
|
|
private:
|
|
|
|
|
// NODE STATE
|
|
|
|
|
// Input:
|
2019-05-19 16:13:13 -04:00
|
|
|
// AstNodeFTask::user1p // Node replaced, rename it
|
2012-02-21 22:23:06 -05:00
|
|
|
|
|
|
|
|
// VISITORS
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstNodeFTaskRef* nodep) override {
|
2019-05-19 16:13:13 -04:00
|
|
|
if (nodep->taskp()->user1()) { // It was converted
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(9, " relinkFTask " << nodep << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
nodep->name(nodep->taskp()->name());
|
|
|
|
|
}
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2012-02-21 22:23:06 -05:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstVarRef* nodep) override {
|
2019-05-19 16:13:13 -04:00
|
|
|
if (nodep->varp()->user1()) { // It was converted
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(9, " relinVarRef " << nodep << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
nodep->name(nodep->varp()->name());
|
|
|
|
|
}
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2015-11-14 09:06:09 -05:00
|
|
|
}
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstIfaceRefDType* nodep) override {
|
2019-05-19 16:13:13 -04:00
|
|
|
// May have changed cell names
|
|
|
|
|
// TypeTable is always after all modules, so names are stable
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(8, " IFACEREFDTYPE " << nodep << endl);
|
2019-05-19 16:13:13 -04:00
|
|
|
if (nodep->cellp()) nodep->cellName(nodep->cellp()->name());
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(8, " rename to " << nodep << endl);
|
2018-05-10 20:55:37 -04:00
|
|
|
iterateChildren(nodep);
|
2015-11-14 09:06:09 -05:00
|
|
|
}
|
2012-02-21 22:23:06 -05:00
|
|
|
//--------------------
|
2022-09-16 11:22:11 +01:00
|
|
|
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
2020-04-04 08:31:14 -04:00
|
|
|
|
2012-02-21 22:23:06 -05:00
|
|
|
public:
|
2019-09-12 07:22:22 -04:00
|
|
|
// CONSTRUCTORS
|
2020-04-15 07:58:34 -04:00
|
|
|
BeginRelinkVisitor(AstNetlist* nodep, BeginState*) { iterate(nodep); }
|
2022-09-16 11:22:11 +01:00
|
|
|
~BeginRelinkVisitor() override = default;
|
2012-02-21 22:23:06 -05:00
|
|
|
};
|
|
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
//######################################################################
|
|
|
|
|
// Task class functions
|
|
|
|
|
|
|
|
|
|
void V3Begin::debeginAll(AstNetlist* nodep) {
|
2020-04-15 07:58:34 -04:00
|
|
|
UINFO(2, __FUNCTION__ << ": " << endl);
|
2018-03-10 12:57:50 -05:00
|
|
|
{
|
|
|
|
|
BeginState state;
|
2021-11-26 10:52:36 -05:00
|
|
|
{ BeginVisitor{nodep, &state}; }
|
|
|
|
|
if (state.anyFuncInBegin()) { BeginRelinkVisitor{nodep, &state}; }
|
2018-03-10 12:57:50 -05:00
|
|
|
} // Destruct before checking
|
2022-09-18 20:53:42 +01:00
|
|
|
V3Global::dumpCheckGlobalTree("begin", 0, dumpTree() >= 3);
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|