Prep for removing begin under first generate, but doesn't work. Commentary instead

git-svn-id: file://localhost/svn/verilator/trunk/verilator@782 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder 2006-09-11 20:42:47 +00:00
parent 88809587f9
commit 12ae70ba95
4 changed files with 33 additions and 39 deletions

View File

@ -1116,10 +1116,25 @@ always @* to prevent these issues.)
Verilator supports dotted references to variables, functions and tasks in Verilator supports dotted references to variables, functions and tasks in
different modules. However, references into named blocks and function-local different modules. However, references into named blocks and function-local
variables are not supported. References into generate statements and variables are not supported. References into arrayed and generated
arrayed instances are possible, but may use different names from the instances work, but still require some work-arounds in the Verilog code:
Verilog standard; arrayed instances are named {cellName}__{instanceNumber},
while for generates, it's genblk{instanceNumber} or genfor{loopCount}. References into arrayed instances use different names from the Verilog
standard; arrayed instances are named {cellName}__{instanceNumber}. For
example a[2] is instead a__2. Thus you cannot use a parameter or variable
to select the index number; expand it into a case statement manually.
References into generate statements also use different names from the
Verilog standard; the top level generate, any begin statement, and any
place where there is a implied begin statement (under each generate-if or
generate-case) adds a hierarchy level named genblkI<instanceNumber>. And
each generate-for adds genforI<loopCount>. The best bet is to comment out
the references and run with --debug and look in the at the _begin.tree
file, and see the hierarchy by looking at the names of all of the CELLs in
question. Replace __DOT__ with . in your program. For example most cells
under a for loop would be something like
"genblk__DOT__genfor0__DOT__I<cellname>"; so use genblk.genfor0.I<cellname> to
see inside that cell.
=head2 Latches =head2 Latches
@ -1354,6 +1369,9 @@ For significantly better performance, split this into 2 separate signals:
wire [2:1] x_21 = x[1:0]; wire [2:1] x_21 = x[1:0];
wire [0:0] x_0 = shift_in; wire [0:0] x_0 = shift_in;
This warning may also be due to clock enables. To fix these, use the
clock_enable meta comment described above.
=item UNSIGNED =item UNSIGNED
Warns that you are comparing a unsigned value in a way that implies it is Warns that you are comparing a unsigned value in a way that implies it is

View File

@ -49,25 +49,6 @@ private:
string m_beginScope; // Name of begin blocks above us string m_beginScope; // Name of begin blocks above us
//int debug() { return 9; } //int debug() { return 9; }
bool nameMatchesGen(const char* namep, string& numr) {
numr = "";
bool needbar = false;
for (const char* cp=namep; *cp; ) {
if (0==strncmp(cp,"genblk",6) || 0==strncmp(cp,"genfor",6)) {
cp += 6;
} else if (isdigit(*cp)) {
if (needbar) { numr += '_'; needbar = false; }
numr += *cp++;
} else if (*cp=='_') {
cp++;
needbar = true;
} else {
return false; // Not exact match
}
}
return true;
}
// VISITORS // VISITORS
virtual void visit(AstModule* nodep, AstNUser*) { virtual void visit(AstModule* nodep, AstNUser*) {
m_modp = nodep; m_modp = nodep;
@ -84,15 +65,6 @@ private:
UINFO(8," "<<nodep<<endl); UINFO(8," "<<nodep<<endl);
string oldScope = m_beginScope; string oldScope = m_beginScope;
{ {
//string nameNum;
//string oldNum;
//if (nameMatchesGen(oldScope.c_str(), oldNum/*ref*/)
// && nameMatchesGen(nodep->name().c_str(), nameNum/*ref*/)
// && 0) { // Messes up V3Link
// // Need to leave the dot or we mess up later V3LinkDot
// // gen[blk|for]##_gen[blk|for]## -> gen[blk|for]##__DOT__##...
// m_beginScope = oldScope + "__DOT__"+nameNum;
//UINFO(8,"nname "<<m_beginScope<<endl); //UINFO(8,"nname "<<m_beginScope<<endl);
// Create data for dotted variable resolution // Create data for dotted variable resolution
string dottedname = nodep->name() + "__DOT__"; // So always found string dottedname = nodep->name() + "__DOT__"; // So always found
@ -100,7 +72,7 @@ private:
while ((pos=dottedname.find("__DOT__")) != string::npos) { while ((pos=dottedname.find("__DOT__")) != string::npos) {
string ident = dottedname.substr(0,pos); string ident = dottedname.substr(0,pos);
dottedname = dottedname.substr(pos+strlen("__DOT__")); dottedname = dottedname.substr(pos+strlen("__DOT__"));
if (m_beginScope=="") m_beginScope = nodep->name(); if (m_beginScope=="") m_beginScope = ident;
else m_beginScope = m_beginScope + "__DOT__"+ident; else m_beginScope = m_beginScope + "__DOT__"+ident;
// Create CellInline for dotted resolution // Create CellInline for dotted resolution
AstCellInline* inlinep = new AstCellInline(nodep->fileline(), AstCellInline* inlinep = new AstCellInline(nodep->fileline(),

View File

@ -127,10 +127,14 @@ private:
nodep->iterateChildren(*this); nodep->iterateChildren(*this);
// After expanding the generate, all statements under it can be moved // After expanding the generate, all statements under it can be moved
// up, and the generate block deleted as it's not relevant // up, and the generate block deleted as it's not relevant
AstNode* stmtsp = nodep->stmtsp()->unlinkFrBackWithNext(); if (AstNode* stmtsp = nodep->stmtsp()) {
stmtsp->unlinkFrBackWithNext();
nodep->replaceWith(stmtsp); nodep->replaceWith(stmtsp);
nodep->deleteTree(); nodep=NULL;
if (debug()>=9) stmtsp->dumpTree(cout,"-genout: "); if (debug()>=9) stmtsp->dumpTree(cout,"-genout: ");
} else {
nodep->unlinkFrBack();
}
nodep->deleteTree(); nodep=NULL;
} }
virtual void visit(AstGenIf* nodep, AstNUser*) { virtual void visit(AstGenIf* nodep, AstNUser*) {
V3Width::widthParams(nodep); // Param typed widthing will NOT recurse the body V3Width::widthParams(nodep); // Param typed widthing will NOT recurse the body

View File

@ -222,7 +222,7 @@ class AstSenTree;
%type<nodep> v2kPort ioDecl varDecl %type<nodep> v2kPort ioDecl varDecl
%type<nodep> modParDecl modParList modParE %type<nodep> modParDecl modParList modParE
%type<nodep> modItem modItemList modItemListOrNone modOrGenItem %type<nodep> modItem modItemList modItemListOrNone modOrGenItem
%type<nodep> genItem genItemList genItemBegin genItemBlock genItemsBlock genCaseList %type<nodep> genItem genItemList genItemBegin genItemBlock genTopBlock genCaseList
%type<nodep> dterm %type<nodep> dterm
%type<varp> onesig sigId sigIdRange paramId sigList regsig regsigList regSigId %type<varp> onesig sigId sigIdRange paramId sigList regsig regsigList regSigId
%type<varp> netSig netSigList %type<varp> netSig netSigList
@ -399,7 +399,7 @@ modItemList: modItem { $$ = $1; }
; ;
modItem: modOrGenItem { $$ = $1; } modItem: modOrGenItem { $$ = $1; }
| yGENERATE genItemsBlock yENDGENERATE { $$ = new AstGenerate($1, $2); } | yGENERATE genTopBlock yENDGENERATE { $$ = new AstGenerate($1, $2); }
| ySCHDR { $$ = new AstScHdr(CRELINE(),*$1); } | ySCHDR { $$ = new AstScHdr(CRELINE(),*$1); }
| ySCINT { $$ = new AstScInt(CRELINE(),*$1); } | ySCINT { $$ = new AstScInt(CRELINE(),*$1); }
| ySCIMP { $$ = new AstScImp(CRELINE(),*$1); } | ySCIMP { $$ = new AstScImp(CRELINE(),*$1); }
@ -437,7 +437,7 @@ genItemBlock: genItem { $$ = new AstBegin(CRELINE(),"genblk",$1); }
| genItemBegin { $$ = $1; } | genItemBegin { $$ = $1; }
; ;
genItemsBlock: genItemList { $$ = new AstBegin(CRELINE(),"genblk",$1); } genTopBlock: genItemList { $$ = new AstBegin(CRELINE(),"genblk",$1); }
| genItemBegin { $$ = $1; } | genItemBegin { $$ = $1; }
; ;