Add the .shift/r functor.
This commit is contained in:
parent
30787fd49e
commit
608e5a4dbb
92
vvp/arith.cc
92
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.8 2001/07/06 04:46:44 steve Exp $"
|
||||
#ident "$Id: arith.cc,v 1.9 2001/07/07 02:57:33 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -392,8 +392,85 @@ void vvp_shiftl::set(vvp_ipoint_t i, functor_t f, bool push)
|
|||
}
|
||||
}
|
||||
|
||||
vvp_shiftr::vvp_shiftr(vvp_ipoint_t b, unsigned w)
|
||||
: vvp_arith_(b, w)
|
||||
{
|
||||
amount_ = 0;
|
||||
}
|
||||
|
||||
|
||||
void vvp_shiftr::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 < (wid_-amount_) ; 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);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned idx = wid_-amount_; idx < wid_ ; 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log: arith.cc,v $
|
||||
* Revision 1.9 2001/07/07 02:57:33 steve
|
||||
* Add the .shift/r functor.
|
||||
*
|
||||
* Revision 1.8 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
|
|
@ -407,18 +484,5 @@ void vvp_shiftl::set(vvp_ipoint_t i, functor_t f, bool push)
|
|||
* Add support for structural multiply in t-dll.
|
||||
* Add code generators and vvp support for both
|
||||
* structural and behavioral multiply.
|
||||
*
|
||||
* Revision 1.4 2001/06/16 03:36:03 steve
|
||||
* Relax width restriction for structural comparators.
|
||||
*
|
||||
* Revision 1.3 2001/06/15 04:07:58 steve
|
||||
* Add .cmp statements for structural comparison.
|
||||
*
|
||||
* Revision 1.2 2001/06/07 03:09:03 steve
|
||||
* Implement .arith/sub subtraction.
|
||||
*
|
||||
* Revision 1.1 2001/06/05 03:05:41 steve
|
||||
* Add structural addition.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
20
vvp/arith.h
20
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.6 2001/07/06 04:46:44 steve Exp $"
|
||||
#ident "$Id: arith.h,v 1.7 2001/07/07 02:57:33 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "functor.h"
|
||||
|
|
@ -126,8 +126,26 @@ class vvp_shiftl : public vvp_arith_ {
|
|||
vvp_shiftl& operator= (const vvp_shiftl&);
|
||||
};
|
||||
|
||||
class vvp_shiftr : public vvp_arith_ {
|
||||
|
||||
public:
|
||||
explicit vvp_shiftr(vvp_ipoint_t b, unsigned wid);
|
||||
|
||||
void set(vvp_ipoint_t i, functor_t f, bool push);
|
||||
|
||||
private:
|
||||
unsigned amount_;
|
||||
|
||||
private: // not implemented
|
||||
vvp_shiftr(const vvp_shiftr&);
|
||||
vvp_shiftr& operator= (const vvp_shiftr&);
|
||||
};
|
||||
|
||||
/*
|
||||
* $Log: arith.h,v $
|
||||
* Revision 1.7 2001/07/07 02:57:33 steve
|
||||
* Add the .shift/r functor.
|
||||
*
|
||||
* Revision 1.6 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.85 2001/07/06 05:02:43 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.86 2001/07/07 02:57:33 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -564,34 +564,9 @@ void compile_cmp_gt(char*label, long wid, unsigned argc, struct symb_s*argv)
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* A .shift/l statement creates an array of functors for the
|
||||
* width. The 0 input is the data vector to be shifted and the 1 input
|
||||
* is the amount of the shift. An unconnected shift amount is set to 0.
|
||||
*/
|
||||
void compile_shiftl(char*label, long wid, unsigned argc, struct symb_s*argv)
|
||||
static void compile_shift_inputs(vvp_arith_*dev, vvp_ipoint_t fdx,
|
||||
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;
|
||||
}
|
||||
|
||||
if (argc > (wid*2)) {
|
||||
fprintf(stderr, "%s; .shift/l has too many 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);
|
||||
|
|
@ -620,6 +595,65 @@ void compile_shiftl(char*label, long wid, unsigned argc, struct symb_s*argv)
|
|||
|
||||
inputs_connect(ptr, tmp_argc, tmp_argv);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A .shift/l statement creates an array of functors for the
|
||||
* width. The 0 input is the data vector to be shifted and the 1 input
|
||||
* is the amount of the shift. An unconnected shift amount is set to 0.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
if (argc > (wid*2)) {
|
||||
fprintf(stderr, "%s; .shift/l has too many 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);
|
||||
|
||||
compile_shift_inputs(dev, fdx, wid, argc, argv);
|
||||
|
||||
free(argv);
|
||||
}
|
||||
|
||||
void compile_shiftr(char*label, long wid, unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
assert( wid > 0 );
|
||||
|
||||
if (argc < (wid+1)) {
|
||||
fprintf(stderr, "%s; .shift/r has too few symbols\n", label);
|
||||
compile_errors += 1;
|
||||
free(label);
|
||||
return;
|
||||
}
|
||||
|
||||
if (argc > (wid*2)) {
|
||||
fprintf(stderr, "%s; .shift/r has too many symbols\n", label);
|
||||
compile_errors += 1;
|
||||
free(label);
|
||||
return;
|
||||
}
|
||||
|
||||
vvp_ipoint_t fdx = functor_allocate(wid);
|
||||
define_functor_symbol(label, fdx);
|
||||
|
||||
vvp_shiftr*dev = new vvp_shiftr(fdx, wid);
|
||||
|
||||
compile_shift_inputs(dev, fdx, wid, argc, argv);
|
||||
|
||||
free(argv);
|
||||
}
|
||||
|
|
@ -1515,6 +1549,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.86 2001/07/07 02:57:33 steve
|
||||
* Add the .shift/r functor.
|
||||
*
|
||||
* Revision 1.85 2001/07/06 05:02:43 steve
|
||||
* Properly initialize unconnected shift inputs.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.30 2001/07/06 04:46:44 steve Exp $"
|
||||
#ident "$Id: compile.h,v 1.31 2001/07/07 02:57:33 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
|
@ -87,6 +87,8 @@ 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_shiftr(char*label, long width,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
|
||||
|
||||
extern void compile_vpi_symbol(const char*label, vpiHandle obj);
|
||||
|
|
@ -202,6 +204,9 @@ extern void compile_net(char*label, char*name,
|
|||
|
||||
/*
|
||||
* $Log: compile.h,v $
|
||||
* Revision 1.31 2001/07/07 02:57:33 steve
|
||||
* Add the .shift/r functor.
|
||||
*
|
||||
* Revision 1.30 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.25 2001/07/06 04:46:44 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.26 2001/07/07 02:57:33 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -79,6 +79,7 @@
|
|||
".resolv" { return K_RESOLV; }
|
||||
".scope" { return K_SCOPE; }
|
||||
".shift/l" { return K_SHIFTL; }
|
||||
".shift/r" { return K_SHIFTR; }
|
||||
".thread" { return K_THREAD; }
|
||||
".var" { return K_VAR; }
|
||||
".var/s" { return K_VAR_S; }
|
||||
|
|
@ -147,6 +148,9 @@ int yywrap()
|
|||
|
||||
/*
|
||||
* $Log: lexor.lex,v $
|
||||
* Revision 1.26 2001/07/07 02:57:33 steve
|
||||
* Add the .shift/r functor.
|
||||
*
|
||||
* Revision 1.25 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
|
|
|
|||
12
vvp/parse.y
12
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.34 2001/07/06 04:46:44 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.35 2001/07/07 02:57:33 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_SHIFTL K_THREAD
|
||||
%token K_RESOLV K_SCOPE K_SHIFTL K_SHIFTR 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
|
||||
|
|
@ -192,6 +192,11 @@ statement
|
|||
compile_shiftl($1, $3, obj.cnt, obj.vect);
|
||||
}
|
||||
|
||||
| T_LABEL K_SHIFTR T_NUMBER ',' symbols ';'
|
||||
{ struct symbv_s obj = $5;
|
||||
compile_shiftr($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
|
||||
|
|
@ -484,6 +489,9 @@ int compile_design(const char*path)
|
|||
|
||||
/*
|
||||
* $Log: parse.y,v $
|
||||
* Revision 1.35 2001/07/07 02:57:33 steve
|
||||
* Add the .shift/r functor.
|
||||
*
|
||||
* Revision 1.34 2001/07/06 04:46:44 steve
|
||||
* Add structural left shift (.shift/l)
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue