Regularize the mode-42 functor handling.
This commit is contained in:
parent
372674b4c0
commit
78af3dbdc0
|
|
@ -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.55 2001/05/06 00:18:13 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.56 2001/05/06 03:51:37 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -408,11 +408,11 @@ void compile_udp_functor(char*label, char*type,
|
|||
if (idx)
|
||||
{
|
||||
iobj->out = fdx;
|
||||
iobj->udp = 0;
|
||||
iobj->obj = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
iobj->udp = u;
|
||||
iobj->obj = u;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1048,6 +1048,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.56 2001/05/06 03:51:37 steve
|
||||
* Regularize the mode-42 functor handling.
|
||||
*
|
||||
* Revision 1.55 2001/05/06 00:18:13 steve
|
||||
* Propagate non-x constant net values.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.15 2001/05/03 04:54:33 steve Exp $"
|
||||
#ident "$Id: functor.cc,v 1.16 2001/05/06 03:51:37 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "functor.h"
|
||||
|
|
@ -260,6 +260,7 @@ void functor_set(vvp_ipoint_t ptr, unsigned bit, bool push)
|
|||
ptr = fp->out;
|
||||
fp = functor_index(ptr);
|
||||
}
|
||||
assert(fp->mode == M42);
|
||||
fp->obj->set(ptr, fp, push);
|
||||
break;
|
||||
}
|
||||
|
|
@ -269,7 +270,7 @@ unsigned functor_get(vvp_ipoint_t ptr)
|
|||
{
|
||||
functor_t fp = functor_index(ptr);
|
||||
assert(fp);
|
||||
if (fp->mode == M42 && fp->obj && fp->obj->get)
|
||||
if ((fp->mode == M42) && fp->obj)
|
||||
return fp->obj->get(ptr, fp);
|
||||
return fp->oval & 3;
|
||||
}
|
||||
|
|
@ -330,6 +331,9 @@ const unsigned char ft_var[16] = {
|
|||
|
||||
/*
|
||||
* $Log: functor.cc,v $
|
||||
* Revision 1.16 2001/05/06 03:51:37 steve
|
||||
* Regularize the mode-42 functor handling.
|
||||
*
|
||||
* Revision 1.15 2001/05/03 04:54:33 steve
|
||||
* Fix handling of a mode 1 functor that feeds into a
|
||||
* mode 2 functor. Feed the result only if the event
|
||||
|
|
|
|||
|
|
@ -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.17 2001/04/29 23:13:34 steve Exp $"
|
||||
#ident "$Id: functor.h,v 1.18 2001/05/06 03:51:37 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "pointers.h"
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
*
|
||||
* MODE 2: NAMED EVENT FUNCTORS
|
||||
*
|
||||
* These fuctors do not bother to check for edges. Any event on the
|
||||
* These functors do not bother to check for edges. Any event on the
|
||||
* input causes an event to be detected. Like mode-1 functors, these
|
||||
* can have %wait instructions waiting on them. Mode-2 functors do not
|
||||
* have structural inputs, however. They take their inputs from %set
|
||||
|
|
@ -75,6 +75,14 @@
|
|||
* functors by setting their outputs to put to the mode-2
|
||||
* functor. Since the mode-2 functor does not take input, any number
|
||||
* of mode-1 and mode-2 functors may point in.
|
||||
*
|
||||
* MODE 42: LIFE, THE UNIVERSE AND EVERYTHING ELSE
|
||||
*
|
||||
* These functors are and escape for all other behaviors. This mode
|
||||
* supports arbitrary complex behavior by replacing the truth table
|
||||
* with a struct vvp_fobj_s pointer. This abstract class has virtual
|
||||
* methods for receiving and retrieving values. See the vvp_fobj_s
|
||||
* definition below.
|
||||
*/
|
||||
|
||||
struct functor_s {
|
||||
|
|
@ -82,7 +90,6 @@ struct functor_s {
|
|||
union {
|
||||
vvp_truth_t table;
|
||||
vvp_event_t event;
|
||||
struct vvp_udp_s *udp; // mode 3
|
||||
struct vvp_fobj_s *obj;
|
||||
};
|
||||
|
||||
|
|
@ -94,7 +101,6 @@ struct functor_s {
|
|||
unsigned char ival;
|
||||
unsigned char oval;
|
||||
/* functor mode: 0 == table ; 1 == event ; 2 == named event */
|
||||
/* 3 == udp */
|
||||
unsigned char mode;
|
||||
union {
|
||||
unsigned char old_ival; // mode 3
|
||||
|
|
@ -105,19 +111,32 @@ 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.
|
||||
* Each instance implements the get and set methods in a type specific
|
||||
* way, so that this represents a completely general functor.
|
||||
*
|
||||
* ::set(...)
|
||||
*
|
||||
* This method is called when any of the 4 inputs of the functor
|
||||
* receives a bit value. This method is called even if the set value
|
||||
* is the same as the existing value.
|
||||
*
|
||||
* ::get(...)
|
||||
*
|
||||
* This method is called to pull the "value" of the functor. Normally,
|
||||
* there is not much of a trick to this, but some types might need to
|
||||
* do complex things here, like look up a memory index. Anyhow, this
|
||||
* method must be idempotent, because I'm only going to tell you that
|
||||
* it happens when it happens.
|
||||
*/
|
||||
|
||||
#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);
|
||||
virtual unsigned get(vvp_ipoint_t i, functor_t f) =0;
|
||||
virtual void set(vvp_ipoint_t i, functor_t f, bool push) =0;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* If functor mode is 1, the event member is valid and the vvp_event_s
|
||||
* points to the extended event information.
|
||||
|
|
@ -203,6 +222,9 @@ extern const unsigned char ft_var[];
|
|||
|
||||
/*
|
||||
* $Log: functor.h,v $
|
||||
* Revision 1.18 2001/05/06 03:51:37 steve
|
||||
* Regularize the mode-42 functor handling.
|
||||
*
|
||||
* Revision 1.17 2001/04/29 23:13:34 steve
|
||||
* Add bufif0 and bufif1 functors.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: memory.cc,v 1.1 2001/05/01 01:09:39 steve Exp $"
|
||||
#ident "$Id: memory.cc,v 1.2 2001/05/06 03:51:37 steve Exp $"
|
||||
#endif
|
||||
|
||||
#include "memory.h"
|
||||
|
|
@ -71,13 +71,16 @@ struct vvp_memory_index_s
|
|||
|
||||
struct vvp_memory_port_s : public vvp_fobj_s
|
||||
{
|
||||
vvp_memory_t mem;
|
||||
vvp_ipoint_t ix;
|
||||
vvp_memory_port_t next;
|
||||
int cur_addr;
|
||||
vvp_memory_bits_t cur_bits;
|
||||
int bitoff;
|
||||
int nbits;
|
||||
unsigned get(vvp_ipoint_t i, functor_t f);
|
||||
void set(vvp_ipoint_t i, functor_t f, bool push);
|
||||
|
||||
vvp_memory_t mem;
|
||||
vvp_ipoint_t ix;
|
||||
vvp_memory_port_t next;
|
||||
int cur_addr;
|
||||
vvp_memory_bits_t cur_bits;
|
||||
int bitoff;
|
||||
int nbits;
|
||||
};
|
||||
|
||||
// Compilation
|
||||
|
|
@ -153,14 +156,11 @@ void memory_new(vvp_memory_t mem, char *name, int msb, int lsb,
|
|||
mem->name = name;
|
||||
}
|
||||
|
||||
static void port_functor_set(vvp_ipoint_t i, functor_t f, bool push);
|
||||
|
||||
void memory_port_new(vvp_memory_t mem, vvp_ipoint_t ix,
|
||||
unsigned nbits, unsigned bitoff)
|
||||
{
|
||||
vvp_memory_port_t a = new struct vvp_memory_port_s;
|
||||
a->set = port_functor_set;
|
||||
a->get = 0x0;
|
||||
|
||||
a->mem = mem;
|
||||
a->ix = ix;
|
||||
|
|
@ -321,13 +321,15 @@ void update_data(vvp_memory_port_t data,
|
|||
}
|
||||
}
|
||||
|
||||
static
|
||||
void port_functor_set(vvp_ipoint_t i, functor_t f, bool push)
|
||||
void vvp_memory_port_s::set(vvp_ipoint_t i, functor_t f, bool push)
|
||||
{
|
||||
vvp_memory_port_t addr = (vvp_memory_port_t)f->obj;
|
||||
if (update_addr_bit(addr, i))
|
||||
update_data(addr, addr->cur_bits);
|
||||
return;
|
||||
if (update_addr_bit(this, i))
|
||||
update_data(this, cur_bits);
|
||||
}
|
||||
|
||||
unsigned vvp_memory_port_s::get(vvp_ipoint_t i, functor_t f)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
static
|
||||
|
|
|
|||
32
vvp/udp.cc
32
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.3 2001/04/26 15:52:22 steve Exp $"
|
||||
#ident "$Id: udp.cc,v 1.4 2001/05/06 03:51:37 steve Exp $"
|
||||
#endif
|
||||
|
||||
#include "udp.h"
|
||||
|
|
@ -29,9 +29,9 @@
|
|||
static symbol_table_t udp_table;
|
||||
|
||||
|
||||
static void udp_functor_set(vvp_ipoint_t ptr, functor_t fp, bool)
|
||||
void vvp_udp_s::set(vvp_ipoint_t ptr, functor_t fp, bool)
|
||||
{
|
||||
unsigned char out = udp_propagate(ptr);
|
||||
unsigned char out = propagate_(ptr);
|
||||
|
||||
if (out != fp->oval)
|
||||
{
|
||||
|
|
@ -40,6 +40,11 @@ static void udp_functor_set(vvp_ipoint_t ptr, functor_t fp, bool)
|
|||
}
|
||||
}
|
||||
|
||||
unsigned vvp_udp_s::get(vvp_ipoint_t i, functor_t f)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
struct vvp_udp_s *udp_create(char *label)
|
||||
{
|
||||
if (!udp_table)
|
||||
|
|
@ -59,9 +64,6 @@ struct vvp_udp_s *udp_create(char *label)
|
|||
u->init = 3;
|
||||
u->table = 0x0;
|
||||
|
||||
u->get = 0x0;
|
||||
u->set = udp_functor_set;
|
||||
|
||||
return u;
|
||||
}
|
||||
|
||||
|
|
@ -71,20 +73,17 @@ struct vvp_udp_s *udp_find(char *label)
|
|||
return (struct vvp_udp_s *)v.ptr;
|
||||
}
|
||||
|
||||
unsigned char udp_propagate(vvp_ipoint_t uix)
|
||||
unsigned char vvp_udp_s::propagate_(vvp_ipoint_t uix)
|
||||
{
|
||||
functor_t fu = functor_index(uix);
|
||||
struct vvp_udp_s *u = fu->udp;
|
||||
assert(u);
|
||||
assert(u->table);
|
||||
|
||||
unsigned char ret = 2;
|
||||
|
||||
for (char **rptr = u->table; *rptr ; rptr++)
|
||||
for (char **rptr = table; *rptr ; rptr++)
|
||||
{
|
||||
char *row = *rptr;
|
||||
|
||||
if (u->sequ)
|
||||
if (sequ)
|
||||
{
|
||||
char old_out = (fu->oval&3)["01xx"];
|
||||
if ( row[0]=='?'
|
||||
|
|
@ -99,7 +98,7 @@ unsigned char udp_propagate(vvp_ipoint_t uix)
|
|||
|
||||
int i;
|
||||
|
||||
for (i=0; i < u->nin; i++, row++)
|
||||
for (i=0; i < nin; i++, row++)
|
||||
{
|
||||
assert (*row);
|
||||
|
||||
|
|
@ -176,7 +175,7 @@ unsigned char udp_propagate(vvp_ipoint_t uix)
|
|||
}
|
||||
}
|
||||
|
||||
if (i == u->nin)
|
||||
if (i == nin)
|
||||
{
|
||||
assert(*row);
|
||||
if (*row == '-')
|
||||
|
|
@ -198,7 +197,7 @@ unsigned char udp_propagate(vvp_ipoint_t uix)
|
|||
}
|
||||
}
|
||||
|
||||
for (int i=0; i < u->nin; i+=4)
|
||||
for (int i=0; i < nin; i+=4)
|
||||
{
|
||||
functor_t fu = functor_index(ipoint_input_index(uix, i));
|
||||
fu->old_ival = fu->ival;
|
||||
|
|
@ -209,6 +208,9 @@ unsigned char udp_propagate(vvp_ipoint_t uix)
|
|||
|
||||
/*
|
||||
* $Log: udp.cc,v $
|
||||
* Revision 1.4 2001/05/06 03:51:37 steve
|
||||
* Regularize the mode-42 functor handling.
|
||||
*
|
||||
* Revision 1.3 2001/04/26 15:52:22 steve
|
||||
* Add the mode-42 functor concept to UDPs.
|
||||
*
|
||||
|
|
|
|||
27
vvp/udp.h
27
vvp/udp.h
|
|
@ -20,27 +20,38 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: udp.h,v 1.5 2001/04/28 20:09:05 steve Exp $"
|
||||
#ident "$Id: udp.h,v 1.6 2001/05/06 03:51:37 steve Exp $"
|
||||
#endif
|
||||
|
||||
#include "pointers.h"
|
||||
#include "functor.h"
|
||||
|
||||
struct vvp_udp_s : public vvp_fobj_s
|
||||
class vvp_udp_s : public vvp_fobj_s
|
||||
{
|
||||
char *name;
|
||||
unsigned short sequ;
|
||||
unsigned short nin;
|
||||
unsigned char init;
|
||||
char **table;
|
||||
public:
|
||||
unsigned get(vvp_ipoint_t i, functor_t f);
|
||||
void set(vvp_ipoint_t i, functor_t f, bool push);
|
||||
|
||||
public:
|
||||
char *name;
|
||||
unsigned short sequ;
|
||||
unsigned short nin;
|
||||
unsigned char init;
|
||||
char **table;
|
||||
|
||||
private:
|
||||
unsigned char propagate_(vvp_ipoint_t i);
|
||||
};
|
||||
|
||||
struct vvp_udp_s *udp_create(char *label);
|
||||
struct vvp_udp_s *udp_find(char *label);
|
||||
unsigned char udp_propagate(vvp_ipoint_t);
|
||||
|
||||
|
||||
/*
|
||||
* $Log: udp.h,v $
|
||||
* Revision 1.6 2001/05/06 03:51:37 steve
|
||||
* Regularize the mode-42 functor handling.
|
||||
*
|
||||
* Revision 1.5 2001/04/28 20:09:05 steve
|
||||
* Excessive header include.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue