Fix UNDRIVEN warnings inside DPI import functions.

This commit is contained in:
Wilson Snyder 2011-10-07 08:29:34 -04:00
parent 194825f78e
commit ca2db37039
6 changed files with 33 additions and 13 deletions

View File

@ -7,10 +7,12 @@ indicates the contributor was also the author of the fix; Thanks!
*** Support $ceil, $floor, etc. [Alex Solomatnikov] *** Support $ceil, $floor, etc. [Alex Solomatnikov]
*** Fix --help output to go to stderr, not stdout, bug397. [Ruben Diez]
*** Add configure options for cc warnings and extended tests. [Ruben Diez] *** Add configure options for cc warnings and extended tests. [Ruben Diez]
*** Fix UNDRIVEN warnings inside DPI import functions. [Ruben Diez]
*** Fix --help output to go to stderr, not stdout, bug397. [Ruben Diez]
**** Fix MSVC compile warning with trunc/round, bug394. [Amir Gonnen] **** Fix MSVC compile warning with trunc/round, bug394. [Amir Gonnen]
**** Fix autoconf and Makefile warnings, bug396. [Ruben Diez] **** Fix autoconf and Makefile warnings, bug396. [Ruben Diez]

View File

@ -217,6 +217,7 @@ private:
// STATE // STATE
vector<UndrivenVarEntry*> m_entryps; // Nodes to delete when we are finished vector<UndrivenVarEntry*> m_entryps; // Nodes to delete when we are finished
bool m_markBoth; // Mark as driven+used bool m_markBoth; // Mark as driven+used
AstNodeFTask* m_taskp; // Current task
// METHODS // METHODS
static int debug() { static int debug() {
@ -241,12 +242,14 @@ private:
virtual void visit(AstVar* nodep, AstNUser*) { virtual void visit(AstVar* nodep, AstNUser*) {
UndrivenVarEntry* entryp = getEntryp (nodep); UndrivenVarEntry* entryp = getEntryp (nodep);
if (nodep->isInput() if (nodep->isInput()
|| nodep->isSigPublic() || nodep->isSigUserRWPublic()) { || nodep->isSigPublic() || nodep->isSigUserRWPublic()
|| (m_taskp && (m_taskp->dpiImport() || m_taskp->dpiExport()))) {
entryp->drivenWhole(); entryp->drivenWhole();
} }
if (nodep->isOutput() if (nodep->isOutput()
|| nodep->isSigPublic() || nodep->isSigUserRWPublic() || nodep->isSigPublic() || nodep->isSigUserRWPublic()
|| nodep->isSigUserRdPublic()) { || nodep->isSigUserRdPublic()
|| (m_taskp && (m_taskp->dpiImport() || m_taskp->dpiExport()))) {
entryp->usedWhole(); entryp->usedWhole();
} }
// Discover variables used in bit definitions, etc // Discover variables used in bit definitions, etc
@ -284,6 +287,13 @@ private:
m_markBoth = prevMark; m_markBoth = prevMark;
} }
virtual void visit(AstNodeFTask* nodep, AstNUser*) {
AstNodeFTask* prevTaskp = m_taskp;
m_taskp = nodep;
nodep->iterateChildren(*this);
m_taskp = prevTaskp;
}
// Until we support tables, primitives will have undriven and unused I/Os // Until we support tables, primitives will have undriven and unused I/Os
virtual void visit(AstPrimitive* nodep, AstNUser*) {} virtual void visit(AstPrimitive* nodep, AstNUser*) {}
@ -303,6 +313,7 @@ public:
// CONSTUCTORS // CONSTUCTORS
UndrivenVisitor(AstNetlist* nodep) { UndrivenVisitor(AstNetlist* nodep) {
m_markBoth = false; m_markBoth = false;
m_taskp = NULL;
nodep->accept(*this); nodep->accept(*this);
} }
virtual ~UndrivenVisitor() { virtual ~UndrivenVisitor() {

View File

@ -65,6 +65,7 @@ Getopt::Long::config ("pass_through");
if (! GetOptions ( if (! GetOptions (
"benchmark:i" => sub { $opt_benchmark = $_[1] ? $_[1] : 1; }, "benchmark:i" => sub { $opt_benchmark = $_[1] ? $_[1] : 1; },
"debug" => \&debug, "debug" => \&debug,
#debugi see parameter()
"atsim|athdl!"=> \$opt_atsim, "atsim|athdl!"=> \$opt_atsim,
"gdb!" => \$opt_gdb, "gdb!" => \$opt_gdb,
"gdbbt!" => \$opt_gdbbt, "gdbbt!" => \$opt_gdbbt,
@ -84,6 +85,7 @@ if (! GetOptions (
"vcs!" => \$opt_vcs, "vcs!" => \$opt_vcs,
"verbose!" => \$opt_verbose, "verbose!" => \$opt_verbose,
"verilated_debug!" => \$Opt_Verilated_Debug, "verilated_debug!" => \$Opt_Verilated_Debug,
#W see parameter()
"<>" => \&parameter, "<>" => \&parameter,
)) { )) {
die "%Error: Bad usage, try '$0 --help'\n"; die "%Error: Bad usage, try '$0 --help'\n";
@ -205,6 +207,9 @@ sub parameter {
push @Opt_Driver_Verilator_Flags, $param; push @Opt_Driver_Verilator_Flags, $param;
$_Parameter_Next_Level = $param; $_Parameter_Next_Level = $param;
} }
elsif ($param =~ /^-?-W/) {
push @Opt_Driver_Verilator_Flags, $param;
}
else { else {
die "%Error: Unknown parameter: $param\n"; die "%Error: Unknown parameter: $param\n";
} }

View File

@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
compile ( compile (
# Amazingly VCS, NC and Verilator all just accept the C file here! # Amazingly VCS, NC and Verilator all just accept the C file here!
v_flags2 => ["t/t_dpi_export_c.cpp"], v_flags2 => ["-Wall -Wno-DECLFILENAME t/t_dpi_export_c.cpp"],
verilator_flags2 => ["-no-l2name"], verilator_flags2 => ["-no-l2name"],
); );

View File

@ -9,7 +9,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di
compile ( compile (
# Amazingly VCS, NC and Verilator all just accept the C file here! # Amazingly VCS, NC and Verilator all just accept the C file here!
v_flags2 => ["t/t_dpi_import_c.cpp"], v_flags2 => ["-Wall -Wno-DECLFILENAME t/t_dpi_import_c.cpp"],
); );
execute ( execute (

View File

@ -73,11 +73,11 @@ module t ();
import "DPI-C" dpii_fa_bit = function int oth_f_int2(input int i); import "DPI-C" dpii_fa_bit = function int oth_f_int2(input int i);
bit i_b, o_b; bit i_b, o_b;
bit [7:0] i_b8, o_b8; bit [7:0] i_b8;
bit [8:0] i_b9, o_b9; bit [8:0] i_b9;
bit [15:0] i_b16, o_b16; bit [15:0] i_b16;
bit [16:0] i_b17, o_b17; bit [16:0] i_b17;
bit [31:0] i_b32, o_b32; bit [31:0] i_b32;
bit [32:0] i_b33, o_b33; bit [32:0] i_b33, o_b33;
bit [63:0] i_b64, o_b64; bit [63:0] i_b64, o_b64;
bit [94:0] i_b95, o_b95; bit [94:0] i_b95, o_b95;
@ -87,19 +87,21 @@ module t ();
byte i_y, o_y; byte i_y, o_y;
shortint i_s, o_s; shortint i_s, o_s;
longint i_l, o_l; longint i_l, o_l;
// verilator lint_off UNDRIVEN
chandle i_c, o_c; chandle i_c, o_c;
string i_n, o_n; string i_n, o_n;
// verilator lint_on UNDRIVEN
real i_d, o_d; real i_d, o_d;
`ifndef NO_SHORTREAL `ifndef NO_SHORTREAL
shortreal i_f, o_f; shortreal i_f, o_f;
`endif `endif
bit [127:0] wide; bit [94:0] wide;
bit [6*8:1] string6; bit [6*8:1] string6;
initial begin initial begin
wide = 128'h36f3e51d15caff7a73c48afee4ffcb57; wide = 95'h15caff7a73c48afee4ffcb57;
i_b = 1'b1; i_b = 1'b1;
i_b8 = {1'b1,wide[8-2:0]}; i_b8 = {1'b1,wide[8-2:0]};