Add arith/mult.r and arith/sum.r
This patch adds the missing real multiplication and summation operators and the code to generate them when needed.
This commit is contained in:
parent
4100ff71ef
commit
e01e7b1280
|
|
@ -1613,7 +1613,10 @@ static void draw_lpm_add(ivl_lpm_t net)
|
||||||
|
|
||||||
switch (ivl_lpm_type(net)) {
|
switch (ivl_lpm_type(net)) {
|
||||||
case IVL_LPM_ADD:
|
case IVL_LPM_ADD:
|
||||||
type = "sum";
|
if (dto == IVL_VT_REAL)
|
||||||
|
type = "sum.r";
|
||||||
|
else
|
||||||
|
type = "sum";
|
||||||
break;
|
break;
|
||||||
case IVL_LPM_SUB:
|
case IVL_LPM_SUB:
|
||||||
if (dto == IVL_VT_REAL)
|
if (dto == IVL_VT_REAL)
|
||||||
|
|
@ -1622,7 +1625,10 @@ static void draw_lpm_add(ivl_lpm_t net)
|
||||||
type = "sub";
|
type = "sub";
|
||||||
break;
|
break;
|
||||||
case IVL_LPM_MULT:
|
case IVL_LPM_MULT:
|
||||||
type = "mult";
|
if (dto == IVL_VT_REAL)
|
||||||
|
type = "mult.r";
|
||||||
|
else
|
||||||
|
type = "mult";
|
||||||
break;
|
break;
|
||||||
case IVL_LPM_DIVIDE:
|
case IVL_LPM_DIVIDE:
|
||||||
if (dto == IVL_VT_REAL)
|
if (dto == IVL_VT_REAL)
|
||||||
|
|
@ -1633,7 +1639,10 @@ static void draw_lpm_add(ivl_lpm_t net)
|
||||||
type = "div";
|
type = "div";
|
||||||
break;
|
break;
|
||||||
case IVL_LPM_MOD:
|
case IVL_LPM_MOD:
|
||||||
type = "mod";
|
if (dto == IVL_VT_REAL)
|
||||||
|
assert(0); /* Not supported for reals, */
|
||||||
|
else
|
||||||
|
type = "mod";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
|
||||||
41
vvp/arith.cc
41
vvp/arith.cc
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2005 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -16,9 +16,6 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
|
||||||
#ident "$Id: arith.cc,v 1.50 2007/01/20 02:09:54 steve Exp $"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# include "arith.h"
|
# include "arith.h"
|
||||||
# include "schedule.h"
|
# include "schedule.h"
|
||||||
|
|
@ -756,6 +753,24 @@ void vvp_arith_real_::dispatch_operand_(vvp_net_ptr_t ptr, double bit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Real multiplication. */
|
||||||
|
vvp_arith_mult_real::vvp_arith_mult_real()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
vvp_arith_mult_real::~vvp_arith_mult_real()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void vvp_arith_mult_real::recv_real(vvp_net_ptr_t ptr, double bit)
|
||||||
|
{
|
||||||
|
dispatch_operand_(ptr, bit);
|
||||||
|
|
||||||
|
double val = op_a_ * op_b_;
|
||||||
|
vvp_send_real(ptr.ptr()->out, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Real division. */
|
||||||
vvp_arith_div_real::vvp_arith_div_real()
|
vvp_arith_div_real::vvp_arith_div_real()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -772,6 +787,24 @@ void vvp_arith_div_real::recv_real(vvp_net_ptr_t ptr, double bit)
|
||||||
vvp_send_real(ptr.ptr()->out, val);
|
vvp_send_real(ptr.ptr()->out, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Real summation. */
|
||||||
|
vvp_arith_sum_real::vvp_arith_sum_real()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
vvp_arith_sum_real::~vvp_arith_sum_real()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void vvp_arith_sum_real::recv_real(vvp_net_ptr_t ptr, double bit)
|
||||||
|
{
|
||||||
|
dispatch_operand_(ptr, bit);
|
||||||
|
|
||||||
|
double val = op_a_ + op_b_;
|
||||||
|
vvp_send_real(ptr.ptr()->out, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Real subtraction. */
|
||||||
vvp_arith_sub_real::vvp_arith_sub_real()
|
vvp_arith_sub_real::vvp_arith_sub_real()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
71
vvp/arith.h
71
vvp/arith.h
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __arith_H
|
#ifndef __arith_H
|
||||||
#define __arith_H
|
#define __arith_H
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2005 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -18,9 +18,6 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
|
||||||
#ident "$Id: arith.h,v 1.34 2006/07/30 02:51:36 steve Exp $"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
# include "vvp_net.h"
|
# include "vvp_net.h"
|
||||||
|
|
||||||
|
|
@ -218,6 +215,14 @@ class vvp_arith_real_ : public vvp_net_fun_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
class vvp_arith_div_real : public vvp_arith_real_ {
|
class vvp_arith_div_real : public vvp_arith_real_ {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -226,6 +231,14 @@ class vvp_arith_div_real : public vvp_arith_real_ {
|
||||||
void recv_real(vvp_net_ptr_t ptr, double bit);
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
class vvp_arith_sub_real : public vvp_arith_real_ {
|
class vvp_arith_sub_real : public vvp_arith_real_ {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -234,54 +247,4 @@ class vvp_arith_sub_real : public vvp_arith_real_ {
|
||||||
void recv_real(vvp_net_ptr_t ptr, double bit);
|
void recv_real(vvp_net_ptr_t ptr, double bit);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* $Log: arith.h,v $
|
|
||||||
* Revision 1.34 2006/07/30 02:51:36 steve
|
|
||||||
* Fix/implement signed right shift.
|
|
||||||
*
|
|
||||||
* Revision 1.33 2006/01/03 06:19:31 steve
|
|
||||||
* Support wide divide nodes.
|
|
||||||
*
|
|
||||||
* Revision 1.32 2005/07/06 04:29:25 steve
|
|
||||||
* Implement real valued signals and arith nodes.
|
|
||||||
*
|
|
||||||
* Revision 1.31 2005/06/22 00:04:48 steve
|
|
||||||
* Reduce vvp_vector4 copies by using const references.
|
|
||||||
*
|
|
||||||
* Revision 1.30 2005/06/11 18:11:18 steve
|
|
||||||
* Remove unneeded references to functor.h
|
|
||||||
*
|
|
||||||
* Revision 1.29 2005/03/19 06:23:49 steve
|
|
||||||
* Handle LPM shifts.
|
|
||||||
*
|
|
||||||
* Revision 1.28 2005/03/12 06:42:28 steve
|
|
||||||
* Implement .arith/mod.
|
|
||||||
*
|
|
||||||
* Revision 1.27 2005/03/09 05:52:04 steve
|
|
||||||
* Handle case inequality in netlists.
|
|
||||||
*
|
|
||||||
* Revision 1.26 2005/02/19 01:32:52 steve
|
|
||||||
* Implement .arith/div.
|
|
||||||
*
|
|
||||||
* Revision 1.25 2005/02/04 05:13:02 steve
|
|
||||||
* Add wide .arith/mult, and vvp_vector2_t vectors.
|
|
||||||
*
|
|
||||||
* Revision 1.24 2005/01/28 05:34:25 steve
|
|
||||||
* Add vector4 implementation of .arith/mult.
|
|
||||||
*
|
|
||||||
* Revision 1.23 2005/01/22 16:21:11 steve
|
|
||||||
* Implement vectored CMP_EQ and NE
|
|
||||||
*
|
|
||||||
* Revision 1.22 2005/01/22 01:06:20 steve
|
|
||||||
* Implement the .cmp/eeq LPM node.
|
|
||||||
*
|
|
||||||
* Revision 1.21 2005/01/16 04:19:08 steve
|
|
||||||
* Reimplement comparators as vvp_vector4_t nodes.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -941,12 +941,24 @@ void compile_arith_mult(char*label, long wid,
|
||||||
make_arith(arith, label, argc, argv);
|
make_arith(arith, label, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void compile_arith_mult_r(char*label, unsigned argc, struct symb_s*argv)
|
||||||
|
{
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "%s .arith/mult.r has wrong number of symbols\n", label);
|
||||||
|
compile_errors += 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vvp_arith_real_ *arith = new vvp_arith_mult_real;
|
||||||
|
make_arith(arith, label, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
void compile_arith_sub(char*label, long wid, unsigned argc, struct symb_s*argv)
|
void compile_arith_sub(char*label, long wid, unsigned argc, struct symb_s*argv)
|
||||||
{
|
{
|
||||||
assert( wid > 0 );
|
assert( wid > 0 );
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr, "%s .arith has wrong number of symbols\n", label);
|
fprintf(stderr, "%s .arith/sub has wrong number of symbols\n", label);
|
||||||
compile_errors += 1;
|
compile_errors += 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -972,7 +984,7 @@ void compile_arith_sum(char*label, long wid, unsigned argc, struct symb_s*argv)
|
||||||
assert( wid > 0 );
|
assert( wid > 0 );
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr, "%s .arith has wrong number of symbols\n", label);
|
fprintf(stderr, "%s .arith/sum has wrong number of symbols\n", label);
|
||||||
compile_errors += 1;
|
compile_errors += 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -981,6 +993,18 @@ void compile_arith_sum(char*label, long wid, unsigned argc, struct symb_s*argv)
|
||||||
make_arith(arith, label, argc, argv);
|
make_arith(arith, label, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void compile_arith_sum_r(char*label, unsigned argc, struct symb_s*argv)
|
||||||
|
{
|
||||||
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "%s .arith/sum.r has wrong number of symbols\n", label);
|
||||||
|
compile_errors += 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vvp_arith_real_ *arith = new vvp_arith_sum_real;
|
||||||
|
make_arith(arith, label, argc, argv);
|
||||||
|
}
|
||||||
|
|
||||||
void compile_cmp_eeq(char*label, long wid,
|
void compile_cmp_eeq(char*label, long wid,
|
||||||
unsigned argc, struct symb_s*argv)
|
unsigned argc, struct symb_s*argv)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __compile_H
|
#ifndef __compile_H
|
||||||
#define __compile_H
|
#define __compile_H
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -169,7 +169,10 @@ extern void compile_cmp_ge(char*label, long width, bool signed_flag,
|
||||||
extern void compile_cmp_gt(char*label, long width, bool signed_flag,
|
extern void compile_cmp_gt(char*label, long width, bool signed_flag,
|
||||||
unsigned argc, struct symb_s*argv);
|
unsigned argc, struct symb_s*argv);
|
||||||
|
|
||||||
|
extern void compile_arith_mult_r(char*label, unsigned argc,
|
||||||
|
struct symb_s*argv);
|
||||||
extern void compile_arith_div_r(char*label, unsigned argc, struct symb_s*argv);
|
extern void compile_arith_div_r(char*label, unsigned argc, struct symb_s*argv);
|
||||||
|
extern void compile_arith_sum_r(char*label, unsigned argc, struct symb_s*argv);
|
||||||
extern void compile_arith_sub_r(char*label, unsigned argc, struct symb_s*argv);
|
extern void compile_arith_sub_r(char*label, unsigned argc, struct symb_s*argv);
|
||||||
|
|
||||||
extern void compile_dff(char*label,
|
extern void compile_dff(char*label,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -91,9 +91,11 @@
|
||||||
".arith/div.s" { return K_ARITH_DIV_S; }
|
".arith/div.s" { return K_ARITH_DIV_S; }
|
||||||
".arith/mod" { return K_ARITH_MOD; }
|
".arith/mod" { return K_ARITH_MOD; }
|
||||||
".arith/mult" { return K_ARITH_MULT; }
|
".arith/mult" { return K_ARITH_MULT; }
|
||||||
|
".arith/mult.r" { return K_ARITH_MULT_R; }
|
||||||
".arith/sub" { return K_ARITH_SUB; }
|
".arith/sub" { return K_ARITH_SUB; }
|
||||||
".arith/sub.r" { return K_ARITH_SUB_R; }
|
".arith/sub.r" { return K_ARITH_SUB_R; }
|
||||||
".arith/sum" { return K_ARITH_SUM; }
|
".arith/sum" { return K_ARITH_SUM; }
|
||||||
|
".arith/sum.r" { return K_ARITH_SUM_R; }
|
||||||
".array" { return K_ARRAY; }
|
".array" { return K_ARRAY; }
|
||||||
".array/i" { return K_ARRAY_I; }
|
".array/i" { return K_ARRAY_I; }
|
||||||
".array/real" { return K_ARRAY_R; }
|
".array/real" { return K_ARRAY_R; }
|
||||||
|
|
|
||||||
16
vvp/parse.y
16
vvp/parse.y
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
%{
|
%{
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -67,8 +67,8 @@ static struct __vpiModPath*modpath_dst = 0;
|
||||||
|
|
||||||
%token K_ALIAS K_ALIAS_S K_ALIAS_R
|
%token K_ALIAS K_ALIAS_S K_ALIAS_R
|
||||||
%token K_ARITH_DIV K_ARITH_DIV_R K_ARITH_DIV_S K_ARITH_MOD K_ARITH_MULT
|
%token K_ARITH_DIV K_ARITH_DIV_R K_ARITH_DIV_S K_ARITH_MOD K_ARITH_MULT
|
||||||
%token K_ARITH_SUB K_ARITH_SUB_R K_ARITH_SUM K_ARRAY K_ARRAY_I K_ARRAY_R
|
%token K_ARITH_MULT_R K_ARITH_SUB K_ARITH_SUB_R K_ARITH_SUM K_ARITH_SUM_R
|
||||||
%token K_ARRAY_S K_ARRAY_PORT
|
%token K_ARRAY K_ARRAY_I K_ARRAY_R K_ARRAY_S K_ARRAY_PORT
|
||||||
%token K_CMP_EEQ K_CMP_EQ K_CMP_NEE K_CMP_NE
|
%token K_CMP_EEQ K_CMP_EQ K_CMP_NEE K_CMP_NE
|
||||||
%token K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
|
%token K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
|
||||||
%token K_CONCAT K_DEBUG K_DELAY K_DFF
|
%token K_CONCAT K_DEBUG K_DELAY K_DFF
|
||||||
|
|
@ -275,6 +275,11 @@ statement
|
||||||
compile_arith_mult($1, $3, obj.cnt, obj.vect);
|
compile_arith_mult($1, $3, obj.cnt, obj.vect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
| T_LABEL K_ARITH_MULT_R T_NUMBER ',' symbols ';'
|
||||||
|
{ struct symbv_s obj = $5;
|
||||||
|
compile_arith_mult_r($1, obj.cnt, obj.vect);
|
||||||
|
}
|
||||||
|
|
||||||
| T_LABEL K_ARITH_SUB T_NUMBER ',' symbols ';'
|
| T_LABEL K_ARITH_SUB T_NUMBER ',' symbols ';'
|
||||||
{ struct symbv_s obj = $5;
|
{ struct symbv_s obj = $5;
|
||||||
compile_arith_sub($1, $3, obj.cnt, obj.vect);
|
compile_arith_sub($1, $3, obj.cnt, obj.vect);
|
||||||
|
|
@ -290,6 +295,11 @@ statement
|
||||||
compile_arith_sum($1, $3, obj.cnt, obj.vect);
|
compile_arith_sum($1, $3, obj.cnt, obj.vect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
| T_LABEL K_ARITH_SUM_R T_NUMBER ',' symbols ';'
|
||||||
|
{ struct symbv_s obj = $5;
|
||||||
|
compile_arith_sum_r($1, obj.cnt, obj.vect);
|
||||||
|
}
|
||||||
|
|
||||||
| T_LABEL K_CMP_EEQ T_NUMBER ',' symbols ';'
|
| T_LABEL K_CMP_EEQ T_NUMBER ',' symbols ';'
|
||||||
{ struct symbv_s obj = $5;
|
{ struct symbv_s obj = $5;
|
||||||
compile_cmp_eeq($1, $3, obj.cnt, obj.vect);
|
compile_cmp_eeq($1, $3, obj.cnt, obj.vect);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue