diff --git a/PWire.cc b/PWire.cc index 72418d501..bf9b36954 100644 --- a/PWire.cc +++ b/PWire.cc @@ -160,11 +160,6 @@ bool PWire::get_isint() const return false; } -bool PWire::get_scalar() const -{ - return is_scalar_; -} - void PWire::set_range_scalar(PWSRType type) { is_scalar_ = true; diff --git a/PWire.h b/PWire.h index 0d8c44a30..f4b792538 100644 --- a/PWire.h +++ b/PWire.h @@ -71,7 +71,6 @@ class PWire : public PNamedItem { void set_signed(bool flag); bool get_signed() const; bool get_isint() const; - bool get_scalar() const; bool set_data_type(ivl_variable_type_t dt); ivl_variable_type_t get_data_type() const; diff --git a/elab_sig.cc b/elab_sig.cc index 3378902eb..47edb73d8 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -645,7 +645,6 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const } } else { netvector_t*tmp = new netvector_t(IVL_VT_LOGIC); - tmp->set_scalar(true); ret_type = tmp; } @@ -951,28 +950,20 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const const long warn_dimension_size = 1 << 30; NetNet::Type wtype = type_; - bool is_implicit_scalar = false; - if (wtype == NetNet::IMPLICIT) { + if (wtype == NetNet::IMPLICIT) wtype = NetNet::WIRE; - is_implicit_scalar = true; - } + // Certain contexts, such as arguments to functions, presume // "reg" instead of "wire". The parser reports these as - // IMPLICIT_REG. Also, certain cases, such as: - // fun(string arg1) ... - // are implicitly NOT scalar, so detect that case here. - if (wtype == NetNet::IMPLICIT_REG) { + // IMPLICIT_REG. + if (wtype == NetNet::IMPLICIT_REG) wtype = NetNet::REG; - if (data_type_!=IVL_VT_STRING) - is_implicit_scalar = true; - } if (debug_elaborate) { cerr << get_fileline() << ": PWire::elaborate_sig: " << "Signal " << basename() << ", wtype=" << wtype << ", data_type_=" << data_type_ - << ", is_implicit_scalar=" << (is_implicit_scalar?"true":"false") << ", unpacked_.size()=" << unpacked_.size() << endl; } @@ -1015,7 +1006,6 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const dimensions_ok &= evaluate_ranges(des, scope, this, plist, port_); nlist = plist; /* An implicit port can have a range so note that here. */ - is_implicit_scalar = false; } assert(port_set_ || port_.empty()); @@ -1324,7 +1314,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const cerr << get_fileline() << ": PWire::elaborate_sig: " << "Create vector signal " << wtype << " data_type=" << data_type_; - if (!get_scalar()) { + if (!packed_dimensions.empty()) { cerr << " " << packed_dimensions; } cerr << " " << name_ << unpacked_dimensions; @@ -1349,8 +1339,6 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const netvector_t*vec = new netvector_t(packed_dimensions, use_data_type); vec->set_signed(get_signed()); vec->set_isint(get_isint()); - if (is_implicit_scalar) vec->set_scalar(true); - else vec->set_scalar(get_scalar()); packed_dimensions.clear(); sig = new NetNet(scope, name_, wtype, unpacked_dimensions, vec); diff --git a/ivtest/ivltests/package_vec_part_select.v b/ivtest/ivltests/package_vec_part_select.v new file mode 100644 index 000000000..7d39d8f90 --- /dev/null +++ b/ivtest/ivltests/package_vec_part_select.v @@ -0,0 +1,20 @@ +// Check that it is possible to do a part select on a vector declared in +// package + +package P; + reg [7:0] x = 8'h5a; + reg [1:0][7:0] y = 16'h5af0; +endpackage + +module test; + + initial begin + if (P::x[3:0] == 4'ha && P::x[7:4] == 4'h5 && + P::y[0] == 8'hf0 && P::y[1] == 8'h5a) begin + $display("PASSED"); + end else begin + $display("FAILED"); + end + end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index d6f190e08..30e6b9704 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -322,6 +322,7 @@ net_class_fail CE,-g2005-sv ivltests net_darray_fail CE,-g2005-sv ivltests net_queue_fail CE,-g2005-sv ivltests net_string_fail CE,-g2005-sv ivltests +package_vec_part_select normal,-g2005-sv ivltests packeda normal,-g2009 ivltests packeda2 normal,-g2009 ivltests parameter_in_generate2 CE,-g2005-sv ivltests diff --git a/netvector.cc b/netvector.cc index f874635e6..4d235eb22 100644 --- a/netvector.cc +++ b/netvector.cc @@ -47,13 +47,13 @@ const netvector_t* netvector_t::integer_type() netvector_t netvector_t::scalar_logic (IVL_VT_LOGIC); netvector_t::netvector_t(ivl_variable_type_t type, long msb, long lsb, bool flag) -: type_(type), signed_(flag), isint_(false), is_scalar_(false) +: type_(type), signed_(flag), isint_(false) { packed_dims_.push_back(netrange_t(msb,lsb)); } netvector_t::netvector_t(ivl_variable_type_t type) -: type_(type), signed_(false), isint_(false), is_scalar_(false) +: type_(type), signed_(false), isint_(false) { } diff --git a/netvector.h b/netvector.h index 59b7905c2..2775a718d 100644 --- a/netvector.h +++ b/netvector.h @@ -54,8 +54,7 @@ class netvector_t : public ivl_type_s { inline void set_isint(bool flag) { isint_ = flag; } inline bool get_isint(void) const { return isint_; } - inline void set_scalar(bool flag) { is_scalar_ = flag; } - inline bool get_scalar(void) const { return is_scalar_; } + inline bool get_scalar(void) const { return packed_dims_.empty(); } ivl_variable_type_t base_type() const; const std::vector&packed_dims() const; @@ -88,13 +87,11 @@ class netvector_t : public ivl_type_s { ivl_variable_type_t type_; bool signed_ : 1; bool isint_ : 1; // original type of integer - bool is_scalar_ : 1; }; inline netvector_t::netvector_t(const std::vector&pd, ivl_variable_type_t type) -: packed_dims_(pd), type_(type), signed_(false), isint_(false), - is_scalar_(false) +: packed_dims_(pd), type_(type), signed_(false), isint_(false) { } diff --git a/pform_dump.cc b/pform_dump.cc index 9367ce0d3..0c0874d00 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -587,7 +587,7 @@ void PWire::dump(ostream&out, unsigned ind) const if (get_isint()) { out << " integer"; } - if (get_scalar()) { + if (is_scalar_) { out << " scalar"; } if (set_data_type_) { diff --git a/tgt-vlog95/scope.c b/tgt-vlog95/scope.c index 393b53c63..1b8916c19 100644 --- a/tgt-vlog95/scope.c +++ b/tgt-vlog95/scope.c @@ -696,7 +696,8 @@ static int find_tfb_process(ivl_process_t proc, ivl_scope_t scope) * processes that are used to set local variables. */ assert(ivl_process_type(proc) == IVL_PR_INITIAL); /* Find the module scope for this task/function. */ - while (ivl_scope_type(mod_scope) != IVL_SCT_MODULE) { + while (ivl_scope_type(mod_scope) != IVL_SCT_MODULE && + ivl_scope_type(mod_scope) != IVL_SCT_PACKAGE) { mod_scope = ivl_scope_parent(mod_scope); assert(mod_scope); } @@ -1154,7 +1155,9 @@ int emit_scope(ivl_scope_t scope, ivl_scope_t parent) for (idx = 0; idx < count; idx += 1) { emit_tran(scope, ivl_scope_switch(scope, idx)); } + } + if (sc_type == IVL_SCT_MODULE || sc_type == IVL_SCT_PACKAGE) { /* Output any initial blocks for tasks or functions or named * blocks defined in this module. Used to initialize local * variables. */