From 8cfef65bd8b972700dd58e283465f2c41ef57c95 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 29 May 2003 02:21:45 +0000 Subject: [PATCH] Implement acc_fetch_defname and its infrastructure in vvp. --- acc_user.h | 6 +++++- libveriuser/a_fetch_fullname.c | 10 +++++++++- tgt-vvp/vvp_scope.c | 10 +++++++--- vpi_user.h | 6 +++++- vvp/compile.h | 7 +++++-- vvp/parse.y | 34 ++++++++++++++++++++++++++++++---- vvp/vpi_priv.h | 6 +++++- vvp/vpi_scope.cc | 17 ++++++++++++++--- 8 files changed, 80 insertions(+), 16 deletions(-) diff --git a/acc_user.h b/acc_user.h index 6626ece9d..f699fb8df 100644 --- a/acc_user.h +++ b/acc_user.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: acc_user.h,v 1.13 2003/05/24 03:02:04 steve Exp $" +#ident "$Id: acc_user.h,v 1.14 2003/05/29 02:21:45 steve Exp $" #endif /* @@ -196,6 +196,7 @@ extern char* acc_fetch_fullname(handle obj); extern int acc_fetch_location(p_location loc, handle obj); extern char* acc_fetch_name(handle obj); +extern char* acc_fetch_defname(handle obj); extern double acc_fetch_paramval(handle obj); @@ -244,6 +245,9 @@ EXTERN_C_END /* * $Log: acc_user.h,v $ + * Revision 1.14 2003/05/29 02:21:45 steve + * Implement acc_fetch_defname and its infrastructure in vvp. + * * Revision 1.13 2003/05/24 03:02:04 steve * Add implementation of acc_handle_by_name. * diff --git a/libveriuser/a_fetch_fullname.c b/libveriuser/a_fetch_fullname.c index 9f043243c..bc4ab8946 100644 --- a/libveriuser/a_fetch_fullname.c +++ b/libveriuser/a_fetch_fullname.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: a_fetch_fullname.c,v 1.4 2003/03/13 05:07:46 steve Exp $" +#ident "$Id: a_fetch_fullname.c,v 1.5 2003/05/29 02:21:45 steve Exp $" #endif #include @@ -37,8 +37,16 @@ char* acc_fetch_name(handle object) return __acc_newstring(vpi_get_str(vpiName, object)); } +char* acc_fetch_defname(handle object) +{ + return __acc_newstring(vpi_get_str(vpiDefName, object)); +} + /* * $Log: a_fetch_fullname.c,v $ + * Revision 1.5 2003/05/29 02:21:45 steve + * Implement acc_fetch_defname and its infrastructure in vvp. + * * Revision 1.4 2003/03/13 05:07:46 steve * Declaration warnings. * diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index cb6cb0336..1f96a2ff2 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vvp_scope.c,v 1.93 2003/05/13 01:56:15 steve Exp $" +#ident "$Id: vvp_scope.c,v 1.94 2003/05/29 02:21:45 steve Exp $" #endif # include "vvp_priv.h" @@ -1558,8 +1558,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) default: type = "?"; assert(0); } - fprintf(vvp_out, "S_%p .scope %s, \"%s\"", - net, type, vvp_mangle_name(ivl_scope_basename(net))); + fprintf(vvp_out, "S_%p .scope %s, \"%s\" \"%s\"", + net, type, vvp_mangle_name(ivl_scope_basename(net)), + ivl_scope_tname(net)); if (parent) { fprintf(vvp_out, ", S_%p;\n", parent); @@ -1647,6 +1648,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) /* * $Log: vvp_scope.c,v $ + * Revision 1.94 2003/05/29 02:21:45 steve + * Implement acc_fetch_defname and its infrastructure in vvp. + * * Revision 1.93 2003/05/13 01:56:15 steve * Allow primitives to hvae unconnected input ports. * diff --git a/vpi_user.h b/vpi_user.h index 8ca04ba29..0aab0fd31 100644 --- a/vpi_user.h +++ b/vpi_user.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_user.h,v 1.26 2003/05/23 04:04:02 steve Exp $" +#ident "$Id: vpi_user.h,v 1.27 2003/05/29 02:21:45 steve Exp $" #endif @@ -187,6 +187,7 @@ typedef struct t_vpi_value { #define vpiName 2 #define vpiFullName 3 #define vpiSize 4 +#define vpiDefName 9 #define vpiTimeUnit 11 #define vpiTimePrecision 12 #define vpiConstType 43 @@ -396,6 +397,9 @@ EXTERN_C_END /* * $Log: vpi_user.h,v $ + * Revision 1.27 2003/05/29 02:21:45 steve + * Implement acc_fetch_defname and its infrastructure in vvp. + * * Revision 1.26 2003/05/23 04:04:02 steve * Add vpi_fopen and vpi_get_file. * diff --git a/vvp/compile.h b/vvp/compile.h index c29482a21..04d12ee09 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: compile.h,v 1.51 2003/04/11 05:15:39 steve Exp $" +#ident "$Id: compile.h,v 1.52 2003/05/29 02:21:45 steve Exp $" #endif # include @@ -243,7 +243,7 @@ extern void compile_codelabel(char*label); * The parser uses these functions to compile .scope statements. * The implementations of these live in the vpi_scope.cc file. */ -extern void compile_scope_decl(char*typ, char*lab, char*nam, char*par); +extern void compile_scope_decl(char*typ, char*lab, char*nam,char*tnam,char*par); extern void compile_scope_recall(char*sym); /* @@ -264,6 +264,9 @@ extern void compile_net(char*label, char*name, /* * $Log: compile.h,v $ + * Revision 1.52 2003/05/29 02:21:45 steve + * Implement acc_fetch_defname and its infrastructure in vvp. + * * Revision 1.51 2003/04/11 05:15:39 steve * Add signed versions of .cmp/gt/ge * diff --git a/vvp/parse.y b/vvp/parse.y index 0cbb621bf..bfccda769 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: parse.y,v 1.53 2003/04/11 05:15:39 steve Exp $" +#ident "$Id: parse.y,v 1.54 2003/05/29 02:21:45 steve Exp $" #endif # include "parse_misc.h" @@ -303,13 +303,36 @@ statement /* Scope statements come in two forms. There are the scope - declaration and the scope recall. */ + declaration and the scope recall. The declarations create the + scope, with their association with a parent. The label of the + scope declaration is associated with the new scope. + + The symbol is module, function task, fork or begin. It is the + general class of the scope. + + The strings are the instance name and type name of the + module. For example, if it is instance U of module foo, the + instance name is "U" and the type name is "foo". + + The final symbol is the label of the parent scope. If there is no + parent scope, then this is a root scope. */ + + | T_LABEL K_SCOPE T_SYMBOL ',' T_STRING T_STRING ';' + { compile_scope_decl($1, $3, $5, $6, 0); } + + | T_LABEL K_SCOPE T_SYMBOL ',' T_STRING T_STRING ',' T_SYMBOL ';' + { compile_scope_decl($1, $3, $5, $6, $8); } + + /* XXXX Legacy declaration has no type name. */ | T_LABEL K_SCOPE T_SYMBOL ',' T_STRING ';' - { compile_scope_decl($1, $3, $5, 0); } + { compile_scope_decl($1, $3, $5, "", 0); } | T_LABEL K_SCOPE T_SYMBOL ',' T_STRING ',' T_SYMBOL ';' - { compile_scope_decl($1, $3, $5, $7); } + { compile_scope_decl($1, $3, $5, "", $7); } + + /* Scope recall has no label of its own, but refers by label to a + declared scope. */ | K_SCOPE T_SYMBOL ';' { compile_scope_recall($2); } @@ -584,6 +607,9 @@ int compile_design(const char*path) /* * $Log: parse.y,v $ + * Revision 1.54 2003/05/29 02:21:45 steve + * Implement acc_fetch_defname and its infrastructure in vvp. + * * Revision 1.53 2003/04/11 05:15:39 steve * Add signed versions of .cmp/gt/ge * diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index daa7c13f9..d1a16ae9e 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_priv.h,v 1.54 2003/05/02 04:29:57 steve Exp $" +#ident "$Id: vpi_priv.h,v 1.55 2003/05/29 02:21:45 steve Exp $" #endif # include "vpi_user.h" @@ -143,6 +143,7 @@ struct __vpiScope { struct __vpiScope *scope; /* The scope has a name. */ const char*name; + const char*tname; /* The scope has a system time of its own. */ struct __vpiSystemTime scoped_time; struct __vpiSystemTime scoped_realtime; @@ -417,6 +418,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type); /* * $Log: vpi_priv.h,v $ + * Revision 1.55 2003/05/29 02:21:45 steve + * Implement acc_fetch_defname and its infrastructure in vvp. + * * Revision 1.54 2003/05/02 04:29:57 steve * Add put_value with transport delay. * diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index d909c9e14..b6e2d212f 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_scope.cc,v 1.30 2003/05/27 16:22:10 steve Exp $" +#ident "$Id: vpi_scope.cc,v 1.31 2003/05/29 02:21:45 steve Exp $" #endif # include "compile.h" @@ -87,7 +87,7 @@ static void construct_scope_fullname(struct __vpiScope*ref, char*buf) static char* scope_get_str(int code, vpiHandle obj) { struct __vpiScope*ref = (struct __vpiScope*)obj; - char *rbuf = need_result_buf(strlen(ref->name) + 1, RBUF_STR); + char *rbuf; assert(handle_is_scope(obj)); @@ -102,9 +102,15 @@ static char* scope_get_str(int code, vpiHandle obj) } case vpiName: + rbuf = need_result_buf(strlen(ref->name) + 1, RBUF_STR); strcpy(rbuf, ref->name); return rbuf; + case vpiDefName: + rbuf = need_result_buf(strlen(ref->tname) + 1, RBUF_STR); + strcpy(rbuf, ref->tname); + return rbuf; + default: assert(0); return 0; @@ -367,7 +373,8 @@ static void attach_to_scope_(struct __vpiScope*scope, vpiHandle obj) * and within the addressed parent. The label is used as a key in the * symbol table and the name is used to construct the actual object. */ -void compile_scope_decl(char*label, char*type, char*name, char*parent) +void +compile_scope_decl(char*label, char*type, char*name, char*tname, char*parent) { struct __vpiScope*scope = new struct __vpiScope; count_vpi_scopes += 1; @@ -396,6 +403,7 @@ void compile_scope_decl(char*label, char*type, char*name, char*parent) assert(scope->base.vpi_type); scope->name = vpip_name_string(name); + scope->tname = vpip_name_string(tname); scope->intern = 0; scope->nintern = 0; scope->threads = 0; @@ -465,6 +473,9 @@ void vpip_attach_to_current_scope(vpiHandle obj) /* * $Log: vpi_scope.cc,v $ + * 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. *