Add arithmetic shift operators.
This commit is contained in:
parent
ae418c6a6d
commit
71a404a546
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: design_dump.cc,v 1.140 2003/05/30 02:55:32 steve Exp $"
|
#ident "$Id: design_dump.cc,v 1.141 2003/06/18 03:55:18 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -863,6 +863,9 @@ void NetEBinary::dump(ostream&o) const
|
||||||
case 'r':
|
case 'r':
|
||||||
o << ">>";
|
o << ">>";
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
o << ">>>";
|
||||||
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
o << "~^";
|
o << "~^";
|
||||||
break;
|
break;
|
||||||
|
|
@ -1040,6 +1043,9 @@ void Design::dump(ostream&o) const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: design_dump.cc,v $
|
* $Log: design_dump.cc,v $
|
||||||
|
* Revision 1.141 2003/06/18 03:55:18 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.140 2003/05/30 02:55:32 steve
|
* Revision 1.140 2003/05/30 02:55:32 steve
|
||||||
* Support parameters in real expressions and
|
* Support parameters in real expressions and
|
||||||
* as real expressions, and fix multiply and
|
* as real expressions, and fix multiply and
|
||||||
|
|
|
||||||
10
elab_expr.cc
10
elab_expr.cc
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: elab_expr.cc,v 1.78 2003/06/10 04:29:57 steve Exp $"
|
#ident "$Id: elab_expr.cc,v 1.79 2003/06/18 03:55:18 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -135,8 +135,9 @@ NetEBinary* PEBinary::elaborate_expr_base_(Design*des,
|
||||||
tmp->set_line(*this);
|
tmp->set_line(*this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l': // <<
|
||||||
case 'r':
|
case 'r': // >>
|
||||||
|
case 'R': // >>>
|
||||||
tmp = new NetEBShift(op_, lp, rp);
|
tmp = new NetEBShift(op_, lp, rp);
|
||||||
tmp->set_line(*this);
|
tmp->set_line(*this);
|
||||||
break;
|
break;
|
||||||
|
|
@ -961,6 +962,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elab_expr.cc,v $
|
* $Log: elab_expr.cc,v $
|
||||||
|
* Revision 1.79 2003/06/18 03:55:18 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.78 2003/06/10 04:29:57 steve
|
* Revision 1.78 2003/06/10 04:29:57 steve
|
||||||
* PR735: bit select indices are signed constants.
|
* PR735: bit select indices are signed constants.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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) && !defined(macintosh)
|
#if !defined(WINNT) && !defined(macintosh)
|
||||||
#ident "$Id: lexor.lex,v 1.81 2003/06/17 04:23:25 steve Exp $"
|
#ident "$Id: lexor.lex,v 1.82 2003/06/18 03:55:18 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -128,7 +128,9 @@ W [ \t\b\f\r]+
|
||||||
"(*" { return K_PSTAR; }
|
"(*" { return K_PSTAR; }
|
||||||
"*)" { return K_STARP; }
|
"*)" { return K_STARP; }
|
||||||
"<<" { return K_LS; }
|
"<<" { return K_LS; }
|
||||||
">>" { return K_RS; }
|
"<<<" { return K_LS; /* Note: Functionally, <<< is the same as <<. */}
|
||||||
|
">>" { return K_RS; }
|
||||||
|
">>>" { return K_RSS; }
|
||||||
"<=" { return K_LE; }
|
"<=" { return K_LE; }
|
||||||
">=" { return K_GE; }
|
">=" { return K_GE; }
|
||||||
"=>" { return K_EG; }
|
"=>" { return K_EG; }
|
||||||
|
|
|
||||||
30
net_expr.cc
30
net_expr.cc
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: net_expr.cc,v 1.19 2003/06/15 18:53:20 steve Exp $"
|
#ident "$Id: net_expr.cc,v 1.20 2003/06/18 03:55:18 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -230,6 +230,31 @@ NetExpr::TYPE NetEBMult::expr_type() const
|
||||||
return ET_VECTOR;
|
return ET_VECTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetEBShift::NetEBShift(char op, NetExpr*l, NetExpr*r)
|
||||||
|
: NetEBinary(op, l, r)
|
||||||
|
{
|
||||||
|
expr_width(l->expr_width());
|
||||||
|
|
||||||
|
// The >>> is signed if the left operand is signed.
|
||||||
|
if (op == 'R') cast_signed(l->has_sign());
|
||||||
|
}
|
||||||
|
|
||||||
|
NetEBShift::~NetEBShift()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetEBShift::has_width() const
|
||||||
|
{
|
||||||
|
return left_->has_width();
|
||||||
|
}
|
||||||
|
|
||||||
|
NetEBShift* NetEBShift::dup_expr() const
|
||||||
|
{
|
||||||
|
NetEBShift*result = new NetEBShift(op_, left_->dup_expr(),
|
||||||
|
right_->dup_expr());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
NetEConcat::NetEConcat(unsigned cnt, NetExpr* r)
|
NetEConcat::NetEConcat(unsigned cnt, NetExpr* r)
|
||||||
: parms_(cnt), repeat_(r)
|
: parms_(cnt), repeat_(r)
|
||||||
{
|
{
|
||||||
|
|
@ -491,6 +516,9 @@ NetExpr::TYPE NetESFunc::expr_type() const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: net_expr.cc,v $
|
* $Log: net_expr.cc,v $
|
||||||
|
* Revision 1.20 2003/06/18 03:55:18 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.19 2003/06/15 18:53:20 steve
|
* Revision 1.19 2003/06/15 18:53:20 steve
|
||||||
* Operands of unsigned multiply are unsigned.
|
* Operands of unsigned multiply are unsigned.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
27
netlist.cc
27
netlist.cc
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: netlist.cc,v 1.215 2003/05/01 01:13:57 steve Exp $"
|
#ident "$Id: netlist.cc,v 1.216 2003/06/18 03:55:18 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -1836,28 +1836,6 @@ NetEBLogic* NetEBLogic::dup_expr() const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetEBShift::NetEBShift(char op, NetExpr*l, NetExpr*r)
|
|
||||||
: NetEBinary(op, l, r)
|
|
||||||
{
|
|
||||||
expr_width(l->expr_width());
|
|
||||||
}
|
|
||||||
|
|
||||||
NetEBShift::~NetEBShift()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NetEBShift::has_width() const
|
|
||||||
{
|
|
||||||
return left_->has_width();
|
|
||||||
}
|
|
||||||
|
|
||||||
NetEBShift* NetEBShift::dup_expr() const
|
|
||||||
{
|
|
||||||
NetEBShift*result = new NetEBShift(op_, left_->dup_expr(),
|
|
||||||
right_->dup_expr());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetEConst::NetEConst(const verinum&val)
|
NetEConst::NetEConst(const verinum&val)
|
||||||
: NetExpr(val.len()), value_(val)
|
: NetExpr(val.len()), value_(val)
|
||||||
{
|
{
|
||||||
|
|
@ -2198,6 +2176,9 @@ const NetProc*NetTaskDef::proc() const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.cc,v $
|
* $Log: netlist.cc,v $
|
||||||
|
* Revision 1.216 2003/06/18 03:55:18 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.215 2003/05/01 01:13:57 steve
|
* Revision 1.215 2003/05/01 01:13:57 steve
|
||||||
* More complete bit range internal error message,
|
* More complete bit range internal error message,
|
||||||
* Better test of part select ranges on non-zero
|
* Better test of part select ranges on non-zero
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: netlist.h,v 1.289 2003/06/05 04:28:24 steve Exp $"
|
#ident "$Id: netlist.h,v 1.290 2003/06/18 03:55:18 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -2343,6 +2343,7 @@ class NetProcTop : public LineInfo, public Attrib {
|
||||||
* O -- Bit-wise NOR (~|)
|
* O -- Bit-wise NOR (~|)
|
||||||
* l -- Left shift (<<)
|
* l -- Left shift (<<)
|
||||||
* r -- Right shift (>>)
|
* r -- Right shift (>>)
|
||||||
|
* R -- signed right shift (>>>)
|
||||||
* X -- Bitwise exclusive NOR (~^)
|
* X -- Bitwise exclusive NOR (~^)
|
||||||
*/
|
*/
|
||||||
class NetEBinary : public NetExpr {
|
class NetEBinary : public NetExpr {
|
||||||
|
|
@ -2535,6 +2536,7 @@ class NetEBMult : public NetEBinary {
|
||||||
*
|
*
|
||||||
* l -- left shift (<<)
|
* l -- left shift (<<)
|
||||||
* r -- right shift (>>)
|
* r -- right shift (>>)
|
||||||
|
* R -- right shift arithmetic (>>>)
|
||||||
*/
|
*/
|
||||||
class NetEBShift : public NetEBinary {
|
class NetEBShift : public NetEBinary {
|
||||||
|
|
||||||
|
|
@ -3304,6 +3306,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.h,v $
|
* $Log: netlist.h,v $
|
||||||
|
* Revision 1.290 2003/06/18 03:55:18 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.289 2003/06/05 04:28:24 steve
|
* Revision 1.289 2003/06/05 04:28:24 steve
|
||||||
* Evaluate <= with real operands.
|
* Evaluate <= with real operands.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
12
parse.y
12
parse.y
|
|
@ -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 HAVE_CVS_IDENT
|
#if HAVE_CVS_IDENT
|
||||||
#ident "$Id: parse.y,v 1.178 2003/06/13 00:27:09 steve Exp $"
|
#ident "$Id: parse.y,v 1.179 2003/06/18 03:55:18 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -127,7 +127,7 @@ const static struct str_pair_t str_strength = { PGate::STRONG, PGate::STRONG };
|
||||||
%token <text> PATHPULSE_IDENTIFIER
|
%token <text> PATHPULSE_IDENTIFIER
|
||||||
%token <number> BASED_NUMBER DEC_NUMBER
|
%token <number> BASED_NUMBER DEC_NUMBER
|
||||||
%token <realtime> REALTIME
|
%token <realtime> REALTIME
|
||||||
%token K_LE K_GE K_EG K_EQ K_NE K_CEQ K_CNE K_LS K_RS K_SG
|
%token K_LE K_GE K_EG K_EQ K_NE K_CEQ K_CNE K_LS K_RS K_RSS K_SG
|
||||||
%token K_PO_POS K_PO_NEG
|
%token K_PO_POS K_PO_NEG
|
||||||
%token K_PSTAR K_STARP
|
%token K_PSTAR K_STARP
|
||||||
%token K_LOR K_LAND K_NAND K_NOR K_NXOR K_TRIGGER
|
%token K_LOR K_LAND K_NAND K_NOR K_NXOR K_TRIGGER
|
||||||
|
|
@ -222,7 +222,7 @@ const static struct str_pair_t str_strength = { PGate::STRONG, PGate::STRONG };
|
||||||
%left '&' K_NAND
|
%left '&' K_NAND
|
||||||
%left K_EQ K_NE K_CEQ K_CNE
|
%left K_EQ K_NE K_CEQ K_CNE
|
||||||
%left K_GE K_LE '<' '>'
|
%left K_GE K_LE '<' '>'
|
||||||
%left K_LS K_RS
|
%left K_LS K_RS K_RSS
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*' '/' '%'
|
%left '*' '/' '%'
|
||||||
%left UNARY_PREC
|
%left UNARY_PREC
|
||||||
|
|
@ -810,6 +810,12 @@ expression
|
||||||
tmp->set_lineno(@2.first_line);
|
tmp->set_lineno(@2.first_line);
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
}
|
}
|
||||||
|
| expression K_RSS expression
|
||||||
|
{ PEBinary*tmp = new PEBinary('R', $1, $3);
|
||||||
|
tmp->set_file(@2.text);
|
||||||
|
tmp->set_lineno(@2.first_line);
|
||||||
|
$$ = tmp;
|
||||||
|
}
|
||||||
| expression K_EQ expression
|
| expression K_EQ expression
|
||||||
{ PEBinary*tmp = new PEBinary('e', $1, $3);
|
{ PEBinary*tmp = new PEBinary('e', $1, $3);
|
||||||
tmp->set_file(@2.text);
|
tmp->set_file(@2.text);
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: set_width.cc,v 1.30 2003/05/20 15:05:33 steve Exp $"
|
#ident "$Id: set_width.cc,v 1.31 2003/06/18 03:55:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -203,6 +203,7 @@ bool NetEBShift::set_width(unsigned w)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
|
case 'R':
|
||||||
if (left_->expr_width() < w)
|
if (left_->expr_width() < w)
|
||||||
left_ = pad_to_width(left_, w);
|
left_ = pad_to_width(left_, w);
|
||||||
break;
|
break;
|
||||||
|
|
@ -410,6 +411,9 @@ bool NetEUReduce::set_width(unsigned w)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: set_width.cc,v $
|
* $Log: set_width.cc,v $
|
||||||
|
* Revision 1.31 2003/06/18 03:55:19 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.30 2003/05/20 15:05:33 steve
|
* Revision 1.30 2003/05/20 15:05:33 steve
|
||||||
* Do not try to set constants to width 0.
|
* Do not try to set constants to width 0.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: eval_expr.c,v 1.101 2003/06/17 19:17:42 steve Exp $"
|
#ident "$Id: eval_expr.c,v 1.102 2003/06/18 03:55:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvp_priv.h"
|
# include "vvp_priv.h"
|
||||||
|
|
@ -773,6 +773,42 @@ static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid)
|
||||||
opcode = "%shiftr";
|
opcode = "%shiftr";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'R': /* >>> (signed right shift) */
|
||||||
|
|
||||||
|
/* with the right shift, there may be high bits that are
|
||||||
|
shifted into the desired width of the expression, so
|
||||||
|
we let the expression size itself, if it is bigger
|
||||||
|
then what is requested of us. */
|
||||||
|
if (wid > ivl_expr_width(le)) {
|
||||||
|
lv = draw_eval_expr_wid(le, wid, 0);
|
||||||
|
} else {
|
||||||
|
lv = draw_eval_expr_wid(le, ivl_expr_width(le), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* shifting 0 gets 0. */
|
||||||
|
if (lv.base == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Sign extend any constant begets itself, if this
|
||||||
|
expression is signed. */
|
||||||
|
if ((lv.base < 4) && (ivl_expr_signed(exp)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (lv.base < 4) {
|
||||||
|
struct vector_info tmp;
|
||||||
|
tmp.base = allocate_vector(lv.wid);
|
||||||
|
tmp.wid = lv.wid;
|
||||||
|
fprintf(vvp_out, " %%mov %u, %u, %u;\n",
|
||||||
|
tmp.base, lv.base, lv.wid);
|
||||||
|
lv = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ivl_expr_signed(exp))
|
||||||
|
opcode = "%shiftr/s";
|
||||||
|
else
|
||||||
|
opcode = "%shiftr";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
@ -1029,6 +1065,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp,
|
||||||
|
|
||||||
case 'l': /* << */
|
case 'l': /* << */
|
||||||
case 'r': /* >> */
|
case 'r': /* >> */
|
||||||
|
case 'R': /* >>> */
|
||||||
rv = draw_binary_expr_lrs(exp, wid);
|
rv = draw_binary_expr_lrs(exp, wid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -2036,6 +2073,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp, int stuff_ok_flag)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: eval_expr.c,v $
|
* $Log: eval_expr.c,v $
|
||||||
|
* Revision 1.102 2003/06/18 03:55:19 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.101 2003/06/17 19:17:42 steve
|
* Revision 1.101 2003/06/17 19:17:42 steve
|
||||||
* Remove short int restrictions from vvp opcodes.
|
* Remove short int restrictions from vvp opcodes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: codes.h,v 1.62 2003/06/17 19:17:42 steve Exp $"
|
#ident "$Id: codes.h,v 1.63 2003/06/18 03:55:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -106,6 +106,7 @@ extern bool of_SET_X0(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_SET_X0_X(vthread_t thr, vvp_code_t code);
|
extern bool of_SET_X0_X(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_SHIFTL_I0(vthread_t thr, vvp_code_t code);
|
extern bool of_SHIFTL_I0(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_SHIFTR_I0(vthread_t thr, vvp_code_t code);
|
extern bool of_SHIFTR_I0(vthread_t thr, vvp_code_t code);
|
||||||
|
extern bool of_SHIFTR_S_I0(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_SUB(vthread_t thr, vvp_code_t code);
|
extern bool of_SUB(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_SUB_WR(vthread_t thr, vvp_code_t code);
|
extern bool of_SUB_WR(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_SUBI(vthread_t thr, vvp_code_t code);
|
extern bool of_SUBI(vthread_t thr, vvp_code_t code);
|
||||||
|
|
@ -173,6 +174,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: codes.h,v $
|
* $Log: codes.h,v $
|
||||||
|
* Revision 1.63 2003/06/18 03:55:19 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.62 2003/06/17 19:17:42 steve
|
* Revision 1.62 2003/06/17 19:17:42 steve
|
||||||
* Remove short int restrictions from vvp opcodes.
|
* Remove short int restrictions from vvp opcodes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: compile.cc,v 1.165 2003/06/17 19:17:42 steve Exp $"
|
#ident "$Id: compile.cc,v 1.166 2003/06/18 03:55:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "arith.h"
|
# include "arith.h"
|
||||||
|
|
@ -151,6 +151,7 @@ const static struct opcode_table_s opcode_table[] = {
|
||||||
{ "%set/x0/x",of_SET_X0_X,3,{OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
|
{ "%set/x0/x",of_SET_X0_X,3,{OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
|
||||||
{ "%shiftl/i0", of_SHIFTL_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
|
{ "%shiftl/i0", of_SHIFTL_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
|
||||||
{ "%shiftr/i0", of_SHIFTR_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
|
{ "%shiftr/i0", of_SHIFTR_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
|
||||||
|
{ "%shiftr/s/i0", of_SHIFTR_S_I0,2,{OA_BIT1,OA_NUMBER, OA_NONE} },
|
||||||
{ "%sub", of_SUB, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%sub", of_SUB, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
{ "%sub/wr", of_SUB_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
|
{ "%sub/wr", of_SUB_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
|
||||||
{ "%subi", of_SUBI, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%subi", of_SUBI, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
|
|
@ -1540,6 +1541,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: compile.cc,v $
|
* $Log: compile.cc,v $
|
||||||
|
* Revision 1.166 2003/06/18 03:55:19 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.165 2003/06/17 19:17:42 steve
|
* Revision 1.165 2003/06/17 19:17:42 steve
|
||||||
* Remove short int restrictions from vvp opcodes.
|
* Remove short int restrictions from vvp opcodes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* $Id: opcodes.txt,v 1.52 2003/05/26 04:44:54 steve Exp $
|
* $Id: opcodes.txt,v 1.53 2003/06/18 03:55:19 steve Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -543,13 +543,15 @@ the lsb of the vector, and <wid> the width of the vector. The shift is
|
||||||
done in place. Zero values are shifted in.
|
done in place. Zero values are shifted in.
|
||||||
|
|
||||||
* %shiftr/i0 <bit>, <wid>
|
* %shiftr/i0 <bit>, <wid>
|
||||||
|
* %shiftr/s/i0 <bit>, <wid>
|
||||||
|
|
||||||
This instruction shifts the vector right (towards the less significant
|
This instruction shifts the vector right (towards the less significant
|
||||||
bits) by the amount in the index register 0. The <bit> is the address
|
bits) by the amount in the index register 0. The <bit> is the address
|
||||||
of the lsb of the vector, and <wid> is the width of the vector. The
|
of the lsb of the vector, and <wid> is the width of the vector. The
|
||||||
shift is done in place.
|
shift is done in place.
|
||||||
|
|
||||||
This is an unsigned down shift, so zeros are shifted into the top bits.
|
%shiftr/i0 is an unsigned down shift, so zeros are shifted into the
|
||||||
|
top bits. %shiftr/s/i0 is a signed shift, so the value is sign-extended.
|
||||||
|
|
||||||
* %sub <bit-l>, <bit-r>, <wid>
|
* %sub <bit-l>, <bit-r>, <wid>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: vthread.cc,v 1.110 2003/06/17 21:28:59 steve Exp $"
|
#ident "$Id: vthread.cc,v 1.111 2003/06/18 03:55:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vthread.h"
|
# include "vthread.h"
|
||||||
|
|
@ -2459,6 +2459,29 @@ bool of_SHIFTR_I0(vthread_t thr, vvp_code_t cp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool of_SHIFTR_S_I0(vthread_t thr, vvp_code_t cp)
|
||||||
|
{
|
||||||
|
unsigned base = cp->bit_idx[0];
|
||||||
|
unsigned wid = cp->number;
|
||||||
|
unsigned long shift = thr->words[0].w_int;
|
||||||
|
unsigned sign = thr_get_bit(thr, base+wid-1);
|
||||||
|
|
||||||
|
if (shift >= wid) {
|
||||||
|
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
||||||
|
thr_put_bit(thr, base+idx, sign);
|
||||||
|
|
||||||
|
} else if (shift > 0) {
|
||||||
|
for (unsigned idx = 0 ; idx < (wid-shift) ; idx += 1) {
|
||||||
|
unsigned src = base + idx + shift;
|
||||||
|
unsigned dst = base + idx;
|
||||||
|
thr_put_bit(thr, dst, thr_get_bit(thr, src));
|
||||||
|
}
|
||||||
|
for (unsigned idx = (wid-shift) ; idx < wid ; idx += 1)
|
||||||
|
thr_put_bit(thr, base+idx, sign);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool of_SUB(vthread_t thr, vvp_code_t cp)
|
bool of_SUB(vthread_t thr, vvp_code_t cp)
|
||||||
{
|
{
|
||||||
assert(cp->bit_idx[0] >= 4);
|
assert(cp->bit_idx[0] >= 4);
|
||||||
|
|
@ -2722,6 +2745,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vthread.cc,v $
|
* $Log: vthread.cc,v $
|
||||||
|
* Revision 1.111 2003/06/18 03:55:19 steve
|
||||||
|
* Add arithmetic shift operators.
|
||||||
|
*
|
||||||
* Revision 1.110 2003/06/17 21:28:59 steve
|
* Revision 1.110 2003/06/17 21:28:59 steve
|
||||||
* Remove short int restrictions from vvp opcodes. (part 2)
|
* Remove short int restrictions from vvp opcodes. (part 2)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue