From adf64f3cc82ec5da55e4355889dd46f6ae801fc6 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 8 Jan 2022 14:20:35 +0100 Subject: [PATCH] Fix base type for nested types with enum or atom2 sub-types To determine the base type structs and packed arrays call the figure_packed_base_type() for their sub-types. This method is not defined for enum or atom2 types and the default implementation returns IVL_VT_NO_TYPE. As a result packed arrays of enum or atom2 types and packed structs with members of enum or atom2 types get elaborated with IVL_VT_NO_TYPE as the base type. For example ``` struct packed { bit signed [31:0] x; } s1; ``` gets elaborated with a base type of IVL_VT_BOOL, while ``` struct packed { int x; } s2; ``` gets elaborated with a base type of IVL_VT_NONE. To fix this define the figure_packed_base_type() for enum_type_t and atom2_type_t. Signed-off-by: Lars-Peter Clausen --- pform_types.cc | 10 ++++++++++ pform_types.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/pform_types.cc b/pform_types.cc index 72f312619..21dc725ab 100644 --- a/pform_types.cc +++ b/pform_types.cc @@ -48,6 +48,16 @@ ivl_variable_type_t vector_type_t::figure_packed_base_type(void) const return base_type; } +ivl_variable_type_t enum_type_t::figure_packed_base_type() const +{ + return base_type; +} + +ivl_variable_type_t atom2_type_t::figure_packed_base_type() const +{ + return IVL_VT_BOOL; +} + atom2_type_t size_type (32, true); PNamedItem::SymbolType enum_type_t::symbol_type() const diff --git a/pform_types.h b/pform_types.h index a323fd999..4e67a72db 100644 --- a/pform_types.h +++ b/pform_types.h @@ -182,6 +182,8 @@ struct enum_type_t : public data_type_t { // Return the elaborated version of the type. virtual ivl_type_s*elaborate_type_raw(Design*des, NetScope*scope) const; + ivl_variable_type_t figure_packed_base_type() const; + SymbolType symbol_type() const; ivl_variable_type_t base_type; @@ -217,6 +219,8 @@ struct atom2_type_t : public data_type_t { virtual std::ostream& debug_dump(std::ostream&out) const; ivl_type_s* elaborate_type_raw(Design*des, NetScope*scope) const; + + ivl_variable_type_t figure_packed_base_type() const; }; extern atom2_type_t size_type;