Fix addition of data types to --xml.

This commit is contained in:
Wilson Snyder 2017-11-09 18:04:16 -05:00
parent 5c919cd0de
commit c0afe96b80
7 changed files with 102 additions and 25 deletions

View File

@ -1708,6 +1708,7 @@ public:
virtual AstNodeDType* virtRefDTypep() const { return NULL; } // Iff has a non-null refDTypep(), as generic node function
virtual void virtRefDTypep(AstNodeDType* nodep) { } // Iff has refDTypep(), set as generic node function
virtual bool similarDType(AstNodeDType* samep) const = 0; // Assignable equivalence. Call skipRefp() on this and samep before calling
virtual AstNodeDType* subDTypep() const { return NULL; } // Iff has a non-null subDTypep(), as generic node function
//
// Changing the width may confuse the data type resolution, so must clear TypeTable cache after use.
void widthForce(int width, int sized) { m_width=width; m_widthMin=sized; }
@ -1811,7 +1812,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); }
virtual AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); }
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
virtual AstNodeDType* virtRefDTypep() const { return m_refDTypep; }
virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); }

View File

@ -179,7 +179,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Type assigning to
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
virtual AstBasicDType* basicp() const { return subDTypep()->basicp(); } // (Slow) recurse down to find basic data type
virtual AstNodeDType* skipRefp() const { return subDTypep()->skipRefp(); }
virtual AstNodeDType* skipRefToConstp() const { return subDTypep()->skipRefToConstp(); }
@ -217,7 +217,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Type assigning to
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
void addAttrsp(AstNode* nodep) { addNOp4p(nodep); }
AstNode* attrsp() const { return op4p(); } // op4 = Attributes during early parse
// METHODS
@ -267,7 +267,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
void* containerp() const { return m_containerp; }
// METHODS
AstNodeDType* dtypeSkipRefp() const { return dtypep()->skipRefp(); } // op1 = Range of variable
@ -478,7 +478,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); } // op1 = Range of variable
virtual AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); } // op1 = Range of variable
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
virtual AstNodeDType* virtRefDTypep() const { return m_refDTypep; }
virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); }
@ -588,7 +588,7 @@ public:
void refDTypep(AstNodeDType* nodep) { m_refDTypep=nodep; }
virtual AstNodeDType* virtRefDTypep() const { return refDTypep(); }
virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); }
AstNodeDType* subDTypep() const { return m_refDTypep; }
virtual AstNodeDType* subDTypep() const { return m_refDTypep; }
AstPackage* packagep() const { return m_packagep; }
void packagep(AstPackage* nodep) { m_packagep=nodep; }
};
@ -642,7 +642,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); }
virtual AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); }
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
virtual AstNodeDType* virtRefDTypep() const { return m_refDTypep; }
virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); }
@ -738,7 +738,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Data type
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); } // op1 = Range of variable
virtual AstNodeDType* subDTypep() const { return m_refDTypep ? m_refDTypep : childDTypep(); } // op1 = Range of variable
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
virtual AstNodeDType* virtRefDTypep() const { return m_refDTypep; }
virtual void virtRefDTypep(AstNodeDType* nodep) { refDTypep(nodep); }
@ -1103,7 +1103,7 @@ public:
void addAttrsp(AstNode* nodep) { addNOp4p(nodep); }
AstNode* attrsp() const { return op4p(); } // op4 = Attributes during early parse
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
void attrClockEn(bool flag) { m_attrClockEn = flag; }
void attrClocker(AstVarAttrClocker flag) { m_attrClocker = flag; }
void attrFileDescr(bool flag) { m_fileDescr = flag; }
@ -4911,7 +4911,7 @@ public:
AstNodeDType* getChildDTypep() const { return childDTypep(); }
AstNodeDType* childDTypep() const { return op1p()->castNodeDType(); } // op1 = Type assigning to
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
AstNode* itemsp() const { return op2p(); } // op2 = AstPatReplicate, AstPatMember, etc
};
class AstPatMember : public AstNodeMath {

View File

@ -80,9 +80,9 @@ class EmitXmlFileVisitor : public AstNVisitor {
if (nodep->name()!="") { puts(" name="); putsQuoted(nodep->prettyName()); }
if (nodep->tag()!="") { puts(" tag="); putsQuoted(nodep->tag()); }
if (AstNodeDType* dtp = nodep->castNodeDType()) {
if (dtp->skipRefp() && dtp->skipRefp()!=dtp) { puts(" sub_dtype_id="); outputId(dtp->skipRefp()); }
if (dtp->subDTypep()) { puts(" sub_dtype_id="); outputId(dtp->subDTypep()->skipRefp()); }
} else {
if (nodep->dtypep()) { puts(" dtype_id="); outputId(nodep->dtypep()); }
if (nodep->dtypep()) { puts(" dtype_id="); outputId(nodep->dtypep()->skipRefp()); }
}
}
void outputChildrenEnd(AstNode* nodep, string tag) {
@ -127,7 +127,7 @@ class EmitXmlFileVisitor : public AstNVisitor {
}
virtual void visit(AstAssignW* nodep) {
outputTag(nodep, "contassign"); // IEEE: vpiContAssign
outputChildrenEnd(nodep, "contAssign");
outputChildrenEnd(nodep, "contassign");
}
// Data types

View File

@ -0,0 +1,70 @@
<?xml version="1.0" ?>
<!-- DESCRIPTION: Verilator output: XML representation of netlist -->
<verilator_xml>
<files>
<file id="a" filename="AstRoot" language="1800-2012"/>
<file id="b" filename="COMMAND_LINE" language="1800-2012"/>
<file id="c" filename="INTERNAL_VERILATOR_DEFINE" language="1800-2012"/>
<file id="d" filename="input.vc" language="1800-2012"/>
<file id="e" filename="t/t_xml_first.v" language="1800-2012"/>
</files>
<netlist>
<module fl="e6" name="t" topModule="1">
<var fl="e12" name="clk" dtype_id="1"/>
<var fl="e13" name="d" dtype_id="2"/>
<var fl="e14" name="q" dtype_id="2"/>
<var fl="e16" name="between" dtype_id="2"/>
<instance fl="e18" name="cell1" defName="mod1">
<port fl="e18" name="q" direction="out" portIndex="1">
<varref fl="e18" name="between" dtype_id="2"/>
</port>
<port fl="e21" name="clk" direction="in" portIndex="2">
<varref fl="e21" name="clk" dtype_id="1"/>
</port>
<port fl="e22" name="d" direction="in" portIndex="3">
<varref fl="e22" name="d" dtype_id="2"/>
</port>
</instance>
<instance fl="e24" name="cell2" defName="mod2">
<port fl="e24" name="d" direction="in" portIndex="1">
<varref fl="e24" name="between" dtype_id="2"/>
</port>
<port fl="e27" name="q" direction="out" portIndex="2">
<varref fl="e27" name="q" dtype_id="2"/>
</port>
<port fl="e29" name="clk" direction="in" portIndex="3">
<varref fl="e29" name="clk" dtype_id="1"/>
</port>
</instance>
</module>
<module fl="e33" name="mod1">
<var fl="e35" name="clk" dtype_id="1"/>
<var fl="e36" name="d" dtype_id="2"/>
<var fl="e37" name="q" dtype_id="2"/>
<always fl="e39">
<sentree fl="e39">
<senitem fl="e39">
<varref fl="e39" name="clk" dtype_id="1"/>
</senitem>
</sentree>
<assigndly fl="e40" dtype_id="2">
<varref fl="e40" name="d" dtype_id="2"/>
<varref fl="e40" name="q" dtype_id="2"/>
</assigndly>
</always>
</module>
<module fl="e44" name="mod2">
<var fl="e46" name="clk" dtype_id="1"/>
<var fl="e47" name="d" dtype_id="2"/>
<var fl="e48" name="q" dtype_id="2"/>
<contassign fl="e51" dtype_id="2">
<varref fl="e51" name="d" dtype_id="2"/>
<varref fl="e51" name="q" dtype_id="2"/>
</contassign>
</module>
<typetable fl="a0">
<basicdtype fl="e46" id="1" name="logic"/>
<basicdtype fl="e13" id="2" name="logic" left="3" right="0"/>
</typetable>
</netlist>
</verilator_xml>

View File

@ -16,7 +16,6 @@ compile (
verilator_make_gcc => 0,
);
file_grep ($out_filename, qr/<verilator_xml>/);
ok(1);
ok(files_identical("$out_filename", "t/$Self->{name}.out"));
1;

View File

@ -17,18 +17,25 @@
<var fl="e23" name="this_struct" dtype_id="3"/>
</module>
<typetable fl="a0">
<basicdtype fl="e23" id="4" name="logic" left="31" right="0"/>
<basicdtype fl="e8" id="1" name="logic"/>
<structdtype fl="e14" id="2">
<memberdtype fl="e15" id="4" name="clk" tag="this is clk" sub_dtype_id="5"/>
<memberdtype fl="e16" id="6" name="k" sub_dtype_id="7"/>
<memberdtype fl="e17" id="8" name="enable" tag="enable" sub_dtype_id="9"/>
<memberdtype fl="e18" id="10" name="data" tag="data" sub_dtype_id="11"/>
<memberdtype fl="e15" id="5" name="clk" tag="this is clk" sub_dtype_id="6"/>
<memberdtype fl="e16" id="7" name="k" sub_dtype_id="8"/>
<memberdtype fl="e17" id="9" name="enable" tag="enable" sub_dtype_id="10"/>
<memberdtype fl="e18" id="11" name="data" tag="data" sub_dtype_id="12"/>
</structdtype>
<basicdtype fl="e15" id="5" name="logic"/>
<basicdtype fl="e16" id="7" name="logic"/>
<basicdtype fl="e17" id="9" name="logic"/>
<basicdtype fl="e18" id="11" name="logic"/>
<refdtype fl="e23" id="3" name="my_struct" sub_dtype_id="2"/>
<basicdtype fl="e15" id="6" name="logic"/>
<basicdtype fl="e16" id="8" name="logic"/>
<basicdtype fl="e17" id="10" name="logic"/>
<basicdtype fl="e18" id="12" name="logic"/>
<unpackarraydtype fl="e23" id="3" sub_dtype_id="2">
<range fl="e23">
<const fl="e23" name="32'h1" dtype_id="4"/>
<const fl="e23" name="32'h0" dtype_id="4"/>
</range>
</unpackarraydtype>
<refdtype fl="e23" id="13" name="my_struct" sub_dtype_id="2"/>
</typetable>
</netlist>
</verilator_xml>

View File

@ -20,6 +20,6 @@ module m
// This is a comment
my_struct this_struct;
my_struct this_struct [2];
endmodule