Add the XNOR operator.

This commit is contained in:
steve 2000-01-13 06:05:46 +00:00
parent ef98be1192
commit d84b72609d
2 changed files with 34 additions and 2 deletions

View File

@ -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.96 2000/01/13 05:11:25 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.97 2000/01/13 06:05:46 steve Exp $"
#endif
# include <iostream>
@ -433,6 +433,10 @@ void vvm_proc_rval::expr_binary(const NetEBinary*expr)
os_ << setw(indent_) << "" << result << " = vvm_binop_shiftr("
<< lres << "," << rres << ");" << endl;
break;
case 'X':
os_ << setw(indent_) << "" << result << " = vvm_binop_xnor("
<< lres << "," << rres << ");" << endl;
break;
case '+':
os_ << setw(indent_) << "" << result << " = vvm_binop_plus("
<< lres << "," << rres << ");" << endl;
@ -2036,6 +2040,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.97 2000/01/13 06:05:46 steve
* Add the XNOR operator.
*
* Revision 1.96 2000/01/13 05:11:25 steve
* Support for multiple VPI modules.
*

View File

@ -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.17 2000/01/13 03:35:35 steve Exp $"
#ident "$Id: vvm_func.h,v 1.18 2000/01/13 06:05:46 steve Exp $"
#endif
# include "vvm.h"
@ -160,6 +160,17 @@ vvm_bitset_t<WIDTH> vvm_binop_or(const vvm_bitset_t<WIDTH>&l,
return result;
}
template <unsigned WIDTH>
vvm_bitset_t<WIDTH> vvm_binop_nor(const vvm_bitset_t<WIDTH>&l,
const vvm_bitset_t<WIDTH>&r)
{
vvm_bitset_t<WIDTH> result;
for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
result[idx] = not(l[idx] | r[idx]);
return result;
}
/*
* Implement the binary + operator in the verilog way. This takes
* vectors of identical width and returns another vector of same width
@ -228,6 +239,17 @@ vvm_bitset_t<WIDTH> vvm_binop_xor(const vvm_bitset_t<WIDTH>&l,
return result;
}
template <unsigned WIDTH>
vvm_bitset_t<WIDTH> vvm_binop_xnor(const vvm_bitset_t<WIDTH>&l,
const vvm_bitset_t<WIDTH>&r)
{
vvm_bitset_t<WIDTH> result;
for (unsigned idx = 0 ; idx < WIDTH ; idx += 1)
result[idx] = not(l[idx] ^ r[idx]);
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
@ -626,6 +648,9 @@ vvm_bitset_t<W> vvm_ternary(vpip_bit_t c, const vvm_bitset_t<W>&t,
/*
* $Log: vvm_func.h,v $
* Revision 1.18 2000/01/13 06:05:46 steve
* Add the XNOR operator.
*
* Revision 1.17 2000/01/13 03:35:35 steve
* Multiplication all the way to simulation.
*