Fix triangle symbol resolution error broke in 3.840, bug550.

This requires the parse symbol table persist across all parse runs. This is
probably more correct than before, but may result in some fallout if people
relied on data types not being persistant across separately parsed cells.
This commit is contained in:
Wilson Snyder 2012-08-15 21:28:30 -04:00
parent 8ece0a8a5f
commit f0e1d204fa
8 changed files with 38 additions and 17 deletions

View File

@ -15,6 +15,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix duplicate begin error broke in 3.840, bug548. [Alex Solomatnikov]
**** Fix triangle symbol resolution error broke in 3.840, bug550. [Ted Campbell]
* Verilator 3.840 2012/07/31 Beta

View File

@ -96,6 +96,7 @@ private:
// STATE
V3InFilter* m_filterp; // Parser filter
V3ParseSym* m_parseSymp; // Parser symbol table
// Below state needs to be preserved between each module call.
AstNodeModule* m_modp; // Current module
@ -202,7 +203,7 @@ private:
// Read-subfile
// If file not found, make AstNotFoundModule, rather than error out.
// We'll throw the error when we know the module will really be needed.
V3Parse parser (v3Global.rootp(), m_filterp);
V3Parse parser (v3Global.rootp(), m_filterp, m_parseSymp);
parser.parseFile(nodep->fileline(), nodep->modName(), false, "");
V3Error::abortIfErrors();
// We've read new modules, grab new pointers to their names
@ -284,6 +285,7 @@ private:
if (nodep->modp()) {
nodep->iterateChildren(*this);
}
UINFO(4," Link Cell done: "<<nodep<<endl);
}
// Accelerate the recursion
@ -316,9 +318,10 @@ private:
public:
// CONSTUCTORS
LinkCellsVisitor(AstNetlist* rootp, V3InFilter* filterp)
LinkCellsVisitor(AstNetlist* rootp, V3InFilter* filterp, V3ParseSym* parseSymp)
: m_mods(rootp) {
m_filterp = filterp;
m_parseSymp = parseSymp;
m_modp = NULL;
m_libVertexp = NULL;
m_topVertexp = NULL;
@ -330,7 +333,7 @@ public:
//######################################################################
// Link class functions
void V3LinkCells::link(AstNetlist* rootp, V3InFilter* filterp) {
void V3LinkCells::link(AstNetlist* rootp, V3InFilter* filterp, V3ParseSym* parseSymp) {
UINFO(4,__FUNCTION__<<": "<<endl);
LinkCellsVisitor visitor (rootp, filterp);
LinkCellsVisitor visitor (rootp, filterp, parseSymp);
}

View File

@ -26,12 +26,13 @@
#include "V3Ast.h"
class V3InFilter;
class V3ParseSym;
//============================================================================
class V3LinkCells {
public:
static void link(AstNetlist* nodep, V3InFilter* filterp);
static void link(AstNetlist* nodep, V3InFilter* filterp, V3ParseSym* parseSymp);
};
#endif // Guard

View File

@ -28,6 +28,7 @@
class AstNetlist;
class V3InFilter;
class V3ParseImp;
class V3ParseSym;
//============================================================================
@ -38,7 +39,7 @@ private:
public:
// CONSTRUCTORS
// We must allow reading multiple files into one parser
V3Parse(AstNetlist* rootp, V3InFilter* filterp);
V3Parse(AstNetlist* rootp, V3InFilter* filterp, V3ParseSym* symp);
~V3Parse();
// METHODS

View File

@ -159,8 +159,8 @@ void V3ParseImp::lexFile(const string& modname) {
//======================================================================
// V3Parse functions
V3Parse::V3Parse(AstNetlist* rootp, V3InFilter* filterp) {
m_impp = new V3ParseImp (rootp, filterp);
V3Parse::V3Parse(AstNetlist* rootp, V3InFilter* filterp, V3ParseSym* symp) {
m_impp = new V3ParseImp (rootp, filterp, symp);
}
V3Parse::~V3Parse() {
delete m_impp; m_impp = NULL;

View File

@ -92,11 +92,12 @@ class V3ParseImp {
// MEMBERS
AstNetlist* m_rootp; // Root of the design
V3InFilter* m_filterp; // Reading filter
V3ParseSym* m_symp; // Symbol table
V3Lexer* m_lexerp; // Current FlexLexer
static V3ParseImp* s_parsep; // Current THIS, bison() isn't class based
FileLine* m_fileline; // Filename/linenumber currently active
V3ParseSym m_sym; // Symbol table
bool m_inCellDefine; // Inside a `celldefine
bool m_inLibrary; // Currently reading a library vs. regular file
int m_inBeginKwd; // Inside a `begin_keywords
@ -193,14 +194,14 @@ public:
size_t flexPpInputToLex(char* buf, size_t max_size) { return ppInputToLex(buf,max_size); }
//==== Symbol tables
V3ParseSym* symp() { return &m_sym; }
V3ParseSym* symp() { return m_symp; }
public:
// CREATORS
V3ParseImp(AstNetlist* rootp, V3InFilter* filterp)
: m_filterp(filterp), m_sym(rootp) {
V3ParseImp(AstNetlist* rootp, V3InFilter* filterp, V3ParseSym* parserSymp)
: m_rootp(rootp), m_filterp(filterp), m_symp(parserSymp) {
m_fileline = NULL;
m_rootp = rootp; m_lexerp = NULL;
m_lexerp = NULL;
m_inCellDefine = false;
m_inLibrary = false;
m_inBeginKwd = 0;

View File

@ -53,7 +53,7 @@ private:
VSymEnt* m_parentp; // Table that created this table, dot notation needed to resolve into it
AstPackage* m_packagep; // Package node is in (for V3LinkDot, unused here)
string m_symPrefix; // String to prefix symbols with (for V3LinkDot, unused here)
#if 0 // debug
#ifdef VL_DEBUG
static int debug() {
static int level = -1;
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel("V3LinkDot.cpp");
@ -87,7 +87,18 @@ public:
// METHODS
VSymEnt(VSymGraph* graphp, AstNode* nodep); // Below
~VSymEnt() {}
~VSymEnt() {
// Change links so we coredump if used
#ifdef VL_DEBUG
m_nodep = (AstNode*)1;
m_fallbackp = (VSymEnt*)1;
m_parentp = (VSymEnt*)1;
m_packagep = (AstPackage*)1;
#endif
}
#if defined(VL_DEBUG) && !defined(VL_LEAK_CHECKS)
void operator delete(void* objp, size_t size) {} // For testing, leak so above destructor 1 assignments work
#endif
void fallbackp(VSymEnt* entp) { m_fallbackp = entp; }
void parentp(VSymEnt* entp) { m_parentp = entp; }
VSymEnt* parentp() const { return m_parentp; }

View File

@ -70,6 +70,7 @@
#include "V3Order.h"
#include "V3Param.h"
#include "V3Parse.h"
#include "V3ParseSym.h"
#include "V3PreShell.h"
#include "V3Premit.h"
#include "V3Scope.h"
@ -111,8 +112,9 @@ void V3Global::readFiles() {
AstUser4InUse inuser4;
V3InFilter filter (v3Global.opt.pipeFilter());
V3ParseSym parseSyms (v3Global.rootp()); // Symbol table must be common across all parsing
V3Parse parser (v3Global.rootp(), &filter);
V3Parse parser (v3Global.rootp(), &filter, &parseSyms);
// Read top module
for (V3StringList::const_iterator it = v3Global.opt.vFiles().begin();
it != v3Global.opt.vFiles().end(); ++it) {
@ -135,7 +137,7 @@ void V3Global::readFiles() {
if (!v3Global.opt.preprocOnly()) {
// Resolve all modules cells refer to
V3LinkCells::link(v3Global.rootp(), &filter);
V3LinkCells::link(v3Global.rootp(), &filter, &parseSyms);
}
}