1999-11-27 20:07:57 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 1999 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
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
2000-02-23 03:56:53 +01:00
|
|
|
#if !defined(WINNT) && !defined(macintosh)
|
|
|
|
|
#ident "$Id: vpi_scope.c,v 1.5 2000/02/23 02:56:56 steve Exp $"
|
1999-11-27 20:07:57 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "vpi_priv.h"
|
1999-11-28 01:56:08 +01:00
|
|
|
# include <stdlib.h>
|
1999-11-27 20:07:57 +01:00
|
|
|
# include <assert.h>
|
|
|
|
|
|
1999-11-28 01:56:08 +01:00
|
|
|
static vpiHandle module_iter(int code, vpiHandle obj)
|
|
|
|
|
{
|
|
|
|
|
struct __vpiScope*ref = (struct __vpiScope*)obj;
|
1999-12-15 19:21:20 +01:00
|
|
|
assert((obj->vpi_type->type_code == vpiModule)
|
|
|
|
|
|| (obj->vpi_type->type_code == vpiNamedBegin));
|
1999-11-28 01:56:08 +01:00
|
|
|
|
|
|
|
|
switch (code) {
|
|
|
|
|
case vpiInternalScope:
|
|
|
|
|
return vpip_make_iterator(ref->nintern, ref->intern);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
static const struct __vpirt vpip_module_rt = {
|
|
|
|
|
vpiModule,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
1999-12-15 05:01:14 +01:00
|
|
|
0,
|
1999-11-28 01:56:08 +01:00
|
|
|
module_iter
|
1999-11-27 20:07:57 +01:00
|
|
|
};
|
|
|
|
|
|
1999-12-15 19:21:20 +01:00
|
|
|
static const struct __vpirt vpip_named_begin_rt = {
|
|
|
|
|
vpiNamedBegin,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
module_iter
|
|
|
|
|
};
|
|
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
vpiHandle vpip_make_scope(struct __vpiScope*ref, int type, const char*name)
|
|
|
|
|
{
|
1999-11-28 01:56:08 +01:00
|
|
|
ref->intern = 0;
|
|
|
|
|
ref->nintern = 0;
|
|
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
switch (type) {
|
|
|
|
|
case vpiModule:
|
|
|
|
|
ref->base.vpi_type = &vpip_module_rt;
|
|
|
|
|
break;
|
1999-12-15 19:21:20 +01:00
|
|
|
case vpiNamedBegin:
|
|
|
|
|
ref->base.vpi_type = &vpip_named_begin_rt;
|
|
|
|
|
break;
|
1999-11-27 20:07:57 +01:00
|
|
|
default:
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &ref->base;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-28 01:56:08 +01:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-27 20:07:57 +01:00
|
|
|
/*
|
|
|
|
|
* $Log: vpi_scope.c,v $
|
2000-02-23 03:56:53 +01:00
|
|
|
* Revision 1.5 2000/02/23 02:56:56 steve
|
|
|
|
|
* Macintosh compilers do not support ident.
|
|
|
|
|
*
|
1999-12-15 19:21:20 +01:00
|
|
|
* Revision 1.4 1999/12/15 18:21:20 steve
|
|
|
|
|
* Support named begin scope at run time.
|
|
|
|
|
*
|
1999-12-15 05:01:14 +01:00
|
|
|
* Revision 1.3 1999/12/15 04:01:14 steve
|
|
|
|
|
* Add the VPI implementation of $readmemh.
|
|
|
|
|
*
|
1999-11-28 01:56:08 +01:00
|
|
|
* 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.
|
|
|
|
|
*
|
1999-11-27 20:07:57 +01:00
|
|
|
* Revision 1.1 1999/11/27 19:07:58 steve
|
|
|
|
|
* Support the creation of scopes.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|