From e080b9d565cecb1864a4df39a9ffe910d85e4ff2 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 7 Oct 2011 19:47:10 -0400 Subject: [PATCH] Fix DPI import output of 64 bits, bug398. --- Changes | 2 ++ src/V3Task.cpp | 5 +++++ test_regress/t/t_dpi_import.v | 2 ++ test_regress/t/t_dpi_import_c.cpp | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/Changes b/Changes index 060d0d189..45495b449 100644 --- a/Changes +++ b/Changes @@ -13,6 +13,8 @@ indicates the contributor was also the author of the fix; Thanks! *** Fix --help output to go to stderr, not stdout, bug397. [Ruben Diez] +**** Fix DPI import output of 64 bits, bug398. [Mike Denio] + **** Fix MSVC compile warning with trunc/round, bug394. [Amir Gonnen] **** Fix autoconf and Makefile warnings, bug396. [Ruben Diez] diff --git a/src/V3Task.cpp b/src/V3Task.cpp index f4829f104..28e9dce8f 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -618,6 +618,11 @@ private: stmt += "VL_CVT_VP_Q("; ket += ")"; } + else if (portp->basicp() && portp->basicp()->isBitLogic() && portp->widthMin() != 1 && portp->isQuad()) { + // SV is vector, Verilator isn't + stmt += "VL_SET_QW("; + ket += ")"; + } if (!cvt && portp->basicp() && portp->basicp()->isBitLogic() && portp->widthMin() != 1 && !portp->isWide()) stmt += "*"; // it's a svBitVecVal, which other code won't think is arrayed (as WData aren't), but really is diff --git a/test_regress/t/t_dpi_import.v b/test_regress/t/t_dpi_import.v index ae2ddec79..3efff0f5d 100644 --- a/test_regress/t/t_dpi_import.v +++ b/test_regress/t/t_dpi_import.v @@ -55,6 +55,7 @@ module t (); `ifndef NO_SHORTREAL import "DPI-C" pure function void dpii_v_shortreal(input shortreal i, output shortreal o); `endif + import "DPI-C" pure function void dpii_v_bit64 (input bit [64-1:0] i, output bit [64-1:0] o); import "DPI-C" pure function void dpii_v_bit95 (input bit [95-1:0] i, output bit [95-1:0] o); import "DPI-C" pure function void dpii_v_bit96 (input bit [96-1:0] i, output bit [96-1:0] o); @@ -161,6 +162,7 @@ module t (); `ifndef NO_SHORTREAL dpii_v_shortreal(i_f,o_f); if (o_f != i_f+1.5) $stop; `endif + dpii_v_bit64 (i_b64,o_b64); if (o_b64 !== ~i_b64) $stop; dpii_v_bit95 (i_b95,o_b95); if (o_b95 !== ~i_b95) $stop; dpii_v_bit96 (i_b96,o_b96); if (o_b96 !== ~i_b96) $stop; diff --git a/test_regress/t/t_dpi_import_c.cpp b/test_regress/t/t_dpi_import_c.cpp index c4345ab6c..1340e1fa1 100644 --- a/test_regress/t/t_dpi_import_c.cpp +++ b/test_regress/t/t_dpi_import_c.cpp @@ -101,6 +101,10 @@ void dpii_v_string (const char* i, const char** o) { *o = i; } void dpii_v_real (double i, double* o) { *o = i + 1.5; } void dpii_v_shortreal(float i, float* o) { *o = i + 1.5; } +void dpii_v_bit64(const svBitVecVal* i, svBitVecVal* o) { + o[0] = ~i[0]; + o[1] = ~i[1]; +} void dpii_v_bit95(const svBitVecVal* i, svBitVecVal* o) { o[0] = ~i[0]; o[1] = ~i[1];