Build up the lists in the scope of a module,

and get $dumpvars to scan the scope for items.
This commit is contained in:
steve 1999-11-28 00:56:08 +00:00
parent 4cfa3e4047
commit bf42be12de
5 changed files with 123 additions and 52 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: t-vvm.cc,v 1.80 1999/11/27 19:07:58 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.81 1999/11/28 00:56:08 steve Exp $"
#endif
# include <iostream>
@ -720,7 +720,21 @@ bool target_vvm::process(ostream&os, const NetProcTop*top)
void target_vvm::signal(ostream&os, const NetNet*sig)
{
#if 1
os << "// XXXX handle signal " << sig->name() << endl;
string net_name = mangle(sig->name());
os << "static vvm_bitset_t<" << sig->pin_count() << "> " <<
net_name<< "_bits; /* " << sig->name() <<
" */" << endl;
os << "static vvm_signal_t<" << sig->pin_count() << "> " <<
net_name << "(&" << net_name << "_bits);" << endl;
init_code << " vpip_make_reg(&" << net_name <<
", \"" << sig->name() << "\");" << endl;
if (const NetScope*scope = sig->scope()) {
string sname = mangle(scope->name()) + "_scope";
init_code << " vpip_attach_to_scope(&" << sname
<< ", &" << net_name << ".base);" << endl;
}
#endif
/* Scan the signals of the vector, passing the initial value
@ -1299,6 +1313,7 @@ void target_vvm::net_const(ostream&os, const NetConst*gate)
void target_vvm::net_esignal(ostream&os, const NetESignal*net)
{
#if 0
bool&flag = esignal_printed_flag[net->name()];
if (flag)
return;
@ -1313,16 +1328,6 @@ void target_vvm::net_esignal(ostream&os, const NetESignal*net)
init_code << " vpip_make_reg(&" << net_name <<
", \"" << net->name() << "\");" << endl;
#if 0
/* If the signal (that I am declaring and initializing) is
attached to a scope in the netlist, then attach it to the
scope for real here. */
if (const NetScope*scope = net->scope()) {
init_code << " vpip_attach_to_scope(&" <<
mangle(scope->name()) << "_scope, &" << net_name <<
".base);" << endl;
}
#endif
}
@ -1987,6 +1992,10 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.81 1999/11/28 00:56:08 steve
* Build up the lists in the scope of a module,
* and get $dumpvars to scan the scope for items.
*
* Revision 1.80 1999/11/27 19:07:58 steve
* Support the creation of scopes.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: sys_vcd.c,v 1.1 1999/11/07 20:33:30 steve Exp $"
#ident "$Id: sys_vcd.c,v 1.2 1999/11/28 00:56:08 steve Exp $"
#endif
/*
@ -122,13 +122,60 @@ static int sys_dumpfile_calltf(char*name)
return 0;
}
static int sys_dumpvars_calltf(char*name)
static void scan_scope(unsigned depth, vpiHandle argv)
{
struct t_cb_data cb;
struct vcd_info*info;
char ident[64];
unsigned nident = 0;
vpiHandle item;
vpiHandle sublist;
cb.reason = cbValueChange;
cb.cb_rtn = variable_cb;
for (item = vpi_scan(argv) ; item ; item = vpi_scan(argv)) {
const char*type;
switch (vpi_get(vpiType, item)) {
case vpiNet:
case vpiReg:
type = "wire";
if (vpi_get(vpiType, item) == vpiReg)
type = "reg";
sprintf(ident, "<%u", nident++);
info = malloc(sizeof(*info));
info->time.type = vpiSimTime;
cb.time = &info->time;
cb.user_data = (char*)info;
cb.obj = item;
info->item = item;
info->ident = strdup(ident);
info->cb = vpi_register_cb(&cb);
info->next = vcd_list;
vcd_list = info;
fprintf(dump_file, "$var %s %u %s %s $end\n",
type, vpi_get(vpiSize, item), ident,
vpi_get_str(vpiFullName, item));
break;
case vpiModule:
sublist = vpi_iterate(vpiInternalScope, item);
if (sublist && (depth > 0))
scan_scope(depth-1, sublist);
break;
default:
vpi_printf("ERROR: $dumpvars: Unsupported parameter type\n");
}
}
}
static int sys_dumpvars_calltf(char*name)
{
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, sys);
vpiHandle item = vpi_scan(argv);
@ -140,40 +187,7 @@ static int sys_dumpvars_calltf(char*name)
assert(dump_file);
cb.reason = cbValueChange;
cb.cb_rtn = variable_cb;
for (item = vpi_scan(argv) ; item ; item = vpi_scan(argv)) {
switch (vpi_get(vpiType, item)) {
case vpiNet:
case vpiReg: {
const char*type = "wire";
if (vpi_get(vpiType, item) == vpiReg)
type = "reg";
sprintf(ident, "<%u", nident++);
info = malloc(sizeof(*info));
info->time.type = vpiSimTime;
cb.time = &info->time;
cb.user_data = (char*)info;
cb.obj = item;
info->item = item;
info->ident = strdup(ident);
info->cb = vpi_register_cb(&cb);
info->next = vcd_list;
vcd_list = info;
fprintf(dump_file, "$var %s %u %s %s $end\n",
type, vpi_get(vpiSize, item), ident,
vpi_get_str(vpiFullName, item));
break;
}
default:
vpi_printf("ERROR: (%s): Unsupported parameter type\n",
name);
}
}
scan_scope(99, argv);
fprintf(dump_file, "$enddefinitions $end\n");
fprintf(dump_file, "#0\n");
@ -212,6 +226,10 @@ void sys_vcd_register()
/*
* $Log: sys_vcd.c,v $
* Revision 1.2 1999/11/28 00:56:08 steve
* Build up the lists in the scope of a module,
* and get $dumpvars to scan the scope for items.
*
* Revision 1.1 1999/11/07 20:33:30 steve
* Add VCD output and related system tasks.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_user.h,v 1.8 1999/11/27 19:07:58 steve Exp $"
#ident "$Id: vpi_user.h,v 1.9 1999/11/28 00:56:08 steve Exp $"
#endif
#ifdef __cplusplus
@ -107,6 +107,7 @@ typedef struct t_vpi_value {
#define vpiTimeVar 63
#define vpiSysTfCall 85
#define vpiArgument 89
#define vpiInternalScope 92
#define vpiCallback 1000
@ -210,6 +211,10 @@ extern void (*vlog_startup_routines[])();
/*
* $Log: vpi_user.h,v $
* Revision 1.9 1999/11/28 00:56:08 steve
* Build up the lists in the scope of a module,
* and get $dumpvars to scan the scope for items.
*
* Revision 1.8 1999/11/27 19:07:58 steve
* Support the creation of scopes.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_priv.h,v 1.7 1999/11/27 19:07:58 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.8 1999/11/28 00:56:08 steve Exp $"
#endif
/*
@ -123,6 +123,9 @@ struct __vpiScope {
struct __vpiHandle base;
/* The scope has a name. (this points to static memory.) */
const char*name;
/* Keep an array of internal scope items. */
struct __vpiHandle**intern;
unsigned nintern;
};
extern void vpip_attach_to_scope(struct __vpiScope*scope, vpiHandle obj);
@ -271,6 +274,10 @@ extern int vpip_finished();
/*
* $Log: vpi_priv.h,v $
* Revision 1.8 1999/11/28 00:56:08 steve
* Build up the lists in the scope of a module,
* and get $dumpvars to scan the scope for items.
*
* Revision 1.7 1999/11/27 19:07:58 steve
* Support the creation of scopes.
*

View File

@ -17,23 +17,39 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_scope.c,v 1.1 1999/11/27 19:07:58 steve Exp $"
#ident "$Id: vpi_scope.c,v 1.2 1999/11/28 00:56:08 steve Exp $"
#endif
# include "vpi_priv.h"
# include <stdlib.h>
# include <assert.h>
static vpiHandle module_iter(int code, vpiHandle obj)
{
struct __vpiScope*ref = (struct __vpiScope*)obj;
assert(obj->vpi_type->type_code == vpiModule);
switch (code) {
case vpiInternalScope:
return vpip_make_iterator(ref->nintern, ref->intern);
}
return 0;
}
static const struct __vpirt vpip_module_rt = {
vpiModule,
0,
0,
0,
0,
0
module_iter
};
vpiHandle vpip_make_scope(struct __vpiScope*ref, int type, const char*name)
{
ref->intern = 0;
ref->nintern = 0;
switch (type) {
case vpiModule:
ref->base.vpi_type = &vpip_module_rt;
@ -45,8 +61,24 @@ vpiHandle vpip_make_scope(struct __vpiScope*ref, int type, const char*name)
return &ref->base;
}
void vpip_attach_to_scope(struct __vpiScope*ref, vpiHandle obj)
{
unsigned idx = ref->nintern++;
if (ref->intern == 0)
ref->intern = malloc(sizeof(vpiHandle));
else
ref->intern = realloc(ref->intern, sizeof(vpiHandle)*ref->nintern);
ref->intern[idx] = obj;
}
/*
* $Log: vpi_scope.c,v $
* Revision 1.2 1999/11/28 00:56:08 steve
* Build up the lists in the scope of a module,
* and get $dumpvars to scan the scope for items.
*
* Revision 1.1 1999/11/27 19:07:58 steve
* Support the creation of scopes.
*