Get .arith/sub working.

This commit is contained in:
steve 2005-01-30 05:06:49 +00:00
parent e6cdd32c19
commit 84b3e8e2dc
4 changed files with 38 additions and 20 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: arith.cc,v 1.36 2005/01/28 05:34:25 steve Exp $"
#ident "$Id: arith.cc,v 1.37 2005/01/30 05:06:49 steve Exp $"
#endif
# include "arith.h"
@ -361,10 +361,10 @@ vvp_arith_sub::~vvp_arith_sub()
}
/*
* Subtraction works by adding the 2s complement of the B, C and D
* inputs from the A input. The 2s complement is the 1s complement
* plus one, so we further reduce the operation to adding in the
* inverted value and adding a correction.
* Subtraction works by adding the 2s complement of the B input from
* the A input. The 2s complement is the 1s complement plus one, so we
* further reduce the operation to adding in the inverted value and
* adding a correction.
*/
void vvp_arith_sub::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
{
@ -381,7 +381,7 @@ void vvp_arith_sub::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
vvp_bit4_t carry = BIT4_1;
for (unsigned idx = 0 ; idx < wid_ ; idx += 1) {
vvp_bit4_t a = (idx >= op_a_.size())? pad : op_a_.value(idx);
vvp_bit4_t b = (idx >= op_b_.size())? pad : op_b_.value(idx);
vvp_bit4_t b = (idx >= op_b_.size())? pad : ~op_b_.value(idx);
vvp_bit4_t cur = add_with_carry(a, b, carry);
if (cur == BIT4_X) {
@ -652,6 +652,9 @@ void vvp_shiftr::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
/*
* $Log: arith.cc,v $
* Revision 1.37 2005/01/30 05:06:49 steve
* Get .arith/sub working.
*
* Revision 1.36 2005/01/28 05:34:25 steve
* Add vector4 implementation of .arith/mult.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: compile.cc,v 1.184 2005/01/29 17:53:25 steve Exp $"
#ident "$Id: compile.cc,v 1.185 2005/01/30 05:06:49 steve Exp $"
#endif
# include "arith.h"
@ -885,21 +885,13 @@ void compile_arith_sub(char*label, long wid, unsigned argc, struct symb_s*argv)
{
assert( wid > 0 );
if ((argc % wid) != 0) {
fprintf(stderr, "%s; .arith has wrong number of symbols\n", label);
compile_errors += 1;
return;
}
unsigned opcount = argc / wid;
if (opcount > 4) {
fprintf(stderr, "%s; .arith has too many operands.\n", label);
if (argc != 2) {
fprintf(stderr, "%s .arith has wrong number of symbols\n", label);
compile_errors += 1;
return;
}
vvp_arith_ *arith = new vvp_arith_sub(wid);
make_arith(arith, label, wid, argc, argv);
}
@ -1585,6 +1577,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
/*
* $Log: compile.cc,v $
* Revision 1.185 2005/01/30 05:06:49 steve
* Get .arith/sub working.
*
* Revision 1.184 2005/01/29 17:53:25 steve
* Use scheduler to initialize constant functor inputs.
*

View File

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ident "$Id: vvp_net.cc,v 1.10 2005/01/29 17:52:06 steve Exp $"
#ident "$Id: vvp_net.cc,v 1.11 2005/01/30 05:06:49 steve Exp $"
# include "vvp_net.h"
# include <stdio.h>
@ -72,6 +72,18 @@ vvp_bit4_t operator & (vvp_bit4_t a, vvp_bit4_t b)
return BIT4_1;
}
vvp_bit4_t operator ~ (vvp_bit4_t a)
{
switch (a) {
case BIT4_0:
return BIT4_1;
case BIT4_1:
return BIT4_0;
default:
return BIT4_X;
}
}
void vvp_send_vec4(vvp_net_ptr_t ptr, vvp_vector4_t val)
{
while (struct vvp_net_t*cur = ptr.ptr()) {
@ -852,6 +864,9 @@ vvp_bit4_t compare_gtge_signed(const vvp_vector4_t&a,
/*
* $Log: vvp_net.cc,v $
* Revision 1.11 2005/01/30 05:06:49 steve
* Get .arith/sub working.
*
* Revision 1.10 2005/01/29 17:52:06 steve
* move AND to buitin instead of table.
*

View File

@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ident "$Id: vvp_net.h,v 1.10 2005/01/29 17:52:06 steve Exp $"
#ident "$Id: vvp_net.h,v 1.11 2005/01/30 05:06:49 steve Exp $"
# include <assert.h>
@ -52,7 +52,9 @@ enum vvp_bit4_t {
extern vvp_bit4_t add_with_carry(vvp_bit4_t a, vvp_bit4_t b, vvp_bit4_t&c);
/* Return TRUE if the bit is BIT4_X or BIT4_Z */
extern bool bit4_is_xz(vvp_bit4_t a);
/* Some common boolean operators */
/* Some common boolean operators. These implement the Verilog rules
for 4-value bit operations. */
extern vvp_bit4_t operator ~ (vvp_bit4_t a);
extern vvp_bit4_t operator & (vvp_bit4_t a, vvp_bit4_t b);
/*
@ -507,6 +509,9 @@ class vvp_fun_signal : public vvp_net_fun_t {
/*
* $Log: vvp_net.h,v $
* Revision 1.11 2005/01/30 05:06:49 steve
* Get .arith/sub working.
*
* Revision 1.10 2005/01/29 17:52:06 steve
* move AND to buitin instead of table.
*