Fix error on parameters with dotted references, bug1146.

This commit is contained in:
Wilson Snyder 2017-03-28 19:55:20 -04:00
parent c27a60658f
commit e9125a3a22
4 changed files with 45 additions and 1 deletions

View File

@ -29,6 +29,8 @@ The contributors that suggested a given feature are shown in []. Thanks!
**** Fix missing error on interface size mismatch, bug1143. [Johan Bjork]
**** Fix error on parameters with dotted references, bug1146. [Johan Bjork]
* Verilator 3.900 2017-01-15

View File

@ -1184,7 +1184,14 @@ private:
}
virtual void visit(AstNodeVarRef* nodep) {
if (nodep->didWidth()) return;
if (!nodep->varp()) nodep->v3fatalSrc("Unlinked varref");
if (!nodep->varp()) {
if (m_paramsOnly && nodep->castVarXRef()) {
checkConstantOrReplace(nodep, "Parameter-resolved constants must not use dotted references: "+nodep->prettyName()); VL_DANGLING(nodep);
return;
} else {
nodep->v3fatalSrc("Unlinked varref");
}
}
if (!nodep->varp()->didWidth()) {
// Var hasn't been widthed, so make it so.
userIterate(nodep->varp(), NULL);

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 (
fails=>1,
expect=>
q{%Error: t/t_interface_param_another_bad.v:\d+: Parameter-resolved constants must not use dotted references: dummy
%Error: Exiting due to.*},
);
ok(1);
1;

View File

@ -0,0 +1,17 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2017 by Johan Bjork.
module t ();
simple_bus sb_intf();
simple_bus #(.PARAMETER($bits(sb_intf.dummy))) simple();
initial begin
$write("*-* All Finished *-*\n");
$finish;
end
endmodule
interface simple_bus #(PARAMETER = 0);
logic dummy;
endinterface