From bbe44deec2f4c0bad737153c08c9e8066bee6e0c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 19 Jan 2022 11:00:18 +0100 Subject: [PATCH] Support all packed types for module ports Currently module ports only support vectors, atom2, enum and struct packed types, but not packed arrays. Generalize the code so that any packed type is supported. Signed-off-by: Lars-Peter Clausen --- pform.cc | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/pform.cc b/pform.cc index ce1eea9ca..27416c9c3 100644 --- a/pform.cc +++ b/pform.cc @@ -2620,8 +2620,7 @@ void pform_module_define_port(const struct vlltype&li, list*attr, bool keep_attr) { - struct_type_t*struct_type = 0; - enum_type_t*enum_type = 0; + data_type_t*packed_type = 0; ivl_variable_type_t data_type = IVL_VT_NO_TYPE; bool signed_flag = false; @@ -2669,19 +2668,14 @@ void pform_module_define_port(const struct vlltype&li, __FILE__, __LINE__); } - } else if ((struct_type = dynamic_cast(vtype))) { - data_type = struct_type->figure_packed_base_type(); - signed_flag = false; - prange = 0; - - } else if ((enum_type = dynamic_cast(vtype))) { - data_type = enum_type->base_type; - signed_flag = enum_type->signed_flag; - prange = 0; - } else if (vtype) { - VLerror(li, "sorry: Given type %s not supported here (%s:%d).", - typeid(*vtype).name(), __FILE__, __LINE__); + if (vtype->figure_packed_base_type() != IVL_VT_NO_TYPE) { + data_type = vtype->figure_packed_base_type(); + packed_type = vtype; + } else { + VLerror(li, "sorry: Given type %s not supported here (%s:%d).", + typeid(*vtype).name(), __FILE__, __LINE__); + } } @@ -2694,11 +2688,8 @@ void pform_module_define_port(const struct vlltype&li, cur->set_signed(signed_flag); - if (struct_type) { - cur->set_data_type(struct_type); - - } else if (enum_type) { - cur->set_data_type(enum_type); + if (packed_type) { + cur->set_data_type(packed_type); } else if (prange == 0) { cur->set_range_scalar((type == NetNet::IMPLICIT) ? SR_PORT : SR_BOTH);