Add %cvt/ir and %cvt/ri instructions, and support

real values passed as arguments to VPI tasks.
This commit is contained in:
steve 2003-01-26 18:16:22 +00:00
parent 9a5a00f836
commit 7de4108bad
7 changed files with 135 additions and 8 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.55 2003/01/25 23:48:06 steve Exp $"
#ident "$Id: codes.h,v 1.56 2003/01/26 18:16:22 steve Exp $"
#endif
@ -54,6 +54,8 @@ extern bool of_CMPU(vthread_t thr, vvp_code_t code);
extern bool of_CMPWR(vthread_t thr, vvp_code_t code);
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_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);
@ -166,6 +168,10 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
/*
* $Log: codes.h,v $
* Revision 1.56 2003/01/26 18:16:22 steve
* Add %cvt/ir and %cvt/ri instructions, and support
* real values passed as arguments to VPI tasks.
*
* Revision 1.55 2003/01/25 23:48:06 steve
* Add thread word array, and add the instructions,
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.

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.148 2003/01/25 23:48:06 steve Exp $"
#ident "$Id: compile.cc,v 1.149 2003/01/26 18:16:22 steve Exp $"
#endif
# include "arith.h"
@ -101,6 +101,8 @@ const static struct opcode_table_s opcode_table[] = {
{ "%cmp/x", of_CMPX, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%cmp/z", of_CMPZ, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%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} },
{ "%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} },
@ -403,7 +405,13 @@ bool vpi_handle_resolv_list_s::resolve(bool mes)
val.ptr = vpip_make_vthr_vector(base, wid, signed_flag);
sym_set_value(sym_vpi, label, val);
} else if (2 == sscanf(label, "W<%u,%[r]>%n", &base, ss, &n)
&& n == strlen(label)) {
val.ptr = vpip_make_vthr_word(base, ss);
sym_set_value(sym_vpi, label, val);
}
}
if (!val.ptr) {
@ -1499,6 +1507,10 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
/*
* $Log: compile.cc,v $
* Revision 1.149 2003/01/26 18:16:22 steve
* Add %cvt/ir and %cvt/ri instructions, and support
* real values passed as arguments to VPI tasks.
*
* Revision 1.148 2003/01/25 23:48:06 steve
* Add thread word array, and add the instructions,
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: opcodes.txt,v 1.46 2003/01/25 23:48:06 steve Exp $
* $Id: opcodes.txt,v 1.47 2003/01/26 18:16:22 steve Exp $
*/
@ -176,6 +176,14 @@ instruction will also treat x values in either operand as don't care.
Only bit 4 is set by these instructions.
* %cvt/ir <bit-l>, <bit-r>
* %cvt/ri <bit-l>, <bit-r>
Copy a word from r to l, converting int from real to integer in the
process.
* %delay <delay>
This opcode pauses the thread, and causes it to be rescheduled for a

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_priv.h,v 1.43 2003/01/25 23:48:06 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.44 2003/01/26 18:16:22 steve Exp $"
#endif
# include "vpi_user.h"
@ -288,6 +288,8 @@ vpiHandle vpip_make_dec_const(struct __vpiDecConst*obj, int value);
vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid, bool signed_flag);
vpiHandle vpip_make_vthr_word(unsigned base, const char*type);
/*
* This function is called before any compilation to load VPI
* modules. This gives the modules a chance to announce their
@ -390,6 +392,10 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
/*
* $Log: vpi_priv.h,v $
* Revision 1.44 2003/01/26 18:16:22 steve
* Add %cvt/ir and %cvt/ri instructions, and support
* real values passed as arguments to VPI tasks.
*
* Revision 1.43 2003/01/25 23:48:06 steve
* Add thread word array, and add the instructions,
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_vthr_vector.cc,v 1.8 2002/08/12 01:35:09 steve Exp $"
#ident "$Id: vpi_vthr_vector.cc,v 1.9 2003/01/26 18:16:22 steve Exp $"
#endif
/*
@ -360,9 +360,72 @@ vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid, bool signed_flag)
return &obj->base;
}
struct __vpiVThrWord {
struct __vpiHandle base;
char* name;
int subtype;
unsigned short index;
};
static void vthr_real_get_value(vpiHandle ref, s_vpi_value*vp)
{
assert(ref->vpi_type->type_code==vpiConstant);
struct __vpiVThrWord*obj = (struct __vpiVThrWord*)ref;
static char buf[64];
double val = vthread_get_real(vpip_current_vthread, obj->index);
switch (vp->format) {
case vpiObjTypeVal:
vp->format = vpiRealVal;
case vpiRealVal:
vp->value.real = val;
break;
case vpiDecStrVal:
sprintf(buf, "%0.0f", val);
vp->value.str = buf;
break;
default:
vp->format = vpiSuppressVal;
break;
}
}
static const struct __vpirt vpip_vthr_const_real_rt = {
vpiConstant,
0,
0,
vthr_real_get_value,
0,
0,
0
};
vpiHandle vpip_make_vthr_word(unsigned base, const char*type)
{
struct __vpiVThrWord*obj = (struct __vpiVThrWord*)
malloc(sizeof(struct __vpiVThrWord));
assert(type[0] == 'r');
obj->base.vpi_type = &vpip_vthr_const_real_rt;
obj->name = "W<>";
obj->subtype = vpiRealConst;
obj->index = base;
return &obj->base;
}
/*
* $Log: vpi_vthr_vector.cc,v $
* Revision 1.9 2003/01/26 18:16:22 steve
* Add %cvt/ir and %cvt/ri instructions, and support
* real values passed as arguments to VPI tasks.
*
* Revision 1.8 2002/08/12 01:35:09 steve
* conditional ident string using autoconfig.
*

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.97 2003/01/25 23:48:06 steve Exp $"
#ident "$Id: vthread.cc,v 1.98 2003/01/26 18:16:22 steve Exp $"
#endif
# include "vthread.h"
@ -182,6 +182,11 @@ void vthread_put_bit(struct vthread_s*thr, unsigned addr, unsigned bit)
thr_put_bit(thr, addr, bit);
}
double vthread_get_real(struct vthread_s*thr, unsigned addr)
{
return thr->words[addr].w_real;
}
static unsigned long* vector_to_array(struct vthread_s*thr,
unsigned addr, unsigned wid)
{
@ -806,6 +811,22 @@ bool of_CMPZ(vthread_t thr, vvp_code_t cp)
return true;
}
bool of_CVT_IR(vthread_t thr, vvp_code_t cp)
{
double r = thr->words[cp->bit_idx[1]].w_real;
thr->words[cp->bit_idx[0]].w_int = (long)(r);
return true;
}
bool of_CVT_RI(vthread_t thr, vvp_code_t cp)
{
long r = thr->words[cp->bit_idx[1]].w_int;
thr->words[cp->bit_idx[0]].w_real = (double)(r);
return true;
}
bool of_DELAY(vthread_t thr, vvp_code_t cp)
{
//printf("thread %p: %%delay %lu\n", thr, cp->number);
@ -1379,7 +1400,7 @@ bool of_IX_GET(vthread_t thr, vvp_code_t cp)
}
v |= vv << i;
}
thr->words[cp->bit_idx[0] & 3].w_int = v;
thr->words[cp->bit_idx[0]].w_int = v;
/* Set bit 4 as a flag if the input is unknown. */
thr_put_bit(thr, 4, unknown_flag? 1 : 0);
return true;
@ -1874,6 +1895,7 @@ bool of_MUL_WR(vthread_t thr, vvp_code_t cp)
double l = thr->words[cp->bit_idx[0]].w_real;
double r = thr->words[cp->bit_idx[1]].w_real;
thr->words[cp->bit_idx[0]].w_real = l * r;
return true;
}
@ -2581,6 +2603,10 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.98 2003/01/26 18:16:22 steve
* Add %cvt/ir and %cvt/ri instructions, and support
* real values passed as arguments to VPI tasks.
*
* Revision 1.97 2003/01/25 23:48:06 steve
* Add thread word array, and add the instructions,
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vthread.h,v 1.8 2002/08/12 01:35:09 steve Exp $"
#ident "$Id: vthread.h,v 1.9 2003/01/26 18:16:22 steve Exp $"
#endif
/*
@ -71,8 +71,14 @@ extern void vthread_schedule_list(vthread_t thr);
extern unsigned vthread_get_bit(struct vthread_s*thr, unsigned addr);
extern void vthread_put_bit(struct vthread_s*thr, unsigned addr, unsigned bit);
extern double vthread_get_real(struct vthread_s*thr, unsigned addr);
/*
* $Log: vthread.h,v $
* Revision 1.9 2003/01/26 18:16:22 steve
* Add %cvt/ir and %cvt/ri instructions, and support
* real values passed as arguments to VPI tasks.
*
* Revision 1.8 2002/08/12 01:35:09 steve
* conditional ident string using autoconfig.
*