2001-06-05 05:05:41 +02:00
|
|
|
#ifndef __arith_H
|
|
|
|
|
#define __arith_H
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
2002-08-12 03:34:58 +02:00
|
|
|
#ifdef HAVE_CVS_IDENT
|
2004-12-11 03:31:25 +01:00
|
|
|
#ident "$Id: arith.h,v 1.20 2004/12/11 02:31:29 steve Exp $"
|
2001-06-05 05:05:41 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "functor.h"
|
2004-12-11 03:31:25 +01:00
|
|
|
# include "vvp_net.h"
|
2001-06-05 05:05:41 +02:00
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
// base class for arithmetic functors
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
class vvp_arith_ : public vvp_net_fun_t {
|
2001-06-07 05:09:03 +02:00
|
|
|
|
|
|
|
|
public:
|
2004-12-11 03:31:25 +01:00
|
|
|
explicit vvp_arith_(unsigned wid);
|
2001-06-07 05:09:03 +02:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
unsigned wid_;
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
vvp_vector4_t op_a_;
|
|
|
|
|
vvp_vector4_t op_b_;
|
|
|
|
|
// Precalculated X result for propagation.
|
|
|
|
|
vvp_vector4_t x_val_;
|
2001-10-16 04:47:37 +02:00
|
|
|
};
|
|
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
/*
|
|
|
|
|
* This class is functor for arithmetic sum. Inputs that come
|
|
|
|
|
* in cause the 4-input summation to be calculated, and output
|
|
|
|
|
* functors that are affected cause propagations.
|
|
|
|
|
*/
|
2001-06-17 01:45:05 +02:00
|
|
|
class vvp_arith_mult : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
2001-10-31 05:27:46 +01:00
|
|
|
explicit vvp_arith_mult(unsigned wid) : vvp_arith_(wid) {}
|
2001-06-17 01:45:05 +02:00
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
|
|
|
|
void wide(vvp_ipoint_t base, bool push);
|
2001-06-17 01:45:05 +02:00
|
|
|
};
|
|
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
class vvp_arith_div : public vvp_arith_ {
|
2001-06-05 05:05:41 +02:00
|
|
|
|
|
|
|
|
public:
|
2004-06-30 04:15:57 +02:00
|
|
|
explicit vvp_arith_div(unsigned wid, bool signed_flag)
|
|
|
|
|
: vvp_arith_(wid), signed_flag_(signed_flag) {}
|
2001-06-29 03:20:20 +02:00
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
|
|
|
|
void wide(vvp_ipoint_t base, bool push);
|
2004-06-30 04:15:57 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool signed_flag_;
|
2001-06-05 05:05:41 +02:00
|
|
|
};
|
|
|
|
|
|
2002-01-03 05:19:01 +01:00
|
|
|
class vvp_arith_mod : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_mod(unsigned wid) : vvp_arith_(wid) {}
|
|
|
|
|
|
|
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
|
|
|
|
void wide(vvp_ipoint_t base, bool push);
|
|
|
|
|
};
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
class vvp_arith_sum : public vvp_arith_ {
|
2001-06-07 05:09:03 +02:00
|
|
|
|
|
|
|
|
public:
|
2004-12-11 03:31:25 +01:00
|
|
|
explicit vvp_arith_sum(unsigned wid);
|
|
|
|
|
~vvp_arith_sum();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
|
2001-06-07 05:09:03 +02:00
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
};
|
2001-06-07 05:09:03 +02:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
class vvp_arith_sub : public vvp_arith_ {
|
2001-07-13 02:38:57 +02:00
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
public:
|
2004-12-11 03:31:25 +01:00
|
|
|
explicit vvp_arith_sub(unsigned wid);
|
|
|
|
|
~vvp_arith_sub();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
|
2001-10-31 05:27:46 +01:00
|
|
|
|
2001-06-07 05:09:03 +02:00
|
|
|
};
|
|
|
|
|
|
2004-06-16 18:33:25 +02:00
|
|
|
class vvp_cmp_eq : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_eq(unsigned wid);
|
|
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_cmp_ne : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_ne(unsigned wid);
|
|
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2004-09-22 18:44:07 +02:00
|
|
|
class vvp_cmp_gtge_base_ : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_gtge_base_(unsigned wid, bool signed_flag);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void set_base(vvp_ipoint_t i, bool push, unsigned val, unsigned str,
|
|
|
|
|
unsigned out_if_equal);
|
|
|
|
|
private:
|
|
|
|
|
bool signed_flag_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_cmp_ge : public vvp_cmp_gtge_base_ {
|
2001-06-15 06:07:57 +02:00
|
|
|
|
|
|
|
|
public:
|
2003-04-11 07:15:38 +02:00
|
|
|
explicit vvp_cmp_ge(unsigned wid, bool signed_flag);
|
2001-10-31 05:27:46 +01:00
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
2003-04-11 07:15:38 +02:00
|
|
|
|
|
|
|
|
private:
|
2001-06-15 06:07:57 +02:00
|
|
|
};
|
|
|
|
|
|
2004-09-22 18:44:07 +02:00
|
|
|
class vvp_cmp_gt : public vvp_cmp_gtge_base_ {
|
2001-06-15 06:07:57 +02:00
|
|
|
|
|
|
|
|
public:
|
2003-04-11 07:15:38 +02:00
|
|
|
explicit vvp_cmp_gt(unsigned wid, bool signed_flag);
|
2001-10-31 05:27:46 +01:00
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
2003-04-11 07:15:38 +02:00
|
|
|
|
|
|
|
|
private:
|
2001-06-15 06:07:57 +02:00
|
|
|
};
|
2001-07-06 06:46:44 +02:00
|
|
|
|
|
|
|
|
class vvp_shiftl : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
2001-10-31 05:27:46 +01:00
|
|
|
explicit vvp_shiftl(unsigned wid) : vvp_arith_(wid) {}
|
2001-07-06 06:46:44 +02:00
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
2001-07-06 06:46:44 +02:00
|
|
|
};
|
|
|
|
|
|
2001-07-07 04:57:33 +02:00
|
|
|
class vvp_shiftr : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
2001-10-31 05:27:46 +01:00
|
|
|
explicit vvp_shiftr(unsigned wid) : vvp_arith_(wid) {}
|
2001-07-07 04:57:33 +02:00
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
void set(vvp_ipoint_t i, bool push, unsigned val, unsigned str);
|
2001-07-07 04:57:33 +02:00
|
|
|
};
|
|
|
|
|
|
2001-06-05 05:05:41 +02:00
|
|
|
/*
|
|
|
|
|
* $Log: arith.h,v $
|
2004-12-11 03:31:25 +01:00
|
|
|
* Revision 1.20 2004/12/11 02:31:29 steve
|
|
|
|
|
* Rework of internals to carry vectors through nexus instead
|
|
|
|
|
* of single bits. Make the ivl, tgt-vvp and vvp initial changes
|
|
|
|
|
* down this path.
|
2001-06-05 05:05:41 +02:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#endif
|