%set/x0 instruction to support bounds checking.

This commit is contained in:
steve 2002-11-21 22:43:13 +00:00
parent 00b2d467e4
commit 03afbf157b
5 changed files with 39 additions and 26 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vvp_process.c,v 1.75 2002/11/17 18:31:09 steve Exp $"
#ident "$Id: vvp_process.c,v 1.76 2002/11/21 22:43:13 steve Exp $"
#endif
# include "vvp_priv.h"
@ -79,8 +79,8 @@ static void set_to_lvariable(ivl_lval_t lval, unsigned idx,
if (ivl_lval_mux(lval)) {
assert(wid == 1);
fprintf(vvp_out, " %%set/x V_%s, %u, 0;\n",
vvp_signal_label(sig), bit);
fprintf(vvp_out, " %%set/x0 V_%s, %u, %u;\n",
vvp_signal_label(sig), bit, ivl_signal_pins(sig)-1);
} else if (wid == 1) {
fprintf(vvp_out, " %%set V_%s[%u], %u;\n",
vvp_signal_label(sig), idx+part_off, bit);
@ -191,6 +191,8 @@ static int show_stmt_assign(ivl_statement_t net)
value and write it into index0. */
if (ivl_lval_mux(lval)) {
calculate_into_x0(ivl_lval_mux(lval));
/* Generate code to skip around the set
if the index has X values. */
fprintf(vvp_out, " %%jmp/1 t_%u, 4;\n", skip_set);
skip_set_flag = 1;
}
@ -198,6 +200,8 @@ static int show_stmt_assign(ivl_statement_t net)
mem = ivl_lval_mem(lval);
if (mem) {
draw_memory_index_expr(mem, ivl_lval_idx(lval));
/* Generate code to skip around the set
if the index has X values. */
fprintf(vvp_out, " %%jmp/1 t_%u, 4;\n", skip_set);
skip_set_flag = 1;
}
@ -234,14 +238,7 @@ static int show_stmt_assign(ivl_statement_t net)
idx += cnt;
}
#if 0
for (idx = 0 ; idx < bit_limit ; idx += 1) {
set_to_lvariable(lval, idx,
bitchar_to_idx(bits[cur_rbit]), 1);
cur_rbit += 1;
}
#endif
if (bit_limit < ivl_lval_pins(lval)) {
unsigned cnt = ivl_lval_pins(lval) - bit_limit;
set_to_lvariable(lval, bit_limit, 0, cnt);
@ -1452,6 +1449,9 @@ int draw_func_definition(ivl_scope_t scope)
/*
* $Log: vvp_process.c,v $
* Revision 1.76 2002/11/21 22:43:13 steve
* %set/x0 instruction to support bounds checking.
*
* Revision 1.75 2002/11/17 18:31:09 steve
* Generate unique labels for force functors.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: codes.h,v 1.53 2002/11/08 04:59:57 steve Exp $"
#ident "$Id: codes.h,v 1.54 2002/11/21 22:43:13 steve Exp $"
#endif
@ -92,7 +92,7 @@ extern bool of_RELEASE(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_SET_VEC(vthread_t thr, vvp_code_t code);
extern bool of_SET_X(vthread_t thr, vvp_code_t code);
extern bool of_SET_X0(vthread_t thr, vvp_code_t code);
extern bool of_SHIFTL_I0(vthread_t thr, vvp_code_t code);
extern bool of_SHIFTR_I0(vthread_t thr, vvp_code_t code);
extern bool of_SUB(vthread_t thr, vvp_code_t code);
@ -160,6 +160,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
/*
* $Log: codes.h,v $
* Revision 1.54 2002/11/21 22:43:13 steve
* %set/x0 instruction to support bounds checking.
*
* Revision 1.53 2002/11/08 04:59:57 steve
* Add the %assign/v0 instruction.
*

View File

@ -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.145 2002/11/08 04:59:58 steve Exp $"
#ident "$Id: compile.cc,v 1.146 2002/11/21 22:43:13 steve Exp $"
#endif
# include "arith.h"
@ -137,7 +137,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} },
{ "%set/m", of_SET_MEM,2, {OA_MEM_PTR, OA_BIT1, OA_NONE} },
{ "%set/v", of_SET_VEC,3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%set/x", of_SET_X, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%set/x0", of_SET_X0, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%shiftl/i0", of_SHIFTL_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
{ "%shiftr/i0", of_SHIFTR_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
{ "%sub", of_SUB, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
@ -1483,6 +1483,9 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
/*
* $Log: compile.cc,v $
* Revision 1.146 2002/11/21 22:43:13 steve
* %set/x0 instruction to support bounds checking.
*
* Revision 1.145 2002/11/08 04:59:58 steve
* Add the %assign/v0 instruction.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: opcodes.txt,v 1.44 2002/11/08 04:59:58 steve Exp $
* $Id: opcodes.txt,v 1.45 2002/11/21 22:43:13 steve Exp $
*/
@ -459,15 +459,17 @@ address zero is the LSB of the first memory word. This instruction
sets only a single bit.
* %set/x <var-label>, <bit>, <idx>
* %set/x0 <var-label>, <bit>, <top>
This sets the bit of a variable functor, the address calculated by
using the index register <idx> (0, 1, 2 or 3) to index the functor
address of <var-label>.
using the index register 0 to index the functor address of
<var-label>.
If the index value in index register <idx> is <0 (for example if
%ix/get converted an unknown value into the register) then the set is
not performed.
If the index value in index register is <0 (for example if %ix/get
converted an unknown value into the register) then the set is not
performed. Also, if the index value is > the immediate top value, then
the set is not performed. The 0 and <top> values suffice to provide
complete bounds checking.
* %shiftl/i0 <bit>, <wid>

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vthread.cc,v 1.93 2002/11/08 04:59:58 steve Exp $"
#ident "$Id: vthread.cc,v 1.94 2002/11/21 22:43:14 steve Exp $"
#endif
# include "vthread.h"
@ -2191,17 +2191,19 @@ bool of_SET_VEC(vthread_t thr, vvp_code_t cp)
* The single bit goes into the indexed functor. Abort the instruction
* if the index is <0.
*/
bool of_SET_X(vthread_t thr, vvp_code_t cp)
bool of_SET_X0(vthread_t thr, vvp_code_t cp)
{
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx[0]);
long idx = thr->index[cp->bit_idx[1]&3];
long idx = thr->index[0];
/* If idx < 0, then the index value is probably generated from
an undefined value. At any rate, this is defined to have no
effect so quit now. */
if (idx < 0) {
if (idx < 0)
return true;
if (idx > cp->bit_idx[1])
return true;
}
/* Form the functor pointer from the base pointer and the
index from the index register. */
@ -2492,6 +2494,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.94 2002/11/21 22:43:14 steve
* %set/x0 instruction to support bounds checking.
*
* Revision 1.93 2002/11/08 04:59:58 steve
* Add the %assign/v0 instruction.
*