A resolver that understands some simple strengths.
This commit is contained in:
parent
4d8954be4c
commit
f05b13c630
|
|
@ -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.62 2001/05/10 00:26:53 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.63 2001/05/12 20:38:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -257,28 +257,37 @@ static void inputs_connect(vvp_ipoint_t fdx, unsigned argc, struct symb_s*argv)
|
|||
|
||||
if (strcmp(argv[idx].text, "C<0>") == 0) {
|
||||
free(argv[idx].text);
|
||||
iobj->ival &= ~(3 << idx*2);
|
||||
functor_put_input(iobj, idx, 0, 6, 6);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[idx].text, "C<pu0>") == 0) {
|
||||
free(argv[idx].text);
|
||||
functor_put_input(iobj, idx, 0, 5, 5);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[idx].text, "C<1>") == 0) {
|
||||
free(argv[idx].text);
|
||||
iobj->ival &= ~(3 << idx*2);
|
||||
iobj->ival |= 1 << idx*2;
|
||||
functor_put_input(iobj, idx, 1, 6, 6);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[idx].text, "C<pu1>") == 0) {
|
||||
free(argv[idx].text);
|
||||
functor_put_input(iobj, idx, 1, 5, 5);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[idx].text, "C<x>") == 0) {
|
||||
free(argv[idx].text);
|
||||
iobj->ival &= ~(3 << idx*2);
|
||||
iobj->ival |= 2 << idx*2;
|
||||
functor_put_input(iobj, idx, 2, 6, 6);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strcmp(argv[idx].text, "C<z>") == 0) {
|
||||
free(argv[idx].text);
|
||||
iobj->ival &= ~(3 << idx*2);
|
||||
iobj->ival |= 3 << idx*2;
|
||||
functor_put_input(iobj, idx, 3, 6, 6);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -393,7 +402,13 @@ void compile_resolver(char*label, char*type, unsigned argc, struct symb_s*argv)
|
|||
obj->breakpoint = 0;
|
||||
#endif
|
||||
|
||||
obj->obj = new vvp_resolv_s;
|
||||
if (strcmp(type,"tri") == 0) {
|
||||
obj->obj = new vvp_resolv_s;
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "invalid resolver type: %s\n", type);
|
||||
compile_errors += 1;
|
||||
}
|
||||
|
||||
/* Connect the inputs of this functor to the given symbols. If
|
||||
there are C<X> inputs, set the ival appropriately. */
|
||||
|
|
@ -1095,6 +1110,7 @@ void compile_cleanup(void)
|
|||
res->source);
|
||||
res->next = resolv_list;
|
||||
resolv_list = res;
|
||||
compile_errors += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1118,6 +1134,7 @@ void compile_cleanup(void)
|
|||
free(res->lab);
|
||||
|
||||
} else {
|
||||
compile_errors += 1;
|
||||
fprintf(stderr, "unresolved code label: %s\n", res->lab);
|
||||
res->next = cresolv_list;
|
||||
cresolv_list = res;
|
||||
|
|
@ -1141,6 +1158,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.63 2001/05/12 20:38:06 steve
|
||||
* A resolver that understands some simple strengths.
|
||||
*
|
||||
* Revision 1.62 2001/05/10 00:26:53 steve
|
||||
* VVP support for memories in expressions,
|
||||
* including general support for thread bit
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: functor.cc,v 1.19 2001/05/09 04:23:18 steve Exp $"
|
||||
#ident "$Id: functor.cc,v 1.20 2001/05/12 20:38:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "functor.h"
|
||||
|
|
@ -134,6 +134,23 @@ functor_t functor_index(vvp_ipoint_t point)
|
|||
return functor_table[point]->table[index1]->table + index0;
|
||||
}
|
||||
|
||||
void functor_put_input(functor_t fp, unsigned pp, unsigned val,
|
||||
unsigned drive0, unsigned drive1)
|
||||
{
|
||||
/* Change the bits of the input. */
|
||||
static const unsigned char ival_mask[4] = { 0xfc, 0xf3, 0xcf, 0x3f };
|
||||
unsigned char imask = ival_mask[pp];
|
||||
fp->ival = (fp->ival & imask) | ((val & 3) << (2*pp));
|
||||
|
||||
/* change the bits of the drive. */
|
||||
static const unsigned drive_mask[4] = { 0xffffc0, 0xfff03f,
|
||||
0xfc0fff, 0x03ffff };
|
||||
unsigned dmask = drive_mask[pp];
|
||||
fp->idrive = (fp->idrive & dmask)
|
||||
| (drive1 << (3+6*pp))
|
||||
| (drive0 << 6*pp);
|
||||
}
|
||||
|
||||
static void functor_set_mode0(vvp_ipoint_t ptr, functor_t fp, bool push)
|
||||
{
|
||||
/* Locate the new output value in the table. */
|
||||
|
|
@ -245,10 +262,8 @@ void functor_set(vvp_ipoint_t ptr, unsigned bit,
|
|||
assert(drive0 <= 8);
|
||||
assert(drive1 <= 8);
|
||||
|
||||
/* Change the bits of the input. */
|
||||
static const unsigned char mask_table[4] = { 0xfc, 0xf3, 0xcf, 0x3f };
|
||||
unsigned char mask = mask_table[pp];
|
||||
fp->ival = (fp->ival & mask) | ((bit & 3) << (2*pp));
|
||||
/* Store the value and strengths in the input bits. */
|
||||
functor_put_input(fp, pp, bit, drive0, drive1);
|
||||
|
||||
switch (fp->mode) {
|
||||
case 0:
|
||||
|
|
@ -339,6 +354,9 @@ const unsigned char ft_var[16] = {
|
|||
|
||||
/*
|
||||
* $Log: functor.cc,v $
|
||||
* Revision 1.20 2001/05/12 20:38:06 steve
|
||||
* A resolver that understands some simple strengths.
|
||||
*
|
||||
* Revision 1.19 2001/05/09 04:23:18 steve
|
||||
* Now that the interactive debugger exists,
|
||||
* there is no use for the output dump.
|
||||
|
|
|
|||
|
|
@ -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.21 2001/05/09 04:23:18 steve Exp $"
|
||||
#ident "$Id: functor.h,v 1.22 2001/05/12 20:38:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "pointers.h"
|
||||
|
|
@ -116,7 +116,9 @@ struct functor_s {
|
|||
/* These are the input ports. */
|
||||
vvp_ipoint_t port[4];
|
||||
/* These are the input values. */
|
||||
unsigned char ival;
|
||||
unsigned ival : 8;
|
||||
/* Input strengths, for strength aware functors. */
|
||||
unsigned idrive : 4*6;
|
||||
/* Output value (low bits, and drive1 and drive0 strength. */
|
||||
unsigned oval : 2;
|
||||
unsigned odrive0 : 3;
|
||||
|
|
@ -194,6 +196,14 @@ extern void functor_init(void);
|
|||
*/
|
||||
extern vvp_ipoint_t functor_allocate(unsigned wid);
|
||||
|
||||
/*
|
||||
* This function is used by the compile time to initialize the value
|
||||
* of an input, and by the run time to manipulate the bits of the
|
||||
* input in a uniform manner.
|
||||
*/
|
||||
extern void functor_put_input(functor_t fp, unsigned pp, unsigned val,
|
||||
unsigned drive0, unsigned drive1);
|
||||
|
||||
/*
|
||||
* functor_set sets the addressed input to the specified value, and
|
||||
* calculates a new output value. If there is any propagation to do,
|
||||
|
|
@ -254,6 +264,9 @@ extern const unsigned char ft_var[];
|
|||
|
||||
/*
|
||||
* $Log: functor.h,v $
|
||||
* Revision 1.22 2001/05/12 20:38:06 steve
|
||||
* A resolver that understands some simple strengths.
|
||||
*
|
||||
* Revision 1.21 2001/05/09 04:23:18 steve
|
||||
* Now that the interactive debugger exists,
|
||||
* there is no use for the output dump.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: main.cc,v 1.12 2001/05/11 03:26:31 steve Exp $"
|
||||
#ident "$Id: main.cc,v 1.13 2001/05/12 20:38:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
|
|
@ -90,7 +90,7 @@ int main(int argc, char*argv[])
|
|||
return compile_errors;
|
||||
}
|
||||
|
||||
#if defined(HAVE_DEBUG)
|
||||
#if defined(WITH_DEBUG)
|
||||
if (debug_flag)
|
||||
breakpoint();
|
||||
#endif
|
||||
|
|
@ -102,6 +102,9 @@ int main(int argc, char*argv[])
|
|||
|
||||
/*
|
||||
* $Log: main.cc,v $
|
||||
* Revision 1.13 2001/05/12 20:38:06 steve
|
||||
* A resolver that understands some simple strengths.
|
||||
*
|
||||
* Revision 1.12 2001/05/11 03:26:31 steve
|
||||
* No entry breakpoint if debug is compiled out.
|
||||
*
|
||||
|
|
|
|||
146
vvp/resolv.cc
146
vvp/resolv.cc
|
|
@ -17,12 +17,106 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: resolv.cc,v 1.1 2001/05/09 02:53:53 steve Exp $"
|
||||
#ident "$Id: resolv.cc,v 1.2 2001/05/12 20:38:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "resolv.h"
|
||||
# include "schedule.h"
|
||||
|
||||
static void blend(unsigned&val, unsigned&drv0, unsigned drv1,
|
||||
unsigned inp, unsigned inp0, unsigned inp1)
|
||||
{
|
||||
switch (val) {
|
||||
case 3:
|
||||
val = inp;
|
||||
drv0 = inp0;
|
||||
drv1 = inp1;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
switch (inp) {
|
||||
case 0:
|
||||
if (drv0 < inp0)
|
||||
drv0 = inp0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (drv0 < inp1) {
|
||||
val = 1;
|
||||
drv1 = inp1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (drv0 < inp1) {
|
||||
val = 2;
|
||||
if (drv0 < inp0)
|
||||
drv0 = inp0;
|
||||
if (drv1 < inp1)
|
||||
drv0 = inp1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
switch (inp) {
|
||||
case 0:
|
||||
if (drv1 < inp0) {
|
||||
val = 0;
|
||||
drv1 = inp1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (drv1 < inp1) {
|
||||
drv1 = inp1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (drv1 < inp0) {
|
||||
val = 2;
|
||||
if (drv0 < inp0)
|
||||
drv0 = inp0;
|
||||
if (drv1 < inp1)
|
||||
drv0 = inp1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
switch (inp) {
|
||||
case 0:
|
||||
if (drv1 < inp0) {
|
||||
val = 0;
|
||||
drv0 = inp0;
|
||||
drv1 = inp1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (drv0 < inp1) {
|
||||
val = 1;
|
||||
drv0 = inp0;
|
||||
drv1 = inp1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (drv0 < inp0)
|
||||
drv0 = inp0;
|
||||
if (drv1 < inp1)
|
||||
drv0 = inp1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* For now, cheat and resolve the values without using the actual
|
||||
* strengths. The strengths are not yet available to the inputs, so
|
||||
|
|
@ -30,38 +124,27 @@
|
|||
*/
|
||||
void vvp_resolv_s::set(vvp_ipoint_t ptr, functor_t fp, bool push)
|
||||
{
|
||||
unsigned in1 = (fp->ival >> 0) & 3;
|
||||
unsigned in2 = (fp->ival >> 2) & 3;
|
||||
unsigned in3 = (fp->ival >> 4) & 3;
|
||||
unsigned in4 = (fp->ival >> 5) & 3;
|
||||
unsigned val = (fp->ival >> 0) & 3;
|
||||
unsigned drv0 = (fp->idrive >> 0) & 7;
|
||||
unsigned drv1 = (fp->idrive >> 3) & 7;
|
||||
|
||||
unsigned val = in1;
|
||||
if (in2 != 3) {
|
||||
if (val == 3) {
|
||||
val = in2;
|
||||
} else if (val != in2) {
|
||||
val = 2;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
blend(val, drv0, drv1,
|
||||
(fp->ival >> 2) & 3,
|
||||
(fp->idrive >> 6) & 7,
|
||||
(fp->idrive >> 9) & 7);
|
||||
|
||||
if (in3 != 3) {
|
||||
if (val == 3) {
|
||||
val = in3;
|
||||
} else if (val != in3) {
|
||||
val = 2;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
blend(val, drv0, drv1,
|
||||
(fp->ival >> 4) & 3,
|
||||
(fp->idrive >>12) & 7,
|
||||
(fp->idrive >>15) & 7);
|
||||
|
||||
if (in4 != 3) {
|
||||
if (val == 3) {
|
||||
val = in4;
|
||||
} else if (val != in4) {
|
||||
val = 2;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
blend(val, drv0, drv1,
|
||||
(fp->ival >> 6) & 3,
|
||||
(fp->idrive >>18) & 7,
|
||||
(fp->idrive >>21) & 7);
|
||||
|
||||
fp->odrive0 = drv0;
|
||||
fp->odrive1 = drv1;
|
||||
|
||||
/* If the output changes, then create a propagation event. */
|
||||
if (val != fp->oval) {
|
||||
|
|
@ -75,6 +158,9 @@ void vvp_resolv_s::set(vvp_ipoint_t ptr, functor_t fp, bool push)
|
|||
|
||||
/*
|
||||
* $Log: resolv.cc,v $
|
||||
* Revision 1.2 2001/05/12 20:38:06 steve
|
||||
* A resolver that understands some simple strengths.
|
||||
*
|
||||
* Revision 1.1 2001/05/09 02:53:53 steve
|
||||
* Implement the .resolv syntax.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue