diff --git a/Changes b/Changes index bb3b4384a..9a51dad5c 100644 --- a/Changes +++ b/Changes @@ -5,15 +5,15 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.813**** -**** Support bit vectors > 64 bits wide in DPI import and exports. - -**** Fix error on enum references to other packages, bug339. [Alex Solomatnikov] +*** Support bit vectors > 64 bits wide in DPI import and exports. *** Fix out of memory on slice syntax error, bug354. [Alex Solomatnikov] +**** Fix error on enum references to other packages, bug339. [Alex Solomatnikov] + **** Fix DPI undeclared svBitVecVal compile error, bug346. [Chandan Egbert] -**** Fix DPI bit vector compile errors, bug347. [Chandan Egbert] +**** Fix DPI bit vector compile errors, bug347, bug359. [Chandan Egbert] **** Fix CDCRSTLOGIC report showing endpoint flops without resets. diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 572312c1a..96761b907 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -127,6 +127,7 @@ public: nodep->lhsp()->iterateAndNext(*this); puts(", "); } else if (nodep->isWide() && nodep->lhsp()->castVarRef() + && !nodep->rhsp()->castCMath() && !nodep->rhsp()->castVarRef() && !nodep->rhsp()->castArraySel()) { // Wide functions assign into the array directly, don't need separate assign statement diff --git a/test_regress/t/t_dpi_export.v b/test_regress/t/t_dpi_export.v index 516a7bfb5..9f02d8f92 100644 --- a/test_regress/t/t_dpi_export.v +++ b/test_regress/t/t_dpi_export.v @@ -40,6 +40,8 @@ module t; export "DPI-C" task dpix_t_bit95; task dpix_t_bit95(input bit [94:0] i, output bit [94:0] o); o = ~i; endtask + export "DPI-C" task dpix_t_bit96; + task dpix_t_bit96(input bit [95:0] i, output bit [95:0] o); o = ~i; endtask int lineno; diff --git a/test_regress/t/t_dpi_export_c.cpp b/test_regress/t/t_dpi_export_c.cpp index 9bc0d519a..b343a8e12 100644 --- a/test_regress/t/t_dpi_export_c.cpp +++ b/test_regress/t/t_dpi_export_c.cpp @@ -144,6 +144,14 @@ int dpix_run_tests() { CHECK_RESULT(int, o_vec95[1], ~i_vec95[1]); CHECK_RESULT(int, o_vec95[2], (~i_vec95[2])&0x7fffffffUL); } + { + svBitVecVal i_vec96[3] = {0xf2912312,0xab782a12,0x8a413bd9}; + svBitVecVal o_vec96[3] = {0,0,0}; + dpix_t_bit96(i_vec96, o_vec96); + CHECK_RESULT(int, o_vec96[0], ~i_vec96[0]); + CHECK_RESULT(int, o_vec96[1], ~i_vec96[1]); + CHECK_RESULT(int, o_vec96[2], ~i_vec96[2]); + } if (int bad=check_sub("top.t.a",1)) return bad; if (int bad=check_sub("top.t.b",2)) return bad; diff --git a/test_regress/t/t_dpi_import.v b/test_regress/t/t_dpi_import.v index 33edd4da9..6661a3eb3 100644 --- a/test_regress/t/t_dpi_import.v +++ b/test_regress/t/t_dpi_import.v @@ -60,6 +60,7 @@ module t (); import "DPI-C" pure function void dpii_v_shortreal(input shortreal i, output shortreal o); `endif 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); import "DPI-C" pure function int dpii_f_strlen (input string i); @@ -84,6 +85,7 @@ module t (); bit [32:0] i_b33, o_b33; bit [63:0] i_b64, o_b64; bit [94:0] i_b95, o_b95; + bit [95:0] i_b96, o_b96; int i_i, o_i; byte i_y, o_y; @@ -114,6 +116,7 @@ module t (); i_b33 = {1'b1,wide[33-2:0]}; i_b64 = {1'b1,wide[64-2:0]}; i_b95 = {1'b1,wide[95-2:0]}; + i_b96 = {1'b1,wide[96-2:0]}; i_i = {1'b1,wide[32-2:0]}; i_y = {1'b1,wide[8-2:0]}; @@ -163,6 +166,7 @@ module t (); dpii_v_shortreal(i_f,o_f); if (o_f != i_f+1.5) $stop; `endif 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; if (dpii_f_strlen ("")!=0) $stop; if (dpii_f_strlen ("s")!=1) $stop; diff --git a/test_regress/t/t_dpi_import_c.cpp b/test_regress/t/t_dpi_import_c.cpp index 3fe8150bf..c4345ab6c 100644 --- a/test_regress/t/t_dpi_import_c.cpp +++ b/test_regress/t/t_dpi_import_c.cpp @@ -106,6 +106,11 @@ void dpii_v_bit95(const svBitVecVal* i, svBitVecVal* o) { o[1] = ~i[1]; o[2] = SV_MASK(95-64) & ~i[2]; } +void dpii_v_bit96(const svBitVecVal* i, svBitVecVal* o) { + o[0] = ~i[0]; + o[1] = ~i[1]; + o[2] = ~i[2]; +} int dpii_f_strlen (const char* i) { return strlen(i); }