vvp: Cleaning.

This commit is contained in:
Maciej Suminski 2014-11-20 17:23:16 +01:00
parent 6015aceda2
commit ca2ef5c956
5 changed files with 88 additions and 23 deletions

View File

@ -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];

View File

@ -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);

View File

@ -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 */

View File

@ -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<vvp_fun_signal_object*> (get_net()->fun);
assert(fun);
vvp_object_t obj = fun->get_object();
return obj.peek<vvp_darray>();
}
vpiHandle vpip_make_darray_var(const char*name, vvp_net_t*net)
{
struct __vpiScope*scope = vpip_peek_current_scope();

View File

@ -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);