From 986885bd7032d970a220b861214404a0b8403a4d Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 26 Apr 2001 15:52:22 +0000 Subject: [PATCH] Add the mode-42 functor concept to UDPs. --- vvp/compile.cc | 7 +++++-- vvp/functor.cc | 36 ++++++++++++------------------------ vvp/functor.h | 21 ++++++++++++++++++++- vvp/udp.cc | 20 +++++++++++++++++++- vvp/udp.h | 7 +++++-- 5 files changed, 61 insertions(+), 30 deletions(-) diff --git a/vvp/compile.cc b/vvp/compile.cc index 50c3c1d5c..71016adb8 100644 --- a/vvp/compile.cc +++ b/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.42 2001/04/26 05:12:02 steve Exp $" +#ident "$Id: compile.cc,v 1.43 2001/04/26 15:52:22 steve Exp $" #endif # include "compile.h" @@ -341,7 +341,7 @@ void compile_udp_functor(char*label, char*type, iobj->ival = 0xaa; iobj->old_ival = obj->ival; iobj->oval = u->init; - iobj->mode = 3; + iobj->mode = M42; if (idx) { iobj->out = fdx; @@ -957,6 +957,9 @@ void compile_dump(FILE*fd) /* * $Log: compile.cc,v $ + * Revision 1.43 2001/04/26 15:52:22 steve + * Add the mode-42 functor concept to UDPs. + * * Revision 1.42 2001/04/26 05:12:02 steve * Implement simple MUXZ for ?: operators. * diff --git a/vvp/functor.cc b/vvp/functor.cc index a54ef64a8..10974a8ec 100644 --- a/vvp/functor.cc +++ b/vvp/functor.cc @@ -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.13 2001/04/24 02:23:59 steve Exp $" +#ident "$Id: functor.cc,v 1.14 2001/04/26 15:52:22 steve Exp $" #endif # include "functor.h" @@ -214,27 +214,6 @@ static void functor_set_mode2(functor_t fp) schedule_assign(fp->out, 0, 0); } -/* - * A mode-3 functor is a UDP. - */ -static void functor_set_mode3(vvp_ipoint_t ptr, functor_t fp) -{ - /* If we are down the tree, just propagate */ - if (!fp->udp) - { - functor_propagate(ptr); - return; - } - - unsigned char out = udp_propagate(ptr); - - if (out != fp->oval) - { - fp->oval = out; - functor_propagate(ptr); - } -} - /* * Set the addressed bit of the functor, and recalculate the * output. If the output changes any, then generate the necessary @@ -262,8 +241,12 @@ void functor_set(vvp_ipoint_t ptr, unsigned bit, bool push) case 2: functor_set_mode2(fp); break; - case 3: - functor_set_mode3(ptr, fp); + case M42: + if (!fp->obj) { + ptr = fp->out; + fp = functor_index(ptr); + } + fp->obj->set(ptr, fp, push); break; } } @@ -272,6 +255,8 @@ unsigned functor_get(vvp_ipoint_t ptr) { functor_t fp = functor_index(ptr); assert(fp); + if (fp->mode == M42 && fp->obj && fp->obj->get) + return fp->obj->get(ptr, fp); return fp->oval & 3; } @@ -331,6 +316,9 @@ const unsigned char ft_var[16] = { /* * $Log: functor.cc,v $ + * Revision 1.14 2001/04/26 15:52:22 steve + * Add the mode-42 functor concept to UDPs. + * * Revision 1.13 2001/04/24 02:23:59 steve * Support for UDP devices in VVP (Stephen Boettcher) * diff --git a/vvp/functor.h b/vvp/functor.h index c60b29263..198c02cea 100644 --- a/vvp/functor.h +++ b/vvp/functor.h @@ -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.15 2001/04/26 05:12:02 steve Exp $" +#ident "$Id: functor.h,v 1.16 2001/04/26 15:52:22 steve Exp $" #endif # include "pointers.h" @@ -83,6 +83,7 @@ struct functor_s { vvp_truth_t table; vvp_event_t event; struct vvp_udp_s *udp; // mode 3 + struct vvp_fobj_s *obj; }; /* This is the output for the device. */ @@ -102,6 +103,21 @@ struct functor_s { typedef struct functor_s *functor_t; +/* + * This a an `obj' structute for mode-42 functors. + * Each instance stores the get and set funtion pointers, for speed. + * Future, less important pointers may be pushed one level out to a + * `per type' kind of table. + */ + +#define M42 42 + +typedef struct vvp_fobj_s vvp_fobj_t; +struct vvp_fobj_s { + unsigned (*get)(vvp_ipoint_t i, functor_t f); + void (*set)(vvp_ipoint_t i, functor_t f, bool push); +}; + /* * If functor mode is 1, the event member is valid and the vvp_event_s * points to the extended event information. @@ -185,6 +201,9 @@ extern const unsigned char ft_var[]; /* * $Log: functor.h,v $ + * Revision 1.16 2001/04/26 15:52:22 steve + * Add the mode-42 functor concept to UDPs. + * * Revision 1.15 2001/04/26 05:12:02 steve * Implement simple MUXZ for ?: operators. * diff --git a/vvp/udp.cc b/vvp/udp.cc index 8d41feef7..07f09d33d 100644 --- a/vvp/udp.cc +++ b/vvp/udp.cc @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: udp.cc,v 1.2 2001/04/26 03:10:55 steve Exp $" +#ident "$Id: udp.cc,v 1.3 2001/04/26 15:52:22 steve Exp $" #endif #include "udp.h" @@ -28,6 +28,18 @@ static symbol_table_t udp_table; + +static void udp_functor_set(vvp_ipoint_t ptr, functor_t fp, bool) +{ + unsigned char out = udp_propagate(ptr); + + if (out != fp->oval) + { + fp->oval = out; + functor_propagate(ptr); + } +} + struct vvp_udp_s *udp_create(char *label) { if (!udp_table) @@ -47,6 +59,9 @@ struct vvp_udp_s *udp_create(char *label) u->init = 3; u->table = 0x0; + u->get = 0x0; + u->set = udp_functor_set; + return u; } @@ -194,6 +209,9 @@ unsigned char udp_propagate(vvp_ipoint_t uix) /* * $Log: udp.cc,v $ + * Revision 1.3 2001/04/26 15:52:22 steve + * Add the mode-42 functor concept to UDPs. + * * Revision 1.2 2001/04/26 03:10:55 steve * Redo and simplify UDP behavior. * diff --git a/vvp/udp.h b/vvp/udp.h index 891102650..841b0064a 100644 --- a/vvp/udp.h +++ b/vvp/udp.h @@ -20,14 +20,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: udp.h,v 1.3 2001/04/26 03:10:55 steve Exp $" +#ident "$Id: udp.h,v 1.4 2001/04/26 15:52:22 steve Exp $" #endif #include "pointers.h" #include "functor.h" #include "udp.h" -struct vvp_udp_s +struct vvp_udp_s : public vvp_fobj_s { char *name; unsigned short sequ; @@ -42,6 +42,9 @@ unsigned char udp_propagate(vvp_ipoint_t); /* * $Log: udp.h,v $ + * Revision 1.4 2001/04/26 15:52:22 steve + * Add the mode-42 functor concept to UDPs. + * * Revision 1.3 2001/04/26 03:10:55 steve * Redo and simplify UDP behavior. *