diff --git a/vvp/array.cc b/vvp/array.cc index 5bbcba787..e4b829263 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -82,6 +82,8 @@ vvp_array_t array_find(const char*label) */ struct __vpiArray : public __vpiHandle { __vpiArray(); + int get_type_code(void) const; + struct __vpiScope*scope; const char*name; /* Permanently allocated string */ unsigned array_count; @@ -105,6 +107,7 @@ struct __vpiArray : public __vpiHandle { struct __vpiArrayIterator : public __vpiHandle { __vpiArrayIterator(); + int get_type_code(void) const; struct __vpiArray*array; unsigned next; @@ -112,6 +115,8 @@ struct __vpiArrayIterator : public __vpiHandle { struct __vpiArrayIndex : public __vpiHandle { __vpiArrayIndex(); + int get_type_code(void) const; + struct __vpiDecConst *index; unsigned done; }; @@ -119,6 +124,7 @@ struct __vpiArrayIndex : public __vpiHandle { struct __vpiArrayVthrA : public __vpiHandle { __vpiArrayVthrA(); + int get_type_code(void) const; struct __vpiArray*array; // If this is set, then use it to get the index value. @@ -188,6 +194,8 @@ struct __vpiArrayVthrA : public __vpiHandle { struct __vpiArrayVthrAPV : public __vpiHandle { __vpiArrayVthrAPV(); + int get_type_code(void) const; + struct __vpiArray*array; unsigned word_sel; unsigned part_bit; @@ -250,10 +258,12 @@ bool is_net_array(vpiHandle obj) struct __vpiArrayWord { struct as_word_t : public __vpiHandle { as_word_t(); + int get_type_code(void) const; } as_word; struct as_index_t : public __vpiHandle { as_index_t(); + int get_type_code(void) const; } as_index; union { @@ -311,6 +321,8 @@ inline __vpiArray::__vpiArray() { } +int __vpiArray::get_type_code(void) const +{ return vpiMemory; } static const struct __vpirt vpip_array_iterator_rt = { vpiIterator, @@ -331,6 +343,9 @@ inline __vpiArrayIterator::__vpiArrayIterator() { } +int __vpiArrayIterator::get_type_code(void) const +{ return vpiIterator; } + /* This should look a bit odd since it provides a fake iteration on * this object. This trickery is used to implement the two forms of @@ -354,6 +369,9 @@ inline __vpiArrayIndex::__vpiArrayIndex() { } +int __vpiArrayIndex::get_type_code(void) const +{ return vpiIterator; } + static const struct __vpirt vpip_array_var_word_rt = { vpiMemoryWord, &vpi_array_var_word_get, @@ -372,6 +390,9 @@ inline __vpiArrayWord::as_word_t::as_word_t() { } +int __vpiArrayWord::as_word_t::get_type_code(void) const +{ return vpiMemoryWord; } + static const struct __vpirt vpip_array_var_index_rt = { vpiIndex, 0, @@ -390,6 +411,9 @@ inline __vpiArrayWord::as_index_t::as_index_t() { } +int __vpiArrayWord::as_index_t::get_type_code(void) const +{ return vpiIndex; } + static const struct __vpirt vpip_array_vthr_A_rt = { vpiMemoryWord, &vpi_array_vthr_A_get, @@ -409,6 +433,9 @@ inline __vpiArrayVthrA::__vpiArrayVthrA() { } +int __vpiArrayVthrA::get_type_code(void) const +{ return vpiMemoryWord; } + static const struct __vpirt vpip_array_vthr_APV_rt = { vpiMemoryWord, &vpi_array_vthr_APV_get, @@ -428,6 +455,9 @@ inline __vpiArrayVthrAPV::__vpiArrayVthrAPV() { } +int __vpiArrayVthrAPV::get_type_code(void) const +{ return vpiMemoryWord; } + static struct __vpiArrayWord* array_var_word_from_handle(vpiHandle ref) { if (ref == 0) diff --git a/vvp/delay.cc b/vvp/delay.cc index ef5aa4807..898bb77dc 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2011 Stephen Williams + * Copyright (c) 2005-2012 Stephen Williams * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -990,6 +990,9 @@ inline __vpiModPathSrc::__vpiModPathSrc() { } +int __vpiModPathSrc::get_type_code(void) const +{ return vpiModPath; } + static const struct __vpirt vpip_modpath_term_rt = { vpiPathTerm, pathterm_get, @@ -1009,6 +1012,9 @@ inline __vpiModPathTerm::__vpiModPathTerm() { } +int __vpiModPathTerm::get_type_code(void) const +{ return vpiPathTerm; } + static void initialize_path_term(struct __vpiModPathTerm&obj) { obj.expr = 0; diff --git a/vvp/enum_type.cc b/vvp/enum_type.cc index eacb17fc9..0b9937829 100644 --- a/vvp/enum_type.cc +++ b/vvp/enum_type.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2010-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -27,6 +27,7 @@ struct enumconst_s : public __vpiHandle { enumconst_s(); + int get_type_code(void) const; const char*name; vvp_vector2_t val2; @@ -35,6 +36,7 @@ struct enumconst_s : public __vpiHandle { struct __vpiEnumTypespec : public __vpiHandle { __vpiEnumTypespec(); + int get_type_code(void) const; std::vector names; int base_type_code; @@ -104,6 +106,9 @@ inline __vpiEnumTypespec::__vpiEnumTypespec() { } +int __vpiEnumTypespec::get_type_code(void) const +{ return vpiEnumTypespec; } + static int enum_name_get(int code, vpiHandle obj) { struct enumconst_s*ref = dynamic_cast(obj); @@ -160,6 +165,9 @@ inline enumconst_s::enumconst_s() { } +int enumconst_s::get_type_code(void) const +{ return vpiEnumConst; } + void compile_enum2_type(char*label, long width, bool signed_flag, std::list*names) { diff --git a/vvp/file_line.cc b/vvp/file_line.cc index 22f95fd4b..10044be33 100644 --- a/vvp/file_line.cc +++ b/vvp/file_line.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Cary R. (cygcary@yahoo.com) + * Copyright (C) 2011-2012 Cary R. (cygcary@yahoo.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ struct __vpiFileLine : public __vpiHandle { __vpiFileLine(); + int get_type_code(void) const; const char *description; unsigned file_idx; @@ -79,6 +80,9 @@ inline __vpiFileLine::__vpiFileLine() { } +int __vpiFileLine::get_type_code(void) const +{ return _vpiFileLine; } + vpiHandle vpip_build_file_line(char*description, long file_idx, long lineno) { struct __vpiFileLine*obj = new struct __vpiFileLine; diff --git a/vvp/vpi_callback.cc b/vvp/vpi_callback.cc index 5a3af8215..f79acb429 100644 --- a/vvp/vpi_callback.cc +++ b/vvp/vpi_callback.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -65,6 +65,9 @@ inline __vpiCallback::__vpiCallback() { } +int __vpiCallback::get_type_code(void) const +{ return vpiCallback; } + /* * Callback handles are created when the VPI function registers a diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index d1c639afe..92b77236f 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -184,6 +184,9 @@ inline __vpiStringConst::__vpiStringConst() { } +int __vpiStringConst::get_type_code(void) const +{ return vpiConstant; } + struct __vpiStringConstTEMP : public __vpiStringConst { __vpiStringConstTEMP(); }; @@ -262,6 +265,8 @@ vpiHandle vpip_make_string_const(char*text, bool persistent_flag) struct __vpiStringParam : public __vpiStringConst { __vpiStringParam(); + int get_type_code(void) const; + const char*basename; struct __vpiScope* scope; unsigned file_idx; @@ -328,6 +333,8 @@ inline __vpiStringParam::__vpiStringParam() { } +int __vpiStringParam::get_type_code(void) const +{ return vpiParameter; } vpiHandle vpip_make_string_param(char*name, char*text, long file_idx, long lineno) @@ -426,6 +433,9 @@ inline __vpiBinaryConst::__vpiBinaryConst() { } +int __vpiBinaryConst::get_type_code(void) const +{ return vpiConstant; } + /* * Make a VPI constant from a vector string. The string is normally a * ASCII string, with each letter a 4-value bit. The first character @@ -478,6 +488,8 @@ vvp_vector4_t vector4_from_text(const char*bits, unsigned wid) struct __vpiBinaryParam : public __vpiBinaryConst { __vpiBinaryParam(); + int get_type_code(void) const; + const char*basename; struct __vpiScope*scope; unsigned file_idx; @@ -540,6 +552,9 @@ inline __vpiBinaryParam::__vpiBinaryParam() { } +int __vpiBinaryParam::get_type_code(void) const +{ return vpiParameter; } + vpiHandle vpip_make_binary_param(char*name, const vvp_vector4_t&bits, bool signed_flag, long file_idx, long lineno) @@ -656,6 +671,9 @@ __vpiDecConst::__vpiDecConst(int val) value = val; } +int __vpiDecConst::get_type_code(void) const +{ return vpiConstant; } + static int real_get(int code, vpiHandle) { @@ -712,6 +730,10 @@ inline __vpiRealConst::__vpiRealConst() { } +int __vpiRealConst::get_type_code(void) const +{ return vpiConstant; } + + vpiHandle vpip_make_real_const(double value) { struct __vpiRealConst*obj = new __vpiRealConst; @@ -721,6 +743,8 @@ vpiHandle vpip_make_real_const(double value) struct __vpiRealParam : public __vpiRealConst { __vpiRealParam(); + int get_type_code(void) const; + const char*basename; struct __vpiScope* scope; unsigned file_idx; @@ -783,6 +807,9 @@ inline __vpiRealParam::__vpiRealParam() { } +int __vpiRealParam::get_type_code(void) const +{ return vpiParameter; } + vpiHandle vpip_make_real_param(char*name, double value, long file_idx, long lineno) diff --git a/vvp/vpi_event.cc b/vvp/vpi_event.cc index c28f0aa58..33131f9f6 100644 --- a/vvp/vpi_event.cc +++ b/vvp/vpi_event.cc @@ -85,6 +85,10 @@ inline __vpiNamedEvent::__vpiNamedEvent() { } +int __vpiNamedEvent::get_type_code(void) const +{ return vpiNamedEvent; } + + vpiHandle vpip_make_named_event(const char*name, vvp_net_t*funct) { struct __vpiNamedEvent*obj = new __vpiNamedEvent; diff --git a/vvp/vpi_iter.cc b/vvp/vpi_iter.cc index 229e96ca7..233b037e3 100644 --- a/vvp/vpi_iter.cc +++ b/vvp/vpi_iter.cc @@ -56,6 +56,9 @@ inline __vpiIterator::__vpiIterator() { } +int __vpiIterator::get_type_code(void) const +{ return vpiIterator; } + vpiHandle vpip_make_iterator(unsigned nargs, vpiHandle*args, bool free_args_flag) { diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 91fa50628..accfc21fe 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -89,7 +89,7 @@ extern vpi_mode_t vpi_mode_flag; * pointer to an instance of this structure. */ struct __vpirt { - int type_code; + int type_code_X; /* These methods extract information from the handle. */ int (*vpi_get_)(int, vpiHandle); @@ -124,7 +124,7 @@ class __vpiHandle { // The descructor is virtual so that dynamic types will work. virtual ~__vpiHandle() { } - inline int get_type_code(void) const { return vpi_type_->type_code; } + virtual int get_type_code(void) const =0; inline int vpi_get(int code) { return vpi_type_->vpi_get_? vpi_type_->vpi_get_(code,this) : vpiUndefined; } @@ -178,6 +178,8 @@ class __vpiHandle { */ struct __vpiIterator : public __vpiHandle { __vpiIterator(); + int get_type_code(void) const; + vpiHandle *args; unsigned nargs; unsigned next; @@ -194,6 +196,7 @@ extern vpiHandle vpip_make_iterator(unsigned nargs, vpiHandle*args, */ struct __vpiCallback : public __vpiHandle { __vpiCallback(); + int get_type_code(void) const; // user supplied callback data struct t_cb_data cb_data; @@ -216,6 +219,8 @@ extern void callback_execute(struct __vpiCallback*cur); struct __vpiSystemTime : public __vpiHandle { __vpiSystemTime(); + int get_type_code(void) const; + struct __vpiScope*scope; protected: inline __vpiSystemTime(const struct __vpirt*rt) : __vpiHandle(rt) { } @@ -238,8 +243,6 @@ struct __vpiScopedRealtime : public __vpiSystemTime { * scope. */ struct __vpiScope : public __vpiHandle { - __vpiScope(const struct __vpirt*rt) : __vpiHandle(rt) { } - struct __vpiScope *scope; /* The scope has a name. */ const char*name; @@ -268,6 +271,10 @@ struct __vpiScope : public __vpiHandle { std::set threads; signed int time_units :8; signed int time_precision :8; + + protected: + __vpiScope(const struct __vpirt*rt) : __vpiHandle(rt) { } + }; extern struct __vpiScope* vpip_peek_current_scope(void); @@ -286,7 +293,7 @@ extern void vpip_make_root_iterator(struct __vpiHandle**&table, * a declared name and declaration indices. */ struct __vpiSignal : public __vpiHandle { - inline __vpiSignal(const struct __vpirt*rt) : __vpiHandle(rt) { } + #ifdef CHECK_WITH_VALGRIND struct __vpiSignal *pool; #endif @@ -309,6 +316,8 @@ struct __vpiSignal : public __vpiHandle { public: static void*operator new(std::size_t size); static void operator delete(void*); // not implemented + protected: + inline __vpiSignal(const struct __vpirt*rt) : __vpiHandle(rt) { } private: // Not implemented static void*operator new[] (std::size_t size); static void operator delete[](void*); @@ -322,8 +331,8 @@ extern vpiHandle vpip_make_int4(const char*name, int msb, int lsb, vvp_net_t*vec); extern vpiHandle vpip_make_var4(const char*name, int msb, int lsb, bool signed_flag, vvp_net_t*net); -extern vpiHandle vpip_make_net4(const char*name, const struct __vpirt*rt, - int msb, int lsb, bool signed_flag, vvp_net_t*node); +extern vpiHandle vpip_make_net4(const char*name, int msb, int lsb, + bool signed_flag, vvp_net_t*node); /* * This is used by system calls to represent a bit/part select of @@ -331,6 +340,8 @@ extern vpiHandle vpip_make_net4(const char*name, const struct __vpirt*rt, */ struct __vpiPV : public __vpiHandle { __vpiPV(); + int get_type_code(void) const; + vpiHandle parent; vvp_net_t*net; vpiHandle sbase; @@ -349,6 +360,8 @@ extern void vpip_part_select_value_change(struct __vpiCallback*cbh, vpiHandle ob struct __vpiModPathTerm : public __vpiHandle { __vpiModPathTerm(); + int get_type_code(void) const; + vpiHandle expr; /* The value returned by vpi_get(vpiEdge, ...); */ int edge; @@ -356,6 +369,8 @@ struct __vpiModPathTerm : public __vpiHandle { struct __vpiModPathSrc : public __vpiHandle { __vpiModPathSrc(); + int get_type_code(void) const; + struct __vpiModPath *dest; int type; @@ -405,6 +420,7 @@ extern struct __vpiModPath* vpip_make_modpath(vvp_net_t *net) ; */ struct __vpiNamedEvent : public __vpiHandle { __vpiNamedEvent(); + int get_type_code(void) const; /* base name of the event object */ const char*name; @@ -435,6 +451,8 @@ extern bool is_net_array(vpiHandle obj); */ struct __vpiRealVar : public __vpiHandle { __vpiRealVar(); + int get_type_code(void) const; + union { // The scope or parent array that contains me. vpiHandle parent; struct __vpiScope* scope; @@ -472,6 +490,8 @@ extern vpiHandle vpip_make_real_var(const char*name, vvp_net_t*net); */ struct __vpiUserSystf : public __vpiHandle { __vpiUserSystf(); + int get_type_code(void) const; + s_vpi_systf_data info; bool is_user_defn; }; @@ -483,6 +503,7 @@ extern struct __vpiUserSystf* vpip_find_systf(const char*name); struct __vpiSysTaskCall : public __vpiHandle { __vpiSysTaskCall(const struct __vpirt*rt) : __vpiHandle(rt) { } + struct __vpiScope* scope; struct __vpiUserSystf*defn; unsigned nargs; @@ -510,6 +531,7 @@ extern struct __vpiSysTaskCall*vpip_cur_task; */ struct __vpiStringConst : public __vpiHandle { __vpiStringConst(); + int get_type_code(void) const; char*value; size_t value_len; @@ -523,6 +545,8 @@ vpiHandle vpip_make_string_param(char*name, char*value, struct __vpiBinaryConst : public __vpiHandle { __vpiBinaryConst(); + int get_type_code(void) const; + vvp_vector4_t bits; /* TRUE if this constant is signed. */ int signed_flag :1; @@ -539,11 +563,15 @@ vpiHandle vpip_make_binary_param(char*name, const vvp_vector4_t&bits, struct __vpiDecConst : public __vpiHandle { __vpiDecConst(int val =0); + int get_type_code(void) const; + int value; }; struct __vpiRealConst : public __vpiHandle { __vpiRealConst(); + int get_type_code(void) const; + double value; protected: inline __vpiRealConst(const struct __vpirt*rt) : __vpiHandle(rt) { } diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index f0b5b8bc8..c13449e8d 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2010 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -155,6 +155,9 @@ inline __vpiRealVar::__vpiRealVar() { } +int __vpiRealVar::get_type_code(void) const +{ return vpiRealVar; } + void vpip_real_value_change(struct __vpiCallback*cbh, vpiHandle ref) diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index f3e0e0086..bf0395474 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -320,6 +320,11 @@ static const struct __vpirt vpip_scope_module_rt = { 0 }; +struct vpiScopeModule : public __vpiScope { + inline vpiScopeModule() : __vpiScope(&vpip_scope_module_rt) { } + int get_type_code(void) const { return vpiModule; } +}; + static const struct __vpirt vpip_scope_task_rt = { vpiTask, scope_get, @@ -334,6 +339,11 @@ static const struct __vpirt vpip_scope_task_rt = { 0 }; +struct vpiScopeTask : public __vpiScope { + inline vpiScopeTask() : __vpiScope(&vpip_scope_task_rt) { } + int get_type_code(void) const { return vpiTask; } +}; + static const struct __vpirt vpip_scope_function_rt = { vpiFunction, scope_get, @@ -348,6 +358,11 @@ static const struct __vpirt vpip_scope_function_rt = { 0 }; +struct vpiScopeFunction : public __vpiScope { + inline vpiScopeFunction() : __vpiScope(&vpip_scope_function_rt) { } + int get_type_code(void) const { return vpiFunction; } +}; + static const struct __vpirt vpip_scope_begin_rt = { vpiNamedBegin, scope_get, @@ -362,6 +377,11 @@ static const struct __vpirt vpip_scope_begin_rt = { 0 }; +struct vpiScopeBegin : public __vpiScope { + inline vpiScopeBegin() : __vpiScope(&vpip_scope_begin_rt) { } + int get_type_code(void) const { return vpiNamedBegin; } +}; + static const struct __vpirt vpip_scope_fork_rt = { vpiNamedFork, scope_get, @@ -376,6 +396,11 @@ static const struct __vpirt vpip_scope_fork_rt = { 0 }; +struct vpiScopeFork : public __vpiScope { + inline vpiScopeFork() : __vpiScope(&vpip_scope_fork_rt) { } + int get_type_code(void) const { return vpiNamedFork; } +}; + /* * The current_scope is a compile time concept. As the vvp source is * compiled, items that have scope are placed in the current @@ -423,19 +448,19 @@ compile_scope_decl(char*label, char*type, char*name, char*tname, struct __vpiScope*scope; if (strcmp(base_type,"module") == 0) { - scope = new __vpiScope(&vpip_scope_module_rt); + scope = new vpiScopeModule; } else if (strcmp(base_type,"function") == 0) { - scope = new __vpiScope(&vpip_scope_function_rt); + scope = new vpiScopeFunction; } else if (strcmp(base_type,"task") == 0) { - scope = new __vpiScope(&vpip_scope_task_rt); + scope = new vpiScopeTask; } else if (strcmp(base_type,"fork") == 0) { - scope = new __vpiScope(&vpip_scope_fork_rt); + scope = new vpiScopeFork; } else if (strcmp(base_type,"begin") == 0) { - scope = new __vpiScope(&vpip_scope_begin_rt); + scope = new vpiScopeBegin; } else if (strcmp(base_type,"generate") == 0) { - scope = new __vpiScope(&vpip_scope_begin_rt); + scope = new vpiScopeBegin; } else { - scope = new __vpiScope(&vpip_scope_module_rt); + scope = new vpiScopeModule; assert(0); } diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index 4e0fbdd35..fb22826b6 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -131,6 +131,10 @@ char *generic_get_str(int code, vpiHandle ref, const char *name, const char *ind return res; } +static vpiHandle fill_in_net4(struct __vpiSignal*obj, + const char*name, int msb, int lsb, + bool signed_flag, vvp_net_t*node); + /* * The standard formating/conversion routines. * They work with full or partial signals. @@ -869,6 +873,10 @@ static const struct __vpirt vpip_reg_rt = { 0, 0 }; +struct signal_reg : public __vpiSignal { + inline signal_reg() : __vpiSignal(&vpip_reg_rt) { } + int get_type_code(void) const { return vpiReg; } +}; static const struct __vpirt vpip_integer_rt = { vpiIntegerVar, @@ -883,6 +891,10 @@ static const struct __vpirt vpip_integer_rt = { 0, 0 }; +struct signal_integer : public __vpiSignal { + inline signal_integer() : __vpiSignal(&vpip_integer_rt) { } + int get_type_code(void) const { return vpiIntegerVar; } +}; static const struct __vpirt vpip_net_rt = { vpiNet, @@ -897,6 +909,10 @@ static const struct __vpirt vpip_net_rt = { 0, 0 }; +struct signal_net : public __vpiSignal { + inline signal_net() : __vpiSignal(&vpip_net_rt) { } + int get_type_code(void) const { return vpiNet; } +}; static const struct __vpirt vpip_byte_rt = { vpiByteVar, @@ -911,6 +927,10 @@ static const struct __vpirt vpip_byte_rt = { 0, 0 }; +struct signal_byte : public __vpiSignal { + inline signal_byte() : __vpiSignal(&vpip_byte_rt) { } + int get_type_code(void) const { return vpiByteVar; } +}; static const struct __vpirt vpip_bitvar_rt = { vpiBitVar, @@ -925,6 +945,10 @@ static const struct __vpirt vpip_bitvar_rt = { 0, 0 }; +struct signal_bitvar : public __vpiSignal { + inline signal_bitvar() : __vpiSignal(&vpip_bitvar_rt) { } + int get_type_code(void) const { return vpiBitVar; } +}; static const struct __vpirt vpip_shortint_rt = { vpiShortIntVar, @@ -939,6 +963,10 @@ static const struct __vpirt vpip_shortint_rt = { 0, 0 }; +struct signal_shortint : public __vpiSignal { + inline signal_shortint() : __vpiSignal(&vpip_shortint_rt) { } + int get_type_code(void) const { return vpiShortIntVar; } +}; static const struct __vpirt vpip_int_rt = { vpiIntVar, @@ -953,6 +981,10 @@ static const struct __vpirt vpip_int_rt = { 0, 0 }; +struct signal_int : public __vpiSignal { + inline signal_int() : __vpiSignal(&vpip_int_rt) { } + int get_type_code(void) const { return vpiIntVar; } +}; static const struct __vpirt vpip_longint_rt = { vpiLongIntVar, @@ -967,6 +999,10 @@ static const struct __vpirt vpip_longint_rt = { 0, 0 }; +struct signal_longint : public __vpiSignal { + inline signal_longint() : __vpiSignal(&vpip_longint_rt) { } + int get_type_code(void) const { return vpiLongIntVar; } +}; /* @@ -976,9 +1012,8 @@ static const struct __vpirt vpip_longint_rt = { */ vpiHandle vpip_make_int4(const char*name, int msb, int lsb, vvp_net_t*vec) { - vpiHandle obj = vpip_make_net4(name, &vpip_integer_rt, - msb,lsb, true, vec); - return obj; + __vpiSignal*obj = new signal_integer; + return fill_in_net4(obj, name, msb, lsb, true, vec); } /* @@ -987,37 +1022,37 @@ vpiHandle vpip_make_int4(const char*name, int msb, int lsb, vvp_net_t*vec) vpiHandle vpip_make_int2(const char*name, int msb, int lsb, bool signed_flag, vvp_net_t*vec) { - const struct __vpirt*vpi_type; + __vpiSignal*obj; // All unsigned 2-state variables are a vpiBitVar. All 2-state // variables with a non-zero lsb are also a vpiBitVar. if ((! signed_flag) || (lsb != 0) ) { - vpi_type = &vpip_bitvar_rt; + obj = new signal_bitvar; } else { // These could also be bit declarations with matching // information, but for now they get the apparent type. switch (msb) { case 7: - vpi_type = &vpip_byte_rt; + obj = new signal_byte; break; case 15: - vpi_type = &vpip_shortint_rt; + obj = new signal_shortint; break; case 31: - vpi_type = &vpip_int_rt; + obj = new signal_int; break; case 63: - vpi_type = &vpip_longint_rt; + obj = new signal_longint; break; default: // Every other type of bit vector is a vpiBitVar with // array dimensions. - vpi_type = &vpip_bitvar_rt; + obj = new signal_bitvar; break; } } - return vpip_make_net4(name, vpi_type, msb, lsb, signed_flag, vec); + return fill_in_net4(obj, name, msb, lsb, signed_flag, vec); } /* @@ -1026,7 +1061,8 @@ vpiHandle vpip_make_int2(const char*name, int msb, int lsb, bool signed_flag, vpiHandle vpip_make_var4(const char*name, int msb, int lsb, bool signed_flag, vvp_net_t*vec) { - return vpip_make_net4(name, &vpip_reg_rt, msb,lsb, signed_flag, vec); + __vpiSignal*obj = new signal_reg; + return fill_in_net4(obj, name, msb, lsb, signed_flag, vec); } #ifdef CHECK_WITH_VALGRIND @@ -1072,7 +1108,7 @@ void* __vpiSignal::operator new(size_t siz) return cur; } -void __vpiSignal::operator delete(void*ptr) +void __vpiSignal::operator delete(void*) { assert(0); } @@ -1114,11 +1150,10 @@ void signal_pool_delete() * The name is the PLI name for the object. If it is an array it is * []. */ -vpiHandle vpip_make_net4(const char*name, const struct __vpirt*rt, - int msb, int lsb, bool signed_flag, vvp_net_t*node) +static vpiHandle fill_in_net4(struct __vpiSignal*obj, + const char*name, int msb, int lsb, + bool signed_flag, vvp_net_t*node) { - if (rt == 0) rt = &vpip_net_rt; - struct __vpiSignal*obj = new __vpiSignal(rt); obj->id.name = name? vpip_name_string(name) : 0; obj->msb = msb; obj->lsb = lsb; @@ -1136,6 +1171,13 @@ vpiHandle vpip_make_net4(const char*name, const struct __vpirt*rt, return obj; } +vpiHandle vpip_make_net4(const char*name, int msb, int lsb, + bool signed_flag, vvp_net_t*node) +{ + struct __vpiSignal*obj = new signal_net; + return fill_in_net4(obj, name, msb, lsb, signed_flag, node); +} + static int PV_get_base(struct __vpiPV*rfp) { /* We return from the symbol base if it is defined. */ @@ -1403,6 +1445,9 @@ inline __vpiPV::__vpiPV() { } +int __vpiPV::get_type_code(void) const +{ return vpiPartSelect; } + vpiHandle vpip_make_PV(char*var, int base, int width) { struct __vpiPV*obj = new __vpiPV; diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index 22e91b880..933fa0366 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -54,6 +54,10 @@ inline __vpiUserSystf::__vpiUserSystf() { } +int __vpiUserSystf::get_type_code(void) const +{ return vpiUserSystf; } + + static vpiHandle systask_handle(int type, vpiHandle ref) { struct __vpiSysTaskCall*rfp = dynamic_cast<__vpiSysTaskCall*>(ref); @@ -163,6 +167,10 @@ static const struct __vpirt vpip_systask_rt = { 0, 0 }; +struct systask_def : public __vpiSysTaskCall { + inline systask_def() : __vpiSysTaskCall(&vpip_systask_rt) { } + int get_type_code(void) const { return vpiSysTaskCall; } +}; /* * A value *can* be put to a vpiSysFuncCall object. This is how the @@ -173,6 +181,7 @@ static const struct __vpirt vpip_systask_rt = { static vpiHandle sysfunc_put_value(vpiHandle ref, p_vpi_value vp, int) { struct __vpiSysTaskCall*rfp = dynamic_cast<__vpiSysTaskCall*>(ref); + assert(rfp); rfp->put_value = true; @@ -456,7 +465,6 @@ static vpiHandle sysfunc_put_no_value(vpiHandle, p_vpi_value, int) return 0; } - static const struct __vpirt vpip_sysfunc_rt = { vpiSysFuncCall, sysfunc_get, @@ -470,6 +478,10 @@ static const struct __vpirt vpip_sysfunc_rt = { 0, 0 }; +struct sysfunc_def : public __vpiSysTaskCall { + inline sysfunc_def() : __vpiSysTaskCall(&vpip_sysfunc_rt) { } + int get_type_code(void) const { return vpiSysFuncCall; } +}; static const struct __vpirt vpip_sysfunc_real_rt = { vpiSysFuncCall, @@ -484,6 +496,10 @@ static const struct __vpirt vpip_sysfunc_real_rt = { 0, 0 }; +struct sysfunc_real : public __vpiSysTaskCall { + inline sysfunc_real() : __vpiSysTaskCall(&vpip_sysfunc_real_rt) { } + int get_type_code(void) const { return vpiSysFuncCall; } +}; static const struct __vpirt vpip_sysfunc_4net_rt = { vpiSysFuncCall, @@ -498,6 +514,10 @@ static const struct __vpirt vpip_sysfunc_4net_rt = { 0, 0 }; +struct sysfunc_4net : public __vpiSysTaskCall { + inline sysfunc_4net() : __vpiSysTaskCall(&vpip_sysfunc_4net_rt) { } + int get_type_code(void) const { return vpiSysFuncCall; } +}; static const struct __vpirt vpip_sysfunc_rnet_rt = { vpiSysFuncCall, @@ -512,6 +532,10 @@ static const struct __vpirt vpip_sysfunc_rnet_rt = { 0, 0 }; +struct sysfunc_rnet : public __vpiSysTaskCall { + inline sysfunc_rnet() : __vpiSysTaskCall(&vpip_sysfunc_rnet_rt) { } + int get_type_code(void) const { return vpiSysFuncCall; } +}; static const struct __vpirt vpip_sysfunc_no_rt = { vpiSysFuncCall, @@ -526,6 +550,10 @@ static const struct __vpirt vpip_sysfunc_no_rt = { 0, 0 }; +struct sysfunc_no : public __vpiSysTaskCall { + inline sysfunc_no() : __vpiSysTaskCall(&vpip_sysfunc_no_rt) { } + int get_type_code(void) const { return vpiSysFuncCall; } +}; /* **** Manipulate the internal data structures. **** */ @@ -574,6 +602,8 @@ void def_table_delete(void) struct __vpiSystfIterator : public __vpiHandle { __vpiSystfIterator(); + int get_type_code(void) const; + unsigned next; }; @@ -624,6 +654,9 @@ inline __vpiSystfIterator::__vpiSystfIterator() { } +int __vpiSystfIterator::get_type_code(void) const +{ return vpiIterator; } + vpiHandle vpip_make_systf_iterator(void) { /* Check to see if there are any user defined functions. */ @@ -812,24 +845,24 @@ vpiHandle vpip_build_vpi_call(const char*name, unsigned vbit, int vwid, switch (defn->info.type) { case vpiSysTask: - obj = new __vpiSysTaskCall(&vpip_systask_rt); + obj = new systask_def; break; case vpiSysFunc: if (fnet && vwid == -vpiRealConst) { - obj = new __vpiSysTaskCall(&vpip_sysfunc_rnet_rt); + obj = new sysfunc_rnet; } else if (fnet && vwid > 0) { - obj = new __vpiSysTaskCall(&vpip_sysfunc_4net_rt); + obj = new sysfunc_4net; } else if (vwid == -vpiRealConst) { - obj = new __vpiSysTaskCall(&vpip_sysfunc_real_rt); + obj = new sysfunc_real; } else if (vwid > 0) { - obj = new __vpiSysTaskCall(&vpip_sysfunc_rt); + obj = new sysfunc_def; } else if (vwid == 0 && fnet == 0) { - obj = new __vpiSysTaskCall(&vpip_sysfunc_no_rt); + obj = new sysfunc_no; } else { assert(0); @@ -857,7 +890,7 @@ vpiHandle vpip_build_vpi_call(const char*name, unsigned vbit, int vwid, #ifdef CHECK_WITH_VALGRIND void vpi_call_delete(vpiHandle item) { - struct __vpiSysTaskCall*obj = (struct __vpiSysTaskCall *) item; + struct __vpiSysTaskCall*obj = dynamic_cast<__vpiSysTaskCall*>(item); /* The object can be NULL if there was an error. */ if (!obj) return; for (unsigned arg = 0; arg < obj->nargs; arg += 1) { diff --git a/vvp/vpi_time.cc b/vvp/vpi_time.cc index e298d9b8b..d45f23eac 100644 --- a/vvp/vpi_time.cc +++ b/vvp/vpi_time.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -366,6 +366,11 @@ __vpiSystemTime::__vpiSystemTime() scope = 0; } +int __vpiSystemTime::get_type_code(void) const +{ + return vpiSysFuncCall; +} + static const struct __vpirt vpip_system_realtime_rt = { vpiSysFuncCall, timevar_realtime_get, diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index b4abc871c..6f875997a 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -37,6 +37,8 @@ struct __vpiVThrVec : public __vpiHandle { __vpiVThrVec(); + int get_type_code(void) const; + unsigned bas; unsigned wid; unsigned signed_flag : 1; @@ -445,11 +447,14 @@ static const struct __vpirt vpip_vthr_const_rt = { 0, 0 }; -__vpiVThrVec::__vpiVThrVec() +inline __vpiVThrVec::__vpiVThrVec() : __vpiHandle(&vpip_vthr_const_rt) { } +int __vpiVThrVec::get_type_code(void) const +{ return vpiConstant; } + /* * Construct a vpiReg object. Give the object specified dimensions, @@ -485,6 +490,8 @@ static void thread_vthr_delete_real(vpiHandle item) struct __vpiVThrWord : public __vpiHandle { __vpiVThrWord(); + int get_type_code(void) const; + const char* name; int subtype; unsigned index; @@ -597,6 +604,9 @@ inline __vpiVThrWord::__vpiVThrWord() { } +int __vpiVThrWord::get_type_code(void) const +{ return vpiConstant; } + vpiHandle vpip_make_vthr_word(unsigned base, const char*type) { struct __vpiVThrWord*obj = new __vpiVThrWord; diff --git a/vvp/words.cc b/vvp/words.cc index 22fa2bede..2cfdcd3dc 100644 --- a/vvp/words.cc +++ b/vvp/words.cc @@ -258,7 +258,7 @@ static void do_compile_net(vvp_net_t*node, vvp_array_t array, vpiHandle obj = 0; if (! local_flag) { /* Make the vpiHandle for the reg. */ - obj = vpip_make_net4(name, 0, msb, lsb, signed_flag, node); + obj = vpip_make_net4(name, msb, lsb, signed_flag, node); /* This attaches the label to the vpiHandle */ compile_vpi_symbol(my_label, obj); }