From d0223e6ed902c1f273fb693ff056dc6edff0fd6c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 8 Jan 2022 11:55:35 +0100 Subject: [PATCH] Support signals of packed arrays of packed types Currently it is only possible to declare packed array variables with a struct type as the element type. Add support for packed arrays of other packed types. This includes packed arrays of enums and vectors as well as packed arrays of packed arrays. Since packed arrays of packed types are already supported for class members the infrastructure for elaborating all types of packed arrays exists. It just needs to be called when elaborating a signal. Signed-off-by: Lars-Peter Clausen --- elab_sig.cc | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/elab_sig.cc b/elab_sig.cc index 561f61d6b..d0cb720b4 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -873,37 +873,6 @@ void PWhile::elaborate_sig(Design*des, NetScope*scope) const statement_->elaborate_sig(des, scope); } -static ivl_type_s*elaborate_type(Design*des, NetScope*scope, - data_type_t*pform_type) -{ - if (struct_type_t*struct_type = dynamic_cast(pform_type)) { - ivl_type_s*use_type = struct_type->elaborate_type(des, scope); - return use_type; - } - - cerr << pform_type->get_fileline() << ": sorry: I don't know how to elaborate " - << typeid(*pform_type).name() << " here." << endl; - des->errors += 1; - - return 0; -} - -static netparray_t* elaborate_parray_type(Design*des, NetScope*scope, const LineInfo*li, - parray_type_t*data_type) -{ - - vectorpacked_dimensions; - bool dimensions_ok = evaluate_ranges(des, scope, li, packed_dimensions, * data_type->dims); - ivl_assert(*data_type, dimensions_ok); - - ivl_type_s*element_type = elaborate_type(des, scope, data_type->base_type); - - netparray_t*res = new netparray_t(packed_dimensions, element_type); - //res->set_line(*data_type); - - return res; -} - bool test_ranges_eeq(const vector&lef, const vector&rig) { if (lef.size() != rig.size()) @@ -1307,7 +1276,8 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const // The trick here is that the parray type has an // arbitrary sub-type, and not just a scalar bit... - netparray_t*use_type = elaborate_parray_type(des, scope, this, parray_type); + ivl_type_t tmp_type = parray_type->elaborate_type(des, scope); + const netparray_t*use_type = dynamic_cast(tmp_type); // Should not be getting packed dimensions other than // through the parray type declaration. ivl_assert(*this, packed_dimensions.empty());