diff --git a/vvp/array.cc b/vvp/array.cc index 46fdcf456..9231ba4c7 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -387,6 +387,9 @@ static vpiHandle vpi_array_get_handle(int code, vpiHandle ref) case vpiScope: return &obj->scope->base; + + case vpiModule: + return vpip_module(obj->scope); } return 0; @@ -529,6 +532,9 @@ static vpiHandle vpi_array_var_word_get_handle(int code, vpiHandle ref) case vpiScope: return &parent->scope->base; + + case vpiModule: + return vpip_module(parent->scope); } return 0; @@ -720,6 +726,9 @@ static vpiHandle vpi_array_vthr_A_get_handle(int code, vpiHandle ref) case vpiScope: return &parent->scope->base; + + case vpiModule: + return vpip_module(parent->scope); } return 0; diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index a43b33527..c802170a4 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -291,6 +291,9 @@ static vpiHandle string_param_handle(int code, vpiHandle obj) case vpiScope: return &rfp->scope->base; + case vpiModule: + return vpip_module(rfp->scope); + default: return 0; } @@ -492,6 +495,9 @@ static vpiHandle binary_param_handle(int code, vpiHandle obj) case vpiScope: return &rfp->scope->base; + case vpiModule: + return vpip_module(rfp->scope); + default: return 0; } @@ -745,6 +751,9 @@ static vpiHandle real_param_handle(int code, vpiHandle obj) case vpiScope: return &rfp->scope->base; + case vpiModule: + return vpip_module(rfp->scope); + default: return 0; } diff --git a/vvp/vpi_event.cc b/vvp/vpi_event.cc index bb0385603..ae3b80ab5 100644 --- a/vvp/vpi_event.cc +++ b/vvp/vpi_event.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2007 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-2009 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 @@ -61,9 +61,11 @@ static vpiHandle named_event_get_handle(int code, vpiHandle ref) struct __vpiNamedEvent*obj = (struct __vpiNamedEvent*)ref; switch (code) { - case vpiScope: return &obj->scope->base; + + case vpiModule: + return vpip_module(obj->scope); } return 0; diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index f42dfbcde..b3a559e70 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -66,6 +66,15 @@ struct __vpiScope* vpip_scope(__vpiRealVar*sig) return sig->within.scope; } +vpiHandle vpip_module(struct __vpiScope*scope) +{ + while(scope && scope->base.vpi_type->type_code != vpiModule) { + scope = scope->scope; + } + assert(scope); + return &scope->base; +} + const char *vpip_string(const char*str) { static vpip_string_chunk first_chunk = {0, {0}}; @@ -218,6 +227,12 @@ static const char* vpi_type_values(PLI_INT32 code) return "vpiMemoryWord"; case vpiModule: return "vpiModule"; + case vpiNamedBegin: + return "vpiNamedBegin"; + case vpiNamedEvent: + return "vpiNamedEvent"; + case vpiNamedFork: + return "vpiNamedFork"; case vpiNet: return "vpiNet"; case vpiParameter: diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 528e9d572..dc8b8fca6 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -595,4 +595,7 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type); extern char *simple_set_rbuf_str(const char *s1); extern char *generic_get_str(int code, vpiHandle ref, const char *name, const char *index); +/* A routine to find the enclosing module. */ +extern vpiHandle vpip_module(struct __vpiScope*scope); + #endif diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index 0f8aa2d4e..abc058029 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2009 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 @@ -103,6 +103,9 @@ static vpiHandle real_var_get_handle(int code, vpiHandle ref) case vpiScope: return &(vpip_scope(rfp)->base); + + case vpiModule: + return vpip_module(vpip_scope(rfp)); } return 0; diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index b30136f0a..6941fc9bc 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -596,13 +596,7 @@ static vpiHandle signal_get_handle(int code, vpiHandle ref) return &(vpip_scope(rfp)->base); case vpiModule: - { struct __vpiScope*scope = vpip_scope(rfp); - while (scope && scope->base.vpi_type->type_code != vpiModule) - scope = scope->scope; - - assert(scope); - return &scope->base; - } + return vpip_module(vpip_scope(rfp)); } return 0; @@ -977,7 +971,7 @@ static int PV_get(int code, vpiHandle ref) return rfp->sbase == 0 && rfp->twid == 0; case vpiLeftRange: - rval += rfp->width; + rval += rfp->width - 1; case vpiRightRange: rval += vpi_get(vpiRightRange, rfp->parent) + PV_get_base(rfp); return rval; @@ -1129,10 +1123,11 @@ static vpiHandle PV_get_handle(int code, vpiHandle ref) struct __vpiPV*rfp = (struct __vpiPV*)ref; switch (code) { - case vpiParent: return rfp->parent; - break; + + case vpiModule: + return vpi_handle(vpiModule, rfp->parent); } return 0; diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index 34c117ce8..114810b22 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2009 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 @@ -62,6 +62,7 @@ static vpiHandle systask_handle(int type, vpiHandle ref) switch (type) { case vpiScope: return &rfp->scope->base; + default: return 0; }; @@ -75,8 +76,13 @@ static int systask_get(int type, vpiHandle ref) || (ref->vpi_type->type_code == vpiSysFuncCall)); switch (type) { + /* This is not the correct way to get this information, but + * some of the code that implements the acc and tf routines + * use this method so we will keep it in for now. */ case vpiTimeUnit: return rfp->scope->time_units; + case vpiTimePrecision: + return rfp->scope->time_precision; case vpiLineNo: return rfp->lineno;