Fix names of foreach blocks (#4264)

This commit is contained in:
Ryszard Rozak 2023-06-06 16:24:42 +02:00 committed by GitHub
parent 058233fc87
commit c3e5db5f04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 14 deletions

View File

@ -158,9 +158,7 @@ private:
std::array<ScopeAliasMap, SAMN__MAX> m_scopeAliasMap; // Map of <lhs,rhs> aliases
std::vector<VSymEnt*> m_ifaceVarSyms; // List of AstIfaceRefDType's to be imported
IfaceModSyms m_ifaceModSyms; // List of AstIface+Symbols to be processed
bool m_forPrimary; // First link
bool m_forPrearray; // Compress cell__[array] refs
bool m_forScopeCreation; // Remove VarXRefs for V3Scope
const VLinkDotStep m_step; // Operational step
public:
// METHODS
@ -202,11 +200,9 @@ public:
// CONSTRUCTORS
LinkDotState(AstNetlist* rootp, VLinkDotStep step)
: m_syms{rootp} {
: m_syms{rootp}
, m_step(step) {
UINFO(4, __FUNCTION__ << ": " << endl);
m_forPrimary = (step == LDS_PRIMARY);
m_forPrearray = (step == LDS_PARAMED || step == LDS_PRIMARY);
m_forScopeCreation = (step == LDS_SCOPED);
s_errorThisp = this;
V3Error::errorExitCb(preErrorDumpHandler); // If get error, dump self
}
@ -217,9 +213,10 @@ public:
// ACCESSORS
VSymGraph* symsp() { return &m_syms; }
bool forPrimary() const { return m_forPrimary; }
bool forPrearray() const { return m_forPrearray; }
bool forScopeCreation() const { return m_forScopeCreation; }
int stepNumber() const { return int(m_step); }
bool forPrimary() const { return m_step == LDS_PRIMARY; }
bool forPrearray() const { return m_step == LDS_PARAMED || m_step == LDS_PRIMARY; }
bool forScopeCreation() const { return m_step == LDS_SCOPED; }
// METHODS
static string nodeTextType(AstNode* nodep) {
@ -590,7 +587,7 @@ public:
baddot = ident; // So user can see where they botched it
okSymp = lookupSymp;
string altIdent;
if (m_forPrearray) {
if (forPrearray()) {
// GENFOR Begin is foo__BRA__##__KET__ after we've genloop unrolled,
// but presently should be just "foo".
// Likewise cell foo__[array] before we've expanded arrays is just foo
@ -620,7 +617,7 @@ public:
else if (ident == "$root") {
lookupSymp = rootEntp();
// We've added the '$root' module, now everything else is one lower
if (!m_forPrearray) {
if (!forPrearray()) {
lookupSymp = lookupSymp->findIdFlat(ident);
UASSERT(lookupSymp, "Cannot find $root module under netlist");
}
@ -1017,9 +1014,12 @@ class LinkDotFindVisitor final : public VNVisitor {
for (AstNode* stmtp = nodep->stmtsp(); stmtp; stmtp = stmtp->nextp()) {
if (VN_IS(stmtp, Var) || VN_IS(stmtp, Foreach)) {
std::string name;
const std::string stepStr = m_statep->forPrimary()
? ""
: std::to_string(m_statep->stepNumber()) + "_";
do {
++m_modBlockNum;
name = "unnamedblk" + cvtToStr(m_modBlockNum);
name = "unnamedblk" + stepStr + cvtToStr(m_modBlockNum);
// Increment again if earlier pass of V3LinkDot claimed this name
} while (m_curSymp->findIdFlat(name));
nodep->name(name);

View File

@ -12,5 +12,8 @@ module t;
end
foreach (a[i]) begin
end
begin
int x;
end
endfunction
endmodule

View File

@ -1,2 +1,2 @@
[0] %Error: t_randcase_bad.v:12: Assertion failed in top.t.unnamedblk1: All randcase items had 0 weights (IEEE 1800-2017 18.16)
[0] %Error: t_randcase_bad.v:12: Assertion failed in top.t.unnamedblk2_1: All randcase items had 0 weights (IEEE 1800-2017 18.16)
*-* All Finished *-*