mirror of
https://github.com/verilator/verilator.git
synced 2025-05-02 13:36:55 +00:00
Run EmitV test after all stages, and fix resulting fallout
This commit is contained in:
parent
64a6e1ac8b
commit
e931c6230a
@ -21,6 +21,7 @@
|
|||||||
#include "V3File.h"
|
#include "V3File.h"
|
||||||
#include "V3Global.h"
|
#include "V3Global.h"
|
||||||
#include "V3Broken.h"
|
#include "V3Broken.h"
|
||||||
|
#include "V3EmitV.h"
|
||||||
#include "V3String.h"
|
#include "V3String.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
@ -1141,6 +1142,7 @@ void AstNode::dumpTreeFile(const string& filename, bool append, bool doDump, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (doDump && v3Global.opt.debugEmitV()) V3EmitV::debugEmitV(filename + ".v");
|
||||||
if (doCheck && (v3Global.opt.debugCheck() || v3Global.opt.dumpTree())) {
|
if (doCheck && (v3Global.opt.debugCheck() || v3Global.opt.dumpTree())) {
|
||||||
// Error check
|
// Error check
|
||||||
checkTree();
|
checkTree();
|
||||||
|
@ -305,7 +305,7 @@ public:
|
|||||||
AstClassPackage(FileLine* fl, const string& name)
|
AstClassPackage(FileLine* fl, const string& name)
|
||||||
: ASTGEN_SUPER_ClassPackage(fl, name) {}
|
: ASTGEN_SUPER_ClassPackage(fl, name) {}
|
||||||
ASTNODE_NODE_FUNCS(ClassPackage)
|
ASTNODE_NODE_FUNCS(ClassPackage)
|
||||||
virtual string verilogKwd() const override { return "/*class*/package"; }
|
virtual string verilogKwd() const override { return "classpackage"; }
|
||||||
virtual const char* broken() const override;
|
virtual const char* broken() const override;
|
||||||
virtual void cloneRelink() override;
|
virtual void cloneRelink() override;
|
||||||
virtual bool timescaleMatters() const override { return false; }
|
virtual bool timescaleMatters() const override { return false; }
|
||||||
@ -2730,6 +2730,7 @@ public:
|
|||||||
ASTNODE_NODE_FUNCS(Iface)
|
ASTNODE_NODE_FUNCS(Iface)
|
||||||
// Interfaces have `timescale applicability but lots of code seems to
|
// Interfaces have `timescale applicability but lots of code seems to
|
||||||
// get false warnings if we enable this
|
// get false warnings if we enable this
|
||||||
|
virtual string verilogKwd() const override { return "interface"; }
|
||||||
virtual bool timescaleMatters() const override { return false; }
|
virtual bool timescaleMatters() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,9 +65,8 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
puts(nodep->prettyName());
|
puts(nodep->prettyName());
|
||||||
puts(";\n");
|
puts(";\n");
|
||||||
// Only putfs the first time for each visitor; later for same node is putqs
|
// Only putfs the first time for each visitor; later for same node is putqs
|
||||||
putqs(nodep, "begin\n");
|
|
||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextNull(nodep->stmtsp());
|
||||||
putqs(nodep, "end\n");
|
putfs(nodep, nodep->isFunction() ? "endfunction\n" : "endtask\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void visit(AstBegin* nodep) override {
|
virtual void visit(AstBegin* nodep) override {
|
||||||
@ -599,6 +598,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
puts(nodep->verilogKwd() + " ");
|
puts(nodep->verilogKwd() + " ");
|
||||||
if (nodep->packed()) puts("packed ");
|
if (nodep->packed()) puts("packed ");
|
||||||
puts("\n");
|
puts("\n");
|
||||||
|
puts("{");
|
||||||
iterateAndNextNull(nodep->membersp());
|
iterateAndNextNull(nodep->membersp());
|
||||||
puts("}");
|
puts("}");
|
||||||
}
|
}
|
||||||
@ -606,7 +606,6 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
iterate(nodep->subDTypep());
|
iterate(nodep->subDTypep());
|
||||||
puts(" ");
|
puts(" ");
|
||||||
puts(nodep->name());
|
puts(nodep->name());
|
||||||
puts("}");
|
|
||||||
}
|
}
|
||||||
virtual void visit(AstNodeFTaskRef* nodep) override {
|
virtual void visit(AstNodeFTaskRef* nodep) override {
|
||||||
if (nodep->dotted() != "") {
|
if (nodep->dotted() != "") {
|
||||||
@ -631,18 +630,26 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
if (nodep->varScopep()) {
|
if (nodep->varScopep()) {
|
||||||
putfs(nodep, nodep->varScopep()->prettyName());
|
putfs(nodep, nodep->varScopep()->prettyName());
|
||||||
} else {
|
} else {
|
||||||
if (nodep->selfPointer().empty()) {
|
if (nodep->varp()) {
|
||||||
putfs(nodep, nodep->varp()->prettyName());
|
if (nodep->selfPointer().empty()) {
|
||||||
|
putfs(nodep, nodep->varp()->prettyName());
|
||||||
|
} else {
|
||||||
|
putfs(nodep, nodep->selfPointer() + "->");
|
||||||
|
puts(nodep->varp()->prettyName());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
putfs(nodep, nodep->selfPointer() + "->");
|
putfs(nodep, nodep->name());
|
||||||
puts(nodep->varp()->prettyName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void visit(AstVarXRef* nodep) override {
|
virtual void visit(AstVarXRef* nodep) override {
|
||||||
putfs(nodep, nodep->dotted());
|
putfs(nodep, nodep->dotted());
|
||||||
puts(".");
|
puts(".");
|
||||||
puts(nodep->varp()->prettyName());
|
if (nodep->varp()) {
|
||||||
|
puts(nodep->varp()->prettyName());
|
||||||
|
} else {
|
||||||
|
puts(nodep->prettyName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
virtual void visit(AstConst* nodep) override { putfs(nodep, nodep->num().ascii(true, true)); }
|
virtual void visit(AstConst* nodep) override { putfs(nodep, nodep->num().ascii(true, true)); }
|
||||||
|
|
||||||
@ -682,6 +689,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||||||
iterateAndNextNull(nodep->stmtsp());
|
iterateAndNextNull(nodep->stmtsp());
|
||||||
m_sensesp = nullptr;
|
m_sensesp = nullptr;
|
||||||
}
|
}
|
||||||
|
virtual void visit(AstParseRef* nodep) override { puts(nodep->prettyName()); }
|
||||||
virtual void visit(AstVarScope*) override {}
|
virtual void visit(AstVarScope*) override {}
|
||||||
virtual void visit(AstNodeText*) override {}
|
virtual void visit(AstNodeText*) override {}
|
||||||
virtual void visit(AstTraceDecl*) override {}
|
virtual void visit(AstTraceDecl*) override {}
|
||||||
@ -856,10 +864,8 @@ void V3EmitV::emitvFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3EmitV::debugEmitV(const string& stage) {
|
void V3EmitV::debugEmitV(const string& filename) {
|
||||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||||
const string filename
|
|
||||||
= v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__" + stage + ".v";
|
|
||||||
V3OutVFile of(filename);
|
V3OutVFile of(filename);
|
||||||
{ EmitVFileVisitor{v3Global.rootp(), &of, true, true}; }
|
{ EmitVFileVisitor{v3Global.rootp(), &of, true, true}; }
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
static void verilogPrefixedTree(AstNode* nodep, std::ostream& os, const string& prefix,
|
static void verilogPrefixedTree(AstNode* nodep, std::ostream& os, const string& prefix,
|
||||||
int flWidth, AstSenTree* domainp, bool user3mark);
|
int flWidth, AstSenTree* domainp, bool user3mark);
|
||||||
static void emitvFiles();
|
static void emitvFiles();
|
||||||
static void debugEmitV(const string& stage);
|
static void debugEmitV(const string& filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // Guard
|
#endif // Guard
|
||||||
|
@ -636,8 +636,8 @@ string V3OutFormatter::indentSpaces(int num) {
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool V3OutFormatter::tokenStart(const char* cp, const char* cmp) {
|
bool V3OutFormatter::tokenMatch(const char* cp, const char* cmp) {
|
||||||
while (*cmp == *cp) {
|
while (*cmp && *cmp == *cp) {
|
||||||
++cp;
|
++cp;
|
||||||
++cmp;
|
++cmp;
|
||||||
}
|
}
|
||||||
@ -646,8 +646,18 @@ bool V3OutFormatter::tokenStart(const char* cp, const char* cmp) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool V3OutFormatter::tokenStart(const char* cp) {
|
||||||
|
return (tokenMatch(cp, "begin") || tokenMatch(cp, "case") || tokenMatch(cp, "casex")
|
||||||
|
|| tokenMatch(cp, "casez") || tokenMatch(cp, "class") || tokenMatch(cp, "function")
|
||||||
|
|| tokenMatch(cp, "interface") || tokenMatch(cp, "module") || tokenMatch(cp, "package")
|
||||||
|
|| tokenMatch(cp, "task"));
|
||||||
|
}
|
||||||
|
|
||||||
bool V3OutFormatter::tokenEnd(const char* cp) {
|
bool V3OutFormatter::tokenEnd(const char* cp) {
|
||||||
return (tokenStart(cp, "end") || tokenStart(cp, "endcase") || tokenStart(cp, "endmodule"));
|
return (tokenMatch(cp, "end") || tokenMatch(cp, "endcase") || tokenMatch(cp, "endclass")
|
||||||
|
|| tokenMatch(cp, "endfunction") || tokenMatch(cp, "endinterface")
|
||||||
|
|| tokenMatch(cp, "endmodule") || tokenMatch(cp, "endpackage")
|
||||||
|
|| tokenMatch(cp, "endtask"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int V3OutFormatter::endLevels(const char* strg) {
|
int V3OutFormatter::endLevels(const char* strg) {
|
||||||
@ -698,6 +708,10 @@ void V3OutFormatter::puts(const char* strg) {
|
|||||||
bool equalsForBracket = false; // Looking for "= {"
|
bool equalsForBracket = false; // Looking for "= {"
|
||||||
for (const char* cp = strg; *cp; cp++) {
|
for (const char* cp = strg; *cp; cp++) {
|
||||||
putcNoTracking(*cp);
|
putcNoTracking(*cp);
|
||||||
|
if (isalpha(*cp)) {
|
||||||
|
if (wordstart && m_lang == LA_VERILOG && tokenStart(cp)) indentInc();
|
||||||
|
if (wordstart && m_lang == LA_VERILOG && tokenEnd(cp)) indentDec();
|
||||||
|
}
|
||||||
switch (*cp) {
|
switch (*cp) {
|
||||||
case '\n':
|
case '\n':
|
||||||
m_lineno++;
|
m_lineno++;
|
||||||
@ -775,26 +789,6 @@ void V3OutFormatter::puts(const char* strg) {
|
|||||||
if (cp > strg && cp[-1] == '/') indentDec(); // < ..... /> stays same level
|
if (cp > strg && cp[-1] == '/') indentDec(); // < ..... /> stays same level
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'b':
|
|
||||||
if (wordstart && m_lang == LA_VERILOG && tokenStart(cp, "begin")) indentInc();
|
|
||||||
wordstart = false;
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
if (wordstart && m_lang == LA_VERILOG
|
|
||||||
&& (tokenStart(cp, "case") || tokenStart(cp, "casex")
|
|
||||||
|| tokenStart(cp, "casez"))) {
|
|
||||||
indentInc();
|
|
||||||
}
|
|
||||||
wordstart = false;
|
|
||||||
break;
|
|
||||||
case 'e':
|
|
||||||
if (wordstart && m_lang == LA_VERILOG && tokenEnd(cp)) indentDec();
|
|
||||||
wordstart = false;
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
if (wordstart && m_lang == LA_VERILOG && tokenStart(cp, "module")) indentInc();
|
|
||||||
wordstart = false;
|
|
||||||
break;
|
|
||||||
default: wordstart = false; break;
|
default: wordstart = false; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,8 @@ public:
|
|||||||
puts(strg);
|
puts(strg);
|
||||||
}
|
}
|
||||||
bool exceededWidth() const { return m_column > m_commaWidth; }
|
bool exceededWidth() const { return m_column > m_commaWidth; }
|
||||||
bool tokenStart(const char* cp, const char* cmp);
|
bool tokenMatch(const char* cp, const char* cmp);
|
||||||
|
bool tokenStart(const char* cp);
|
||||||
bool tokenEnd(const char* cp);
|
bool tokenEnd(const char* cp);
|
||||||
void indentInc() { m_indentLevel += m_blockIndent; }
|
void indentInc() { m_indentLevel += m_blockIndent; }
|
||||||
void indentDec() {
|
void indentDec() {
|
||||||
|
@ -111,7 +111,6 @@ static void reportStatsIfEnabled() {
|
|||||||
V3Stats::statsFinalAll(v3Global.rootp());
|
V3Stats::statsFinalAll(v3Global.rootp());
|
||||||
V3Stats::statsReport();
|
V3Stats::statsReport();
|
||||||
}
|
}
|
||||||
if (v3Global.opt.debugEmitV()) V3EmitV::debugEmitV("final");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process() {
|
static void process() {
|
||||||
@ -376,7 +375,6 @@ static void process() {
|
|||||||
V3ActiveTop::activeTopAll(v3Global.rootp());
|
V3ActiveTop::activeTopAll(v3Global.rootp());
|
||||||
|
|
||||||
if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "PreOrder");
|
if (v3Global.opt.stats()) V3Stats::statsStageAll(v3Global.rootp(), "PreOrder");
|
||||||
if (v3Global.opt.debugEmitV()) V3EmitV::debugEmitV("preorder");
|
|
||||||
|
|
||||||
// Order the code; form SBLOCKs and BLOCKCALLs
|
// Order the code; form SBLOCKs and BLOCKCALLs
|
||||||
V3Order::orderAll(v3Global.rootp());
|
V3Order::orderAll(v3Global.rootp());
|
||||||
|
Loading…
Reference in New Issue
Block a user