Implement the .cmp/eeq LPM node.
This commit is contained in:
parent
1d1dda5a5d
commit
b86fdd6bbc
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: README.txt,v 1.53 2005/01/16 04:19:08 steve Exp $
|
||||
* $Id: README.txt,v 1.54 2005/01/22 01:06:20 steve Exp $
|
||||
*/
|
||||
|
||||
VVP SIMULATION ENGINE
|
||||
|
|
@ -550,6 +550,7 @@ have wide outputs, but the comparators have single bit output, so they
|
|||
are implemented a bit differently. The syntax, however, is very
|
||||
similar:
|
||||
|
||||
<label> .cmp/eeq <wid>, <A>, <B>;
|
||||
<label> .cmp/eq <wid>, <A>, <B>;
|
||||
<label> .cmp/ne <wid>, <A>, <B>;
|
||||
<label> .cmp/ge <wid>, <A>, <B>;
|
||||
|
|
@ -557,10 +558,10 @@ similar:
|
|||
<label> .cmp/ge.s <wid>, <A>, <B>;
|
||||
<label> .cmp/gt.s <wid>, <A>, <B>;
|
||||
|
||||
Whereas the arithmetic statements generate an outpout the width if
|
||||
Whereas the arithmetic statements generate an output the width of
|
||||
<wid>, the comparisons produce a single bit vector result. The plain
|
||||
versions do unsigned comparison, but the ".s" versions to signed
|
||||
comparisons. (Eqlality doesn't need to care about sign.)
|
||||
comparisons. (Equality doesn't need to care about sign.)
|
||||
|
||||
|
||||
STRUCTURAL SHIFTER STATEMENTS:
|
||||
|
|
|
|||
57
vvp/arith.cc
57
vvp/arith.cc
|
|
@ -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.32 2005/01/16 04:19:08 steve Exp $"
|
||||
#ident "$Id: arith.cc,v 1.33 2005/01/22 01:06:20 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -35,6 +35,24 @@ vvp_arith_::vvp_arith_(unsigned wid)
|
|||
{
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
||||
x_val_.set_bit(idx, BIT4_X);
|
||||
|
||||
op_a_ = x_val_;
|
||||
op_b_ = x_val_;
|
||||
}
|
||||
|
||||
void vvp_arith_::dispatch_operand_(vvp_net_ptr_t ptr, vvp_vector4_t bit)
|
||||
{
|
||||
unsigned port = ptr.port();
|
||||
switch (port) {
|
||||
case 0:
|
||||
op_a_ = bit;
|
||||
break;
|
||||
case 1:
|
||||
op_b_ = bit;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -321,18 +339,7 @@ vvp_arith_sub::~vvp_arith_sub()
|
|||
*/
|
||||
void vvp_arith_sub::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
|
||||
{
|
||||
unsigned port = ptr.port();
|
||||
|
||||
switch (port) {
|
||||
case 0:
|
||||
op_a_ = bit;
|
||||
break;
|
||||
case 1:
|
||||
op_b_ = bit;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
dispatch_operand_(ptr, bit);
|
||||
|
||||
vvp_net_t*net = ptr.ptr();
|
||||
|
||||
|
|
@ -359,7 +366,28 @@ void vvp_arith_sub::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
|
|||
vvp_send_vec4(net->out, value);
|
||||
}
|
||||
|
||||
vvp_cmp_eeq::vvp_cmp_eeq(unsigned wid)
|
||||
: vvp_arith_(wid)
|
||||
{
|
||||
}
|
||||
|
||||
void vvp_cmp_eeq::recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit)
|
||||
{
|
||||
dispatch_operand_(ptr, bit);
|
||||
|
||||
vvp_vector4_t eeq (1);
|
||||
eeq.set_bit(0, BIT4_1);
|
||||
|
||||
assert(op_a_.size() == op_b_.size());
|
||||
for (unsigned idx = 0 ; idx < op_a_.size() ; idx += 1)
|
||||
if (op_a_.value(idx) != op_b_.value(idx)) {
|
||||
eeq.set_bit(0, BIT4_0);
|
||||
break;
|
||||
}
|
||||
|
||||
vvp_net_t*net = ptr.ptr();
|
||||
vvp_send_vec4(net->out, eeq);
|
||||
}
|
||||
|
||||
vvp_cmp_eq::vvp_cmp_eq(unsigned wid)
|
||||
: vvp_arith_(wid)
|
||||
|
|
@ -594,6 +622,9 @@ void vvp_shiftr::set(vvp_ipoint_t i, bool push, unsigned val, unsigned)
|
|||
|
||||
/*
|
||||
* $Log: arith.cc,v $
|
||||
* Revision 1.33 2005/01/22 01:06:20 steve
|
||||
* Implement the .cmp/eeq LPM node.
|
||||
*
|
||||
* Revision 1.32 2005/01/16 04:19:08 steve
|
||||
* Reimplement comparators as vvp_vector4_t nodes.
|
||||
*
|
||||
|
|
|
|||
22
vvp/arith.h
22
vvp/arith.h
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: arith.h,v 1.21 2005/01/16 04:19:08 steve Exp $"
|
||||
#ident "$Id: arith.h,v 1.22 2005/01/22 01:06:20 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "functor.h"
|
||||
|
|
@ -30,12 +30,20 @@
|
|||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
class vvp_arith_ : public vvp_net_fun_t {
|
||||
|
||||
public:
|
||||
explicit vvp_arith_(unsigned wid);
|
||||
|
||||
protected:
|
||||
void dispatch_operand_(vvp_net_ptr_t ptr, vvp_vector4_t bit);
|
||||
|
||||
protected:
|
||||
unsigned wid_;
|
||||
|
||||
|
|
@ -103,6 +111,15 @@ class vvp_arith_sub : public vvp_arith_ {
|
|||
|
||||
};
|
||||
|
||||
class vvp_cmp_eeq : public vvp_arith_ {
|
||||
|
||||
public:
|
||||
explicit vvp_cmp_eeq(unsigned wid);
|
||||
|
||||
void recv_vec4(vvp_net_ptr_t ptr, vvp_vector4_t bit);
|
||||
|
||||
};
|
||||
|
||||
class vvp_cmp_eq : public vvp_arith_ {
|
||||
|
||||
public:
|
||||
|
|
@ -171,6 +188,9 @@ class vvp_shiftr : public vvp_arith_ {
|
|||
|
||||
/*
|
||||
* $Log: arith.h,v $
|
||||
* 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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.180 2005/01/16 04:19:08 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.181 2005/01/22 01:06:20 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -910,6 +910,22 @@ void compile_arith_sum(char*label, long wid, unsigned argc, struct symb_s*argv)
|
|||
make_arith(arith, label, wid, argc, argv);
|
||||
}
|
||||
|
||||
void compile_cmp_eeq(char*label, long wid,
|
||||
unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
assert( wid > 0 );
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "%s .cmp/eeq has wrong number of symbols\n",label);
|
||||
compile_errors += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
vvp_arith_ *arith = new vvp_cmp_eeq(wid);
|
||||
|
||||
make_arith(arith, label, wid, argc, argv);
|
||||
}
|
||||
|
||||
void compile_cmp_eq(char*label, long wid, unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
assert( wid > 0 );
|
||||
|
|
@ -1564,6 +1580,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.181 2005/01/22 01:06:20 steve
|
||||
* Implement the .cmp/eeq LPM node.
|
||||
*
|
||||
* Revision 1.180 2005/01/16 04:19:08 steve
|
||||
* Reimplement comparators as vvp_vector4_t nodes.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: compile.h,v 1.59 2005/01/09 20:11:15 steve Exp $"
|
||||
#ident "$Id: compile.h,v 1.60 2005/01/22 01:06:20 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
|
@ -124,6 +124,8 @@ extern void compile_arith_sum(char*label, long width,
|
|||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_arith_sub(char*label, long width,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_cmp_eeq(char*label, long width,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_cmp_eq(char*label, long width,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_cmp_ne(char*label, long width,
|
||||
|
|
@ -285,6 +287,9 @@ extern void compile_net(char*label, char*name,
|
|||
|
||||
/*
|
||||
* $Log: compile.h,v $
|
||||
* Revision 1.60 2005/01/22 01:06:20 steve
|
||||
* Implement the .cmp/eeq LPM node.
|
||||
*
|
||||
* Revision 1.59 2005/01/09 20:11:15 steve
|
||||
* Add the .part/pv node and related functionality.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: lexor.lex,v 1.46 2005/01/09 20:11:15 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.47 2005/01/22 01:06:20 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -89,6 +89,7 @@
|
|||
".arith/mult" { return K_ARITH_MULT; }
|
||||
".arith/sub" { return K_ARITH_SUB; }
|
||||
".arith/sum" { return K_ARITH_SUM; }
|
||||
".cmp/eeq" { return K_CMP_EEQ; }
|
||||
".cmp/eq" { return K_CMP_EQ; }
|
||||
".cmp/ne" { return K_CMP_NE; }
|
||||
".cmp/ge" { return K_CMP_GE; }
|
||||
|
|
@ -185,6 +186,9 @@ int yywrap()
|
|||
|
||||
/*
|
||||
* $Log: lexor.lex,v $
|
||||
* Revision 1.47 2005/01/22 01:06:20 steve
|
||||
* Implement the .cmp/eeq LPM node.
|
||||
*
|
||||
* Revision 1.46 2005/01/09 20:11:15 steve
|
||||
* Add the .part/pv node and related functionality.
|
||||
*
|
||||
|
|
|
|||
12
vvp/parse.y
12
vvp/parse.y
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: parse.y,v 1.63 2005/01/09 20:11:15 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.64 2005/01/22 01:06:20 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -59,7 +59,7 @@ extern FILE*yyin;
|
|||
|
||||
%token K_ARITH_DIV K_ARITH_DIV_S K_ARITH_MOD K_ARITH_MULT
|
||||
%token K_ARITH_SUB K_ARITH_SUM
|
||||
%token K_CMP_EQ K_CMP_NE K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
|
||||
%token K_CMP_EEQ K_CMP_EQ K_CMP_NE K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
|
||||
%token K_CONCAT
|
||||
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S K_PARAM K_PART K_PART_PV
|
||||
%token K_RESOLV K_SCOPE K_SHIFTL K_SHIFTR K_THREAD K_TIMESCALE K_UFUNC
|
||||
|
|
@ -236,6 +236,11 @@ statement
|
|||
compile_arith_sum($1, $3, obj.cnt, obj.vect);
|
||||
}
|
||||
|
||||
| T_LABEL K_CMP_EEQ T_NUMBER ',' symbols ';'
|
||||
{ struct symbv_s obj = $5;
|
||||
compile_cmp_eeq($1, $3, obj.cnt, obj.vect);
|
||||
}
|
||||
|
||||
| T_LABEL K_CMP_EQ T_NUMBER ',' symbols ';'
|
||||
{ struct symbv_s obj = $5;
|
||||
compile_cmp_eq($1, $3, obj.cnt, obj.vect);
|
||||
|
|
@ -645,6 +650,9 @@ int compile_design(const char*path)
|
|||
|
||||
/*
|
||||
* $Log: parse.y,v $
|
||||
* Revision 1.64 2005/01/22 01:06:20 steve
|
||||
* Implement the .cmp/eeq LPM node.
|
||||
*
|
||||
* Revision 1.63 2005/01/09 20:11:15 steve
|
||||
* Add the .part/pv node and related functionality.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue