Return value of correct width for dynamic array out-of-bound access
Commit e1870acfac ("Return the correct value when a queue or darray
references an undefined element") added support for specifying the width of
the vector elements stored in a queue or dynamic array, so that an
out-of-bounds access can create a word with the right width.
To get the element width of a queue or dynamic array it uses the
`packed_width()` method. But this method is only implemented for
`netqueue_t` and returns always 1 for dynamic arrays. As a result
out-of-bounds access on a dynamic array will push a vector of the wrong
width onto the stack if the vector element is wider than 1 bit. This will
usually trigger an assert in vvp.
Fix this by moving the `packed_width()` method implementation from
`netqueue_t` to its base class `netdarray_t` so that it works for all types
of dynamic arrays.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
278e071b35
commit
abc3ad95e6
|
|
@ -36,6 +36,9 @@ class netdarray_t : public netarray_t {
|
||||||
// A dynamic array may have a type that is signed.
|
// A dynamic array may have a type that is signed.
|
||||||
inline bool get_signed() const { return element_type()->get_signed(); }
|
inline bool get_signed() const { return element_type()->get_signed(); }
|
||||||
|
|
||||||
|
// Use the packed width to pass the element width
|
||||||
|
long packed_width() const { return element_type()->packed_width(); }
|
||||||
|
|
||||||
// This is the base_type() of the element of the array. We
|
// This is the base_type() of the element of the array. We
|
||||||
// need this in some cases in order to get the base type of
|
// need this in some cases in order to get the base type of
|
||||||
// the element, and not the IVL_VT_DARRAY of the array itself.
|
// the element, and not the IVL_VT_DARRAY of the array itself.
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,6 @@ class netqueue_t : public netdarray_t {
|
||||||
// IVL_VT_QUEUE for queues.
|
// IVL_VT_QUEUE for queues.
|
||||||
ivl_variable_type_t base_type() const;
|
ivl_variable_type_t base_type() const;
|
||||||
|
|
||||||
// Use the packed width to pass the element width
|
|
||||||
long packed_width(void) const { return element_type()->packed_width(); }
|
|
||||||
|
|
||||||
long max_idx(void) const { return max_idx_; }
|
long max_idx(void) const { return max_idx_; }
|
||||||
|
|
||||||
std::ostream& debug_dump(std::ostream&) const;
|
std::ostream& debug_dump(std::ostream&) const;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue