From 951f9f2bbfbc3143457e7adedbf7f1cecfc7fdf9 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 15 Aug 2007 21:05:42 -0700 Subject: [PATCH] Add vpiType to the vpi_get_str() function. vpi_get_str() can now return a reasonable value for most of the types used in vvp. I'm not certain I got all of them, but they are easy to add if any are missing. I also fixed a couple of typos that I found while looking for all the different types. --- vvp/vpi.txt | 2 +- vvp/vpi_priv.cc | 26 +++++++++++- vvp/vpi_scope.cc | 105 +++++++++++----------------------------------- vvp/vpi_signal.cc | 2 +- 4 files changed, 52 insertions(+), 83 deletions(-) diff --git a/vvp/vpi.txt b/vvp/vpi.txt index 182e865ca..5da91374b 100644 --- a/vvp/vpi.txt +++ b/vvp/vpi.txt @@ -113,7 +113,7 @@ declare a scope with the same name more than once in a parent scope. The name string given when creating the scope is the basename for the scope. The vvp automatically constructs full names from the scope hierarchy, and runtime VPI code can access that full name with the -vpiFullname reference. +vpiFullName reference. The .timescale directive changes the scope units from the simulation precision to the specified precision. The .timescale directive affects diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 57b507eae..bc5df13aa 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -185,12 +185,22 @@ static const char* vpi_type_values(PLI_INT32 code) switch (code) { case vpiConstant: return "vpiConstant"; + case vpiIntegerVar: + return "vpiIntegerVar"; + case vpiFunction: + return "vpiFunction"; case vpiModule: return "vpiModule"; case vpiNet: return "vpiNet"; + case vpiParameter: + return "vpiParameter"; + case vpiRealVar: + return "vpiRealVar"; case vpiReg: return "vpiReg"; + case vpiTask: + return "vpiTask"; default: sprintf(buf, "%d", code); } @@ -242,7 +252,21 @@ char* vpi_get_str(PLI_INT32 property, vpiHandle ref) return 0; } - assert(ref); + if (property == vpiType) { + if (vpi_trace) { + fprintf(vpi_trace, "vpi_get(vpiType, %p) --> %s\n", + ref, vpi_type_values(ref->vpi_type->type_code)); + } + + struct __vpiSignal*rfp = (struct __vpiSignal*)ref; + PLI_INT32 type; + if (ref->vpi_type->type_code == vpiReg && rfp->isint_) + type = vpiIntegerVar; + else + type = ref->vpi_type->type_code; + return (char *)vpi_type_values(type); + } + if (ref->vpi_type->vpi_get_str_ == 0) { if (vpi_trace) { fprintf(vpi_trace, "vpi_get_str(%s, %p) --X\n", diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index 13bf3d27d..b9203118d 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -83,6 +83,25 @@ static void construct_scope_fullname(struct __vpiScope*ref, char*buf) strcat(buf, ref->name); } +static const char* scope_get_type(int code) +{ + switch (code) { + case vpiModule: + return "vpiModule"; + case vpiFunction: + return "vpiFunction"; + case vpiTask: + return "vpiTask"; + case vpiNamedBegin: + return "vpiNamedBegin"; + case vpiNamedFork: + return "vpiNamedFork"; + default: + fprintf(stderr, "ERROR: invalid code %d.", code); + assert(0); + } +} + static char* scope_get_str(int code, vpiHandle obj) { struct __vpiScope*ref = (struct __vpiScope*)obj; @@ -110,7 +129,13 @@ static char* scope_get_str(int code, vpiHandle obj) strcpy(rbuf, ref->tname); return rbuf; + case vpiType: + rbuf = need_result_buf(strlen(scope_get_type(code)) + 1, RBUF_STR); + strcpy(rbuf, scope_get_type(code)); + return rbuf; + default: + fprintf(stderr, "ERROR: invalid code %d.", code); assert(0); return 0; } @@ -384,83 +409,3 @@ void vpip_attach_to_current_scope(vpiHandle obj) attach_to_scope_(current_scope, obj); } - -/* - * $Log: vpi_scope.cc,v $ - * Revision 1.36 2006/04/10 00:37:43 steve - * Add support for generate loops w/ wires and gates. - * - * Revision 1.35 2006/03/06 05:43:15 steve - * Cleanup vpi_const to use vec4 values. - * - * Revision 1.34 2005/06/12 01:10:26 steve - * Remove useless references to functor.h - * - * Revision 1.33 2005/04/28 04:59:53 steve - * Remove dead functor code. - * - * Revision 1.32 2004/10/04 01:10:59 steve - * Clean up spurious trailing white space. - * - * Revision 1.31 2003/05/29 02:21:45 steve - * Implement acc_fetch_defname and its infrastructure in vvp. - * - * Revision 1.30 2003/05/27 16:22:10 steve - * PLI get time units/precision. - * - * Revision 1.29 2003/03/14 05:01:22 steve - * vpiModule handle of scope is parent scope. - * - * Revision 1.28 2003/03/06 04:32:00 steve - * Use hashed name strings for identifiers. - * - * Revision 1.27 2003/03/03 01:47:50 steve - * .scope directives store only the base names. - * - * Revision 1.26 2003/02/27 21:54:44 steve - * Add scope type have a vpi_get function. - * - * Revision 1.25 2003/02/23 06:41:54 steve - * Add to interactive stop mode support for - * current scope, the ability to scan/traverse - * scopes, and the ability to call system tasks. - * - * Revision 1.24 2003/02/11 05:20:45 steve - * Include vpiRealVar objects in vpiVariables scan. - * - * Revision 1.23 2003/02/09 23:33:26 steve - * Spelling fixes. - * - * Revision 1.22 2002/12/21 00:55:58 steve - * The $time system task returns the integer time - * scaled to the local units. Change the internal - * implementation of vpiSystemTime the $time functions - * to properly account for this. Also add $simtime - * to get the simulation time. - * - * Revision 1.21 2002/11/15 22:14:12 steve - * Add vpiScope iterate on vpiScope objects. - * - * Revision 1.20 2002/08/12 01:35:09 steve - * conditional ident string using autoconfig. - * - * Revision 1.19 2002/07/17 05:13:43 steve - * Implementation of vpi_handle_by_name, and - * add the vpiVariables iterator. - * - * Revision 1.18 2002/07/14 02:52:05 steve - * Fix vpiScope iterator. - * - * Revision 1.17 2002/07/12 18:23:30 steve - * Use result buf for event and scope names. - * - * Revision 1.16 2002/07/05 17:14:15 steve - * Names of vpi objects allocated as vpip_strings. - * - * Revision 1.15 2002/05/18 02:34:11 steve - * Add vpi support for named events. - * - * Add vpi_mode_flag to track the mode of the - * vpi engine. This is for error checking. - */ - diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index 622b4dba7..05a793dc2 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -656,7 +656,7 @@ static const struct __vpirt vpip_net_rt = { }; /* - * Construct a vpiIntegetVar object. Indicate the type using a flag + * Construct a vpiIntegerVar object. Indicate the type using a flag * to minimize the code modifications. Icarus implements integers * as 'reg signed [31:0]'. */