diff --git a/Changes b/Changes index 39befa53f..4191175e0 100644 --- a/Changes +++ b/Changes @@ -8,6 +8,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Suppress VARHIDDEN on dpi import arguments. [Ruben Diez] +**** Fix dpi exports with > 32 bit but < 64 bit args, bug423. [Chandan Egbert] + * Verilator 3.830 2011/11/27 diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 052ff2343..683021643 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -627,7 +627,7 @@ private: ket += ")"; } if (!cvt - && portp->basicp() && portp->basicp()->isBitLogic() && portp->widthMin() != 1 && !portp->isWide()) + && portp->basicp() && portp->basicp()->isBitLogic() && portp->widthMin() != 1 && !portp->isWide() && !portp->isQuad()) stmt += "*"; // it's a svBitVecVal, which other code won't think is arrayed (as WData aren't), but really is stmt += frName; stmt += ket; diff --git a/test_regress/t/t_dpi_qw.pl b/test_regress/t/t_dpi_qw.pl new file mode 100755 index 000000000..cd7f6f5d3 --- /dev/null +++ b/test_regress/t/t_dpi_qw.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2011 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 ( + v_flags2 => ["t/t_dpi_qw_c.cpp"], + verilator_flags2 => ["-Wall -Wno-DECLFILENAME -no-l2name"], + ); + +execute ( + check_finished=>1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_dpi_qw.v b/test_regress/t/t_dpi_qw.v new file mode 100644 index 000000000..e7d1fb455 --- /dev/null +++ b/test_regress/t/t_dpi_qw.v @@ -0,0 +1,41 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// Copyright 2009 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. + +module t; + + wire [39:0] out; + sub a(.value(out)); + + import "DPI-C" context function void poke_value(input int i); + + + initial begin + poke_value(32'hdeadbeef); + if (out !== 40'hdeadbeef) begin + $display("[%0t] %%Error: t_dpi_qw: failed", $time); + $stop; + end + + $write("*-* All Finished *-*\n"); + $finish; + end + +endmodule + +module sub(value); + parameter WIDTH = 40; + + output [WIDTH-1:0] value; + + reg [WIDTH-1:0] value; + + task set_value(input bit [WIDTH-1:0] v); + value = v; + endtask + + export "DPI-C" task set_value; +endmodule diff --git a/test_regress/t/t_dpi_qw_c.cpp b/test_regress/t/t_dpi_qw_c.cpp new file mode 100644 index 000000000..b8af96eda --- /dev/null +++ b/test_regress/t/t_dpi_qw_c.cpp @@ -0,0 +1,44 @@ +// -*- C++ -*- +// DESCRIPTION: Verilator: Verilog Test module +// +// Copyright 2009 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. +//************************************************************************* + +#include +#include +#include "svdpi.h" + +//====================================================================== + +#include "Vt_dpi_qw__Dpi.h" + +//====================================================================== + +// Called from our Verilog code to run the tests +void poke_value(int i) { + printf("poke_value(%d)\n", i); + +#ifdef VERILATOR + static int didDump = 0; + if (didDump++ == 0) { +# ifdef TEST_VERBOSE + Verilated::scopesDump(); +# endif + } +#endif + + svScope scope = svGetScopeFromName("top.t.a"); + if (scope == NULL) { + printf("%%Error: null scope for top.t.a\n"); + return; + } + + svSetScope(scope); + svBitVecVal val[2]; + val[0] = i; + val[1] = 0; + set_value(val); +}