From a2d465804f9e44a0583b77ba58fa64a34125bbb5 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 23 Jun 2001 18:26:26 +0000 Subject: [PATCH] Add the %shiftl/i0 instruction. --- vvp/codes.h | 6 +++++- vvp/compile.cc | 6 +++++- vvp/main.cc | 6 +++++- vvp/opcodes.txt | 9 ++++++++- vvp/vthread.cc | 28 +++++++++++++++++++++++++++- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/vvp/codes.h b/vvp/codes.h index 90fa25f8f..96b1a1739 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: codes.h,v 1.29 2001/06/18 01:09:32 steve Exp $" +#ident "$Id: codes.h,v 1.30 2001/06/23 18:26:26 steve Exp $" #endif @@ -72,6 +72,7 @@ extern bool of_OR(vthread_t thr, vvp_code_t code); extern bool of_ORR(vthread_t thr, vvp_code_t code); extern bool of_SET(vthread_t thr, vvp_code_t code); extern bool of_SET_MEM(vthread_t thr, vvp_code_t code); +extern bool of_SHIFTL_I0(vthread_t thr, vvp_code_t code); extern bool of_SUB(vthread_t thr, vvp_code_t code); extern bool of_VPI_CALL(vthread_t thr, vvp_code_t code); extern bool of_WAIT(vthread_t thr, vvp_code_t code); @@ -134,6 +135,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr); /* * $Log: codes.h,v $ + * Revision 1.30 2001/06/23 18:26:26 steve + * Add the %shiftl/i0 instruction. + * * Revision 1.29 2001/06/18 01:09:32 steve * More behavioral unary reduction operators. * (Stephan Boettcher) diff --git a/vvp/compile.cc b/vvp/compile.cc index 617a76f16..df6c75908 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 */ #if !defined(WINNT) -#ident "$Id: compile.cc,v 1.80 2001/06/23 01:04:07 steve Exp $" +#ident "$Id: compile.cc,v 1.81 2001/06/23 18:26:26 steve Exp $" #endif # include "arith.h" @@ -111,6 +111,7 @@ const static struct opcode_table_s opcode_table[] = { { "%or/r", of_ORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} }, { "%set/m", of_SET_MEM,2, {OA_MEM_PTR, OA_BIT1, OA_NONE} }, + { "%shiftl/i0", of_SHIFTL_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} }, { "%sub", of_SUB, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%wait", of_WAIT, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, { "%xnor", of_XNOR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, @@ -1448,6 +1449,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name) /* * $Log: compile.cc,v $ + * Revision 1.81 2001/06/23 18:26:26 steve + * Add the %shiftl/i0 instruction. + * * Revision 1.80 2001/06/23 01:04:07 steve * Allow forward references of task scopes. (Stephan Boettcher) * diff --git a/vvp/main.cc b/vvp/main.cc index 9903163bb..b8be21643 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: main.cc,v 1.15 2001/06/12 03:53:11 steve Exp $" +#ident "$Id: main.cc,v 1.16 2001/06/23 18:26:26 steve Exp $" #endif # include "config.h" @@ -27,6 +27,7 @@ # include "schedule.h" # include "vpi_priv.h" # include +# include #if defined(HAVE_GETOPT_H) # include #endif @@ -111,6 +112,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.16 2001/06/23 18:26:26 steve + * Add the %shiftl/i0 instruction. + * * Revision 1.15 2001/06/12 03:53:11 steve * Change the VPI call process so that loaded .vpi modules * use a function table instead of implicit binding. diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index 9487b047b..8f9ffa2f6 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) * - * $Id: opcodes.txt,v 1.23 2001/06/16 23:45:05 steve Exp $ + * $Id: opcodes.txt,v 1.24 2001/06/23 18:26:26 steve Exp $ */ @@ -293,6 +293,13 @@ address zero is the LSB of the first memory word. This instruction sets only a single bit. +* %shiftl/i0 , + +This instruction shifts the vector left (towards more significant +bits) by the amount in index register 0. The is the address of +the lsb of the vector, and the width of the vector. The shift is +done in place. Zero values are shifted in. + * %sub , , This instruction arithmetically subtracts the right vector out of the diff --git a/vvp/vthread.cc b/vvp/vthread.cc index a65339441..fb4084c73 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vthread.cc,v 1.45 2001/06/22 00:03:05 steve Exp $" +#ident "$Id: vthread.cc,v 1.46 2001/06/23 18:26:26 steve Exp $" #endif # include "vthread.h" @@ -30,6 +30,7 @@ # include # include +#include /* * This vhtread_s structure describes all there is to know about a * thread, including its program counter, all the private bits it @@ -1076,6 +1077,28 @@ bool of_SET_MEM(vthread_t thr, vvp_code_t cp) return true; } +bool of_SHIFTL_I0(vthread_t thr, vvp_code_t cp) +{ + unsigned base = cp->bit_idx1; + unsigned wid = cp->number; + long shift = thr->index[0]; + + if (shift >= wid) { + for (unsigned idx = 0 ; idx < wid ; idx += 1) + thr_put_bit(thr, base+idx, 0); + + } else if (shift > 0) { + for (unsigned idx = wid ; idx > shift ; idx -= 1) { + unsigned src = base+idx-shift-1; + unsigned dst = base + idx - 1; + thr_put_bit(thr, dst, thr_get_bit(thr, src)); + } + for (unsigned idx = 0 ; idx < shift ; idx += 1) + thr_put_bit(thr, base+idx, 0); + } + return true; +} + bool of_SUB(vthread_t thr, vvp_code_t cp) { assert(cp->bit_idx1 >= 4); @@ -1226,6 +1249,9 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t) /* * $Log: vthread.cc,v $ + * Revision 1.46 2001/06/23 18:26:26 steve + * Add the %shiftl/i0 instruction. + * * Revision 1.45 2001/06/22 00:03:05 steve * Infinitely wide behavioral add. *