Fix imports causing symbol table error, bug490.

This commit is contained in:
Wilson Snyder 2012-04-24 21:21:26 -04:00
parent fb90e47e70
commit f3867d7f80
5 changed files with 58 additions and 6 deletions

View File

@ -15,6 +15,7 @@ indicates the contributor was also the author of the fix; Thanks!
*** Fix generate operators not short circuiting, bug413. [by Jeremy Bennett]
**** Fix imports causing symbol table error, bug490. [Alex Solomatnikov]
* Verilator 3.833 2012/04/15

View File

@ -215,18 +215,17 @@ private:
}
// VISITs
virtual void visit(AstNetlist* nodep, AstNUser*) {
virtual void visit(AstNetlist* nodep, AstNUser* vup) {
// Top scope
m_curVarsp = symsFindNew(nodep, NULL);
// And recurse...
// Recurse...
// Recurse..., backward as must do packages before using packages
m_idState = ID_FIND;
nodep->iterateChildren(*this);
nodep->iterateChildrenBackwards(*this);
if (debug()==9) m_curVarsp->dump(cout,"-curvars: ",true/*user4p_is_table*/);
m_idState = ID_PARAM;
nodep->iterateChildren(*this);
nodep->iterateChildrenBackwards(*this);
m_idState = ID_RESOLVE;
nodep->iterateChildren(*this);
nodep->iterateChildrenBackwards(*this);
nodep->checkTree();
}

View File

@ -176,6 +176,13 @@ private:
m_modp = NULL;
}
virtual void visit(AstPackageImport* nodep, AstNUser*) {
// Package Import: We need to do the package before the use of a package
nodep->iterateChildren(*this);
if (!nodep->packagep()) nodep->v3fatalSrc("Unlinked package"); // Parser should set packagep
new V3GraphEdge(&m_graph, vertex(m_modp), vertex(nodep->packagep()), 1, false);
}
virtual void visit(AstCell* nodep, AstNUser*) {
// Cell: Resolve its filename. If necessary, parse it.
if (!nodep->modp()) {

18
test_regress/t/t_package_abs.pl Executable file
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,27 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2012 by Wilson Snyder.
// see bug491
package functions;
function real abs (real num);
abs = (num <0) ? -num : num;
endfunction
endpackage
module t ();
import functions::*;
localparam P = 1;
generate
if (P == 1) begin
initial begin
if (abs(-2.1) != 2.1) $stop;
if (abs(2.2) != 2.2) $stop;
$write("*-* All Finished *-*\n");
$finish;
end
end
endgenerate
endmodule