From 45766445916ffc129c7539c366e5bf6d9b46cf82 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 17 Oct 2020 21:09:10 -0400 Subject: [PATCH] Prep for future queue slicing. --- include/verilated_heavy.h | 4 +- src/V3Width.cpp | 4 +- test_regress/t/t_queue_slice.out | 85 +------------------------------- test_regress/t/t_queue_slice.pl | 6 +-- test_regress/t/t_queue_slice.v | 26 ++++++++-- 5 files changed, 31 insertions(+), 94 deletions(-) diff --git a/include/verilated_heavy.h b/include/verilated_heavy.h index eb43fe595..8b7412f03 100644 --- a/include/verilated_heavy.h +++ b/include/verilated_heavy.h @@ -281,7 +281,7 @@ public: // Clear array. Verilog: function void delete([input index]) void clear() { m_deque.clear(); } void erase(size_t index) { - if (VL_LIKELY(index < m_deque.size())) m_deque.erase(index); + if (VL_LIKELY(index < m_deque.size())) m_deque.erase(m_deque.begin() + index); } // Dynamic array new[] becomes a renew() @@ -349,7 +349,7 @@ public: // function void q.insert(index, value); void insert(size_t index, const T_Value& value) { if (VL_UNLIKELY(index >= m_deque.size())) return; - m_deque[index] = value; + m_deque.insert(m_deque.begin() + index, value); } // For save/restore diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 8514f01a0..506b6dcf1 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -151,7 +151,9 @@ public: if (!m_dtypep) { str << " VUP(s=" << m_stage << ",self)"; } else { - str << " VUP(s=" << m_stage << ",dt=" << cvtToHex(dtypep()) << ")"; + str << " VUP(s=" << m_stage << ",dt=" << cvtToHex(dtypep()); + dtypep()->dumpSmall(str); + str << ")"; } } }; diff --git a/test_regress/t/t_queue_slice.out b/test_regress/t/t_queue_slice.out index 2df592095..ec304cf36 100644 --- a/test_regress/t/t_queue_slice.out +++ b/test_regress/t/t_queue_slice.out @@ -1,85 +1,4 @@ -%Error-UNSUPPORTED: t/t_queue_slice.v:22:11: Unsupported: Assignment pattern applies against non struct/union data type: 'string[$]' - : ... In instance t - 22 | q = '{"q", "b", "c", "d", "e", "f"}; +%Error-UNSUPPORTED: t/t_queue_slice.v:21:11: Unsupported: Empty '{} + 21 | q = '{}; | ^~ -%Error-UNSUPPORTED: t/t_queue_slice.v:25:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 25 | q = {"q", "b", "c", "d", "e", "f"}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:28:9: Unsupported: Queue .delete(index) method, as is O(n) complexity and slow. - : ... In instance t - 28 | q.delete(1); - | ^~~~~~ -%Error-UNSUPPORTED: t/t_queue_slice.v:32:9: Unsupported: Queue .insert method, as is O(n) complexity and slow. - : ... In instance t - 32 | q.insert(2, "ins2"); - | ^~~~~~ -%Error-UNSUPPORTED: t/t_queue_slice.v:38:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 38 | q = {"q", "b", "c", "d", "e", "f"}; - | ^ -%Error: t/t_queue_slice.v:39:12: Illegal range select; type already selected, or bad dimension: data type is 'string[$]' - : ... In instance t - 39 | q = q[2:3]; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:41:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 41 | q = {"q", "b", "c", "d", "e", "f"}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:42:15: Unsupported/illegal unbounded ('$') in this context. - : ... In instance t - 42 | q = q[3:$]; - | ^ -%Error: t/t_queue_slice.v:42:15: First value of [a:b] isn't a constant, maybe you want +: or -: - : ... In instance t - 42 | q = q[3:$]; - | ^ -%Error: t/t_queue_slice.v:42:12: Illegal range select; type already selected, or bad dimension: data type is 'string[$]' - : ... In instance t - 42 | q = q[3:$]; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:46:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 46 | q = {q, "f1"}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:47:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 47 | q = {q, "f2"}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:48:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 48 | q = {"b1", q}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:49:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 49 | q = {"b2", q}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:50:11: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 50 | q = {q[0], q[2:$]}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:50:22: Unsupported/illegal unbounded ('$') in this context. - : ... In instance t - 50 | q = {q[0], q[2:$]}; - | ^ -%Error: t/t_queue_slice.v:50:22: First value of [a:b] isn't a constant, maybe you want +: or -: - : ... In instance t - 50 | q = {q[0], q[2:$]}; - | ^ -%Error: t/t_queue_slice.v:50:19: Illegal range select; type already selected, or bad dimension: data type is 'string[$]' - : ... In instance t - 50 | q = {q[0], q[2:$]}; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:54:25: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 54 | string ai[$] = { "Foo", "Bar" }; - | ^ -%Error-UNSUPPORTED: t/t_queue_slice.v:59:14: Unsupported: Assignment pattern applies against non struct/union data type: 'string[$]' - : ... In instance t - 59 | q = '{ "BB", "CC" }; - | ^~ -%Error-UNSUPPORTED: t/t_queue_slice.v:62:14: Unsupported: Replication to form 'string[$]' data type - : ... In instance t - 62 | q = { "BB", "CC" }; - | ^ %Error: Exiting due to diff --git a/test_regress/t/t_queue_slice.pl b/test_regress/t/t_queue_slice.pl index f4321c541..be66c40e6 100755 --- a/test_regress/t/t_queue_slice.pl +++ b/test_regress/t/t_queue_slice.pl @@ -15,9 +15,9 @@ compile( expect_filename => $Self->{golden_filename}, ); -#execute( -# check_finished => 1, -# ); +execute( + check_finished => 1, + ) if !$Self->{vlt_all}; ok(1); 1; diff --git a/test_regress/t/t_queue_slice.v b/test_regress/t/t_queue_slice.v index e60539f4a..b1cd39408 100644 --- a/test_regress/t/t_queue_slice.v +++ b/test_regress/t/t_queue_slice.v @@ -7,7 +7,6 @@ `define stop $stop `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); `define checks(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='%s' exp='%s'\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); -`define checkg(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='%g' exp='%g'\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); module t (/*AUTOARG*/); initial begin @@ -19,7 +18,14 @@ module t (/*AUTOARG*/); i = q.size(); `checkh(i, 1); v = $sformatf("%p", q); `checks(v, "'{\"non-empty\"} "); + q = '{}; + i = q.size(); `checkh(i, 0); + + q = '{"q"}; + v = $sformatf("%p", q); `checks(v, "'{\"q\"} "); + q = '{"q", "b", "c", "d", "e", "f"}; + if (q[0] !== "q") $stop; v = $sformatf("%p", q); `checks(v, "'{\"q\", \"b\", \"c\", \"d\", \"e\", \"f\"} "); q = {"q", "b", "c", "d", "e", "f"}; @@ -27,6 +33,7 @@ module t (/*AUTOARG*/); q.delete(1); v = q[1]; `checks(v, "c"); + v = $sformatf("%p", q); `checks(v, "'{\"q\", \"c\", \"d\", \"e\", \"f\"} "); q.insert(0, "ins0"); q.insert(2, "ins2"); @@ -35,23 +42,32 @@ module t (/*AUTOARG*/); v = $sformatf("%p", q); `checks(v, "'{\"ins0\", \"q\", \"ins2\", \"c\", \"d\", \"e\", \"f\"} "); // Slicing - q = {"q", "b", "c", "d", "e", "f"}; + q = '{"q", "b", "c", "d", "e", "f"}; q = q[2:3]; v = $sformatf("%p", q); `checks(v, "'{\"c\", \"d\"} "); - q = {"q", "b", "c", "d", "e", "f"}; + q = '{"q", "b", "c", "d", "e", "f"}; q = q[3:$]; v = $sformatf("%p", q); `checks(v, "'{\"d\", \"e\", \"f\"} "); + q = q[$:$]; + v = $sformatf("%p", q); `checks(v, "'{\"f\"} "); // Similar using implied notation + q = '{"f"}; q = {q, "f1"}; // push_front q = {q, "f2"}; // push_front q = {"b1", q}; // push_back q = {"b2", q}; // push_back + v = $sformatf("%p", q); `checks(v, "'{\"b2\", \"b1\", \"f\", \"f1\", \"f2\"} "); + q = {q[0], q[2:$]}; // delete element 1 - v = $sformatf("%p", q); `checks(v, "'{\"b2\", \"d\", \"e\", \"f\", \"f1\", \"f2\"} "); + v = $sformatf("%p", q); `checks(v, "'{\"b2\", \"f\", \"f1\", \"f2\"} "); + + q = {"a", "b"}; + q = {q, q}; + v = $sformatf("%p", q); `checks(v, "'{\"a\", \"b\", \"a\", \"b\"} "); begin - string ai[$] = { "Foo", "Bar" }; + string ai[$] = '{ "Foo", "Bar" }; q = ai; // Copy i = q.size(); `checkh(i, 2); v = q.pop_front(); `checks(v, "Foo");