diff --git a/Changes b/Changes index 923bc65a4..3877b1e8b 100644 --- a/Changes +++ b/Changes @@ -13,6 +13,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix $display mangling on GCC 4.7 and speed up, msg927, bug373. [R Diez] +**** Fix array of struct references giving false error, bug566. [Julius Baxter] + **** Fix missing var access functions when no DPI, bug572. [Amir Gonnen] **** Fix name collision on unnamed blocks, bug567. [Chandan Egbert] diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 2e2b51e50..a1e6013a9 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -1019,7 +1019,7 @@ private: AstCell* m_cellp; // Current cell AstNodeModule* m_modp; // Current module AstNodeFTask* m_ftaskp; // Current function/task - AstDot* m_dotp; // Current dot + AstDot* m_dotp; // Current dot DotPosition m_dotPos; // Scope part of dotted resolution bool m_dotErr; // Error found in dotted resolution, ignore upwards string m_dotText; // String of dotted names found in below parseref @@ -1252,6 +1252,7 @@ private: if (m_dotText!="") m_dotText += "."; m_dotText += nodep->name(); m_dotSymp = foundp; + m_dotPos = DP_SCOPE; // Upper AstDot visitor will handle it from here } } @@ -1471,8 +1472,8 @@ private: } virtual void visit(AstSelBit* nodep, AstNUser*) { if (nodep->user3SetOnce()) return; + nodep->lhsp()->iterateAndNext(*this); if (m_dotPos == DP_SCOPE) { // Already under dot, so this is {modulepart} DOT {modulepart} - nodep->lhsp()->iterateAndNext(*this); if (AstConst* constp = nodep->rhsp()->castConst()) { string index = AstNode::encodeNumber(constp->toSInt()); m_dotText += "__BRA__"+index+"__KET__"; @@ -1480,9 +1481,9 @@ private: nodep->v3error("Unsupported: Non-constant inside []'s in the cell part of a dotted reference"); } // And pass up m_dotText - } else { - nodep->iterateChildren(*this); } + nodep->fromp()->iterateAndNext(*this); + nodep->bitp()->iterateAndNext(*this); } virtual void visit(AstBegin* nodep, AstNUser*) { UINFO(5," "<1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_struct_array.v b/test_regress/t/t_struct_array.v new file mode 100644 index 000000000..614e537e3 --- /dev/null +++ b/test_regress/t/t_struct_array.v @@ -0,0 +1,37 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2012 by Wilson Snyder. + +package TEST_TYPES; + typedef struct packed { + logic stuff; + } a_struct_t; +endpackage // TEST_TYPES + +module t(clk); + input clk; + TEST_TYPES::a_struct_t [3:0] a_out; + sub sub (.a_out); + always @ (posedge clk) begin + if (a_out[0] != 1'b0) $stop; + if (a_out[1] != 1'b1) $stop; + if (a_out[2] != 1'b0) $stop; + if (a_out[3] != 1'b1) $stop; + $write("*-* All Finished *-*\n"); + $finish; + end +endmodule + +module sub(a_out); + parameter n = 4; + output TEST_TYPES::a_struct_t [n-1:0] a_out; + always_comb begin + for (int i=0;i