Support functor delays for gates and UDP devices.

(Stephan Boettcher)
This commit is contained in:
steve 2001-12-06 03:31:24 +00:00
parent c8319bcc02
commit ec4f8c80d5
18 changed files with 255 additions and 142 deletions

View File

@ -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: vvp_scope.c,v 1.56 2001/11/01 04:26:57 steve Exp $" #ident "$Id: vvp_scope.c,v 1.57 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "vvp_priv.h" # include "vvp_priv.h"
@ -427,6 +427,21 @@ static void draw_net_in_scope(ivl_signal_t sig)
free(args); free(args);
} }
static void draw_delay(ivl_net_logic_t lptr)
{
unsigned d0 = ivl_logic_delay(lptr, 0);
unsigned d1 = ivl_logic_delay(lptr, 1);
unsigned d2 = ivl_logic_delay(lptr, 2);
if (d0 == 0 && d1 == 0 && d2 == 0)
return;
if (d0 == d1 && d1 == d2)
fprintf(vvp_out, " (%d)", d0);
else
fprintf(vvp_out, " (%d,%d,%d)", d0, d1, d2);
}
static void draw_udp_def(ivl_udp_t udp) static void draw_udp_def(ivl_udp_t udp)
{ {
unsigned init; unsigned init;
@ -491,6 +506,7 @@ static void draw_udp_in_scope(ivl_net_logic_t lptr)
vvp_mangle_id(ivl_logic_name(lptr))); vvp_mangle_id(ivl_logic_name(lptr)));
fprintf(vvp_out, " UDP_%s", fprintf(vvp_out, " UDP_%s",
vvp_mangle_id(ivl_udp_name(udp))); vvp_mangle_id(ivl_udp_name(udp)));
draw_delay(lptr);
for (pdx = 1 ; pdx < ivl_logic_pins(lptr) ; pdx += 1) for (pdx = 1 ; pdx < ivl_logic_pins(lptr) ; pdx += 1)
{ {
@ -636,10 +652,12 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr)
vvp_mangle_id(ivl_logic_name(lptr)), vvp_mangle_id(ivl_logic_name(lptr)),
level, inst, level, inst,
lcasc); lcasc);
else else {
fprintf(vvp_out, "L_%s .functor %s", fprintf(vvp_out, "L_%s .functor %s",
vvp_mangle_id(ivl_logic_name(lptr)), vvp_mangle_id(ivl_logic_name(lptr)),
ltype); ltype);
draw_delay(lptr);
}
for (pdx = inst; pdx < ninp && pdx < inst+4 ; pdx += 1) { for (pdx = inst; pdx < ninp && pdx < inst+4 ; pdx += 1) {
if (level) { if (level) {
fprintf(vvp_out, ", L_%s/%d/%d", fprintf(vvp_out, ", L_%s/%d/%d",
@ -1217,6 +1235,10 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/* /*
* $Log: vvp_scope.c,v $ * $Log: vvp_scope.c,v $
* Revision 1.57 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.56 2001/11/01 04:26:57 steve * Revision 1.56 2001/11/01 04:26:57 steve
* Generate code for deassign and cassign. * Generate code for deassign and cassign.
* *

View File

@ -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: arith.cc,v 1.20 2001/11/07 03:34:41 steve Exp $" #ident "$Id: arith.cc,v 1.21 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "arith.h" # include "arith.h"
@ -36,7 +36,7 @@ void vvp_arith_::output_x_(vvp_ipoint_t base, bool push, unsigned val)
vvp_ipoint_t ptr = ipoint_index(base,idx); vvp_ipoint_t ptr = ipoint_index(base,idx);
functor_t obj = functor_index(ptr); functor_t obj = functor_index(ptr);
obj->put_oval(push, val); obj->put_oval(val, push);
} }
} }
@ -49,7 +49,7 @@ void vvp_arith_::output_val_(vvp_ipoint_t base, bool push, unsigned long sum)
unsigned val = sum & 1; unsigned val = sum & 1;
sum >>= 1; sum >>= 1;
obj->put_oval(push, val); obj->put_oval(val, push);
} }
} }
@ -79,7 +79,7 @@ void vvp_wide_arith_::output_val_(vvp_ipoint_t base, bool push)
page += 1; page += 1;
} }
obj->put_oval(push, val); obj->put_oval(val, push);
} }
} }
@ -213,7 +213,7 @@ void vvp_arith_mult::wide(vvp_ipoint_t base, bool push)
unsigned val = sum[idx]; unsigned val = sum[idx];
obj->put_oval(push, val); obj->put_oval(val, push);
} }
delete[]sum; delete[]sum;
@ -369,7 +369,7 @@ void vvp_cmp_ge::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
} }
} }
put_oval(push, out_val); put_oval(out_val, push);
} }
void vvp_cmp_gt::set(vvp_ipoint_t i, bool push, unsigned val, unsigned) void vvp_cmp_gt::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
@ -403,7 +403,7 @@ void vvp_cmp_gt::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
} }
} }
put_oval(push, out_val); put_oval(out_val, push);
} }
@ -442,7 +442,7 @@ void vvp_shiftl::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
for (unsigned idx = 0 ; idx < amount ; idx += 1) { for (unsigned idx = 0 ; idx < amount ; idx += 1) {
optr = ipoint_index(base, idx); optr = ipoint_index(base, idx);
ofp = functor_index(optr); ofp = functor_index(optr);
ofp->put_oval(push, 0); ofp->put_oval(0, push);
} }
for (unsigned idx = amount ; idx < wid_ ; idx += 1) { for (unsigned idx = amount ; idx < wid_ ; idx += 1) {
@ -451,7 +451,7 @@ void vvp_shiftl::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
iptr = ipoint_index(base, idx - amount); iptr = ipoint_index(base, idx - amount);
ifp = functor_index(iptr); ifp = functor_index(iptr);
ofp->put_oval(push, ifp->ival & 3); ofp->put_oval(ifp->ival & 3, push);
} }
} }
} }
@ -494,13 +494,13 @@ void vvp_shiftr::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
iptr = ipoint_index(base, idx + amount); iptr = ipoint_index(base, idx + amount);
ifp = functor_index(iptr); ifp = functor_index(iptr);
ofp->put_oval(push, ifp->ival & 3); ofp->put_oval(ifp->ival & 3, push);
} }
for (unsigned idx = wid_-amount; idx < wid_ ; idx += 1) { for (unsigned idx = wid_-amount; idx < wid_ ; idx += 1) {
optr = ipoint_index(base, idx); optr = ipoint_index(base, idx);
ofp = functor_index(optr); ofp = functor_index(optr);
ofp->put_oval(push, 0); ofp->put_oval(0, push);
} }
} }
} }
@ -508,6 +508,10 @@ void vvp_shiftr::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
/* /*
* $Log: arith.cc,v $ * $Log: arith.cc,v $
* Revision 1.21 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.20 2001/11/07 03:34:41 steve * Revision 1.20 2001/11/07 03:34:41 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -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: bufif.cc,v 1.3 2001/11/07 03:34:42 steve Exp $" #ident "$Id: bufif.cc,v 1.4 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "bufif.h" # include "bufif.h"
@ -80,11 +80,15 @@ void vvp_bufif1_s::set(vvp_ipoint_t ptr, bool push, unsigned v, unsigned)
break; break;
} }
put_ostr(push, val, str); put_ostr(val, str, push);
} }
/* /*
* $Log: bufif.cc,v $ * $Log: bufif.cc,v $
* Revision 1.4 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.3 2001/11/07 03:34:42 steve * Revision 1.3 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -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: compile.cc,v 1.114 2001/11/07 03:34:42 steve Exp $" #ident "$Id: compile.cc,v 1.115 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "arith.h" # include "arith.h"
@ -579,7 +579,7 @@ static vvp_ipoint_t make_const_functor(unsigned val,
functor_t obj = new const_functor_s(str0, str1); functor_t obj = new const_functor_s(str0, str1);
functor_define(fdx, obj); functor_define(fdx, obj);
obj->put_oval(false, val); obj->put_oval(val, false);
return fdx; return fdx;
} }
@ -929,6 +929,7 @@ char **compile_udp_table(char **table, char *row)
} }
void compile_udp_functor(char*label, char*type, void compile_udp_functor(char*label, char*type,
vvp_delay_t delay,
unsigned argc, struct symb_s*argv) unsigned argc, struct symb_s*argv)
{ {
struct vvp_udp_s *u = udp_find(type); struct vvp_udp_s *u = udp_find(type);
@ -951,11 +952,13 @@ void compile_udp_functor(char*label, char*type,
} }
} }
udp->delay = delay;
inputs_connect(fdx, argc, argv); inputs_connect(fdx, argc, argv);
free(argv); free(argv);
if (u->sequ) if (u->sequ)
udp->put_oval(false, u->init); udp->put_oval(u->init, false);
} }
@ -1341,6 +1344,10 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
/* /*
* $Log: compile.cc,v $ * $Log: compile.cc,v $
* Revision 1.115 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.114 2001/11/07 03:34:42 steve * Revision 1.114 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -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: compile.h,v 1.37 2001/11/06 03:07:22 steve Exp $" #ident "$Id: compile.h,v 1.38 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include <stdio.h> # include <stdio.h>
@ -73,6 +73,7 @@ extern void compile_vpi_time_precision(long pre);
* to existing functors to manage the linking. * to existing functors to manage the linking.
*/ */
extern void compile_functor(char*label, char*type, extern void compile_functor(char*label, char*type,
vvp_delay_t delay,
unsigned argc, struct symb_s*argv); unsigned argc, struct symb_s*argv);
@ -128,6 +129,7 @@ extern void compile_udp_def(int sequ, char*label, char *name,
unsigned nin, unsigned init, char **table); unsigned nin, unsigned init, char **table);
extern void compile_udp_functor(char*label, char*type, extern void compile_udp_functor(char*label, char*type,
vvp_delay_t delay,
unsigned argc, struct symb_s*argv); unsigned argc, struct symb_s*argv);
extern char **compile_udp_table(char **table, char *row); extern char **compile_udp_table(char **table, char *row);
@ -220,6 +222,10 @@ extern void compile_net(char*label, char*name,
/* /*
* $Log: compile.h,v $ * $Log: compile.h,v $
* Revision 1.38 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.37 2001/11/06 03:07:22 steve * Revision 1.37 2001/11/06 03:07:22 steve
* Code rearrange. (Stephan Boettcher) * Code rearrange. (Stephan Boettcher)
* *

View File

@ -19,9 +19,11 @@
* 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: delay.h,v 1.1 2001/11/10 18:07:11 steve Exp $" #ident "$Id: delay.h,v 1.2 2001/12/06 03:31:24 steve Exp $"
#endif #endif
#include "pointers.h"
/* /*
** vvp_delay_t del; ** vvp_delay_t del;
** **
@ -61,8 +63,6 @@
** tgt and src are deleted. ** tgt and src are deleted.
*/ */
typedef struct vvp_delay_s *vvp_delay_t;
struct vvp_delay_s { struct vvp_delay_s {
vvp_delay_s(unsigned); vvp_delay_s(unsigned);
unsigned delay(unsigned char idx) { return del[tab[idx]]; } unsigned delay(unsigned char idx) { return del[tab[idx]]; }
@ -113,6 +113,10 @@ vvp_delay_t vvp_delay_set(vvp_delay_t tgt, vvp_delay_t src,
/* /*
** $Log: delay.h,v $ ** $Log: delay.h,v $
** Revision 1.2 2001/12/06 03:31:24 steve
** Support functor delays for gates and UDP devices.
** (Stephan Boettcher)
**
** Revision 1.1 2001/11/10 18:07:11 steve ** Revision 1.1 2001/11/10 18:07:11 steve
** Runtime support for functor delays. (Stephan Boettcher) ** Runtime support for functor delays. (Stephan Boettcher)
** **

View File

@ -18,7 +18,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: force.cc,v 1.3 2001/11/07 03:34:42 steve Exp $" #ident "$Id: force.cc,v 1.4 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "codes.h" # include "codes.h"
@ -35,41 +35,29 @@ inline bool functor_s::disable(vvp_ipoint_t ptr)
inline bool functor_s::enable(vvp_ipoint_t ptr) inline bool functor_s::enable(vvp_ipoint_t ptr)
{ {
unsigned val;
if (ostr == 0)
val = 3;
else switch (ostr & 0x88) {
case 0x00: val = 0; break;
case 0x88: val = 1; break;
default: val = 2;
}
if (val != oval) {
oval = val;
propagate(true);
}
bool r = inhibit; bool r = inhibit;
inhibit = 0; inhibit = 0;
if (r) {
if (get_str() != get_ostr())
propagate();
else
assert(get() == get_oval());
}
return r; return r;
} }
inline void functor_s::force(unsigned val, unsigned str) void force_functor_s::set(vvp_ipoint_t i, bool push,
unsigned val, unsigned str)
{ {
if (ostr != str || oval != val) { if (ipoint_port(i) == 0) {
unsigned save = ostr;
oval = val; oval = val;
ostr = str; ostr = str;
propagate(true); if (active && out) {
ostr = save;
}
}
void force_functor_s::set(vvp_ipoint_t i, bool, unsigned val, unsigned str)
{
put(i, val);
if (ipoint_port(i) == 0) {
if (active && out) {
functor_t tgt = functor_index(out); functor_t tgt = functor_index(out);
tgt->force(ival&3, get_ostr()); if (str != tgt->get_str())
tgt->propagate(val, str, push);
else
assert(val == tgt->get());
} }
} }
} }
@ -123,7 +111,7 @@ bool of_FORCE(vthread_t thr, vvp_code_t cp)
fofu->port[3] = tgt->out; fofu->port[3] = tgt->out;
tgt->out = ipoint_make(ifofu, 3); tgt->out = ipoint_make(ifofu, 3);
fofu->set(ifofu, false, fofu->ival&3, fofu->get_ostr()); fofu->set(ifofu, false, fofu->get_oval(), fofu->get_ostr());
} }
return true; return true;
@ -136,7 +124,6 @@ bool of_RELEASE(vthread_t thr, vvp_code_t cp)
if (release_force(itgt, tgt)) if (release_force(itgt, tgt))
tgt->enable(itgt); tgt->enable(itgt);
// bug: a strength change will not be propagated.
return true; return true;
} }
@ -158,7 +145,7 @@ void var_functor_s::set(vvp_ipoint_t ptr, bool push, unsigned val, unsigned)
unsigned pp = ipoint_port(ptr); unsigned pp = ipoint_port(ptr);
if (assigned() && pp==1 || !assigned() && pp==0) { if (assigned() && pp==1 || !assigned() && pp==0) {
put_oval(push, val); put_oval(val, push);
} }
} }
@ -249,6 +236,10 @@ bool of_DEASSIGN(vthread_t thr, vvp_code_t cp)
/* /*
* $Log: force.cc,v $ * $Log: force.cc,v $
* Revision 1.4 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.3 2001/11/07 03:34:42 steve * Revision 1.3 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -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.34 2001/11/16 04:22:27 steve Exp $" #ident "$Id: functor.cc,v 1.35 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "functor.h" # include "functor.h"
@ -114,10 +114,12 @@ functor_s::functor_s()
port[2] = 0; port[2] = 0;
port[3] = 0; port[3] = 0;
ival = 0xaa; ival = 0xaa;
cval = 2;
oval = 2; oval = 2;
odrive0 = 6; odrive0 = 6;
odrive1 = 6; odrive1 = 6;
ostr = StX; ostr = StX;
cstr = StX;
inhibit = 0; inhibit = 0;
#if defined(WITH_DEBUG) #if defined(WITH_DEBUG)
breakpoint = 0; breakpoint = 0;
@ -169,6 +171,10 @@ edge_inputs_functor_s::~edge_inputs_functor_s()
/* /*
* $Log: functor.cc,v $ * $Log: functor.cc,v $
* Revision 1.35 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.34 2001/11/16 04:22:27 steve * Revision 1.34 2001/11/16 04:22:27 steve
* include stdlib.h for portability. * include stdlib.h for portability.
* *

View File

@ -19,19 +19,12 @@
* 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.39 2001/11/10 18:07:12 steve Exp $" #ident "$Id: functor.h,v 1.40 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "pointers.h" # include "pointers.h"
# include "delay.h" # include "delay.h"
/*
* Create a propagation event. The fun parameter points to the functor
* to have its output propagated, and the delay is the delay to
* schedule the propagation.
*/
extern void schedule_functor(functor_t fun, unsigned delay);
/* /*
* The vvp_ipoint_t is an integral type that is 32bits. The low 2 bits * The vvp_ipoint_t is an integral type that is 32bits. The low 2 bits
* select the port of the referenced functor, and the remaining 30 * select the port of the referenced functor, and the remaining 30
@ -68,7 +61,7 @@ extern void schedule_functor(functor_t fun, unsigned delay);
* STRONG = 6, * STRONG = 6,
* SUPPLY = 7 * SUPPLY = 7
* *
* The output value (oval) is combined with the drive specifications * The output value (cval) is combined with the drive specifications
* to make a fully strength aware output, as described below. * to make a fully strength aware output, as described below.
* *
* OUTPUT STRENGTHS: * OUTPUT STRENGTHS:
@ -81,9 +74,9 @@ extern void schedule_functor(functor_t fun, unsigned delay);
* strength-value closest to supply0. * strength-value closest to supply0.
* *
* The functor calculates, when it operates, a 4-value output into * The functor calculates, when it operates, a 4-value output into
* oval and a fully strength aware value into ostr. The mode-0 * oval and a fully strength aware value into ostr. Functors with
* functors use the odrive0 and odrive1 fields to form the strength * fixed drive strength use the odrive0 and odrive1 fields to form the
* value. * strength value.
*/ */
/* /*
@ -163,14 +156,19 @@ struct functor_s {
private: private:
/* Output value (low bits) and drive1 and drive0 strength. */ /* Output value (low bits) and drive1 and drive0 strength. */
unsigned oval : 2; unsigned cval : 2;
protected: protected:
unsigned odrive0 : 3; unsigned odrive0 : 3;
unsigned odrive1 : 3; unsigned odrive1 : 3;
private: private:
/* Strength form of the output value. */ /* Strength form of the output value. */
unsigned cstr : 8;
protected:
unsigned ostr : 8; unsigned ostr : 8;
unsigned oval : 2;
private:
unsigned inhibit : 1; unsigned inhibit : 1;
public: public:
@ -178,18 +176,24 @@ struct functor_s {
/* True if this functor triggers a breakpoint. */ /* True if this functor triggers a breakpoint. */
unsigned breakpoint : 1; unsigned breakpoint : 1;
#endif #endif
public:
virtual void set(vvp_ipoint_t ipt, bool push, virtual void set(vvp_ipoint_t ipt, bool push,
unsigned val, unsigned str = 0) = 0; unsigned val, unsigned str = 0) = 0;
inline unsigned char get() { return oval; } inline unsigned char get() { return cval; }
inline unsigned char get_str() { return cstr; }
inline unsigned char get_oval() { return oval; }
inline unsigned char get_ostr() { return ostr; } inline unsigned char get_ostr() { return ostr; }
void put(vvp_ipoint_t ipt, unsigned val); void put(vvp_ipoint_t ipt, unsigned val);
void put_oval(bool push, unsigned val); void put_oval(unsigned val, bool push = true);
void put_ostr(bool push, unsigned val, unsigned str); void put_ostr(unsigned val, unsigned str, bool push = true);
void schedule(unsigned delay);
bool disable(vvp_ipoint_t ptr); bool disable(vvp_ipoint_t ptr);
bool enable(vvp_ipoint_t ptr); bool enable(vvp_ipoint_t ptr);
void propagate(bool push); void propagate(bool push = true);
void force(unsigned val, unsigned str); void propagate(unsigned val, unsigned str, bool push = true);
}; };
/* /*
@ -204,63 +208,72 @@ inline void functor_s::put(vvp_ipoint_t ptr, unsigned val)
ival = (ival & imask) | ((val & 3) << (2*pp)); ival = (ival & imask) | ((val & 3) << (2*pp));
} }
inline void functor_s::propagate(bool push) inline void functor_s::propagate(unsigned val, unsigned str, bool push)
{ {
cval = val;
cstr = str;
vvp_ipoint_t idx = out; vvp_ipoint_t idx = out;
while (idx) { while (idx) {
functor_t idxp = functor_index(idx); functor_t idxp = functor_index(idx);
idxp->set(idx, push, oval, ostr); idxp->set(idx, push, val, str);
idx = idxp->port[ipoint_port(idx)]; idx = idxp->port[ipoint_port(idx)];
#if defined(WITH_DEBUG)
if (fp->breakpoint)
breakpoint();
#endif
} }
#if defined(WITH_DEBUG)
if (breakpoint)
breakpoint();
#endif
} }
inline void functor_s::put_ostr(bool push, unsigned val, unsigned str) inline void functor_s::propagate(bool push)
{ {
if (val != oval || str != ostr) { propagate(get_oval(), get_ostr(), push);
}
inline void functor_s::put_ostr(unsigned val, unsigned str, bool push)
{
if (str != get_ostr() || val != get_oval()) {
unsigned char ooval = oval;
ostr = str; ostr = str;
oval = val;
if (inhibit) if (inhibit)
return; return;
oval = val;
unsigned del; unsigned del;
if (delay) if (delay)
del = vvp_delay_get(delay, oval, val); del = vvp_delay_get(delay, ooval, val);
else else
del = 0; del = 0;
if (del == 0 && push) if (push && del == 0) {
propagate(true); propagate();
}
else else
schedule_functor(this, del); schedule(del);
} }
} }
inline void functor_s::put_oval(bool push, unsigned val) inline void functor_s::put_oval(unsigned val, bool push)
{ {
unsigned char str;
switch (val) { switch (val) {
case 0: case 0:
ostr = 0x00 | (odrive0<<0) | (odrive0<<4); str = 0x00 | (odrive0<<0) | (odrive0<<4);
break; break;
case 1: case 1:
ostr = 0x88 | (odrive1<<0) | (odrive1<<4); str = 0x88 | (odrive1<<0) | (odrive1<<4);
break; break;
case 2: case 2:
ostr = 0x80 | (odrive0<<0) | (odrive1<<4); str = 0x80 | (odrive0<<0) | (odrive1<<4);
break; break;
case 3: default:
ostr = 0x00; str = 0x00;
break; break;
} }
put_ostr(push, val, ostr); put_ostr(val, str, push);
} }
/* /*
@ -280,7 +293,7 @@ inline void functor_s::put_oval(bool push, unsigned val)
* propagation events to pass the output on. * propagation events to pass the output on.
*/ */
inline static inline static
void functor_set(vvp_ipoint_t ptr, unsigned val, unsigned str, bool push) void functor_set(vvp_ipoint_t ptr, unsigned val, unsigned str, bool push = true)
{ {
functor_t fp = functor_index(ptr); functor_t fp = functor_index(ptr);
fp->set(ptr, push, val, str); fp->set(ptr, push, val, str);
@ -302,20 +315,6 @@ unsigned functor_get(vvp_ipoint_t ptr)
return fp->get(); return fp->get();
} }
/*
* When a propagation event happens, this function is called with the
* address of the affected functor. It propagates the output to all
* the inputs it is connected to, creating new propagation event on
* the way.
*/
inline static
void functor_propagate(functor_t fp, bool push=true)
{
fp->propagate(push);
}
// Special infrastructure functor types // Special infrastructure functor types
@ -376,6 +375,10 @@ extern vvp_fvector_t vvp_fvector_continuous_new(unsigned size, vvp_ipoint_t p);
/* /*
* $Log: functor.h,v $ * $Log: functor.h,v $
* Revision 1.40 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.39 2001/11/10 18:07:12 steve * Revision 1.39 2001/11/10 18:07:12 steve
* Runtime support for functor delays. (Stephan Boettcher) * Runtime support for functor delays. (Stephan Boettcher)
* *

View File

@ -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: logic.cc,v 1.3 2001/11/16 04:22:27 steve Exp $" #ident "$Id: logic.cc,v 1.4 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "logic.h" # include "logic.h"
@ -53,7 +53,7 @@ void table_functor_s::set(vvp_ipoint_t ptr, bool push, unsigned v, unsigned)
val >>= 2 * (ival&0x03); val >>= 2 * (ival&0x03);
val &= 0x03; val &= 0x03;
put_oval(push, val); put_oval(val, push);
} }
/* /*
@ -62,7 +62,9 @@ void table_functor_s::set(vvp_ipoint_t ptr, bool push, unsigned v, unsigned)
* functor. Also resolve the inputs to the functor. * functor. Also resolve the inputs to the functor.
*/ */
void compile_functor(char*label, char*type, unsigned argc, struct symb_s*argv) void compile_functor(char*label, char*type,
vvp_delay_t delay,
unsigned argc, struct symb_s*argv)
{ {
functor_t obj; functor_t obj;
@ -130,6 +132,8 @@ void compile_functor(char*label, char*type, unsigned argc, struct symb_s*argv)
define_functor_symbol(label, fdx); define_functor_symbol(label, fdx);
free(label); free(label);
obj->delay = delay;
inputs_connect(fdx, argc, argv); inputs_connect(fdx, argc, argv);
free(argv); free(argv);
} }
@ -137,6 +141,10 @@ void compile_functor(char*label, char*type, unsigned argc, struct symb_s*argv)
/* /*
* $Log: logic.cc,v $ * $Log: logic.cc,v $
* Revision 1.4 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.3 2001/11/16 04:22:27 steve * Revision 1.3 2001/11/16 04:22:27 steve
* include stdlib.h for portability. * include stdlib.h for portability.
* *

View File

@ -18,7 +18,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: memory.cc,v 1.13 2001/11/07 03:34:42 steve Exp $" #ident "$Id: memory.cc,v 1.14 2001/12/06 03:31:24 steve Exp $"
#endif #endif
#include "memory.h" #include "memory.h"
@ -317,7 +317,7 @@ void update_data(vvp_memory_port_t data)
vvp_ipoint_t dx = ipoint_index(data->ix, i); vvp_ipoint_t dx = ipoint_index(data->ix, i);
functor_t df = functor_index(dx); functor_t df = functor_index(dx);
unsigned char out = get_bit(data->cur_bits, i + data->bitoff); unsigned char out = get_bit(data->cur_bits, i + data->bitoff);
df->put_oval(false, out); df->put_oval(out);
} }
} }
@ -338,7 +338,7 @@ void update_data_ports(vvp_memory_t mem, vvp_memory_bits_t bits, int bit,
{ {
vvp_ipoint_t ix = ipoint_index(a->ix, i); vvp_ipoint_t ix = ipoint_index(a->ix, i);
functor_t df = functor_index(ix); functor_t df = functor_index(ix);
df->put_oval(false, val); df->put_oval(val);
} }
} }
a = a->next; a = a->next;

View File

@ -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: npmos.cc,v 1.6 2001/11/07 03:34:42 steve Exp $" #ident "$Id: npmos.cc,v 1.7 2001/12/06 03:31:24 steve Exp $"
#endif #endif
# include "npmos.h" # include "npmos.h"
@ -58,10 +58,13 @@ void vvp_pmos_s::set(vvp_ipoint_t ptr, bool push, unsigned v, unsigned s)
unsigned char val; unsigned char val;
unsigned char str; unsigned char str;
if (in0 == 3 || in1 == 0) { if (in1 == 0) {
// gate on; output follows input // gate on; output follows input
val = in0; val = in0;
str = istr; str = istr;
} else if (in0 == 3) {
val = 3;
str = HiZ;
} else if (in1 == 2 || in1 == 3) { } else if (in1 == 2 || in1 == 3) {
// gate X or Z; output is undefined // gate X or Z; output is undefined
val = 2; val = 2;
@ -82,11 +85,15 @@ void vvp_pmos_s::set(vvp_ipoint_t ptr, bool push, unsigned v, unsigned s)
str = HiZ; str = HiZ;
} }
put_ostr(push, val, str); put_ostr(val, str, push);
} }
/* /*
* $Log: npmos.cc,v $ * $Log: npmos.cc,v $
* Revision 1.7 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.6 2001/11/07 03:34:42 steve * Revision 1.6 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -19,11 +19,12 @@
* 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: parse.y,v 1.40 2001/11/01 03:00:19 steve Exp $" #ident "$Id: parse.y,v 1.41 2001/12/06 03:31:25 steve Exp $"
#endif #endif
# include "parse_misc.h" # include "parse_misc.h"
# include "compile.h" # include "compile.h"
# include "delay.h"
# include <stdio.h> # include <stdio.h>
# include <stdlib.h> # include <stdlib.h>
# include <assert.h> # include <assert.h>
@ -51,6 +52,8 @@ extern FILE*yyin;
struct argv_s argv; struct argv_s argv;
vpiHandle vpi; vpiHandle vpi;
vvp_delay_t cdelay;
}; };
@ -79,6 +82,7 @@ extern FILE*yyin;
%type <argv> argument_opt argument_list %type <argv> argument_opt argument_list
%type <vpi> argument %type <vpi> argument
%type <cdelay> delay
%% %%
@ -117,13 +121,11 @@ statement
/* Functor statements define functors. The functor must have a /* Functor statements define functors. The functor must have a
label and a type name, and may have operands. */ label and a type name, and may have operands. */
: T_LABEL K_FUNCTOR T_SYMBOL ',' symbols ';' : T_LABEL K_FUNCTOR T_SYMBOL delay ',' symbols ';'
{ struct symbv_s obj = $5; { compile_functor($1, $3, $4, $6.cnt, $6.vect); }
compile_functor($1, $3, obj.cnt, obj.vect);
}
| T_LABEL K_FUNCTOR T_SYMBOL',' T_NUMBER ';' | T_LABEL K_FUNCTOR T_SYMBOL delay ',' T_NUMBER ';'
{ compile_functor($1, $3, 0, 0); } { compile_functor($1, $3, $4, 0, 0); }
/* UDP statements define or instantiate UDPs. Definitions take a /* UDP statements define or instantiate UDPs. Definitions take a
@ -136,8 +138,8 @@ statement
| T_LABEL K_UDP_C T_STRING ',' T_NUMBER ',' udp_table ';' | T_LABEL K_UDP_C T_STRING ',' T_NUMBER ',' udp_table ';'
{ compile_udp_def(0, $1, $3, $5, 0, $7); } { compile_udp_def(0, $1, $3, $5, 0, $7); }
| T_LABEL K_UDP T_SYMBOL ',' symbols ';' | T_LABEL K_UDP T_SYMBOL delay ',' symbols ';'
{ compile_udp_functor($1, $3, $5.cnt, $5.vect); } { compile_udp_functor($1, $3, $4, $6.cnt, $6.vect); }
/* Memory. Definition, port, initialization */ /* Memory. Definition, port, initialization */
@ -495,6 +497,17 @@ o_komma
| ',' | ','
; ;
delay
: /* empty */
{ $$ = 0; }
| '(' T_NUMBER ')'
{ $$ = new vvp_delay_2_s($2, $2); }
| '(' T_NUMBER ',' T_NUMBER ')'
{ $$ = new vvp_delay_2_s($2, $4); }
| '(' T_NUMBER ',' T_NUMBER ',' T_NUMBER ')'
{ $$ = new vvp_delay_3_s($2, $4, $6); }
;
%% %%
int compile_design(const char*path) int compile_design(const char*path)
@ -514,6 +527,10 @@ int compile_design(const char*path)
/* /*
* $Log: parse.y,v $ * $Log: parse.y,v $
* Revision 1.41 2001/12/06 03:31:25 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.40 2001/11/01 03:00:19 steve * Revision 1.40 2001/11/01 03:00:19 steve
* Add force/cassign/release/deassign support. (Stephan Boettcher) * Add force/cassign/release/deassign support. (Stephan Boettcher)
* *

View File

@ -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: pointers.h,v 1.7 2001/11/07 03:34:42 steve Exp $" #ident "$Id: pointers.h,v 1.8 2001/12/06 03:31:25 steve Exp $"
#endif #endif
/* /*
@ -104,8 +104,17 @@ typedef struct vthread_s*vthread_t;
typedef struct vvp_fvector_s *vvp_fvector_t; typedef struct vvp_fvector_s *vvp_fvector_t;
/* delay object */
typedef struct vvp_delay_s *vvp_delay_t;
/* /*
* $Log: pointers.h,v $ * $Log: pointers.h,v $
* Revision 1.8 2001/12/06 03:31:25 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.7 2001/11/07 03:34:42 steve * Revision 1.7 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -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: resolv.cc,v 1.8 2001/11/07 03:34:42 steve Exp $" #ident "$Id: resolv.cc,v 1.9 2001/12/06 03:31:25 steve Exp $"
#endif #endif
# include "resolv.h" # include "resolv.h"
@ -164,11 +164,21 @@ void resolv_functor_s::set(vvp_ipoint_t i, bool push, unsigned, unsigned str)
} }
/* If the output changes, then create a propagation event. */ /* If the output changes, then create a propagation event. */
put_ostr(push, val, sval);
// Do not propagate (push). Why? Because if, for example, a
// clock buffer is modeled as parallel inverters, the output
// must not show 'bx transitions when the inverters all propagte
// at the same time.
put_ostr(val, sval, false);
} }
/* /*
* $Log: resolv.cc,v $ * $Log: resolv.cc,v $
* Revision 1.9 2001/12/06 03:31:25 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.8 2001/11/07 03:34:42 steve * Revision 1.8 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -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: schedule.cc,v 1.13 2001/11/07 03:34:42 steve Exp $" #ident "$Id: schedule.cc,v 1.14 2001/12/06 03:31:25 steve Exp $"
#endif #endif
# include "schedule.h" # include "schedule.h"
@ -56,6 +56,7 @@ struct event_s {
}; };
unsigned val :2; unsigned val :2;
unsigned type :2; unsigned type :2;
// unsigned char str;
struct event_s*next; struct event_s*next;
struct event_s*last; struct event_s*last;
@ -238,13 +239,15 @@ void schedule_vthread(vthread_t thr, unsigned delay)
schedule_event_(cur); schedule_event_(cur);
} }
void schedule_functor(functor_t funp, unsigned delay) void functor_s::schedule(unsigned delay)
{ {
struct event_s*cur = e_alloc(); struct event_s*cur = e_alloc();
cur->delay = delay; cur->delay = delay;
cur->funp = funp; cur->funp = this;
cur->type = TYPE_PROP; cur->type = TYPE_PROP;
// cur->str = get_ostr();
// cur->val = get_oval();
schedule_event_(cur); schedule_event_(cur);
} }
@ -320,23 +323,23 @@ void schedule_simulate(void)
case TYPE_PROP: case TYPE_PROP:
//printf("Propagate %p\n", cur->fun); //printf("Propagate %p\n", cur->fun);
functor_propagate(cur->funp); cur->funp->propagate();
e_free(cur); e_free(cur);
break; break;
case TYPE_ASSIGN: case TYPE_ASSIGN:
switch (cur->val) { switch (cur->val) {
case 0: case 0:
functor_set(cur->fun, cur->val, St0, false); functor_set(cur->fun, cur->val, St0);
break; break;
case 1: case 1:
functor_set(cur->fun, cur->val, St1, false); functor_set(cur->fun, cur->val, St1);
break; break;
case 2: case 2:
functor_set(cur->fun, cur->val, StX, false); functor_set(cur->fun, cur->val, StX);
break; break;
case 3: case 3:
functor_set(cur->fun, cur->val, HiZ, false); functor_set(cur->fun, cur->val, HiZ);
break; break;
} }
e_free(cur); e_free(cur);
@ -361,6 +364,10 @@ void schedule_simulate(void)
/* /*
* $Log: schedule.cc,v $ * $Log: schedule.cc,v $
* Revision 1.14 2001/12/06 03:31:25 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.13 2001/11/07 03:34:42 steve * Revision 1.13 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -18,7 +18,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: udp.cc,v 1.13 2001/11/07 03:34:42 steve Exp $" #ident "$Id: udp.cc,v 1.14 2001/12/06 03:31:25 steve Exp $"
#endif #endif
#include "udp.h" #include "udp.h"
@ -31,12 +31,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
void udp_functor_s::set(vvp_ipoint_t i, bool, unsigned val, unsigned) void udp_functor_s::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
{ {
// old_ival is set on the way out // old_ival is set on the way out
put(i, val); put(i, val);
unsigned char out = udp->propagate(this, i); unsigned char out = udp->propagate(this, i);
put_oval(false, out); put_oval(out, push);
} }
@ -350,6 +350,10 @@ void vvp_udp_s::compile_row_(udp_table_entry_t row, char *rchr)
/* /*
* $Log: udp.cc,v $ * $Log: udp.cc,v $
* Revision 1.14 2001/12/06 03:31:25 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.13 2001/11/07 03:34:42 steve * Revision 1.13 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *

View File

@ -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: vpi_signal.cc,v 1.29 2001/11/07 03:34:42 steve Exp $" #ident "$Id: vpi_signal.cc,v 1.30 2001/12/06 03:31:25 steve Exp $"
#endif #endif
/* /*
@ -404,7 +404,7 @@ static void functor_poke(struct __vpiSignal*rfp, unsigned idx,
{ {
vvp_ipoint_t ptr = vvp_fvector_get(rfp->bits,idx); vvp_ipoint_t ptr = vvp_fvector_get(rfp->bits,idx);
functor_t fu = functor_index(ptr); functor_t fu = functor_index(ptr);
fu->put_ostr(true, val, str); fu->put_ostr(val, str, true);
} }
static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp, static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
@ -552,6 +552,10 @@ vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
/* /*
* $Log: vpi_signal.cc,v $ * $Log: vpi_signal.cc,v $
* Revision 1.30 2001/12/06 03:31:25 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.29 2001/11/07 03:34:42 steve * Revision 1.29 2001/11/07 03:34:42 steve
* Use functor pointers where vvp_ipoint_t is unneeded. * Use functor pointers where vvp_ipoint_t is unneeded.
* *