From ca2ef5c95627532782d2a24121efa70aca0d93a5 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 20 Nov 2014 17:23:16 +0100 Subject: [PATCH] vvp: Cleaning. --- vvp/array.cc | 4 +-- vvp/array.h | 1 - vvp/array_common.h | 2 -- vvp/vpi_darray.cc | 85 ++++++++++++++++++++++++++++++++++++++++------ vvp/vpi_priv.h | 19 +++++++---- 5 files changed, 88 insertions(+), 23 deletions(-) diff --git a/vvp/array.cc b/vvp/array.cc index 40941c1c0..5e81beb8b 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -367,8 +367,6 @@ void __vpiArray::get_word_value(struct __vpiArrayWord*word, p_vpi_value vp) } break; - // TODO *StrVal variants - default: fprintf(stderr, "vpi sorry: format is not implemented"); assert(false); @@ -383,7 +381,7 @@ 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) +vpiHandle __vpiArray::get_iter_index(struct __vpiArrayIterator*, int idx) { if (nets) return nets[idx]; diff --git a/vvp/array.h b/vvp/array.h index d1766ed15..b4aba35c1 100644 --- a/vvp/array.h +++ b/vvp/array.h @@ -31,7 +31,6 @@ class value_callback; */ extern vvp_array_t array_find(const char*label); extern unsigned get_array_word_size(vvp_array_t array); -extern vpiHandle array_index_iterate(int code, vpiHandle ref); extern void array_word_change(vvp_array_t array, unsigned long addr); diff --git a/vvp/array_common.h b/vvp/array_common.h index d4d6bce0c..8b4d8c334 100644 --- a/vvp/array_common.h +++ b/vvp/array_common.h @@ -95,6 +95,4 @@ struct __vpiArrayWord { struct __vpiArrayWord*array_var_word_from_handle(vpiHandle ref); struct __vpiArrayWord*array_var_index_from_handle(vpiHandle ref); -vpiHandle array_index_iterate(int code, vpiHandle ref); - #endif /* ARRAY_COMMON_H */ diff --git a/vvp/vpi_darray.cc b/vvp/vpi_darray.cc index 3f3694e4c..bb1fbd055 100644 --- a/vvp/vpi_darray.cc +++ b/vvp/vpi_darray.cc @@ -55,6 +55,72 @@ unsigned __vpiDarrayVar::get_size() const return aval->get_size(); } +vpiHandle __vpiDarrayVar::get_left_range() +{ + return NULL; +} + +vpiHandle __vpiDarrayVar::get_right_range() +{ + return NULL; +} + +int __vpiDarrayVar::get_word_size() const +{ + return get_vvp_darray()->get_size(); +} + +char*__vpiDarrayVar::get_word_str(struct __vpiArrayWord*word, int code) +{ + return NULL; +} + +void __vpiDarrayVar::get_word_value(struct __vpiArrayWord*word, p_vpi_value vp) +{ + unsigned index = word->get_index(); + vvp_darray*aobj = get_vvp_darray(); + + switch(vp->format) { + case vpiIntVal: + case vpiVectorVal: + { + vvp_vector4_t v; + aobj->get_word(index, v); + vpip_vec2_get_value(v, get_word_size(), true, vp); + } + break; + + case vpiRealVal: + { + double d; + aobj->get_word(index, d); + vpip_real_get_value(d, vp); + } + break; + + case vpiStringVal: + { + string s; + aobj->get_word(index, s); + vpip_string_get_value(s, vp); + } + break; + + default: + fprintf(stderr, "vpi sorry: format is not implemented"); + assert(false); + } +} + +void __vpiDarrayVar::put_word_value(struct __vpiArrayWord*word, p_vpi_value vp, int flags) +{ +} + +vpiHandle __vpiDarrayVar::get_iter_index(struct __vpiArrayIterator*iter, int idx) +{ + return NULL; +} + int __vpiDarrayVar::vpi_get(int code) { switch (code) { @@ -70,21 +136,11 @@ int __vpiDarrayVar::vpi_get(int code) char* __vpiDarrayVar::vpi_get_str(int code) { - // TODO orson return NULL; } vpiHandle __vpiDarrayVar::vpi_handle(int code) { - // TODO orson - //switch (code) { - //case vpiScope: - //return scope_; - - //case vpiModule: - //return vpip_module(scope_); - //} - return 0; } @@ -106,6 +162,15 @@ void __vpiDarrayVar::vpi_get_value(p_vpi_value val) val->format = vpiSuppressVal; } +vvp_darray*__vpiDarrayVar::get_vvp_darray() const +{ + vvp_fun_signal_object*fun = dynamic_cast (get_net()->fun); + assert(fun); + vvp_object_t obj = fun->get_object(); + + return obj.peek(); +} + vpiHandle vpip_make_darray_var(const char*name, vvp_net_t*net) { struct __vpiScope*scope = vpip_peek_current_scope(); diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 4987cca94..8d9feafcb 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -35,6 +35,8 @@ class class_type; +class vvp_darray; + typedef struct __vpiArray* vvp_array_t; /* @@ -566,16 +568,16 @@ class __vpiDarrayVar : public __vpiBaseVar, public __vpiArrayBase { int get_type_code() const { return vpiArrayVar; } unsigned get_size() const; - vpiHandle get_left_range() { return NULL; } - vpiHandle get_right_range() { return NULL; } + vpiHandle get_left_range(); + vpiHandle get_right_range(); struct __vpiScope*get_scope() const { return scope_; } - int get_word_size() const { return 0; } // TODO - char*get_word_str(struct __vpiArrayWord*word, int code) { return NULL; } - void get_word_value(struct __vpiArrayWord*word, p_vpi_value vp) {} - void put_word_value(struct __vpiArrayWord*word, p_vpi_value vp, int flags) {} + int get_word_size() const; + char*get_word_str(struct __vpiArrayWord*word, int code); + 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) {}; + vpiHandle get_iter_index(struct __vpiArrayIterator*iter, int idx); int vpi_get(int code); char* vpi_get_str(int code); @@ -583,6 +585,9 @@ class __vpiDarrayVar : public __vpiBaseVar, public __vpiArrayBase { vpiHandle vpi_index(int index); void vpi_get_value(p_vpi_value val); + + protected: + vvp_darray*get_vvp_darray() const; }; extern vpiHandle vpip_make_darray_var(const char*name, vvp_net_t*net);