Use `netrange_width()` helper where appropriate
The `netrange_width()` helper function computes the total width of a set of ranges. There are a few places where this is currently open-coded and `netrange_width()` can be used. This removes a bit of duplicated code. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
4269388878
commit
bdbe74252c
|
|
@ -1965,9 +1965,8 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope,
|
|||
use_width = 1;
|
||||
while (const netuarray_t *utype =
|
||||
dynamic_cast<const netuarray_t*>(data_type)) {
|
||||
const vector<netrange_t> &dims = utype->static_dimensions();
|
||||
for (size_t i = 0; i < dims.size(); i++)
|
||||
use_width *= dims[i].width();
|
||||
use_width = netrange_width(utype->static_dimensions(),
|
||||
use_width);
|
||||
data_type = utype->element_type();
|
||||
}
|
||||
if (!data_type->packed()) {
|
||||
|
|
|
|||
|
|
@ -819,12 +819,7 @@ bool NetNet::sb_to_slice(const list<long>&indices, long sb, long&loff, unsigned
|
|||
|
||||
unsigned NetNet::unpacked_count() const
|
||||
{
|
||||
unsigned c = 1;
|
||||
for (size_t idx = 0 ; idx < unpacked_dims_.size() ; idx += 1) {
|
||||
c *= unpacked_dims_[idx].width();
|
||||
}
|
||||
|
||||
return c;
|
||||
return netrange_width(unpacked_dims_);
|
||||
}
|
||||
|
||||
void NetNet::incr_eref()
|
||||
|
|
|
|||
10
netparray.cc
10
netparray.cc
|
|
@ -42,14 +42,8 @@ bool netparray_t::packed(void) const
|
|||
|
||||
long netparray_t::packed_width(void) const
|
||||
{
|
||||
long cur_width = element_type()->packed_width();
|
||||
|
||||
for (vector<netrange_t>::const_iterator cur = static_dimensions().begin()
|
||||
; cur != static_dimensions().end() ; ++cur) {
|
||||
cur_width *= cur->width();
|
||||
}
|
||||
|
||||
return cur_width;
|
||||
return netrange_width(static_dimensions(),
|
||||
element_type()->packed_width());
|
||||
}
|
||||
|
||||
vector<netrange_t> netparray_t::slice_dimensions() const
|
||||
|
|
|
|||
Loading…
Reference in New Issue