Collect functor reference handling into a single function. (Stephan Boettcher)
This commit is contained in:
parent
c7bc35ad75
commit
789efb9832
205
vvp/compile.cc
205
vvp/compile.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: compile.cc,v 1.101 2001/10/09 02:28:16 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.102 2001/10/09 16:57:47 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -289,46 +289,44 @@ void postpone_functor_input(vvp_ipoint_t ptr, char*lab, unsigned idx)
|
|||
}
|
||||
|
||||
/*
|
||||
* fvector_set lookup
|
||||
* Generic functor reference lookup.
|
||||
*/
|
||||
|
||||
struct fvector_resolv_list_s: public resolv_list_s {
|
||||
struct functor_gen_resolv_list_s: public resolv_list_s {
|
||||
char*source;
|
||||
unsigned idx;
|
||||
vvp_fvector_t vec;
|
||||
unsigned vidx;
|
||||
vvp_ipoint_t *ref;
|
||||
virtual bool resolve(bool mes);
|
||||
};
|
||||
|
||||
bool fvector_resolv_list_s::resolve(bool mes)
|
||||
bool functor_gen_resolv_list_s::resolve(bool mes)
|
||||
{
|
||||
vvp_ipoint_t tmp = lookup_functor_symbol(source);
|
||||
|
||||
if (tmp) {
|
||||
tmp = ipoint_index(tmp, idx);
|
||||
vvp_fvector_set(vec, vidx, tmp);
|
||||
|
||||
*ref = tmp;
|
||||
|
||||
free(source);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mes) {
|
||||
fprintf(stderr,
|
||||
"unresolved functor reference (net input): %s\n",
|
||||
source);
|
||||
}
|
||||
|
||||
if (mes)
|
||||
fprintf(stderr, "unresolved functor reference: %s\n", source);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline static
|
||||
void postpone_fvector_input(vvp_fvector_t vec, unsigned vidx,
|
||||
char*lab, unsigned idx)
|
||||
void functor_ref_lookup(vvp_ipoint_t *ref, char*lab, unsigned idx)
|
||||
{
|
||||
struct fvector_resolv_list_s*res = new struct fvector_resolv_list_s;
|
||||
struct functor_gen_resolv_list_s*res =
|
||||
new struct functor_gen_resolv_list_s;
|
||||
|
||||
res->vec = vec;
|
||||
res->vidx = vidx;
|
||||
res->ref = ref;
|
||||
res->source = lab;
|
||||
res->idx = idx;
|
||||
res->idx = idx;
|
||||
|
||||
resolv_submit(res);
|
||||
}
|
||||
|
|
@ -519,11 +517,11 @@ void compile_cleanup(void)
|
|||
resolv_list = cur;
|
||||
}
|
||||
}
|
||||
if (last && nerrs)
|
||||
if (nerrs && last)
|
||||
fprintf(stderr,
|
||||
"compile_cleanup: %d unresolved items\n",
|
||||
nerrs);
|
||||
} while (nerrs && nerrs != lnerrs && !last);
|
||||
} while (nerrs && !last);
|
||||
|
||||
compile_errors += nerrs;
|
||||
}
|
||||
|
|
@ -639,6 +637,88 @@ static void inputs_connect(vvp_ipoint_t fdx, unsigned argc, struct symb_s*argv)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Lookup a functor[idx] and save the ipoint in *ref. */
|
||||
|
||||
static vvp_ipoint_t make_const_functor(unsigned val,
|
||||
unsigned str0,
|
||||
unsigned str1)
|
||||
{
|
||||
vvp_ipoint_t fdx = functor_allocate(1);
|
||||
functor_t obj = functor_index(fdx);
|
||||
|
||||
obj->table = ft_var;
|
||||
obj->ival = val;
|
||||
obj->oval = val;
|
||||
obj->odrive0 = str0;
|
||||
obj->odrive1 = str1;
|
||||
obj->mode = 0;
|
||||
#if defined(WITH_DEBUG)
|
||||
obj->breakpoint = 0;
|
||||
#endif
|
||||
schedule_functor(fdx, 0);
|
||||
return fdx;
|
||||
}
|
||||
|
||||
static void functor_reference(vvp_ipoint_t *ref, char *lab, unsigned idx)
|
||||
{
|
||||
if (lab == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(3,6,6);
|
||||
*ref = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(lab, "C<0>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(0,6,6);
|
||||
*ref = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(lab, "C<su0>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(0,7,7);
|
||||
*ref = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(lab, "C<1>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(1,6,6);
|
||||
*ref = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(lab, "C<su1>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(1,7,7);
|
||||
*ref = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(lab, "C<x>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(2,6,6);
|
||||
*ref = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(lab, "C<z>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(3,6,6);
|
||||
*ref = cf;
|
||||
} else {
|
||||
|
||||
functor_ref_lookup(ref, lab, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
free(lab);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The parser calls this function to create a functor. I allocate a
|
||||
* functor, and map the name to the vvp_ipoint_t address for the
|
||||
|
|
@ -1531,26 +1611,6 @@ void compile_variable(char*label, char*name, int msb, int lsb,
|
|||
free(label);
|
||||
}
|
||||
|
||||
static vvp_ipoint_t make_const_functor(unsigned val,
|
||||
unsigned str0,
|
||||
unsigned str1)
|
||||
{
|
||||
vvp_ipoint_t fdx = functor_allocate(1);
|
||||
functor_t obj = functor_index(fdx);
|
||||
|
||||
obj->table = ft_var;
|
||||
obj->ival = val;
|
||||
obj->oval = val;
|
||||
obj->odrive0 = str0;
|
||||
obj->odrive1 = str1;
|
||||
obj->mode = 0;
|
||||
#if defined(WITH_DEBUG)
|
||||
obj->breakpoint = 0;
|
||||
#endif
|
||||
schedule_functor(fdx, 0);
|
||||
return fdx;
|
||||
}
|
||||
|
||||
void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
|
||||
unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
|
|
@ -1562,64 +1622,8 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
|
|||
assert(argc == wid);
|
||||
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
|
||||
vvp_ipoint_t ipt = 0;
|
||||
|
||||
if (argv[idx].text == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(3,6,6);
|
||||
ipt = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(argv[idx].text, "C<0>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(0,6,6);
|
||||
ipt = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(argv[idx].text, "C<su0>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(0,7,7);
|
||||
ipt = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(argv[idx].text, "C<1>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(1,6,6);
|
||||
ipt = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(argv[idx].text, "C<su1>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(1,7,7);
|
||||
ipt = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(argv[idx].text, "C<x>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(2,6,6);
|
||||
ipt = cf;
|
||||
} else
|
||||
|
||||
if (strcmp(argv[idx].text, "C<z>") == 0) {
|
||||
static vvp_ipoint_t cf=0;
|
||||
if (!cf)
|
||||
cf = make_const_functor(3,6,6);
|
||||
ipt = cf;
|
||||
} else {
|
||||
|
||||
postpone_fvector_input(vec, idx,
|
||||
argv[idx].text, argv[idx].idx);
|
||||
continue;
|
||||
}
|
||||
|
||||
vvp_fvector_set(vec, idx, ipt);
|
||||
vvp_ipoint_t *ref = vvp_fvector_member(vec, idx);
|
||||
functor_reference(ref, argv[idx].text, argv[idx].idx);
|
||||
}
|
||||
|
||||
/* Make the vpiHandle for the reg. */
|
||||
|
|
@ -1646,6 +1650,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.102 2001/10/09 16:57:47 steve
|
||||
* Collect functor reference handling into a single function. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.101 2001/10/09 02:28:16 steve
|
||||
* Add the PMOS and NMOS functor types.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: functor.h,v 1.31 2001/10/09 02:28:17 steve Exp $"
|
||||
#ident "$Id: functor.h,v 1.32 2001/10/09 16:57:47 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "pointers.h"
|
||||
|
|
@ -284,6 +284,7 @@ inline unsigned functor_oval(vvp_ipoint_t fptr)
|
|||
extern unsigned vvp_fvector_size(vvp_fvector_t v);
|
||||
extern vvp_ipoint_t vvp_fvector_get(vvp_fvector_t v, unsigned i);
|
||||
extern void vvp_fvector_set(vvp_fvector_t v, unsigned i, vvp_ipoint_t p);
|
||||
extern vvp_ipoint_t *vvp_fvector_member(vvp_fvector_t v, unsigned i);
|
||||
extern vvp_fvector_t vvp_fvector_new(unsigned size);
|
||||
extern vvp_fvector_t vvp_fvector_continuous_new(unsigned size, vvp_ipoint_t p);
|
||||
|
||||
|
|
@ -318,6 +319,9 @@ extern const unsigned char ft_var[];
|
|||
|
||||
/*
|
||||
* $Log: functor.h,v $
|
||||
* Revision 1.32 2001/10/09 16:57:47 steve
|
||||
* Collect functor reference handling into a single function. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.31 2001/10/09 02:28:17 steve
|
||||
* Add the PMOS and NMOS functor types.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: fvectors.cc,v 1.3 2001/09/15 18:27:05 steve Exp $"
|
||||
#ident "$Id: fvectors.cc,v 1.4 2001/10/09 16:57:47 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -60,6 +60,12 @@ void vvp_fvector_set(vvp_fvector_t v, unsigned i, vvp_ipoint_t p)
|
|||
v->iptrs[i] = p;
|
||||
}
|
||||
|
||||
vvp_ipoint_t *vvp_fvector_member(vvp_fvector_t v, unsigned i)
|
||||
{
|
||||
assert(i < v->size);
|
||||
return &v->iptrs[i];
|
||||
}
|
||||
|
||||
vvp_fvector_t vvp_fvector_continuous_new(unsigned size, vvp_ipoint_t p)
|
||||
{
|
||||
vvp_fvector_t v = (vvp_fvector_t)
|
||||
|
|
|
|||
Loading…
Reference in New Issue