2001-06-05 05:05:41 +02:00
|
|
|
#ifndef __arith_H
|
|
|
|
|
#define __arith_H
|
|
|
|
|
/*
|
2008-01-04 08:44:14 +01:00
|
|
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
2001-06-05 05:05:41 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
# include "vvp_net.h"
|
2001-06-05 05:05:41 +02:00
|
|
|
|
2005-01-16 05:19:08 +01:00
|
|
|
/*
|
|
|
|
|
* Base class for arithmetic functors.
|
|
|
|
|
* The wid constructor is used to size the output. This includes
|
|
|
|
|
* precalculating an X value. Most arithmetic nodes can handle
|
|
|
|
|
* whatever width comes in, given the knowledge of the output width.
|
2005-01-22 02:06:20 +01:00
|
|
|
*
|
|
|
|
|
* The width is also used to make initial values for the op_a_ and
|
|
|
|
|
* op_b_ operands. Most arithmetic operators expect the widths of the
|
|
|
|
|
* inputs to match, and since only one input at a time changes, the
|
|
|
|
|
* other will need to be initialized to X.
|
2005-01-16 05:19:08 +01:00
|
|
|
*/
|
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
|
|
|
|
2005-01-22 02:06:20 +01:00
|
|
|
protected:
|
|
|
|
|
void dispatch_operand_(vvp_net_ptr_t ptr, vvp_vector4_t bit);
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
2008-05-07 05:37:00 +02:00
|
|
|
class vvp_arith_abs : public vvp_net_fun_t {
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_abs();
|
|
|
|
|
~vvp_arith_abs();
|
|
|
|
|
|
|
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
};
|
|
|
|
|
|
2008-06-18 02:07:19 +02:00
|
|
|
class vvp_arith_cast_real : public vvp_net_fun_t {
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_cast_real(bool signed_flag);
|
|
|
|
|
~vvp_arith_cast_real();
|
|
|
|
|
|
|
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool signed_;
|
|
|
|
|
};
|
|
|
|
|
|
2001-10-31 05:27:46 +01:00
|
|
|
class vvp_arith_div : public vvp_arith_ {
|
2001-06-05 05:05:41 +02:00
|
|
|
|
|
|
|
|
public:
|
2005-02-19 02:32:52 +01:00
|
|
|
explicit vvp_arith_div(unsigned wid, bool signed_flag);
|
|
|
|
|
~vvp_arith_div();
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2004-06-30 04:15:57 +02:00
|
|
|
private:
|
2006-01-03 07:19:31 +01:00
|
|
|
void wide4_(vvp_net_ptr_t ptr);
|
2004-06-30 04:15:57 +02:00
|
|
|
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:
|
2005-03-12 07:42:28 +01:00
|
|
|
explicit vvp_arith_mod(unsigned wid, bool signed_flag);
|
|
|
|
|
~vvp_arith_mod();
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2005-03-12 07:42:28 +01:00
|
|
|
private:
|
|
|
|
|
void wide_(vvp_net_ptr_t ptr);
|
|
|
|
|
bool signed_flag_;
|
2002-01-03 05:19:01 +01:00
|
|
|
};
|
|
|
|
|
|
2005-01-28 06:34:25 +01:00
|
|
|
/* vvp_cmp_* objects...
|
|
|
|
|
* the vvp_cmp_* objects all are special vvp_arith_ objects in that
|
|
|
|
|
* their widths are only for their inputs. The output widths are all
|
|
|
|
|
* exactly 1 bit.
|
|
|
|
|
*/
|
2001-06-07 05:09:03 +02:00
|
|
|
|
2005-01-22 02:06:20 +01:00
|
|
|
class vvp_cmp_eeq : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_eeq(unsigned wid);
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2005-01-22 02:06:20 +01:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2005-03-09 06:52:03 +01:00
|
|
|
class vvp_cmp_nee : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_nee(unsigned wid);
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2005-03-09 06:52:03 +01:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2004-06-16 18:33:25 +02:00
|
|
|
class vvp_cmp_eq : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_eq(unsigned wid);
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2004-06-16 18:33:25 +02:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_cmp_ne : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_ne(unsigned wid);
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2004-06-16 18:33:25 +02:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2005-01-22 17:21:11 +01:00
|
|
|
|
2005-01-16 05:19:08 +01:00
|
|
|
/*
|
|
|
|
|
* This base class implements both GT and GE comparisons. The derived
|
|
|
|
|
* GT and GE call the recv_vec4_base_ method with a different
|
|
|
|
|
* out_if_equal argument that reflects the different expectations.
|
|
|
|
|
*/
|
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:
|
2005-01-16 05:19:08 +01:00
|
|
|
void recv_vec4_base_(vvp_net_ptr_t ptr, vvp_vector4_t bit,
|
|
|
|
|
vvp_bit4_t out_if_equal);
|
2004-09-22 18:44:07 +02:00
|
|
|
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);
|
|
|
|
|
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2005-01-16 05:19:08 +01:00
|
|
|
|
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);
|
|
|
|
|
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2001-06-15 06:07:57 +02:00
|
|
|
};
|
2001-07-06 06:46:44 +02:00
|
|
|
|
2005-01-28 06:34:25 +01:00
|
|
|
/*
|
|
|
|
|
* NOTE: The inputs to the vvp_arith_mult are not necessarily the same
|
|
|
|
|
* width as the output. This is different from the typical vvp_arith_
|
|
|
|
|
* object. Perhaps that means this isn't quite a vvp_arith_ object?
|
|
|
|
|
*/
|
|
|
|
|
class vvp_arith_mult : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_mult(unsigned wid);
|
|
|
|
|
~vvp_arith_mult();
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2005-02-04 06:13:02 +01:00
|
|
|
private:
|
|
|
|
|
void wide_(vvp_net_ptr_t ptr);
|
2005-01-28 06:34:25 +01:00
|
|
|
};
|
|
|
|
|
|
2008-02-06 04:09:30 +01:00
|
|
|
class vvp_arith_pow : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
2008-02-09 02:32:57 +01:00
|
|
|
explicit vvp_arith_pow(unsigned wid, bool signed_flag);
|
2008-02-06 04:09:30 +01:00
|
|
|
~vvp_arith_pow();
|
|
|
|
|
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
|
2008-02-09 02:32:57 +01:00
|
|
|
private:
|
|
|
|
|
bool signed_flag_;
|
2008-02-06 04:09:30 +01:00
|
|
|
};
|
|
|
|
|
|
2005-01-28 06:34:25 +01:00
|
|
|
class vvp_arith_sub : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_sub(unsigned wid);
|
|
|
|
|
~vvp_arith_sub();
|
2005-06-22 02:04:48 +02:00
|
|
|
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2005-01-28 06:34:25 +01:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_arith_sum : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_sum(unsigned wid);
|
|
|
|
|
~vvp_arith_sum();
|
2005-06-22 02:04:48 +02:00
|
|
|
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2005-01-28 06:34:25 +01:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2001-07-06 06:46:44 +02:00
|
|
|
class vvp_shiftl : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
2005-03-19 07:23:49 +01:00
|
|
|
explicit vvp_shiftl(unsigned wid);
|
|
|
|
|
~vvp_shiftl();
|
2005-06-22 02:04:48 +02:00
|
|
|
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2001-07-06 06:46:44 +02:00
|
|
|
};
|
|
|
|
|
|
2001-07-07 04:57:33 +02:00
|
|
|
class vvp_shiftr : public vvp_arith_ {
|
|
|
|
|
|
|
|
|
|
public:
|
2006-07-30 04:51:35 +02:00
|
|
|
explicit vvp_shiftr(unsigned wid, bool signed_flag);
|
2005-03-19 07:23:49 +01:00
|
|
|
~vvp_shiftr();
|
2005-06-22 02:04:48 +02:00
|
|
|
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2006-07-30 04:51:35 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool signed_flag_;
|
2001-07-07 04:57:33 +02:00
|
|
|
};
|
|
|
|
|
|
2005-07-06 06:29:25 +02:00
|
|
|
/*
|
|
|
|
|
* Base class for real valued expressions. These are similar to the
|
|
|
|
|
* vector expression classes, but the inputs are collected from the
|
|
|
|
|
* recv_real method.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_arith_real_ : public vvp_net_fun_t {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_real_();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void dispatch_operand_(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
double op_a_;
|
|
|
|
|
double op_b_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2008-01-04 08:44:14 +01:00
|
|
|
class vvp_arith_sum_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_sum_real();
|
|
|
|
|
~vvp_arith_sum_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
};
|
|
|
|
|
|
2005-07-06 06:29:25 +02:00
|
|
|
class vvp_arith_div_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_div_real();
|
|
|
|
|
~vvp_arith_div_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
};
|
|
|
|
|
|
2008-01-31 03:32:27 +01:00
|
|
|
class vvp_arith_mod_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_mod_real();
|
|
|
|
|
~vvp_arith_mod_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
};
|
|
|
|
|
|
2008-01-04 08:44:14 +01:00
|
|
|
class vvp_arith_mult_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_mult_real();
|
|
|
|
|
~vvp_arith_mult_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
};
|
|
|
|
|
|
2008-01-31 02:53:06 +01:00
|
|
|
class vvp_arith_pow_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_pow_real();
|
|
|
|
|
~vvp_arith_pow_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
};
|
|
|
|
|
|
2005-07-06 06:29:25 +02:00
|
|
|
class vvp_arith_sub_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_arith_sub_real();
|
|
|
|
|
~vvp_arith_sub_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
|
|
|
|
};
|
|
|
|
|
|
2008-01-15 19:54:04 +01:00
|
|
|
class vvp_cmp_eq_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_eq_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, const double bit);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_cmp_ne_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_ne_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, const double bit);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_cmp_ge_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_ge_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, const double bit);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class vvp_cmp_gt_real : public vvp_arith_real_ {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_cmp_gt_real();
|
|
|
|
|
void recv_real(vvp_net_ptr_t ptr, const double bit);
|
|
|
|
|
};
|
|
|
|
|
|
2001-06-05 05:05:41 +02:00
|
|
|
#endif
|