Add structural left shift (.shift/l)
This commit is contained in:
parent
bcaa122fb9
commit
39c39f0162
78
vvp/arith.cc
78
vvp/arith.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: arith.cc,v 1.7 2001/06/29 01:21:48 steve Exp $"
|
||||
#ident "$Id: arith.cc,v 1.8 2001/07/06 04:46:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -319,8 +319,84 @@ void vvp_cmp_gt::set(vvp_ipoint_t i, functor_t f, bool push)
|
|||
}
|
||||
}
|
||||
|
||||
vvp_shiftl::vvp_shiftl(vvp_ipoint_t b, unsigned w)
|
||||
: vvp_arith_(b, w)
|
||||
{
|
||||
amount_ = 0;
|
||||
}
|
||||
|
||||
void vvp_shiftl::set(vvp_ipoint_t i, functor_t f, bool push)
|
||||
{
|
||||
amount_ = 0;
|
||||
for (unsigned idx = 0 ; idx < wid_ ; idx += 1) {
|
||||
vvp_ipoint_t ptr = ipoint_index(base_, idx);
|
||||
functor_t fp = functor_index(ptr);
|
||||
|
||||
unsigned val = (fp->ival >> 2) & 0x03;
|
||||
switch (val) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
amount_ |= 1 << idx;
|
||||
break;
|
||||
default:
|
||||
output_x_(push);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (amount_ >= wid_) {
|
||||
for (unsigned idx = 0 ; idx < wid_ ; idx += 1) {
|
||||
vvp_ipoint_t optr = ipoint_index(base_, idx);
|
||||
functor_t ofp = functor_index(optr);
|
||||
if (ofp->oval != 0) {
|
||||
ofp->oval = 0;
|
||||
if (push)
|
||||
functor_propagate(optr);
|
||||
else
|
||||
schedule_functor(optr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
vvp_ipoint_t optr, iptr;
|
||||
functor_t ofp, ifp;
|
||||
|
||||
for (unsigned idx = 0 ; idx < amount_ ; idx += 1) {
|
||||
optr = ipoint_index(base_, idx);
|
||||
ofp = functor_index(optr);
|
||||
if (ofp->oval != 0) {
|
||||
ofp->oval = 0;
|
||||
if (push)
|
||||
functor_propagate(optr);
|
||||
else
|
||||
schedule_functor(optr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned idx = amount_ ; idx < wid_ ; idx += 1) {
|
||||
optr = ipoint_index(base_, idx);
|
||||
ofp = functor_index(optr);
|
||||
iptr = ipoint_index(base_, idx - amount_);
|
||||
ifp = functor_index(iptr);
|
||||
|
||||
if (ofp->oval != (ifp->ival&3)) {
|
||||
ofp->oval = ifp->ival&3;
|
||||
if (push)
|
||||
functor_propagate(optr);
|
||||
else
|
||||
schedule_functor(optr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: arith.cc,v $
|
||||
* Revision 1.8 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
* Revision 1.7 2001/06/29 01:21:48 steve
|
||||
* Relax limit on width of structural sum.
|
||||
*
|
||||
|
|
|
|||
21
vvp/arith.h
21
vvp/arith.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: arith.h,v 1.5 2001/06/29 01:20:20 steve Exp $"
|
||||
#ident "$Id: arith.h,v 1.6 2001/07/06 04:46:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "functor.h"
|
||||
|
|
@ -110,8 +110,27 @@ class vvp_cmp_gt : public vvp_arith_ {
|
|||
vvp_cmp_gt(const vvp_cmp_gt&);
|
||||
vvp_cmp_gt& operator= (const vvp_cmp_gt&);
|
||||
};
|
||||
|
||||
class vvp_shiftl : public vvp_arith_ {
|
||||
|
||||
public:
|
||||
explicit vvp_shiftl(vvp_ipoint_t b, unsigned wid);
|
||||
|
||||
void set(vvp_ipoint_t i, functor_t f, bool push);
|
||||
|
||||
private:
|
||||
unsigned amount_;
|
||||
|
||||
private: // not implemented
|
||||
vvp_shiftl(const vvp_shiftl&);
|
||||
vvp_shiftl& operator= (const vvp_shiftl&);
|
||||
};
|
||||
|
||||
/*
|
||||
* $Log: arith.h,v $
|
||||
* Revision 1.6 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
* Revision 1.5 2001/06/29 01:20:20 steve
|
||||
* Relax limit on width of structural sum.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.83 2001/06/30 23:03:16 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.84 2001/07/06 04:46:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -564,6 +564,50 @@ void compile_cmp_gt(char*label, long wid, unsigned argc, struct symb_s*argv)
|
|||
|
||||
}
|
||||
|
||||
void compile_shiftl(char*label, long wid, unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
assert( wid > 0 );
|
||||
|
||||
if (argc < (wid+1)) {
|
||||
fprintf(stderr, "%s; .shift/l has too few symbols\n", label);
|
||||
compile_errors += 1;
|
||||
free(label);
|
||||
return;
|
||||
}
|
||||
|
||||
vvp_ipoint_t fdx = functor_allocate(wid);
|
||||
define_functor_symbol(label, fdx);
|
||||
|
||||
vvp_shiftl*dev = new vvp_shiftl(fdx, wid);
|
||||
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
vvp_ipoint_t ptr = ipoint_index(fdx,idx);
|
||||
functor_t obj = functor_index(ptr);
|
||||
|
||||
obj->ival = 0xaa;
|
||||
obj->oval = 2;
|
||||
obj->odrive0 = 6;
|
||||
obj->odrive1 = 6;
|
||||
obj->mode = M42;
|
||||
obj->obj = dev;
|
||||
#if defined(WITH_DEBUG)
|
||||
obj->breakpoint = 0;
|
||||
#endif
|
||||
|
||||
struct symb_s tmp_argv[3];
|
||||
unsigned tmp_argc = 1;
|
||||
tmp_argv[0] = argv[idx];
|
||||
if ((wid+idx) < argc) {
|
||||
tmp_argv[1] = argv[wid+idx];
|
||||
tmp_argc += 1;
|
||||
}
|
||||
|
||||
inputs_connect(ptr, tmp_argc, tmp_argv);
|
||||
}
|
||||
|
||||
free(argv);
|
||||
}
|
||||
|
||||
void compile_resolver(char*label, char*type, unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
vvp_ipoint_t fdx = functor_allocate(1);
|
||||
|
|
@ -1455,6 +1499,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.84 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
* Revision 1.83 2001/06/30 23:03:16 steve
|
||||
* support fast programming by only writing the bits
|
||||
* that are listed in the input file.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: compile.h,v 1.29 2001/06/30 23:03:17 steve Exp $"
|
||||
#ident "$Id: compile.h,v 1.30 2001/07/06 04:46:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
|
@ -85,6 +85,8 @@ extern void compile_cmp_ge(char*label, long width,
|
|||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_cmp_gt(char*label, long width,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_shiftl(char*label, long width,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
|
||||
|
||||
extern void compile_vpi_symbol(const char*label, vpiHandle obj);
|
||||
|
|
@ -200,6 +202,9 @@ extern void compile_net(char*label, char*name,
|
|||
|
||||
/*
|
||||
* $Log: compile.h,v $
|
||||
* Revision 1.30 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
* Revision 1.29 2001/06/30 23:03:17 steve
|
||||
* support fast programming by only writing the bits
|
||||
* that are listed in the input file.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: lexor.lex,v 1.24 2001/06/30 23:03:17 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.25 2001/07/06 04:46:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -78,6 +78,7 @@
|
|||
".net/s" { return K_NET_S; }
|
||||
".resolv" { return K_RESOLV; }
|
||||
".scope" { return K_SCOPE; }
|
||||
".shift/l" { return K_SHIFTL; }
|
||||
".thread" { return K_THREAD; }
|
||||
".var" { return K_VAR; }
|
||||
".var/s" { return K_VAR_S; }
|
||||
|
|
@ -146,6 +147,9 @@ int yywrap()
|
|||
|
||||
/*
|
||||
* $Log: lexor.lex,v $
|
||||
* Revision 1.25 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
* Revision 1.24 2001/06/30 23:03:17 steve
|
||||
* support fast programming by only writing the bits
|
||||
* that are listed in the input file.
|
||||
|
|
|
|||
13
vvp/parse.y
13
vvp/parse.y
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: parse.y,v 1.33 2001/06/30 23:03:17 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.34 2001/07/06 04:46:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -56,7 +56,7 @@ extern FILE*yyin;
|
|||
|
||||
%token K_ARITH_MULT K_ARITH_SUB K_ARITH_SUM K_CMP_GE K_CMP_GT
|
||||
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S
|
||||
%token K_RESOLV K_SCOPE K_THREAD
|
||||
%token K_RESOLV K_SCOPE K_SHIFTL K_THREAD
|
||||
%token K_UDP K_UDP_C K_UDP_S
|
||||
%token K_MEM K_MEM_P K_MEM_I
|
||||
%token K_VAR K_VAR_S K_vpi_call K_vpi_func K_disable K_fork
|
||||
|
|
@ -187,6 +187,12 @@ statement
|
|||
}
|
||||
|
||||
|
||||
| T_LABEL K_SHIFTL T_NUMBER ',' symbols ';'
|
||||
{ struct symbv_s obj = $5;
|
||||
compile_shiftl($1, $3, obj.cnt, obj.vect);
|
||||
}
|
||||
|
||||
|
||||
/* Event statements take a label, a type (the first T_SYMBOL) and a
|
||||
list of inputs. If the type is instead a string, then we have a
|
||||
named event instead. */
|
||||
|
|
@ -478,6 +484,9 @@ int compile_design(const char*path)
|
|||
|
||||
/*
|
||||
* $Log: parse.y,v $
|
||||
* Revision 1.34 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
* Revision 1.33 2001/06/30 23:03:17 steve
|
||||
* support fast programming by only writing the bits
|
||||
* that are listed in the input file.
|
||||
|
|
|
|||
Loading…
Reference in New Issue