From 4269388878f5b3411600e50cee6a68ddade14971 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 23 Jul 2023 08:00:53 -0700 Subject: [PATCH] `netrange_width()`: Add a base_width parameter There are sometimes cases where calculating the total width of a `vector` has to take into account an existing base width. E.g. when chaining multiple `vector`. Add support to the `netrange_width()` function to be able to handle this case. Signed-off-by: Lars-Peter Clausen --- nettypes.cc | 5 +++-- nettypes.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nettypes.cc b/nettypes.cc index 5efb8ab63..a426cc5fc 100644 --- a/nettypes.cc +++ b/nettypes.cc @@ -97,9 +97,10 @@ ivl_variable_type_t netarray_t::base_type() const return element_type_->base_type(); } -unsigned long netrange_width(const vector&packed) +unsigned long netrange_width(const vector&packed, + unsigned int base_width) { - unsigned wid = 1; + unsigned wid = base_width; for (vector::const_iterator cur = packed.begin() ; cur != packed.end() ; ++cur) { unsigned use_wid = cur->width(); diff --git a/nettypes.h b/nettypes.h index 0f0d57958..df2cf457b 100644 --- a/nettypes.h +++ b/nettypes.h @@ -149,7 +149,8 @@ class netrange_t { extern std::ostream&operator << (std::ostream&out, const std::list&rlist); extern std::ostream&operator << (std::ostream&out, const std::vector&rlist); -extern unsigned long netrange_width(const std::vector&dims); +extern unsigned long netrange_width(const std::vector&dims, + unsigned int base_width = 1); extern bool netrange_equivalent(const std::vector &a, const std::vector &b);