Internals: Remove the name field from `AstVarRef` (#4395)
This commit is contained in:
parent
446f21d2a0
commit
9caa79a7ea
|
|
@ -125,9 +125,7 @@ string AstNode::encodeNumber(int64_t num) {
|
|||
}
|
||||
}
|
||||
|
||||
string AstNode::nameProtect() const VL_MT_STABLE {
|
||||
return VIdProtect::protectIf(name(), protect());
|
||||
}
|
||||
string AstNode::nameProtect() const { return VIdProtect::protectIf(name(), protect()); }
|
||||
string AstNode::origNameProtect() const { return VIdProtect::protectIf(origName(), protect()); }
|
||||
|
||||
string AstNode::shortName() const {
|
||||
|
|
@ -285,7 +283,7 @@ string AstNode::vpiName(const string& namein) {
|
|||
return pretty;
|
||||
}
|
||||
|
||||
string AstNode::prettyTypeName() const VL_MT_STABLE {
|
||||
string AstNode::prettyTypeName() const {
|
||||
if (name() == "") return typeName();
|
||||
return std::string{typeName()} + " '" + prettyName() + "'";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1686,7 +1686,7 @@ public:
|
|||
static constexpr int INSTR_COUNT_PLI = 20; // PLI routines
|
||||
|
||||
// ACCESSORS
|
||||
virtual string name() const VL_MT_STABLE { return ""; }
|
||||
virtual string name() const { return ""; }
|
||||
virtual string origName() const { return ""; }
|
||||
virtual void name(const string& name) {
|
||||
this->v3fatalSrc("name() called on object without name() method");
|
||||
|
|
@ -1694,7 +1694,7 @@ public:
|
|||
virtual void tag(const string& text) {}
|
||||
virtual string tag() const { return ""; }
|
||||
virtual string verilogKwd() const { return ""; }
|
||||
string nameProtect() const VL_MT_STABLE; // Name with --protect-id applied
|
||||
string nameProtect() const; // Name with --protect-id applied
|
||||
string origNameProtect() const; // origName with --protect-id applied
|
||||
string shortName() const; // Name with __PVT__ removed for concatenating scopes
|
||||
static string dedotName(const string& namein); // Name with dots removed
|
||||
|
|
@ -1707,10 +1707,10 @@ public:
|
|||
static string encodeName(const string& namein);
|
||||
static string encodeNumber(int64_t num); // Encode number into internal C representation
|
||||
static string vcdName(const string& namein); // Name for printing out to vcd files
|
||||
string prettyName() const VL_MT_STABLE { return prettyName(name()); }
|
||||
string prettyName() const { return prettyName(name()); }
|
||||
string prettyNameQ() const { return prettyNameQ(name()); }
|
||||
// "VARREF" for error messages (NOT dtype's pretty name)
|
||||
string prettyTypeName() const VL_MT_STABLE;
|
||||
string prettyTypeName() const;
|
||||
virtual string prettyOperatorName() const { return "operator " + prettyTypeName(); }
|
||||
FileLine* fileline() const VL_MT_SAFE { return m_fileline; }
|
||||
void fileline(FileLine* fl) { m_fileline = fl; }
|
||||
|
|
|
|||
|
|
@ -154,12 +154,15 @@ AstCExpr::AstCExpr(FileLine* fl, const string& textStmt, int setwidth, bool clea
|
|||
}
|
||||
|
||||
AstVarRef::AstVarRef(FileLine* fl, AstVar* varp, const VAccess& access)
|
||||
: ASTGEN_SUPER_VarRef(fl, varp->name(), varp, access) {}
|
||||
: ASTGEN_SUPER_VarRef(fl, varp, access) {}
|
||||
// This form only allowed post-link (see above)
|
||||
AstVarRef::AstVarRef(FileLine* fl, AstVarScope* varscp, const VAccess& access)
|
||||
: ASTGEN_SUPER_VarRef(fl, varscp->varp()->name(), varscp->varp(), access) {
|
||||
: ASTGEN_SUPER_VarRef(fl, varscp->varp(), access) {
|
||||
varScopep(varscp);
|
||||
}
|
||||
|
||||
string AstVarRef::name() const { return varp() ? varp()->name() : "<null>"; }
|
||||
|
||||
bool AstVarRef::same(const AstVarRef* samep) const {
|
||||
if (varScopep()) {
|
||||
return (varScopep() == samep->varScopep() && access() == samep->access());
|
||||
|
|
@ -179,7 +182,8 @@ bool AstVarRef::sameNoLvalue(AstVarRef* samep) const {
|
|||
}
|
||||
|
||||
AstVarXRef::AstVarXRef(FileLine* fl, AstVar* varp, const string& dotted, const VAccess& access)
|
||||
: ASTGEN_SUPER_VarXRef(fl, varp->name(), varp, access)
|
||||
: ASTGEN_SUPER_VarXRef(fl, varp, access)
|
||||
, m_name{varp->name()}
|
||||
, m_dotted{dotted} {
|
||||
dtypeFrom(varp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,13 +126,13 @@ public:
|
|||
const char* charIQWN() const {
|
||||
return (isString() ? "N" : isWide() ? "W" : isQuad() ? "Q" : "I");
|
||||
}
|
||||
string cType(const string& name, bool forFunc, bool isRef) const VL_MT_STABLE;
|
||||
string cType(const string& name, bool forFunc, bool isRef) const;
|
||||
// Represents a C++ LiteralType? (can be constexpr)
|
||||
bool isLiteralType() const VL_MT_STABLE;
|
||||
|
||||
private:
|
||||
class CTypeRecursed;
|
||||
CTypeRecursed cTypeRecurse(bool compound) const VL_MT_STABLE;
|
||||
CTypeRecursed cTypeRecurse(bool compound) const;
|
||||
};
|
||||
class AstNodeArrayDType VL_NOT_FINAL : public AstNodeDType {
|
||||
// Array data type, ie "some_dtype var_name [2:0]"
|
||||
|
|
|
|||
|
|
@ -450,20 +450,17 @@ class AstNodeVarRef VL_NOT_FINAL : public AstNodeExpr {
|
|||
AstVar* m_varp; // [AfterLink] Pointer to variable itself
|
||||
AstVarScope* m_varScopep = nullptr; // Varscope for hierarchy
|
||||
AstNodeModule* m_classOrPackagep = nullptr; // Package hierarchy
|
||||
string m_name; // Name of variable
|
||||
string m_selfPointer; // Output code object pointer (e.g.: 'this')
|
||||
|
||||
protected:
|
||||
AstNodeVarRef(VNType t, FileLine* fl, const string& name, const VAccess& access)
|
||||
AstNodeVarRef(VNType t, FileLine* fl, const VAccess& access)
|
||||
: AstNodeExpr{t, fl}
|
||||
, m_access{access}
|
||||
, m_name{name} {
|
||||
, m_access{access} {
|
||||
varp(nullptr);
|
||||
}
|
||||
AstNodeVarRef(VNType t, FileLine* fl, const string& name, AstVar* varp, const VAccess& access)
|
||||
AstNodeVarRef(VNType t, FileLine* fl, AstVar* varp, const VAccess& access)
|
||||
: AstNodeExpr{t, fl}
|
||||
, m_access{access}
|
||||
, m_name{name} {
|
||||
, m_access{access} {
|
||||
// May have varp==nullptr
|
||||
this->varp(varp);
|
||||
}
|
||||
|
|
@ -474,8 +471,6 @@ public:
|
|||
const char* broken() const override;
|
||||
int instrCount() const override { return widthInstrs(); }
|
||||
void cloneRelink() override;
|
||||
string name() const override VL_MT_STABLE { return m_name; } // * = Var name
|
||||
void name(const string& name) override { m_name = name; }
|
||||
VAccess access() const { return m_access; }
|
||||
void access(const VAccess& flag) { m_access = flag; } // Avoid using this; Set in constructor
|
||||
AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable
|
||||
|
|
@ -5355,15 +5350,15 @@ public:
|
|||
class AstVarRef final : public AstNodeVarRef {
|
||||
// A reference to a variable (lvalue or rvalue)
|
||||
public:
|
||||
AstVarRef(FileLine* fl, const string& name, const VAccess& access)
|
||||
: ASTGEN_SUPER_VarRef(fl, name, nullptr, access) {}
|
||||
// This form only allowed post-link because output/wire compression may
|
||||
// lead to deletion of AstVar's
|
||||
inline AstVarRef(FileLine* fl, AstVar* varp, const VAccess& access);
|
||||
// This form only allowed post-link (see above)
|
||||
inline AstVarRef(FileLine* fl, AstVarScope* varscp, const VAccess& access);
|
||||
ASTGEN_MEMBERS_AstVarRef;
|
||||
inline string name() const override; // * = Var name
|
||||
void dump(std::ostream& str) const override;
|
||||
const char* broken() const override;
|
||||
bool same(const AstNode* samep) const override;
|
||||
inline bool same(const AstVarRef* samep) const;
|
||||
inline bool sameNoLvalue(AstVarRef* samep) const;
|
||||
|
|
@ -5375,14 +5370,17 @@ public:
|
|||
class AstVarXRef final : public AstNodeVarRef {
|
||||
// A VarRef to something in another module before AstScope.
|
||||
// Includes pin on a cell, as part of a ASSIGN statement to connect I/Os until AstScope
|
||||
string m_name;
|
||||
string m_dotted; // Dotted part of scope the name()'ed reference is under or ""
|
||||
string m_inlinedDots; // Dotted hierarchy flattened out
|
||||
public:
|
||||
AstVarXRef(FileLine* fl, const string& name, const string& dotted, const VAccess& access)
|
||||
: ASTGEN_SUPER_VarXRef(fl, name, nullptr, access)
|
||||
: ASTGEN_SUPER_VarXRef(fl, nullptr, access)
|
||||
, m_name{name}
|
||||
, m_dotted{dotted} {}
|
||||
inline AstVarXRef(FileLine* fl, AstVar* varp, const string& dotted, const VAccess& access);
|
||||
ASTGEN_MEMBERS_AstVarXRef;
|
||||
string name() const override VL_MT_STABLE { return m_name; } // * = Var name
|
||||
void dump(std::ostream& str) const override;
|
||||
string dotted() const { return m_dotted; }
|
||||
void dotted(const string& dotted) { m_dotted = dotted; }
|
||||
|
|
|
|||
|
|
@ -1812,7 +1812,7 @@ public:
|
|||
string dpiTmpVarType(const string& varName) const;
|
||||
// Return Verilator internal type for argument: CData, SData, IData, WData
|
||||
string vlArgType(bool named, bool forReturn, bool forFunc, const string& namespc = "",
|
||||
bool asRef = false) const VL_MT_STABLE;
|
||||
bool asRef = false) const;
|
||||
string vlEnumType() const; // Return VerilatorVarType: VLVT_UINT32, etc
|
||||
string vlEnumDir() const; // Return VerilatorVarDir: VLVD_INOUT, etc
|
||||
string vlPropDecl(const string& propName) const; // Return VerilatorVarProps declaration
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ string AstVar::verilogKwd() const {
|
|||
}
|
||||
|
||||
string AstVar::vlArgType(bool named, bool forReturn, bool forFunc, const string& namespc,
|
||||
bool asRef) const VL_MT_STABLE {
|
||||
bool asRef) const {
|
||||
UASSERT_OBJ(!forReturn, this,
|
||||
"Internal data is never passed as return, but as first argument");
|
||||
string ostatic;
|
||||
|
|
@ -695,12 +695,12 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
string AstNodeDType::cType(const string& name, bool /*forFunc*/, bool isRef) const VL_MT_STABLE {
|
||||
string AstNodeDType::cType(const string& name, bool /*forFunc*/, bool isRef) const {
|
||||
const CTypeRecursed info = cTypeRecurse(false);
|
||||
return info.render(name, isRef);
|
||||
}
|
||||
|
||||
AstNodeDType::CTypeRecursed AstNodeDType::cTypeRecurse(bool compound) const VL_MT_STABLE {
|
||||
AstNodeDType::CTypeRecursed AstNodeDType::cTypeRecurse(bool compound) const {
|
||||
// Legacy compound argument currently just passed through and unused
|
||||
CTypeRecursed info;
|
||||
|
||||
|
|
@ -2076,6 +2076,10 @@ void AstVarRef::dump(std::ostream& str) const {
|
|||
str << "UNLINKED";
|
||||
}
|
||||
}
|
||||
const char* AstVarRef::broken() const {
|
||||
BROKEN_RTN(!varp());
|
||||
return AstNodeVarRef::broken();
|
||||
}
|
||||
bool AstVarRef::same(const AstNode* samep) const {
|
||||
return same(static_cast<const AstVarRef*>(samep));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,39 +40,6 @@ VL_DEFINE_DEBUG_FUNCTIONS;
|
|||
|
||||
//######################################################################
|
||||
|
||||
class RenameStaticVisitor final : public VNVisitor {
|
||||
private:
|
||||
// STATE
|
||||
const std::set<AstVar*>& m_staticFuncVarsr; // Static variables from m_ftaskp
|
||||
AstNodeFTask* const m_ftaskp; // Current function/task
|
||||
|
||||
// VISITORS
|
||||
void visit(AstVarRef* nodep) override {
|
||||
const auto it = m_staticFuncVarsr.find(nodep->varp());
|
||||
if (it != m_staticFuncVarsr.end()) nodep->name((*it)->name());
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
|
||||
void visit(AstInitialStatic* nodep) override {
|
||||
iterateChildren(nodep);
|
||||
nodep->unlinkFrBack();
|
||||
m_ftaskp->addHereThisAsNext(nodep);
|
||||
}
|
||||
|
||||
void visit(AstNode* nodep) override { iterateChildren(nodep); }
|
||||
|
||||
public:
|
||||
// CONSTRUCTORS
|
||||
RenameStaticVisitor(std::set<AstVar*>& staticFuncVars, AstNodeFTask* ftaskp, AstNode* nodep)
|
||||
: m_staticFuncVarsr(staticFuncVars)
|
||||
, m_ftaskp(ftaskp) {
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
~RenameStaticVisitor() override = default;
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
||||
class BeginState final {
|
||||
private:
|
||||
// NODE STATE
|
||||
|
|
@ -105,7 +72,6 @@ private:
|
|||
string m_unnamedScope; // Name of begin blocks, including unnamed blocks
|
||||
int m_ifDepth = 0; // Current if depth
|
||||
bool m_keepBegins = false; // True if begins should not be inlined
|
||||
std::set<AstVar*> m_staticFuncVars; // Static variables from m_ftaskp
|
||||
|
||||
// METHODS
|
||||
|
||||
|
|
@ -212,7 +178,10 @@ private:
|
|||
m_ftaskp = nodep;
|
||||
m_liftedp = nullptr;
|
||||
iterateChildren(nodep);
|
||||
RenameStaticVisitor{m_staticFuncVars, m_ftaskp, nodep};
|
||||
nodep->foreach([&](AstInitialStatic* const initp) {
|
||||
initp->unlinkFrBack();
|
||||
m_ftaskp->addHereThisAsNext(initp);
|
||||
});
|
||||
if (m_liftedp) {
|
||||
// Place lifted nodes at beginning of stmtsp, so Var nodes appear before referenced
|
||||
if (AstNode* const stmtsp = nodep->stmtsp()) {
|
||||
|
|
@ -222,7 +191,6 @@ private:
|
|||
nodep->addStmtsp(m_liftedp);
|
||||
m_liftedp = nullptr;
|
||||
}
|
||||
m_staticFuncVars.clear();
|
||||
m_ftaskp = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -266,7 +234,6 @@ private:
|
|||
nodep->name(newName);
|
||||
nodep->unlinkFrBack();
|
||||
m_ftaskp->addHereThisAsNext(nodep);
|
||||
m_staticFuncVars.insert(nodep);
|
||||
nodep->funcLocal(false);
|
||||
} else if (m_unnamedScope != "") {
|
||||
// Rename it
|
||||
|
|
@ -377,7 +344,6 @@ private:
|
|||
void visit(AstVarRef* nodep) override {
|
||||
if (nodep->varp()->user1()) { // It was converted
|
||||
UINFO(9, " relinVarRef " << nodep << endl);
|
||||
nodep->name(nodep->varp()->name());
|
||||
}
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public:
|
|||
static string symClassAssign() {
|
||||
return symClassName() + "* const __restrict vlSymsp VL_ATTR_UNUSED = vlSelf->vlSymsp;\n";
|
||||
}
|
||||
static string prefixNameProtect(const AstNode* nodep) VL_MT_STABLE { // C++ name with prefix
|
||||
static string prefixNameProtect(const AstNode* nodep) { // C++ name with prefix
|
||||
return v3Global.opt.modPrefix() + "_" + VIdProtect::protect(nodep->name());
|
||||
}
|
||||
static bool isAnonOk(const AstVar* varp) {
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class EmitCGatherDependencies final : VNVisitorConst {
|
|||
}
|
||||
|
||||
public:
|
||||
static const std::set<std::string> gather(AstCFunc* cfuncp) VL_MT_STABLE {
|
||||
static const std::set<std::string> gather(AstCFunc* cfuncp) {
|
||||
const EmitCGatherDependencies visitor{cfuncp};
|
||||
return std::move(visitor.m_dependencies);
|
||||
}
|
||||
|
|
@ -566,8 +566,7 @@ class EmitCImp final : EmitCFunc {
|
|||
~EmitCImp() override = default;
|
||||
|
||||
public:
|
||||
static void main(const AstNodeModule* modp, bool slow,
|
||||
std::deque<AstCFile*>& cfilesr) VL_MT_STABLE {
|
||||
static void main(const AstNodeModule* modp, bool slow, std::deque<AstCFile*>& cfilesr) {
|
||||
EmitCImp{modp, slow, cfilesr};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -176,9 +176,7 @@ public:
|
|||
, m_slow{slow} {}
|
||||
~GateLogicVertex() override = default;
|
||||
// ACCESSORS
|
||||
string name() const override VL_MT_STABLE {
|
||||
return (cvtToHex(m_nodep) + "@" + scopep()->prettyName());
|
||||
}
|
||||
string name() const override { return (cvtToHex(m_nodep) + "@" + scopep()->prettyName()); }
|
||||
string dotColor() const override { return "purple"; }
|
||||
FileLine* fileline() const override { return nodep()->fileline(); }
|
||||
AstNode* nodep() const { return m_nodep; }
|
||||
|
|
|
|||
|
|
@ -384,7 +384,6 @@ private:
|
|||
nodep->v3fatalSrc("Null connection?");
|
||||
}
|
||||
}
|
||||
nodep->name(nodep->varp()->name());
|
||||
}
|
||||
void visit(AstVarXRef* nodep) override {
|
||||
// Track what scope it was originally under so V3LinkDot can resolve it
|
||||
|
|
|
|||
|
|
@ -2065,40 +2065,38 @@ private:
|
|||
} m_ds; // State to preserve across recursions
|
||||
|
||||
// METHODS - Variables
|
||||
void createImplicitVar(VSymEnt* /*lookupSymp*/, AstVarRef* nodep, AstNodeModule* modp,
|
||||
VSymEnt* moduleSymp, bool noWarn) {
|
||||
AstVar* createImplicitVar(VSymEnt* /*lookupSymp*/, AstParseRef* nodep, AstNodeModule* modp,
|
||||
VSymEnt* moduleSymp, bool noWarn) {
|
||||
// Create implicit after warning
|
||||
if (!nodep->varp()) {
|
||||
if (!noWarn) {
|
||||
if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) {
|
||||
const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar{});
|
||||
nodep->v3error("Signal definition not found, and implicit disabled with "
|
||||
"`default_nettype: "
|
||||
<< nodep->prettyNameQ() << '\n'
|
||||
<< (suggest.empty() ? "" : nodep->warnMore() + suggest));
|
||||
if (!noWarn) {
|
||||
if (nodep->fileline()->warnIsOff(V3ErrorCode::I_DEF_NETTYPE_WIRE)) {
|
||||
const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar{});
|
||||
nodep->v3error("Signal definition not found, and implicit disabled with "
|
||||
"`default_nettype: "
|
||||
<< nodep->prettyNameQ() << '\n'
|
||||
<< (suggest.empty() ? "" : nodep->warnMore() + suggest));
|
||||
|
||||
}
|
||||
// Bypass looking for suggestions if IMPLICIT is turned off
|
||||
// as there could be thousands of these suppressed in large netlists
|
||||
else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) {
|
||||
const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar{});
|
||||
nodep->v3warn(IMPLICIT,
|
||||
"Signal definition not found, creating implicitly: "
|
||||
<< nodep->prettyNameQ() << '\n'
|
||||
<< (suggest.empty() ? "" : nodep->warnMore() + suggest));
|
||||
}
|
||||
}
|
||||
AstVar* const newp = new AstVar{nodep->fileline(), VVarType::WIRE, nodep->name(),
|
||||
VFlagLogicPacked{}, 1};
|
||||
newp->trace(modp->modTrace());
|
||||
nodep->varp(newp);
|
||||
modp->addStmtsp(newp);
|
||||
// Link it to signal list, must add the variable under the module;
|
||||
// current scope might be lower now
|
||||
m_statep->insertSym(moduleSymp, newp->name(), newp, nullptr /*classOrPackagep*/);
|
||||
// Bypass looking for suggestions if IMPLICIT is turned off
|
||||
// as there could be thousands of these suppressed in large netlists
|
||||
else if (!nodep->fileline()->warnIsOff(V3ErrorCode::IMPLICIT)) {
|
||||
const string suggest = m_statep->suggestSymFallback(moduleSymp, nodep->name(),
|
||||
LinkNodeMatcherVar{});
|
||||
nodep->v3warn(IMPLICIT,
|
||||
"Signal definition not found, creating implicitly: "
|
||||
<< nodep->prettyNameQ() << '\n'
|
||||
<< (suggest.empty() ? "" : nodep->warnMore() + suggest));
|
||||
}
|
||||
}
|
||||
AstVar* const newp
|
||||
= new AstVar{nodep->fileline(), VVarType::WIRE, nodep->name(), VFlagLogicPacked{}, 1};
|
||||
newp->trace(modp->modTrace());
|
||||
modp->addStmtsp(newp);
|
||||
// Link it to signal list, must add the variable under the module;
|
||||
// current scope might be lower now
|
||||
m_statep->insertSym(moduleSymp, newp->name(), newp, nullptr /*classOrPackagep*/);
|
||||
return newp;
|
||||
}
|
||||
AstVar* foundToVarp(const VSymEnt* symp, AstNode* nodep, VAccess access) {
|
||||
// Return a variable if possible, auto converting a modport to variable
|
||||
|
|
@ -2844,11 +2842,11 @@ private:
|
|||
if (checkImplicit) {
|
||||
// Create if implicit, and also if error (so only complain once)
|
||||
// Else if a scope is allowed, making a signal won't help error cascade
|
||||
auto varp = createImplicitVar(m_curSymp, nodep, m_modp, m_modSymp, err);
|
||||
AstVarRef* const newp
|
||||
= new AstVarRef{nodep->fileline(), nodep->name(), VAccess::READ};
|
||||
= new AstVarRef{nodep->fileline(), varp, VAccess::READ};
|
||||
nodep->replaceWith(newp);
|
||||
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
||||
createImplicitVar(m_curSymp, newp, m_modp, m_modSymp, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -370,9 +370,11 @@ private:
|
|||
// Making an AstAssign (vs AstAssignW) to a wire is an error, suppress it
|
||||
FileLine* const newfl = new FileLine{fl};
|
||||
newfl->warnOff(V3ErrorCode::PROCASSWIRE, true);
|
||||
auto* const assp
|
||||
= new AstAssign{newfl, new AstVarRef{newfl, nodep->name(), VAccess::WRITE},
|
||||
VN_AS(nodep->valuep()->unlinkFrBack(), NodeExpr)};
|
||||
// Create a ParseRef to the wire. We cannot use the var as it may be deleted if
|
||||
// it's a port (see t_var_set_link.v)
|
||||
auto* const assp = new AstAssign{
|
||||
newfl, new AstParseRef{newfl, VParseRefExp::PX_TEXT, nodep->name()},
|
||||
VN_AS(nodep->valuep()->unlinkFrBack(), NodeExpr)};
|
||||
if (nodep->lifetime().isAutomatic()) {
|
||||
nodep->addNextHere(new AstInitialAutomatic{newfl, assp});
|
||||
} else {
|
||||
|
|
@ -381,7 +383,7 @@ private:
|
|||
} // 4. Under blocks, it's an initial value to be under an assign
|
||||
else {
|
||||
nodep->addNextHere(
|
||||
new AstAssign{fl, new AstVarRef{fl, nodep->name(), VAccess::WRITE},
|
||||
new AstAssign{fl, new AstVarRef{fl, nodep, VAccess::WRITE},
|
||||
VN_AS(nodep->valuep()->unlinkFrBack(), NodeExpr)});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,12 +89,7 @@ private:
|
|||
rename(nodep, false);
|
||||
}
|
||||
}
|
||||
void visit(AstVarRef* nodep) override {
|
||||
if (nodep->varp()) {
|
||||
iterate(nodep->varp());
|
||||
nodep->name(nodep->varp()->name());
|
||||
}
|
||||
}
|
||||
void visit(AstVarRef* nodep) override { iterate(nodep->varp()); }
|
||||
void visit(AstCell* nodep) override {
|
||||
if (!nodep->user1()) {
|
||||
rename(nodep, (!nodep->modp()->modPublic() && !VN_IS(nodep->modp(), ClassPackage)));
|
||||
|
|
|
|||
|
|
@ -85,9 +85,10 @@ AstArg* V3ParseGrammar::argWrapList(AstNodeExpr* nodep) {
|
|||
}
|
||||
|
||||
AstNode* V3ParseGrammar::createSupplyExpr(FileLine* fileline, const string& name, int value) {
|
||||
AstAssignW* assignp = new AstAssignW{fileline, new AstVarRef{fileline, name, VAccess::WRITE},
|
||||
value ? new AstConst{fileline, AstConst::All1{}}
|
||||
: new AstConst{fileline, AstConst::All0{}}};
|
||||
AstAssignW* assignp
|
||||
= new AstAssignW{fileline, new AstParseRef{fileline, VParseRefExp::PX_TEXT, name},
|
||||
value ? new AstConst{fileline, AstConst::All1{}}
|
||||
: new AstConst{fileline, AstConst::All0{}}};
|
||||
AstStrengthSpec* strengthSpecp
|
||||
= new AstStrengthSpec{fileline, VStrength::SUPPLY, VStrength::SUPPLY};
|
||||
assignp->strengthSpecp(strengthSpecp);
|
||||
|
|
|
|||
|
|
@ -109,9 +109,7 @@ protected:
|
|||
// ACCESSORS
|
||||
// Do not make accessor for nodep(), It may change due to
|
||||
// reordering a lower block, but we don't repair it
|
||||
string name() const override VL_MT_STABLE {
|
||||
return cvtToHex(m_nodep) + ' ' + m_nodep->prettyTypeName();
|
||||
}
|
||||
string name() const override { return cvtToHex(m_nodep) + ' ' + m_nodep->prettyTypeName(); }
|
||||
FileLine* fileline() const override { return nodep()->fileline(); }
|
||||
|
||||
public:
|
||||
|
|
@ -148,7 +146,7 @@ public:
|
|||
SplitVarPostVertex(V3Graph* graphp, AstNode* nodep)
|
||||
: SplitNodeVertex{graphp, nodep} {}
|
||||
~SplitVarPostVertex() override = default;
|
||||
string name() const override VL_MT_STABLE { return string{"POST "} + SplitNodeVertex::name(); }
|
||||
string name() const override { return string{"POST "} + SplitNodeVertex::name(); }
|
||||
string dotColor() const override { return "CadetBlue"; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -412,7 +412,6 @@ private:
|
|||
AstVarScope* const newvscp = VN_AS(refp->varp()->user2p(), VarScope);
|
||||
refp->varScopep(newvscp);
|
||||
refp->varp(refp->varScopep()->varp());
|
||||
refp->name(refp->varp()->name());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ private:
|
|||
AstNode* const m_nodep; // AST node represented by this graph vertex
|
||||
|
||||
// ACCESSORS
|
||||
string name() const override VL_MT_STABLE {
|
||||
string name() const override {
|
||||
if (m_classp) {
|
||||
if (VN_IS(nodep(), CFunc)) {
|
||||
return cvtToHex(nodep()) + ' ' + classp()->name() + "::" + nodep()->name();
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public:
|
|||
// ACCESSORS
|
||||
AstNode* nodep() const VL_MT_STABLE { return m_nodep; }
|
||||
const AstVar* varp() const { return VN_CAST(nodep(), Var); }
|
||||
string name() const override VL_MT_STABLE {
|
||||
string name() const override {
|
||||
return ((isTristate() ? "tri\\n"
|
||||
: feedsTri() ? "feed\\n"
|
||||
: "-\\n")
|
||||
|
|
@ -672,8 +672,7 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
VFlagBitPacked{}, w}; // 2-state ok; sep enable
|
||||
UINFO(9, " newout " << newLhsp << endl);
|
||||
nodep->addStmtsp(newLhsp);
|
||||
refp->varp(newLhsp); // assign the new var to the varref
|
||||
refp->name(newLhsp->name());
|
||||
refp->varp(newLhsp);
|
||||
|
||||
// create a new var for this drivers enable signal
|
||||
AstVar* const newEnLhsp = new AstVar{varp->fileline(), VVarType::MODULETEMP,
|
||||
|
|
|
|||
|
|
@ -2251,7 +2251,7 @@ tf_variable_identifier<varp>: // IEEE: part of list_of_tf_variable_ide
|
|||
id variable_dimensionListE sigAttrListE exprEqE
|
||||
{ $$ = VARDONEA($<fl>1, *$1, $2, $3);
|
||||
if ($4) AstNode::addNext<AstNode, AstNode>(
|
||||
$$, new AstAssign{$4->fileline(), new AstVarRef{$<fl>1, *$1, VAccess::WRITE}, $4}); }
|
||||
$$, new AstAssign{$4->fileline(), new AstParseRef{$<fl>1, VParseRefExp::PX_TEXT, *$1}, $4}); }
|
||||
;
|
||||
|
||||
variable_declExpr<nodep>: // IEEE: part of variable_decl_assignment - rhs of expr
|
||||
|
|
@ -2995,7 +2995,7 @@ netSig<varp>: // IEEE: net_decl_assignment - one element from
|
|||
{ $$ = VARDONEA($<fl>1, *$1, nullptr, $2); }
|
||||
| netId sigAttrListE '=' expr
|
||||
{ $$ = VARDONEA($<fl>1, *$1, nullptr, $2);
|
||||
auto* const assignp = new AstAssignW{$3, new AstVarRef{$<fl>1, *$1, VAccess::WRITE}, $4};
|
||||
auto* const assignp = new AstAssignW{$3, new AstParseRef{$<fl>1, VParseRefExp::PX_TEXT, *$1}, $4};
|
||||
if (GRAMMARP->m_netStrengthp) assignp->strengthSpecp(GRAMMARP->m_netStrengthp->cloneTree(false));
|
||||
AstNode::addNext<AstNode, AstNode>($$, assignp); }
|
||||
| netId variable_dimensionList sigAttrListE
|
||||
|
|
@ -3912,14 +3912,14 @@ for_initializationItem<nodep>: // IEEE: variable_assignment + for_varia
|
|||
AstVar* const varp = VARDONEA($<fl>2, *$2, nullptr, nullptr);
|
||||
varp->lifetime(VLifetime::AUTOMATIC);
|
||||
$$ = varp;
|
||||
$$->addNext(new AstAssign{$3, new AstVarRef{$<fl>2, *$2, VAccess::WRITE}, $4}); }
|
||||
$$->addNext(new AstAssign{$3, new AstParseRef{$<fl>2, VParseRefExp::PX_TEXT, *$2}, $4}); }
|
||||
// // IEEE-2012:
|
||||
| yVAR data_type idAny/*new*/ '=' expr
|
||||
{ VARRESET_NONLIST(VAR); VARDTYPE($2);
|
||||
AstVar* const varp = VARDONEA($<fl>3, *$3, nullptr, nullptr);
|
||||
varp->lifetime(VLifetime::AUTOMATIC);
|
||||
$$ = varp;
|
||||
$$->addNext(new AstAssign{$4, new AstVarRef{$<fl>3, *$3, VAccess::WRITE}, $5}); }
|
||||
$$->addNext(new AstAssign{$4, new AstParseRef{$<fl>3, VParseRefExp::PX_TEXT, *$3}, $5}); }
|
||||
// // IEEE: variable_assignment
|
||||
// // UNSUP variable_lvalue below
|
||||
| varRefBase '=' expr { $$ = new AstAssign{$2, $1, $3}; }
|
||||
|
|
@ -5614,8 +5614,8 @@ idArrayedForeach<nodeExprp>: // IEEE: id + select (under foreach expression)
|
|||
;
|
||||
|
||||
// VarRef without any dots or vectorizaion
|
||||
varRefBase<varRefp>:
|
||||
id { $$ = new AstVarRef{$<fl>1, *$1, VAccess::READ}; }
|
||||
varRefBase<parseRefp>:
|
||||
id { $$ = new AstParseRef{$<fl>1, VParseRefExp::PX_TEXT, *$1}; }
|
||||
;
|
||||
|
||||
// ParseRef
|
||||
|
|
|
|||
|
|
@ -53,27 +53,27 @@
|
|||
<varscope loc="d,50,22,50,23" name="t.cell2.q" dtype_id="1"/>
|
||||
<assignalias loc="d,15,22,15,23" dtype_id="1">
|
||||
<varref loc="d,15,22,15,23" name="q" dtype_id="1"/>
|
||||
<varref loc="d,15,22,15,23" name="q" dtype_id="1"/>
|
||||
<varref loc="d,15,22,15,23" name="t.q" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,13,10,13,13" dtype_id="2">
|
||||
<varref loc="d,13,10,13,13" name="clk" dtype_id="2"/>
|
||||
<varref loc="d,13,10,13,13" name="clk" dtype_id="2"/>
|
||||
<varref loc="d,13,10,13,13" name="t.clk" dtype_id="2"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,14,16,14,17" dtype_id="1">
|
||||
<varref loc="d,14,16,14,17" name="d" dtype_id="1"/>
|
||||
<varref loc="d,14,16,14,17" name="d" dtype_id="1"/>
|
||||
<varref loc="d,14,16,14,17" name="t.d" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,34,24,34,27" dtype_id="2">
|
||||
<varref loc="d,34,24,34,27" name="t.clk" dtype_id="2"/>
|
||||
<varref loc="d,34,24,34,27" name="cell1.clk" dtype_id="2"/>
|
||||
<varref loc="d,34,24,34,27" name="t.cell1.clk" dtype_id="2"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,35,30,35,31" dtype_id="1">
|
||||
<varref loc="d,35,30,35,31" name="t.d" dtype_id="1"/>
|
||||
<varref loc="d,35,30,35,31" name="cell1.d" dtype_id="1"/>
|
||||
<varref loc="d,35,30,35,31" name="t.cell1.d" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,36,30,36,31" dtype_id="1">
|
||||
<varref loc="d,36,30,36,31" name="t.between" dtype_id="1"/>
|
||||
<varref loc="d,36,30,36,31" name="cell1.q" dtype_id="1"/>
|
||||
<varref loc="d,36,30,36,31" name="t.cell1.q" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<always loc="d,41,4,41,10">
|
||||
<sentree loc="d,41,11,41,12">
|
||||
|
|
@ -88,15 +88,15 @@
|
|||
</always>
|
||||
<assignalias loc="d,48,10,48,13" dtype_id="2">
|
||||
<varref loc="d,48,10,48,13" name="t.clk" dtype_id="2"/>
|
||||
<varref loc="d,48,10,48,13" name="cell2.clk" dtype_id="2"/>
|
||||
<varref loc="d,48,10,48,13" name="t.cell2.clk" dtype_id="2"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,49,16,49,17" dtype_id="1">
|
||||
<varref loc="d,49,16,49,17" name="t.between" dtype_id="1"/>
|
||||
<varref loc="d,49,16,49,17" name="cell2.d" dtype_id="1"/>
|
||||
<varref loc="d,49,16,49,17" name="t.cell2.d" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,50,22,50,23" dtype_id="1">
|
||||
<varref loc="d,50,22,50,23" name="t.q" dtype_id="1"/>
|
||||
<varref loc="d,50,22,50,23" name="cell2.q" dtype_id="1"/>
|
||||
<varref loc="d,50,22,50,23" name="t.cell2.q" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<contassign loc="d,53,13,53,14" dtype_id="1">
|
||||
<varref loc="d,17,22,17,29" name="t.between" dtype_id="1"/>
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@
|
|||
<varscope loc="d,7,24,7,29" name="top.f.i_clk" dtype_id="1"/>
|
||||
<assignalias loc="d,11,24,11,29" dtype_id="1">
|
||||
<varref loc="d,11,24,11,29" name="i_clk" dtype_id="1"/>
|
||||
<varref loc="d,11,24,11,29" name="i_clk" dtype_id="1"/>
|
||||
<varref loc="d,11,24,11,29" name="top.i_clk" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,7,24,7,29" dtype_id="1">
|
||||
<varref loc="d,7,24,7,29" name="top.i_clk" dtype_id="1"/>
|
||||
<varref loc="d,7,24,7,29" name="f.i_clk" dtype_id="1"/>
|
||||
<varref loc="d,7,24,7,29" name="top.f.i_clk" dtype_id="1"/>
|
||||
</assignalias>
|
||||
</scope>
|
||||
</topscope>
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@
|
|||
<varscope loc="d,7,24,7,29" name="top.f.i_clk" dtype_id="1"/>
|
||||
<assignalias loc="d,11,24,11,29" dtype_id="1">
|
||||
<varref loc="d,11,24,11,29" name="i_clk" dtype_id="1"/>
|
||||
<varref loc="d,11,24,11,29" name="i_clk" dtype_id="1"/>
|
||||
<varref loc="d,11,24,11,29" name="top.i_clk" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,7,24,7,29" dtype_id="1">
|
||||
<varref loc="d,7,24,7,29" name="top.i_clk" dtype_id="1"/>
|
||||
<varref loc="d,7,24,7,29" name="f.i_clk" dtype_id="1"/>
|
||||
<varref loc="d,7,24,7,29" name="top.f.i_clk" dtype_id="1"/>
|
||||
</assignalias>
|
||||
</scope>
|
||||
</topscope>
|
||||
|
|
|
|||
|
|
@ -43,19 +43,19 @@
|
|||
<varscope loc="d,17,13,17,14" name="__Vfunc_vlvbound_test.foo__1__i" dtype_id="3"/>
|
||||
<assignalias loc="d,9,25,9,28" dtype_id="1">
|
||||
<varref loc="d,9,25,9,28" name="i_a" dtype_id="1"/>
|
||||
<varref loc="d,9,25,9,28" name="i_a" dtype_id="1"/>
|
||||
<varref loc="d,9,25,9,28" name="vlvbound_test.i_a" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,10,25,10,28" dtype_id="1">
|
||||
<varref loc="d,10,25,10,28" name="i_b" dtype_id="1"/>
|
||||
<varref loc="d,10,25,10,28" name="i_b" dtype_id="1"/>
|
||||
<varref loc="d,10,25,10,28" name="vlvbound_test.i_b" dtype_id="1"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,11,25,11,28" dtype_id="2">
|
||||
<varref loc="d,11,25,11,28" name="o_a" dtype_id="2"/>
|
||||
<varref loc="d,11,25,11,28" name="o_a" dtype_id="2"/>
|
||||
<varref loc="d,11,25,11,28" name="vlvbound_test.o_a" dtype_id="2"/>
|
||||
</assignalias>
|
||||
<assignalias loc="d,12,25,12,28" dtype_id="2">
|
||||
<varref loc="d,12,25,12,28" name="o_b" dtype_id="2"/>
|
||||
<varref loc="d,12,25,12,28" name="o_b" dtype_id="2"/>
|
||||
<varref loc="d,12,25,12,28" name="vlvbound_test.o_b" dtype_id="2"/>
|
||||
</assignalias>
|
||||
<always loc="d,24,14,24,15">
|
||||
<comment loc="d,24,16,24,19" name="Function: foo"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue