Add the cvt/vr instruction.

This commit is contained in:
steve 2003-02-27 20:36:29 +00:00
parent e58030498f
commit aa3297a925
4 changed files with 37 additions and 6 deletions

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.57 2003/02/06 17:41:47 steve Exp $"
#ident "$Id: codes.h,v 1.58 2003/02/27 20:36:29 steve Exp $"
#endif
@ -56,6 +56,7 @@ extern bool of_CMPX(vthread_t thr, vvp_code_t code);
extern bool of_CMPZ(vthread_t thr, vvp_code_t code);
extern bool of_CVT_IR(vthread_t thr, vvp_code_t code);
extern bool of_CVT_RI(vthread_t thr, vvp_code_t code);
extern bool of_CVT_VR(vthread_t thr, vvp_code_t code);
extern bool of_DEASSIGN(vthread_t thr, vvp_code_t code);
extern bool of_DELAY(vthread_t thr, vvp_code_t code);
extern bool of_DELAYX(vthread_t thr, vvp_code_t code);
@ -169,6 +170,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
/*
* $Log: codes.h,v $
* Revision 1.58 2003/02/27 20:36:29 steve
* Add the cvt/vr instruction.
*
* Revision 1.57 2003/02/06 17:41:47 steve
* Add the %sub/wr 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.154 2003/02/09 23:33:26 steve Exp $"
#ident "$Id: compile.cc,v 1.155 2003/02/27 20:36:29 steve Exp $"
#endif
# include "arith.h"
@ -103,6 +103,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%cmpi/u", of_CMPIU, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%cvt/ir", of_CVT_IR, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
{ "%cvt/ri", of_CVT_RI, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
{ "%cvt/vr", of_CVT_VR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%deassign",of_DEASSIGN,2,{OA_FUNC_PTR, OA_BIT1, OA_NONE} },
{ "%delay", of_DELAY, 1, {OA_NUMBER, OA_NONE, OA_NONE} },
{ "%delayx", of_DELAYX, 1, {OA_NUMBER, OA_NONE, OA_NONE} },
@ -1520,6 +1521,9 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
/*
* $Log: compile.cc,v $
* Revision 1.155 2003/02/27 20:36:29 steve
* Add the cvt/vr instruction.
*
* Revision 1.154 2003/02/09 23:33:26 steve
* Spelling fixes.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com)
*
* $Id: opcodes.txt,v 1.49 2003/02/09 23:33:26 steve Exp $
* $Id: opcodes.txt,v 1.50 2003/02/27 20:36:29 steve Exp $
*/
@ -185,10 +185,15 @@ Only bit 4 is set by these instructions.
* %cvt/ir <bit-l>, <bit-r>
* %cvt/ri <bit-l>, <bit-r>
* %cvt/vr <bit-l>, <bit-r>, <wid>
Copy a word from r to l, converting int from real to integer in the
process.
Copy a word from r to l, converting it from real to integer (ir) or
integer to real (ri) in the process. The source and destinaition may
be the same word address, leading to a convert in place.
The %cvt/vr opcode converts a real word <bit-r> to a thread vector
starting at <bit-l> and with the width <wid>. Non-integer precision is
lost in the conversion.
* %delay <delay>

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.103 2003/02/22 06:26:58 steve Exp $"
#ident "$Id: vthread.cc,v 1.104 2003/02/27 20:36:29 steve Exp $"
#endif
# include "vthread.h"
@ -832,6 +832,21 @@ bool of_CVT_RI(vthread_t thr, vvp_code_t cp)
return true;
}
bool of_CVT_VR(vthread_t thr, vvp_code_t cp)
{
double r = thr->words[cp->bit_idx[1]].w_real;
long rl = (long)r;
unsigned base = cp->bit_idx[0];
unsigned wid = cp->number;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
thr_put_bit(thr, base+idx, (rl&1)? 1 : 0);
rl >>= 1;
}
return true;
}
bool of_DELAY(vthread_t thr, vvp_code_t cp)
{
//printf("thread %p: %%delay %lu\n", thr, cp->number);
@ -2664,6 +2679,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.104 2003/02/27 20:36:29 steve
* Add the cvt/vr instruction.
*
* Revision 1.103 2003/02/22 06:26:58 steve
* When checking for stop, remember to reschedule.
*