Support scope for functors. (Stephan Boettcher)
This commit is contained in:
parent
edba542c7a
commit
0aa033ddf3
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: functor.cc,v 1.37 2001/12/18 05:32:11 steve Exp $"
|
#ident "$Id: functor.cc,v 1.38 2002/01/06 17:50:50 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "functor.h"
|
# include "functor.h"
|
||||||
|
|
@ -60,6 +60,11 @@ void functor_init(void)
|
||||||
functor_allocate(1);
|
functor_allocate(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned functor_limit()
|
||||||
|
{
|
||||||
|
return functor_count;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate normally is just a matter of incrementing the functor_count
|
* Allocate normally is just a matter of incrementing the functor_count
|
||||||
* and returning a pointer to the next unallocated functor. However,
|
* and returning a pointer to the next unallocated functor. However,
|
||||||
|
|
@ -196,6 +201,9 @@ void functor_s::debug_print(vvp_ipoint_t fnc)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: functor.cc,v $
|
* $Log: functor.cc,v $
|
||||||
|
* Revision 1.38 2002/01/06 17:50:50 steve
|
||||||
|
* Support scope for functors. (Stephan Boettcher)
|
||||||
|
*
|
||||||
* Revision 1.37 2001/12/18 05:32:11 steve
|
* Revision 1.37 2001/12/18 05:32:11 steve
|
||||||
* Improved functor debug dumps.
|
* Improved functor debug dumps.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: functor.h,v 1.43 2002/01/06 03:15:13 steve Exp $"
|
#ident "$Id: functor.h,v 1.44 2002/01/06 17:50:50 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "pointers.h"
|
# include "pointers.h"
|
||||||
|
|
@ -117,6 +117,11 @@ extern void functor_init(void);
|
||||||
*/
|
*/
|
||||||
extern vvp_ipoint_t functor_allocate(unsigned wid);
|
extern vvp_ipoint_t functor_allocate(unsigned wid);
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Return the number of allocated functors
|
||||||
|
*/
|
||||||
|
extern unsigned functor_limit();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given an ipoint_t pointer, return a C pointer to the functor. This
|
* Given an ipoint_t pointer, return a C pointer to the functor. This
|
||||||
* is like a pointer dereference. The point parameter must have been
|
* is like a pointer dereference. The point parameter must have been
|
||||||
|
|
@ -381,6 +386,9 @@ extern vvp_fvector_t vvp_fvector_continuous_new(unsigned size, vvp_ipoint_t p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: functor.h,v $
|
* $Log: functor.h,v $
|
||||||
|
* Revision 1.44 2002/01/06 17:50:50 steve
|
||||||
|
* Support scope for functors. (Stephan Boettcher)
|
||||||
|
*
|
||||||
* Revision 1.43 2002/01/06 03:15:13 steve
|
* Revision 1.43 2002/01/06 03:15:13 steve
|
||||||
* Support weak functor inputs.
|
* Support weak functor inputs.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vpi_priv.h,v 1.25 2002/01/06 00:48:39 steve Exp $"
|
#ident "$Id: vpi_priv.h,v 1.26 2002/01/06 17:50:50 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vpi_user.h"
|
# include "vpi_user.h"
|
||||||
|
|
@ -240,8 +240,19 @@ vpiHandle vpip_sim_time(void);
|
||||||
extern int vpip_get_time_precision(void);
|
extern int vpip_get_time_precision(void);
|
||||||
extern void vpip_set_time_precision(int pres);
|
extern void vpip_set_time_precision(int pres);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Functions defined in vpi_scope.cc, to keep track of functor scope.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern vpiHandle ipoint_get_scope(vvp_ipoint_t ipt);
|
||||||
|
extern void functor_set_scope(vpiHandle scope);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_priv.h,v $
|
* $Log: vpi_priv.h,v $
|
||||||
|
* Revision 1.26 2002/01/06 17:50:50 steve
|
||||||
|
* Support scope for functors. (Stephan Boettcher)
|
||||||
|
*
|
||||||
* Revision 1.25 2002/01/06 00:48:39 steve
|
* Revision 1.25 2002/01/06 00:48:39 steve
|
||||||
* VPI access to root module scopes.
|
* VPI access to root module scopes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
106
vvp/vpi_scope.cc
106
vvp/vpi_scope.cc
|
|
@ -17,12 +17,13 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vpi_scope.cc,v 1.11 2002/01/06 00:48:39 steve Exp $"
|
#ident "$Id: vpi_scope.cc,v 1.12 2002/01/06 17:50:50 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "compile.h"
|
# include "compile.h"
|
||||||
# include "vpi_priv.h"
|
# include "vpi_priv.h"
|
||||||
# include "symbols.h"
|
# include "symbols.h"
|
||||||
|
# include "functor.h"
|
||||||
#ifdef HAVE_MALLOC_H
|
#ifdef HAVE_MALLOC_H
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -105,6 +106,93 @@ static vpiHandle module_iter(int code, vpiHandle obj)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Keeping track of functor scope. When the scope changes during
|
||||||
|
** compilation, we record the current number of functors in a list.
|
||||||
|
**
|
||||||
|
** Why are we doing this? The SDF annotator needs this for
|
||||||
|
** INTERCONNECT delays. The INTERCONNECT delay is specified between
|
||||||
|
** a source modules output port and a target module input port, which
|
||||||
|
** are connected with a wire. The vpiSignal for both ports point to
|
||||||
|
** the same functor output, together with all other ports that may be
|
||||||
|
** connected to the same wire. The SDF annotator need to find those
|
||||||
|
** functors which are inside the scope of the target module, which
|
||||||
|
** are driven by the source functor. And even this is only an
|
||||||
|
** aproximation, in case the wire is connected to multiple inputs of
|
||||||
|
** the same module. But those should have the same delays anyway.
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct functor_scope_s {
|
||||||
|
vpiHandle scope;
|
||||||
|
unsigned start;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct functor_scope_s * functor_scopes = 0;
|
||||||
|
static unsigned n_functor_scopes = 0;
|
||||||
|
static unsigned a_functor_scopes = 0;
|
||||||
|
|
||||||
|
void functor_set_scope(vpiHandle scope)
|
||||||
|
{
|
||||||
|
unsigned nfun = functor_limit();
|
||||||
|
|
||||||
|
if (n_functor_scopes) {
|
||||||
|
functor_scope_s *last = &functor_scopes[n_functor_scopes - 1];
|
||||||
|
|
||||||
|
if (last->scope == scope) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (last->start == nfun) {
|
||||||
|
last->scope = scope;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
n_functor_scopes += 1;
|
||||||
|
if (n_functor_scopes >= a_functor_scopes) {
|
||||||
|
a_functor_scopes += 512;
|
||||||
|
functor_scopes = (struct functor_scope_s *)
|
||||||
|
realloc(functor_scopes,
|
||||||
|
a_functor_scopes*sizeof(struct functor_scope_s));
|
||||||
|
assert(functor_scopes);
|
||||||
|
}
|
||||||
|
|
||||||
|
functor_scope_s *last = &functor_scopes[n_functor_scopes - 1];
|
||||||
|
last->start = nfun;
|
||||||
|
last->scope = scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Lockup the scope of a functor.
|
||||||
|
**
|
||||||
|
** Cannot use bserach, since we are not looking for an exact match
|
||||||
|
*/
|
||||||
|
vpiHandle ipoint_get_scope(vvp_ipoint_t ipt)
|
||||||
|
{
|
||||||
|
if (n_functor_scopes == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
unsigned fidx = ipt/4;
|
||||||
|
|
||||||
|
unsigned first = 0;
|
||||||
|
unsigned last = n_functor_scopes;
|
||||||
|
while (first < last) {
|
||||||
|
unsigned next = (first+last)/2;
|
||||||
|
functor_scope_s *cur = &functor_scopes[next];
|
||||||
|
|
||||||
|
if (cur->start > fidx)
|
||||||
|
last = next;
|
||||||
|
else if (next == first)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
first = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
functor_scope_s *cur = &functor_scopes[first];
|
||||||
|
return cur->scope;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct __vpirt vpip_scope_module_rt = {
|
static const struct __vpirt vpip_scope_module_rt = {
|
||||||
vpiModule,
|
vpiModule,
|
||||||
0,
|
0,
|
||||||
|
|
@ -183,19 +271,19 @@ void compile_scope_decl(char*label, char*type, char*name, char*parent)
|
||||||
struct __vpiScope*scope = new struct __vpiScope;
|
struct __vpiScope*scope = new struct __vpiScope;
|
||||||
|
|
||||||
switch(type[2]) {
|
switch(type[2]) {
|
||||||
case 'd': /* type == module */
|
case 'd': /* type == moDule */
|
||||||
scope->base.vpi_type = &vpip_scope_module_rt;
|
scope->base.vpi_type = &vpip_scope_module_rt;
|
||||||
break;
|
break;
|
||||||
case 'n': /* type == function */
|
case 'n': /* type == fuNction */
|
||||||
scope->base.vpi_type = &vpip_scope_function_rt;
|
scope->base.vpi_type = &vpip_scope_function_rt;
|
||||||
break;
|
break;
|
||||||
case 's': /* type == task */
|
case 's': /* type == taSk */
|
||||||
scope->base.vpi_type = &vpip_scope_task_rt;
|
scope->base.vpi_type = &vpip_scope_task_rt;
|
||||||
break;
|
break;
|
||||||
case 'r': /* type == fork */
|
case 'r': /* type == foRk */
|
||||||
scope->base.vpi_type = &vpip_scope_fork_rt;
|
scope->base.vpi_type = &vpip_scope_fork_rt;
|
||||||
break;
|
break;
|
||||||
case 'g': /* type == begin */
|
case 'g': /* type == beGin */
|
||||||
scope->base.vpi_type = &vpip_scope_begin_rt;
|
scope->base.vpi_type = &vpip_scope_begin_rt;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -231,12 +319,15 @@ void compile_scope_decl(char*label, char*type, char*name, char*parent)
|
||||||
vpip_root_table_ptr[vpip_root_table_cnt] = &scope->base;
|
vpip_root_table_ptr[vpip_root_table_cnt] = &scope->base;
|
||||||
vpip_root_table_cnt = cnt;
|
vpip_root_table_cnt = cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
functor_set_scope(¤t_scope->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void compile_scope_recall(char*symbol)
|
void compile_scope_recall(char*symbol)
|
||||||
{
|
{
|
||||||
compile_vpi_lookup((vpiHandle*)¤t_scope, symbol);
|
compile_vpi_lookup((vpiHandle*)¤t_scope, symbol);
|
||||||
assert(current_scope);
|
assert(current_scope);
|
||||||
|
functor_set_scope(¤t_scope->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct __vpiScope* vpip_peek_current_scope(void)
|
struct __vpiScope* vpip_peek_current_scope(void)
|
||||||
|
|
@ -252,6 +343,9 @@ void vpip_attach_to_current_scope(vpiHandle obj)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_scope.cc,v $
|
* $Log: vpi_scope.cc,v $
|
||||||
|
* Revision 1.12 2002/01/06 17:50:50 steve
|
||||||
|
* Support scope for functors. (Stephan Boettcher)
|
||||||
|
*
|
||||||
* Revision 1.11 2002/01/06 00:48:39 steve
|
* Revision 1.11 2002/01/06 00:48:39 steve
|
||||||
* VPI access to root module scopes.
|
* VPI access to root module scopes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue