Fix error on enum references to other packages, bug339.
This commit is contained in:
parent
c9f8109c06
commit
5d7ce096c6
8
Changes
8
Changes
|
|
@ -3,9 +3,13 @@ Revision history for Verilator
|
||||||
The contributors that suggested a given feature are shown in []. [by ...]
|
The contributors that suggested a given feature are shown in []. [by ...]
|
||||||
indicates the contributor was also the author of the fix; Thanks!
|
indicates the contributor was also the author of the fix; Thanks!
|
||||||
|
|
||||||
|
* Verilator 3.813****
|
||||||
|
|
||||||
|
**** Fix error on enum references to other packages, bug339. [Alex Solomatnikov]
|
||||||
|
|
||||||
* Verilator 3.812 2011/04/06
|
* Verilator 3.812 2011/04/06
|
||||||
|
|
||||||
*** Add --trace-max-width and --trace-max-array, bug 319. [Alex Solomatnikov]
|
*** Add --trace-max-width and --trace-max-array, bug319. [Alex Solomatnikov]
|
||||||
|
|
||||||
*** Add --Wno-fatal to turn off abort on warnings. [by Stefan Wallentowitz]
|
*** Add --Wno-fatal to turn off abort on warnings. [by Stefan Wallentowitz]
|
||||||
|
|
||||||
|
|
@ -13,7 +17,7 @@ indicates the contributor was also the author of the fix; Thanks!
|
||||||
|
|
||||||
**** Support $bits(data_type), bug327. [Alex Solomatnikov]
|
**** Support $bits(data_type), bug327. [Alex Solomatnikov]
|
||||||
|
|
||||||
**** Support loop unrolling on width mismatches, bug 333. [Joe Eiler]
|
**** Support loop unrolling on width mismatches, bug333. [Joe Eiler]
|
||||||
|
|
||||||
**** Support simple cast operators, bug335. [Alex Solomatnikov]
|
**** Support simple cast operators, bug335. [Alex Solomatnikov]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -364,9 +364,10 @@ public:
|
||||||
struct AstEnumItemRef : public AstNodeMath {
|
struct AstEnumItemRef : public AstNodeMath {
|
||||||
private:
|
private:
|
||||||
AstEnumItem* m_itemp; // [AfterLink] Pointer to item
|
AstEnumItem* m_itemp; // [AfterLink] Pointer to item
|
||||||
|
AstPackage* m_packagep; // Package hierarchy
|
||||||
public:
|
public:
|
||||||
AstEnumItemRef(FileLine* fl, AstEnumItem* itemp)
|
AstEnumItemRef(FileLine* fl, AstEnumItem* itemp, AstPackage* packagep)
|
||||||
: AstNodeMath(fl), m_itemp(itemp) {
|
: AstNodeMath(fl), m_itemp(itemp), m_packagep(packagep) {
|
||||||
if (m_itemp) widthSignedFrom(m_itemp);
|
if (m_itemp) widthSignedFrom(m_itemp);
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(EnumItemRef, ENUMITEMREF)
|
ASTNODE_NODE_FUNCS(EnumItemRef, ENUMITEMREF)
|
||||||
|
|
@ -381,6 +382,8 @@ public:
|
||||||
virtual string emitVerilog() { V3ERROR_NA; return ""; } // Implemented specially
|
virtual string emitVerilog() { V3ERROR_NA; return ""; } // Implemented specially
|
||||||
virtual string emitC() { V3ERROR_NA; return ""; }
|
virtual string emitC() { V3ERROR_NA; return ""; }
|
||||||
virtual bool cleanOut() { return true; }
|
virtual bool cleanOut() { return true; }
|
||||||
|
AstPackage* packagep() const { return m_packagep; }
|
||||||
|
void packagep(AstPackage* nodep) { m_packagep=nodep; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AstEnumDType : public AstNodeDType {
|
struct AstEnumDType : public AstNodeDType {
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,12 @@ private:
|
||||||
nodep->packagep()->user1Inc();
|
nodep->packagep()->user1Inc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
virtual void visit(AstEnumItemRef* nodep, AstNUser*) {
|
||||||
|
nodep->iterateChildren(*this);
|
||||||
|
if (nodep->packagep()) {
|
||||||
|
nodep->packagep()->user1Inc();
|
||||||
|
}
|
||||||
|
}
|
||||||
virtual void visit(AstVarScope* nodep, AstNUser*) {
|
virtual void visit(AstVarScope* nodep, AstNUser*) {
|
||||||
nodep->iterateChildren(*this);
|
nodep->iterateChildren(*this);
|
||||||
m_vscsp.push_back(nodep);
|
m_vscsp.push_back(nodep);
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ private:
|
||||||
nodep->packagep(packageFor(varp));
|
nodep->packagep(packageFor(varp));
|
||||||
}
|
}
|
||||||
else if (AstEnumItem* valuep = foundp->castEnumItem()) {
|
else if (AstEnumItem* valuep = foundp->castEnumItem()) {
|
||||||
AstNode* newp = new AstEnumItemRef(nodep->fileline(), valuep);
|
AstNode* newp = new AstEnumItemRef(nodep->fileline(), valuep, packageFor(valuep));
|
||||||
nodep->replaceWith(newp);
|
nodep->replaceWith(newp);
|
||||||
nodep->deleteTree(); nodep=NULL;
|
nodep->deleteTree(); nodep=NULL;
|
||||||
return true; // Edited
|
return true; // Edited
|
||||||
|
|
|
||||||
|
|
@ -616,6 +616,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void visit(AstEnumDType* nodep, AstNUser* vup) {
|
virtual void visit(AstEnumDType* nodep, AstNUser* vup) {
|
||||||
|
UINFO(5," ENUMDTYPE "<<nodep<<endl);
|
||||||
nodep->dtypep()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
nodep->dtypep()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p());
|
||||||
nodep->widthFrom(nodep->dtypep());
|
nodep->widthFrom(nodep->dtypep());
|
||||||
// Assign widths
|
// Assign widths
|
||||||
|
|
@ -646,6 +647,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void visit(AstEnumItem* nodep, AstNUser* vup) {
|
virtual void visit(AstEnumItem* nodep, AstNUser* vup) {
|
||||||
|
UINFO(5," ENUMITEM "<<nodep<<endl);
|
||||||
int width = vup->c()->width();
|
int width = vup->c()->width();
|
||||||
int mwidth = vup->c()->widthMin();
|
int mwidth = vup->c()->widthMin();
|
||||||
nodep->width(width, mwidth);
|
nodep->width(width, mwidth);
|
||||||
|
|
@ -657,12 +659,13 @@ private:
|
||||||
virtual void visit(AstEnumItemRef* nodep, AstNUser* vup) {
|
virtual void visit(AstEnumItemRef* nodep, AstNUser* vup) {
|
||||||
if (nodep->itemp()->width()==0) {
|
if (nodep->itemp()->width()==0) {
|
||||||
// We need to do the whole enum en-mass
|
// We need to do the whole enum en-mass
|
||||||
AstNode* enump = nodep;
|
AstNode* enump = nodep->itemp();
|
||||||
|
if (!enump) nodep->v3fatalSrc("EnumItemRef not linked");
|
||||||
for (; enump; enump=enump->backp()) {
|
for (; enump; enump=enump->backp()) {
|
||||||
if (enump->castEnumDType()) break;
|
if (enump->castEnumDType()) break;
|
||||||
}
|
}
|
||||||
if (!enump) nodep->v3fatalSrc("EnumItem not under a Enum");
|
if (!enump) nodep->v3fatalSrc("EnumItemRef can't deref back to a Enum");
|
||||||
enump->iterate(*this);
|
enump->iterate(*this,vup);
|
||||||
}
|
}
|
||||||
nodep->widthFrom(nodep->itemp()->valuep());
|
nodep->widthFrom(nodep->itemp()->valuep());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,13 @@
|
||||||
// This file ONLY is placed into the Public Domain, for any use,
|
// This file ONLY is placed into the Public Domain, for any use,
|
||||||
// without warranty, 2009 by Wilson Snyder.
|
// without warranty, 2009 by Wilson Snyder.
|
||||||
|
|
||||||
|
typedef enum logic [4:0]
|
||||||
|
{
|
||||||
|
BIT0 = 5'd0,
|
||||||
|
BIT1 = 5'd1,
|
||||||
|
BIT2 = 5'd2
|
||||||
|
} three_t;
|
||||||
|
|
||||||
module t (/*AUTOARG*/);
|
module t (/*AUTOARG*/);
|
||||||
|
|
||||||
localparam FIVE = 5;
|
localparam FIVE = 5;
|
||||||
|
|
@ -50,6 +57,10 @@ module t (/*AUTOARG*/);
|
||||||
if ($bits(sized_based_on_enum) != 8) $stop;
|
if ($bits(sized_based_on_enum) != 8) $stop;
|
||||||
if ($bits(three_t) != 3) $stop;
|
if ($bits(three_t) != 3) $stop;
|
||||||
|
|
||||||
|
if (FIVE[BIT0] != 1'b1) $stop;
|
||||||
|
if (FIVE[BIT1] != 1'b0) $stop;
|
||||||
|
if (FIVE[BIT2] != 1'b1) $stop;
|
||||||
|
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue