diff --git a/include/verilated_funcs.h b/include/verilated_funcs.h index 4202d9cd3..e311fc9c8 100644 --- a/include/verilated_funcs.h +++ b/include/verilated_funcs.h @@ -2289,7 +2289,7 @@ inline QData VL_PACK_Q_UQ(int /*obits*/, int lbits, const VlUnpacked& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); if (VL_UNLIKELY(obits < q.size() * lbits)) return owp; // Though is illegal for q to be larger const int offset = obits - q.size() * lbits; for (size_t i = 0; i < q.size(); ++i) @@ -2299,7 +2299,7 @@ inline WDataOutP VL_PACK_W_RI(int obits, int lbits, WDataOutP owp, const VlQueue } inline WDataOutP VL_PACK_W_RI(int obits, int lbits, WDataOutP owp, const VlQueue& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); if (VL_UNLIKELY(obits < q.size() * lbits)) return owp; // Though is illegal for q to be larger const int offset = obits - q.size() * lbits; for (size_t i = 0; i < q.size(); ++i) @@ -2309,7 +2309,7 @@ inline WDataOutP VL_PACK_W_RI(int obits, int lbits, WDataOutP owp, const VlQueue } inline WDataOutP VL_PACK_W_RI(int obits, int lbits, WDataOutP owp, const VlQueue& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); if (VL_UNLIKELY(obits < q.size() * lbits)) return owp; // Though is illegal for q to be larger const int offset = obits - q.size() * lbits; for (size_t i = 0; i < q.size(); ++i) @@ -2321,7 +2321,7 @@ inline WDataOutP VL_PACK_W_RI(int obits, int lbits, WDataOutP owp, const VlQueue template inline WDataOutP VL_PACK_W_UI(int obits, int lbits, WDataOutP owp, const VlUnpacked& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); for (size_t i = 0; i < N_Depth; ++i) _vl_insert_WI(owp, q[N_Depth - 1 - i], i * lbits + lbits - 1, i * lbits); return owp; @@ -2330,7 +2330,7 @@ inline WDataOutP VL_PACK_W_UI(int obits, int lbits, WDataOutP owp, template inline WDataOutP VL_PACK_W_UI(int obits, int lbits, WDataOutP owp, const VlUnpacked& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); for (size_t i = 0; i < N_Depth; ++i) _vl_insert_WI(owp, q[N_Depth - 1 - i], i * lbits + lbits - 1, i * lbits); return owp; @@ -2339,14 +2339,14 @@ inline WDataOutP VL_PACK_W_UI(int obits, int lbits, WDataOutP owp, template inline WDataOutP VL_PACK_W_UI(int obits, int lbits, WDataOutP owp, const VlUnpacked& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); for (size_t i = 0; i < N_Depth; ++i) _vl_insert_WI(owp, q[N_Depth - 1 - i], i * lbits + lbits - 1, i * lbits); return owp; } inline WDataOutP VL_PACK_W_RQ(int obits, int lbits, WDataOutP owp, const VlQueue& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); if (VL_UNLIKELY(obits < q.size() * lbits)) return owp; // Though is illegal for q to be larger const int offset = obits - q.size() * lbits; for (size_t i = 0; i < q.size(); ++i) @@ -2358,7 +2358,7 @@ inline WDataOutP VL_PACK_W_RQ(int obits, int lbits, WDataOutP owp, const VlQueue template inline WDataOutP VL_PACK_W_UQ(int obits, int lbits, WDataOutP owp, const VlUnpacked& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); for (size_t i = 0; i < N_Depth; ++i) _vl_insert_WQ(owp, q[N_Depth - 1 - i], i * lbits + lbits - 1, i * lbits); return owp; @@ -2367,7 +2367,7 @@ inline WDataOutP VL_PACK_W_UQ(int obits, int lbits, WDataOutP owp, template inline WDataOutP VL_PACK_W_RW(int obits, int lbits, WDataOutP owp, const VlQueue>& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); if (VL_UNLIKELY(obits < q.size() * lbits)) return owp; // Though is illegal for q to be larger const int offset = obits - q.size() * lbits; for (size_t i = 0; i < q.size(); ++i) @@ -2379,7 +2379,7 @@ inline WDataOutP VL_PACK_W_RW(int obits, int lbits, WDataOutP owp, template inline WDataOutP VL_PACK_W_UW(int obits, int lbits, WDataOutP owp, const VlUnpacked, N_Depth>& q) { - VL_MEMSET_ZERO_W(owp + 1, VL_WORDS_I(obits) - 1); + VL_MEMSET_ZERO_W(owp, VL_WORDS_I(obits)); if (VL_UNLIKELY(obits < q.size() * lbits)) return owp; // Though is illegal for q to be larger const int offset = obits - q.size() * lbits; for (size_t i = 0; i < N_Depth; ++i) diff --git a/test_regress/t/t_stream_bitqueue.v b/test_regress/t/t_stream_bitqueue.v index 973129f4f..ccfbd2b58 100644 --- a/test_regress/t/t_stream_bitqueue.v +++ b/test_regress/t/t_stream_bitqueue.v @@ -516,6 +516,51 @@ module t ( /*AUTOARG*/ 1024'hab3156d4b752f843537d68dfbf48f1f78af787ff8df2c257cd6fa7c795d300000000000000000000000000000000ffffffffa5bbf5cc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000); end + // Streaming a queue into a packed destination wider than the source must assign the whole + // of the destination, including the bits below the left aligned source data. Each case + // first streams a source that is as wide as the destination, so all of the destination is + // set to a non-zero value, then streams a narrower source into the same destination. + begin + cdata_q_t cdata_q; + qdata_logic_q_t qdata_q; + wide_q_t wide_q; + logic [255:0] p256; + logic [383:0] p384; + + // 8-bit elements + cdata_q = cdata_q_t'( + 256'h00010203_04050607_08090a0b_0c0d0e0f_10111213_14151617_18191a1b_1c1d1e1f); + p256 = {>>{cdata_q}}; + `checkh(p256, + 256'h00010203_04050607_08090a0b_0c0d0e0f_10111213_14151617_18191a1b_1c1d1e1f); + cdata_q = cdata_q_t'(64'h00010203_04050607); + p256 = {>>{cdata_q}}; + `checkh(p256, + 256'h00010203_04050607_00000000_00000000_00000000_00000000_00000000_00000000); + + // 64-bit elements + qdata_q = qdata_logic_q_t'( + 256'hdeadbeef_cafebabe_feedface_12345678_11112222_33334444_55556666_77778888); + p256 = {>>{qdata_q}}; + `checkh(p256, + 256'hdeadbeef_cafebabe_feedface_12345678_11112222_33334444_55556666_77778888); + qdata_q = qdata_logic_q_t'(128'hdeadbeef_cafebabe_feedface_12345678); + p256 = {>>{qdata_q}}; + `checkh(p256, + 256'hdeadbeef_cafebabe_feedface_12345678_00000000_00000000_00000000_00000000); + + // 128-bit (VlWide) elements + wide_q = wide_q_t'( + 384'hdeadbeef_cafebabe_feedface_12345678_11112222_33334444_55556666_77778888_aaaabbbb_ccccdddd_eeeeffff_00001111); + p384 = {>>{wide_q}}; + `checkh(p384, + 384'hdeadbeef_cafebabe_feedface_12345678_11112222_33334444_55556666_77778888_aaaabbbb_ccccdddd_eeeeffff_00001111); + wide_q = wide_q_t'(128'hdeadbeef_cafebabe_feedface_12345678); + p384 = {>>{wide_q}}; + `checkh(p384, + 384'hdeadbeef_cafebabe_feedface_12345678_00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000); + end + $write("*-* All Finished *-*\n"); $finish; end