Add some vvm operators from Eric Aardoom.
This commit is contained in:
parent
e1c697a746
commit
efdc1769e6
|
|
@ -307,8 +307,10 @@ Williams. The proper notices are in the head of each file. However,
|
|||
I have received aid in the form of fixes, Verilog guidance, and
|
||||
especially testing from many people, including (in alphabetical order):
|
||||
|
||||
Eric Aardoom <eric_aardoom@yahoo.com>
|
||||
Ed Carter <r47652@email.sps.mot.com>
|
||||
Larry Doolittle <LRDoolittle@lbl.gov>
|
||||
Guy Hutchison <ghutchis@pacbell.net>
|
||||
Ales Hvezda <ahvezda@seul.org>
|
||||
James Lee <jml@seva.com>
|
||||
Peter Monta <pmonta@halibut.imedia.com>
|
||||
|
|
|
|||
17
t-vvm.cc
17
t-vvm.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: t-vvm.cc,v 1.55 1999/10/01 03:58:37 steve Exp $"
|
||||
#ident "$Id: t-vvm.cc,v 1.56 1999/10/01 15:26:28 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <iostream>
|
||||
|
|
@ -316,10 +316,22 @@ void vvm_proc_rval::expr_unary(const NetEUnary*expr)
|
|||
os_ << "vvm_unop_and(" << result << ");"
|
||||
<< endl;
|
||||
break;
|
||||
case '^':
|
||||
os_ << "vvm_unop_xor(" << result << ");"
|
||||
<< endl;
|
||||
break;
|
||||
case '!':
|
||||
os_ << "vvm_unop_lnot(" << result << ");"
|
||||
<< endl;
|
||||
break;
|
||||
case '-':
|
||||
os_ << "vvm_unop_uminus(" << result << ");"
|
||||
<< endl;
|
||||
break;
|
||||
case 'X':
|
||||
os_ << "vvm_unop_xnor(" << result << ");"
|
||||
<< endl;
|
||||
break;
|
||||
default:
|
||||
cerr << "vvm: Unhandled unary op `" << expr->op() << "'"
|
||||
<< endl;
|
||||
|
|
@ -1669,6 +1681,9 @@ extern const struct target tgt_vvm = {
|
|||
};
|
||||
/*
|
||||
* $Log: t-vvm.cc,v $
|
||||
* Revision 1.56 1999/10/01 15:26:28 steve
|
||||
* Add some vvm operators from Eric Aardoom.
|
||||
*
|
||||
* Revision 1.55 1999/10/01 03:58:37 steve
|
||||
* More resilient assignment to memory location.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vvm_func.h,v 1.12 1999/09/29 22:57:26 steve Exp $"
|
||||
#ident "$Id: vvm_func.h,v 1.13 1999/10/01 15:26:29 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vvm.h"
|
||||
|
|
@ -85,6 +85,44 @@ vvm_bitset_t<1> vvm_unop_lnot(const vvm_bitset_t<WIDTH>&r)
|
|||
return vvm_unop_not(res);
|
||||
}
|
||||
|
||||
/*
|
||||
* The unary XOR is the reduction XOR. It returns a single bit.
|
||||
*/
|
||||
template <unsigned WIDTH>
|
||||
vvm_bitset_t<1> vvm_unop_xor(const vvm_bitset_t<WIDTH>&r)
|
||||
{
|
||||
vvm_bitset_t<1> res;
|
||||
res[0] = V0;
|
||||
|
||||
for (unsigned idx = 0 ; idx < WIDTH ; idx += 1) {
|
||||
if (r[idx] == V1)
|
||||
res[0] = not(res[0]);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <unsigned WIDTH>
|
||||
vvm_bitset_t<1> vvm_unop_xnor(const vvm_bitset_t<WIDTH>&r)
|
||||
{
|
||||
return not(vvm_unop_xor(r));
|
||||
}
|
||||
|
||||
//
|
||||
// simple-minded unary minus operator (two's complement)
|
||||
//
|
||||
template <unsigned WIDTH>
|
||||
vvm_bitset_t<WIDTH> vvm_unop_uminus(const vvm_bitset_t<WIDTH>&l)
|
||||
{
|
||||
vvm_bitset_t<WIDTH> res;
|
||||
res = vvm_unop_not(l);
|
||||
vvm_bit_t carry = V1;
|
||||
for (int i = 0; i < WIDTH; i++)
|
||||
res[i] = add_with_carry(res[i], V0, carry);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement the binary AND operator. This is a bitwise and with all
|
||||
* the parameters and the result having the same width.
|
||||
|
|
@ -165,6 +203,40 @@ vvm_bitset_t<WIDTH> vvm_binop_xor(const vvm_bitset_t<WIDTH>&l,
|
|||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* the binary 'l' operator is a logic left-shift by the number of positions
|
||||
* indicated by argument r. r is an unsigned integer, which is represented
|
||||
* internally as a 32-bit bitvector.
|
||||
*/
|
||||
template <unsigned WIDTH>
|
||||
vvm_bitset_t<WIDTH> vvm_binop_shiftl(const vvm_bitset_t<WIDTH>&l,
|
||||
const vvm_bitset_t<32>&r)
|
||||
{
|
||||
vvm_bitset_t<WIDTH> result;
|
||||
vvm_u32 s = r.as_unsigned();
|
||||
for (unsigned idx = 0; idx < WIDTH; idx++)
|
||||
result[idx] = (idx < s) ? V0 : l[idx-s];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* The binary 'r' operator is a logic right-shift by the number of positions
|
||||
* indicated by argument r. r is an unsigned integer, which is represented
|
||||
* internally by a 32-bit bitvector.
|
||||
*/
|
||||
template <unsigned WIDTH>
|
||||
vvm_bitset_t<WIDTH> vvm_binop_shiftr(const vvm_bitset_t<WIDTH>&l,
|
||||
const vvm_bitset_t<32>&r)
|
||||
{
|
||||
vvm_bitset_t<WIDTH> result;
|
||||
vvm_u32 s = r.as_unsigned();
|
||||
for (unsigned idx = 0; idx < WIDTH; idx++)
|
||||
result[idx] = (idx < (WIDTH-s)) ? l[idx+s] : V0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests for equality are a bit tricky, as they allow for the left and
|
||||
* right subexpressions to have different size. The shorter bitset is
|
||||
|
|
@ -529,6 +601,9 @@ vvm_bitset_t<W> vvm_ternary(vvm_bit_t c, const vvm_bitset_t<W>&t,
|
|||
|
||||
/*
|
||||
* $Log: vvm_func.h,v $
|
||||
* Revision 1.13 1999/10/01 15:26:29 steve
|
||||
* Add some vvm operators from Eric Aardoom.
|
||||
*
|
||||
* Revision 1.12 1999/09/29 22:57:26 steve
|
||||
* LT supports different width objects.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue