diff --git a/ivl_target.h b/ivl_target.h index 277685ac6..2639c5ec4 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: ivl_target.h,v 1.168 2006/06/18 04:15:50 steve Exp $" +#ident "$Id: ivl_target.h,v 1.169 2006/07/30 02:51:35 steve Exp $" #endif #ifdef __cplusplus @@ -986,12 +986,16 @@ extern const char* ivl_udp_name(ivl_udp_t net); * input must be signed, and the output will be a vector sign extended * to the desired width. The ivl_lpm_width() value is the output * width, the input will be whatever it wants to be. + * * - Shifts (IVL_LPM_SHIFTL/SHIFTR) * This node takes two inputs, a vector and a shift distance. The * ivl_lpm_data(0) nexus is the vector input, and the ivl_lpm_data(1) * the shift distance. The vector input is the same width as the * output, but the distance has its own width. * + * The ivl_lpm_signed() flag means for IVL_LPM_SHIFTR that the right + * shift is *signed*. For SHIFTL, then signed-ness is emaningless. + * * - System function call (IVL_LPM_SFUNC) * This device represents a netlist call to a system function. The * inputs to the device are passed to a system function, and the @@ -1714,6 +1718,9 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.169 2006/07/30 02:51:35 steve + * Fix/implement signed right shift. + * * Revision 1.168 2006/06/18 04:15:50 steve * Add support for system functions in continuous assignments. * diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 62ef85a4b..2350aa7b6 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: stub.c,v 1.139 2006/06/18 04:15:50 steve Exp $" +#ident "$Id: stub.c,v 1.140 2006/07/30 02:51:36 steve Exp $" #endif # include "config.h" @@ -861,8 +861,9 @@ static void show_lpm_shift(ivl_lpm_t net, const char*shift_dir) ivl_nexus_t nex; unsigned width = ivl_lpm_width(net); - fprintf(out, " LPM_SHIFT%s %s: \n", shift_dir, - ivl_lpm_basename(net), width); + fprintf(out, " LPM_SHIFT%s %s: \n", shift_dir, + ivl_lpm_basename(net), width, + ivl_lpm_signed(net)? "" : "un"); nex = ivl_lpm_q(net, 0); fprintf(out, " Q: %s\n", ivl_nexus_name(nex)); @@ -1646,6 +1647,9 @@ int target_design(ivl_design_t des) /* * $Log: stub.c,v $ + * Revision 1.140 2006/07/30 02:51:36 steve + * Fix/implement signed right shift. + * * Revision 1.139 2006/06/18 04:15:50 steve * Add support for system functions in continuous assignments. * diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index efd817c4a..807db0a37 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vvp_scope.c,v 1.145 2006/06/18 04:15:50 steve Exp $" +#ident "$Id: vvp_scope.c,v 1.146 2006/07/30 02:51:36 steve Exp $" #endif # include "vvp_priv.h" @@ -1788,10 +1788,10 @@ static void draw_lpm_ff(ivl_lpm_t net) static void draw_lpm_shiftl(ivl_lpm_t net) { unsigned width = ivl_lpm_width(net); - + const char* signed_flag = ivl_lpm_signed(net)? "s" : ""; if (ivl_lpm_type(net) == IVL_LPM_SHIFTR) - fprintf(vvp_out, "L_%p .shift/r %u", net, width); + fprintf(vvp_out, "L_%p .shift/r%s %u", net, signed_flag, width); else fprintf(vvp_out, "L_%p .shift/l %u", net, width); @@ -2251,6 +2251,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent) /* * $Log: vvp_scope.c,v $ + * Revision 1.146 2006/07/30 02:51:36 steve + * Fix/implement signed right shift. + * * Revision 1.145 2006/06/18 04:15:50 steve * Add support for system functions in continuous assignments. * diff --git a/vvp/arith.cc b/vvp/arith.cc index 29ff7f299..75010a89f 100644 --- a/vvp/arith.cc +++ b/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.48 2006/01/03 06:19:31 steve Exp $" +#ident "$Id: arith.cc,v 1.49 2006/07/30 02:51:36 steve Exp $" #endif # include "arith.h" @@ -693,8 +693,8 @@ void vvp_shiftl::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit) vvp_send_vec4(ptr.ptr()->out, out); } -vvp_shiftr::vvp_shiftr(unsigned wid) -: vvp_arith_(wid) +vvp_shiftr::vvp_shiftr(unsigned wid, bool signed_flag) +: vvp_arith_(wid), signed_flag_(signed_flag) { } @@ -720,8 +720,12 @@ void vvp_shiftr::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit) for (unsigned idx = shift ; idx < out.size() ; idx += 1) out.set_bit(idx-shift, op_a_.value(idx)); + vvp_bit4_t pad = BIT4_0; + if (signed_flag_ && op_a_.size() > 0) + pad = op_a_.value(op_a_.size()-1); + for (unsigned idx = 0 ; idx < shift ; idx += 1) - out.set_bit(idx+out.size()-shift, BIT4_0); + out.set_bit(idx+out.size()-shift, pad); vvp_send_vec4(ptr.ptr()->out, out); } @@ -780,6 +784,9 @@ void vvp_arith_sub_real::recv_real(vvp_net_ptr_t ptr, double bit) /* * $Log: arith.cc,v $ + * Revision 1.49 2006/07/30 02:51:36 steve + * Fix/implement signed right shift. + * * Revision 1.48 2006/01/03 06:19:31 steve * Support wide divide nodes. * diff --git a/vvp/arith.h b/vvp/arith.h index 37ec87e60..293cb1ae6 100644 --- a/vvp/arith.h +++ b/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.33 2006/01/03 06:19:31 steve Exp $" +#ident "$Id: arith.h,v 1.34 2006/07/30 02:51:36 steve Exp $" #endif # include "vvp_net.h" @@ -191,9 +191,12 @@ class vvp_shiftl : public vvp_arith_ { class vvp_shiftr : public vvp_arith_ { public: - explicit vvp_shiftr(unsigned wid); + explicit vvp_shiftr(unsigned wid, bool signed_flag); ~vvp_shiftr(); virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit); + + private: + bool signed_flag_; }; /* @@ -233,6 +236,9 @@ class vvp_arith_sub_real : public vvp_arith_real_ { /* * $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. * diff --git a/vvp/compile.cc b/vvp/compile.cc index 658013df8..83fe08bcd 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -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.220 2006/06/18 04:15:50 steve Exp $" +#ident "$Id: compile.cc,v 1.221 2006/07/30 02:51:36 steve Exp $" #endif # include "arith.h" @@ -1060,11 +1060,12 @@ void compile_shiftl(char*label, long wid, unsigned argc, struct symb_s*argv) make_arith(arith, label, argc, argv); } -void compile_shiftr(char*label, long wid, unsigned argc, struct symb_s*argv) +void compile_shiftr(char*label, long wid, bool signed_flag, + unsigned argc, struct symb_s*argv) { assert( wid > 0 ); - vvp_arith_ *arith = new vvp_shiftr(wid); + vvp_arith_ *arith = new vvp_shiftr(wid, signed_flag); make_arith(arith, label, argc, argv); } @@ -1495,6 +1496,9 @@ void compile_param_string(char*label, char*name, char*value) /* * $Log: compile.cc,v $ + * Revision 1.221 2006/07/30 02:51:36 steve + * Fix/implement signed right shift. + * * Revision 1.220 2006/06/18 04:15:50 steve * Add support for system functions in continuous assignments. * diff --git a/vvp/compile.h b/vvp/compile.h index 53df3073a..bd70b6c9d 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -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.81 2006/06/18 04:15:50 steve Exp $" +#ident "$Id: compile.h,v 1.82 2006/07/30 02:51:36 steve Exp $" #endif # include @@ -176,7 +176,7 @@ extern void compile_repeat(char*label, long width, long repeat, extern void compile_shiftl(char*label, long width, unsigned argc, struct symb_s*argv); -extern void compile_shiftr(char*label, long width, +extern void compile_shiftr(char*label, long width, bool signed_flag, unsigned argc, struct symb_s*argv); extern void compile_timescale(long units); @@ -345,6 +345,9 @@ extern void compile_alias_real(char*label, char*name, /* * $Log: compile.h,v $ + * Revision 1.82 2006/07/30 02:51:36 steve + * Fix/implement signed right shift. + * * Revision 1.81 2006/06/18 04:15:50 steve * Add support for system functions in continuous assignments. * diff --git a/vvp/lexor.lex b/vvp/lexor.lex index 1a080e335..17b1fc021 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: lexor.lex,v 1.61 2006/06/18 04:15:50 steve Exp $" +#ident "$Id: lexor.lex,v 1.62 2006/07/30 02:51:36 steve Exp $" #endif # include "parse_misc.h" @@ -133,6 +133,7 @@ ".sfunc" { return K_SFUNC; } ".shift/l" { return K_SHIFTL; } ".shift/r" { return K_SHIFTR; } +".shift/rs" { return K_SHIFTRS; } ".thread" { return K_THREAD; } ".timescale" { return K_TIMESCALE; } ".ufunc" { return K_UFUNC; } @@ -209,6 +210,9 @@ int yywrap() /* * $Log: lexor.lex,v $ + * Revision 1.62 2006/07/30 02:51:36 steve + * Fix/implement signed right shift. + * * Revision 1.61 2006/06/18 04:15:50 steve * Add support for system functions in continuous assignments. * diff --git a/vvp/parse.y b/vvp/parse.y index 85b4ffabb..e7c9a0110 100644 --- a/vvp/parse.y +++ b/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.83 2006/06/18 04:15:50 steve Exp $" +#ident "$Id: parse.y,v 1.84 2006/07/30 02:51:36 steve Exp $" #endif # include "parse_misc.h" @@ -67,7 +67,8 @@ extern FILE*yyin; %token K_PARAM_STR K_PARAM_L K_PART K_PART_PV %token K_PART_V K_REDUCE_AND K_REDUCE_OR K_REDUCE_XOR %token K_REDUCE_NAND K_REDUCE_NOR K_REDUCE_XNOR K_REPEAT -%token K_RESOLV K_SCOPE K_SFUNC K_SHIFTL K_SHIFTR K_THREAD K_TIMESCALE K_UFUNC +%token K_RESOLV K_SCOPE K_SFUNC K_SHIFTL K_SHIFTR K_SHIFTRS +%token K_THREAD K_TIMESCALE K_UFUNC %token K_UDP K_UDP_C K_UDP_S %token K_MEM K_MEM_P K_MEM_I %token K_VAR K_VAR_S K_VAR_I K_VAR_R K_vpi_call K_vpi_func K_vpi_func_r @@ -342,7 +343,13 @@ statement | T_LABEL K_SHIFTR T_NUMBER ',' symbols ';' { struct symbv_s obj = $5; - compile_shiftr($1, $3, obj.cnt, obj.vect); + compile_shiftr($1, $3, false, obj.cnt, obj.vect); + } + + + | T_LABEL K_SHIFTRS T_NUMBER ',' symbols ';' + { struct symbv_s obj = $5; + compile_shiftr($1, $3, true, obj.cnt, obj.vect); } @@ -743,6 +750,9 @@ int compile_design(const char*path) /* * $Log: parse.y,v $ + * Revision 1.84 2006/07/30 02:51:36 steve + * Fix/implement signed right shift. + * * Revision 1.83 2006/06/18 04:15:50 steve * Add support for system functions in continuous assignments. *