diff --git a/Changes b/Changes index f2cad212f..060d0d189 100644 --- a/Changes +++ b/Changes @@ -7,10 +7,12 @@ indicates the contributor was also the author of the fix; Thanks! *** 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] +*** 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 autoconf and Makefile warnings, bug396. [Ruben Diez] diff --git a/src/V3Undriven.cpp b/src/V3Undriven.cpp index fe7c801df..dcbdbfb28 100644 --- a/src/V3Undriven.cpp +++ b/src/V3Undriven.cpp @@ -217,6 +217,7 @@ private: // STATE vector m_entryps; // Nodes to delete when we are finished bool m_markBoth; // Mark as driven+used + AstNodeFTask* m_taskp; // Current task // METHODS static int debug() { @@ -241,12 +242,14 @@ private: virtual void visit(AstVar* nodep, AstNUser*) { UndrivenVarEntry* entryp = getEntryp (nodep); if (nodep->isInput() - || nodep->isSigPublic() || nodep->isSigUserRWPublic()) { + || nodep->isSigPublic() || nodep->isSigUserRWPublic() + || (m_taskp && (m_taskp->dpiImport() || m_taskp->dpiExport()))) { entryp->drivenWhole(); } if (nodep->isOutput() || nodep->isSigPublic() || nodep->isSigUserRWPublic() - || nodep->isSigUserRdPublic()) { + || nodep->isSigUserRdPublic() + || (m_taskp && (m_taskp->dpiImport() || m_taskp->dpiExport()))) { entryp->usedWhole(); } // Discover variables used in bit definitions, etc @@ -284,6 +287,13 @@ private: 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 virtual void visit(AstPrimitive* nodep, AstNUser*) {} @@ -303,6 +313,7 @@ public: // CONSTUCTORS UndrivenVisitor(AstNetlist* nodep) { m_markBoth = false; + m_taskp = NULL; nodep->accept(*this); } virtual ~UndrivenVisitor() { diff --git a/test_regress/driver.pl b/test_regress/driver.pl index 0eb5a4500..94245cf07 100755 --- a/test_regress/driver.pl +++ b/test_regress/driver.pl @@ -65,6 +65,7 @@ Getopt::Long::config ("pass_through"); if (! GetOptions ( "benchmark:i" => sub { $opt_benchmark = $_[1] ? $_[1] : 1; }, "debug" => \&debug, + #debugi see parameter() "atsim|athdl!"=> \$opt_atsim, "gdb!" => \$opt_gdb, "gdbbt!" => \$opt_gdbbt, @@ -84,6 +85,7 @@ if (! GetOptions ( "vcs!" => \$opt_vcs, "verbose!" => \$opt_verbose, "verilated_debug!" => \$Opt_Verilated_Debug, + #W see parameter() "<>" => \¶meter, )) { die "%Error: Bad usage, try '$0 --help'\n"; @@ -205,6 +207,9 @@ sub parameter { push @Opt_Driver_Verilator_Flags, $param; $_Parameter_Next_Level = $param; } + elsif ($param =~ /^-?-W/) { + push @Opt_Driver_Verilator_Flags, $param; + } else { die "%Error: Unknown parameter: $param\n"; } diff --git a/test_regress/t/t_dpi_export.pl b/test_regress/t/t_dpi_export.pl index bbe758e10..494e1c8fc 100755 --- a/test_regress/t/t_dpi_export.pl +++ b/test_regress/t/t_dpi_export.pl @@ -11,7 +11,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di compile ( # 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"], ); diff --git a/test_regress/t/t_dpi_import.pl b/test_regress/t/t_dpi_import.pl index 708ef7b4a..d9776a553 100755 --- a/test_regress/t/t_dpi_import.pl +++ b/test_regress/t/t_dpi_import.pl @@ -9,7 +9,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); di compile ( # 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 ( diff --git a/test_regress/t/t_dpi_import.v b/test_regress/t/t_dpi_import.v index c6686cfe6..ae2ddec79 100644 --- a/test_regress/t/t_dpi_import.v +++ b/test_regress/t/t_dpi_import.v @@ -73,11 +73,11 @@ module t (); import "DPI-C" dpii_fa_bit = function int oth_f_int2(input int i); bit i_b, o_b; - bit [7:0] i_b8, o_b8; - bit [8:0] i_b9, o_b9; - bit [15:0] i_b16, o_b16; - bit [16:0] i_b17, o_b17; - bit [31:0] i_b32, o_b32; + bit [7:0] i_b8; + bit [8:0] i_b9; + bit [15:0] i_b16; + bit [16:0] i_b17; + bit [31:0] i_b32; bit [32:0] i_b33, o_b33; bit [63:0] i_b64, o_b64; bit [94:0] i_b95, o_b95; @@ -87,19 +87,21 @@ module t (); byte i_y, o_y; shortint i_s, o_s; longint i_l, o_l; + // verilator lint_off UNDRIVEN chandle i_c, o_c; string i_n, o_n; + // verilator lint_on UNDRIVEN real i_d, o_d; `ifndef NO_SHORTREAL shortreal i_f, o_f; `endif - bit [127:0] wide; + bit [94:0] wide; bit [6*8:1] string6; initial begin - wide = 128'h36f3e51d15caff7a73c48afee4ffcb57; + wide = 95'h15caff7a73c48afee4ffcb57; i_b = 1'b1; i_b8 = {1'b1,wide[8-2:0]};