Fix part select on variables declared in packages
The logic that decides whether a vector is scalar or not incorrectly flags all variables that are declared in packages as scalar. As a result it is not possible to do a part select on a vector declared in a package. Rather than having an independent scalar flag consider a vector as scalar if it does not have any packed dimensions. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
167005f849
commit
b207ebd51a
5
PWire.cc
5
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;
|
||||
|
|
|
|||
1
PWire.h
1
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;
|
||||
|
|
|
|||
22
elab_sig.cc
22
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<netrange_t>&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<netrange_t>&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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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_) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue