diff --git a/vvp/array.cc b/vvp/array.cc index 2ce2728d0..40941c1c0 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -94,6 +94,8 @@ struct __vpiArray : public __vpiArrayBase, public __vpiHandle { void get_word_value(struct __vpiArrayWord*word, p_vpi_value vp); void put_word_value(struct __vpiArrayWord*word, p_vpi_value vp, int flags); + vpiHandle get_iter_index(struct __vpiArrayIterator*iter, int idx); + int vpi_get(int code); char* vpi_get_str(int code); vpiHandle vpi_handle(int code); @@ -381,6 +383,17 @@ void __vpiArray::put_word_value(struct __vpiArrayWord*word, p_vpi_value vp, int) array_set_word(this, index, 0, val); } +vpiHandle __vpiArray::get_iter_index(struct __vpiArrayIterator*iter, int idx) +{ + if (nets) return nets[idx]; + + assert(vals4 || vals); + + if (vals_words == 0) make_vals_words(); + + return &(vals_words[idx].as_word); +} + int __vpiArray::vpi_get(int code) { switch (code) { diff --git a/vvp/array_common.cc b/vvp/array_common.cc index 668a61542..e4c1c810a 100644 --- a/vvp/array_common.cc +++ b/vvp/array_common.cc @@ -36,7 +36,6 @@ vpiHandle __vpiArrayBase::vpi_array_base_iterate(int code) return 0; } -// TODO template void __vpiArrayBase::make_vals_words() { assert(vals_words == 0); @@ -63,14 +62,7 @@ vpiHandle __vpiArrayIterator::vpi_index(int) unsigned use_index = next; next += 1; -// TODO ArrayBase::iterate(int)? - //if (array->nets) return array->nets[use_index]; - - //assert(array->vals4 || array->vals); - - if (array->vals_words == 0) array->make_vals_words(); - - return &(array->vals_words[use_index].as_word); + return array->get_iter_index(this, use_index); } static int array_iterator_free_object(vpiHandle ref) @@ -184,8 +176,6 @@ void __vpiArrayWord::as_index_t::vpi_get_value(p_vpi_value vp) vp->value.integer = index; } - - struct __vpiArrayWord*array_var_word_from_handle(vpiHandle ref) { if (ref == 0) diff --git a/vvp/array_common.h b/vvp/array_common.h index 2cfcb0bbe..d4d6bce0c 100644 --- a/vvp/array_common.h +++ b/vvp/array_common.h @@ -28,7 +28,7 @@ struct __vpiArrayIterator : public __vpiHandle { int get_type_code(void) const { return vpiIterator; } - virtual vpiHandle vpi_index(int idx); + vpiHandle vpi_index(int idx); free_object_fun_t free_object_fun(void); struct __vpiArrayBase*array; diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index ecf2f0c22..4987cca94 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -548,10 +548,13 @@ struct __vpiArrayBase { virtual void get_word_value(struct __vpiArrayWord*word, p_vpi_value vp) = 0; virtual void put_word_value(struct __vpiArrayWord*word, p_vpi_value vp, int flags) = 0; + virtual vpiHandle get_iter_index(struct __vpiArrayIterator*iter, int idx) = 0; + // vpi_iterate is already defined by vpiHandle, so to avoid problems with // classes inheriting from vpiHandle and vpiArrayBase just share the common // code in the following function vpiHandle vpi_array_base_iterate(int code); + virtual void make_vals_words(); struct __vpiArrayWord*vals_words; @@ -572,6 +575,8 @@ class __vpiDarrayVar : public __vpiBaseVar, public __vpiArrayBase { void get_word_value(struct __vpiArrayWord*word, p_vpi_value vp) {} void put_word_value(struct __vpiArrayWord*word, p_vpi_value vp, int flags) {} + vpiHandle get_iter_index(struct __vpiArrayIterator*iter, int idx) {}; + int vpi_get(int code); char* vpi_get_str(int code); vpiHandle vpi_handle(int code);