Fix array of struct references giving false error, bug566.

This commit is contained in:
Wilson Snyder 2012-11-03 09:17:42 -04:00
parent 0431b1909c
commit 6cd9b25a53
4 changed files with 62 additions and 4 deletions

View File

@ -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]

View File

@ -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," "<<nodep<<endl);

View File

@ -0,0 +1,18 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
compile (
);
execute (
check_finished=>1,
);
ok(1);
1;

View File

@ -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<n;i++)
a_out[i].stuff = i[0];
end
endmodule
// Local Variables:
// verilog-typedef-regexp: "_t$"
// End: