From 8de2e60d26150bae29a30c0275503583704a5d15 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 21 Mar 2022 14:20:35 +0100 Subject: [PATCH] Consolidate different NetNet constructors There are a couple of different NetNet constructors for different data types. They are all very similar, consolidate them into a single constructor taking a ivl_type_t. Signed-off-by: Lars-Peter Clausen --- netlist.cc | 39 +++++---------------------------------- netlist.h | 7 +------ 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/netlist.cc b/netlist.cc index cb2ee73a6..aa767c444 100644 --- a/netlist.cc +++ b/netlist.cc @@ -549,6 +549,9 @@ template static unsigned calculate_count(T*type) void NetNet::calculate_slice_widths_from_packed_dims_(void) { ivl_assert(*this, net_type_); + if (!net_type_->packed()) + return; + slice_dims_ = net_type_->slice_dimensions(); // Special case: There are no actual packed dimensions, so @@ -598,42 +601,10 @@ NetNet::NetNet(NetScope*s, perm_string n, Type t, s->add_signal(this); } -/* - * When we create a netnet for a packed struct, create a single - * vector with the msb_/lsb_ chosen to name enough bits for the entire - * packed structure. - */ -NetNet::NetNet(NetScope*s, perm_string n, Type t, netstruct_t*ty) +NetNet::NetNet(NetScope*s, perm_string n, Type t, ivl_type_t type) : NetObj(s, n, 1), type_(t), port_type_(NOT_A_PORT), - local_flag_(false), net_type_(ty), - discipline_(0), - eref_count_(0), lref_count_(0) -{ - //XXXX packed_dims_.push_back(netrange_t(calculate_count(ty)-1, 0)); - calculate_slice_widths_from_packed_dims_(); - - initialize_dir_(); - - s->add_signal(this); -} - -NetNet::NetNet(NetScope*s, perm_string n, Type t, netdarray_t*ty) -: NetObj(s, n, 1), - type_(t), port_type_(NOT_A_PORT), - local_flag_(false), net_type_(ty), - discipline_(0), - eref_count_(0), lref_count_(0) -{ - initialize_dir_(); - - s->add_signal(this); -} - -NetNet::NetNet(NetScope*s, perm_string n, Type t, netvector_t*ty) -: NetObj(s, n, 1), - type_(t), port_type_(NOT_A_PORT), - local_flag_(false), net_type_(ty), + local_flag_(false), net_type_(type), discipline_(0), eref_count_(0), lref_count_(0) { diff --git a/netlist.h b/netlist.h index fdbe730ca..417c0f9ab 100644 --- a/netlist.h +++ b/netlist.h @@ -679,12 +679,7 @@ class NetNet : public NetObj, public PortType { const std::list&unpacked, ivl_type_t type); - // This form builds a NetNet from its record/enum/darray - // definition. They should probably be replaced with a single - // version that takes an ivl_type_s* base. - explicit NetNet(NetScope*s, perm_string n, Type t, netstruct_t*type); - explicit NetNet(NetScope*s, perm_string n, Type t, netdarray_t*type); - explicit NetNet(NetScope*s, perm_string n, Type t, netvector_t*type); + explicit NetNet(NetScope*s, perm_string n, Type t, ivl_type_t type); virtual ~NetNet();