Support signed expressions through to VPI.
This commit is contained in:
parent
b14a0b885a
commit
3275d1f252
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT) & !defined(macintosh)
|
#if !defined(WINNT) & !defined(macintosh)
|
||||||
#ident "$Id: t-dll-expr.cc,v 1.22 2002/01/28 00:52:41 steve Exp $"
|
#ident "$Id: t-dll-expr.cc,v 1.23 2002/04/14 02:56:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -363,12 +363,16 @@ void dll_target::expr_unary(const NetEUnary*net)
|
||||||
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
|
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
|
||||||
expr_->type_ = IVL_EX_UNARY;
|
expr_->type_ = IVL_EX_UNARY;
|
||||||
expr_->width_ = net->expr_width();
|
expr_->width_ = net->expr_width();
|
||||||
|
expr_->signed_ = net->has_sign()? 1 : 0;
|
||||||
expr_->u_.unary_.op_ = net->op();
|
expr_->u_.unary_.op_ = net->op();
|
||||||
expr_->u_.unary_.sub_ = sub;
|
expr_->u_.unary_.sub_ = sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: t-dll-expr.cc,v $
|
* $Log: t-dll-expr.cc,v $
|
||||||
|
* Revision 1.23 2002/04/14 02:56:19 steve
|
||||||
|
* Support signed expressions through to VPI.
|
||||||
|
*
|
||||||
* Revision 1.22 2002/01/28 00:52:41 steve
|
* Revision 1.22 2002/01/28 00:52:41 steve
|
||||||
* Add support for bit select of parameters.
|
* Add support for bit select of parameters.
|
||||||
* This leads to a NetESelect node and the
|
* This leads to a NetESelect node and the
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vvp_process.c,v 1.52 2002/01/11 05:23:05 steve Exp $"
|
#ident "$Id: vvp_process.c,v 1.53 2002/04/14 02:56:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvp_priv.h"
|
# include "vvp_priv.h"
|
||||||
|
|
@ -895,7 +895,8 @@ static int show_system_task_call(ivl_statement_t net)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(veci < vecs);
|
assert(veci < vecs);
|
||||||
fprintf(vvp_out, ", T<%u,%u>", vec[veci].base, vec[veci].wid);
|
fprintf(vvp_out, ", T<%u,%u,%s>", vec[veci].base,
|
||||||
|
vec[veci].wid, ivl_expr_signed(expr)? "s" : "u");
|
||||||
veci++;
|
veci++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1102,6 +1103,9 @@ int draw_func_definition(ivl_scope_t scope)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vvp_process.c,v $
|
* $Log: vvp_process.c,v $
|
||||||
|
* Revision 1.53 2002/04/14 02:56:19 steve
|
||||||
|
* Support signed expressions through to VPI.
|
||||||
|
*
|
||||||
* Revision 1.52 2002/01/11 05:23:05 steve
|
* Revision 1.52 2002/01/11 05:23:05 steve
|
||||||
* Handle certain special cases of stime.
|
* Handle certain special cases of stime.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: compile.cc,v 1.122 2002/03/18 00:19:34 steve Exp $"
|
#ident "$Id: compile.cc,v 1.123 2002/04/14 02:56:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "arith.h"
|
# include "arith.h"
|
||||||
|
|
@ -354,10 +354,31 @@ bool vpi_handle_resolv_list_s::resolve(bool mes)
|
||||||
// check for thread vector T<base,wid>
|
// check for thread vector T<base,wid>
|
||||||
unsigned base, wid;
|
unsigned base, wid;
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
char ss[32];
|
||||||
if (2 <= sscanf(label, "T<%u,%u>%n", &base, &wid, &n)
|
if (2 <= sscanf(label, "T<%u,%u>%n", &base, &wid, &n)
|
||||||
&& n == strlen(label)) {
|
&& n == strlen(label)) {
|
||||||
val.ptr = vpip_make_vthr_vector(base, wid);
|
val.ptr = vpip_make_vthr_vector(base, wid, false);
|
||||||
sym_set_value(sym_vpi, label, val);
|
sym_set_value(sym_vpi, label, val);
|
||||||
|
|
||||||
|
} else if (3 <= sscanf(label, "T<%u,%u,%[su]>%n", &base,
|
||||||
|
&wid, ss, &n)
|
||||||
|
&& n == strlen(label)) {
|
||||||
|
|
||||||
|
bool signed_flag = false;
|
||||||
|
for (char*fp = ss ; *fp ; fp += 1) switch (*fp) {
|
||||||
|
case 's':
|
||||||
|
signed_flag = true;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
signed_flag = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
val.ptr = vpip_make_vthr_vector(base, wid, signed_flag);
|
||||||
|
sym_set_value(sym_vpi, label, val);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1387,6 +1408,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: compile.cc,v $
|
* $Log: compile.cc,v $
|
||||||
|
* Revision 1.123 2002/04/14 02:56:19 steve
|
||||||
|
* Support signed expressions through to VPI.
|
||||||
|
*
|
||||||
* Revision 1.122 2002/03/18 00:19:34 steve
|
* Revision 1.122 2002/03/18 00:19:34 steve
|
||||||
* Add the .ufunc statement.
|
* Add the .ufunc statement.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vpi_priv.h,v 1.28 2002/02/03 01:01:51 steve Exp $"
|
#ident "$Id: vpi_priv.h,v 1.29 2002/04/14 02:56:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vpi_user.h"
|
# include "vpi_user.h"
|
||||||
|
|
@ -195,7 +195,7 @@ vpiHandle vpip_make_dec_const(int value);
|
||||||
* thread.
|
* thread.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid);
|
vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid, bool signed_flag);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is called before any compilation to load VPI
|
* This function is called before any compilation to load VPI
|
||||||
|
|
@ -268,6 +268,9 @@ extern unsigned vpip_bits_to_dec_str(const unsigned char *bits,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_priv.h,v $
|
* $Log: vpi_priv.h,v $
|
||||||
|
* Revision 1.29 2002/04/14 02:56:19 steve
|
||||||
|
* Support signed expressions through to VPI.
|
||||||
|
*
|
||||||
* Revision 1.28 2002/02/03 01:01:51 steve
|
* Revision 1.28 2002/02/03 01:01:51 steve
|
||||||
* Use Larrys bits-to-decimal-string code.
|
* Use Larrys bits-to-decimal-string code.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vpi_vthr_vector.cc,v 1.5 2002/01/10 01:54:04 steve Exp $"
|
#ident "$Id: vpi_vthr_vector.cc,v 1.6 2002/04/14 02:56:19 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -39,6 +39,7 @@ struct __vpiVThrVec {
|
||||||
struct __vpiHandle base;
|
struct __vpiHandle base;
|
||||||
unsigned short bas;
|
unsigned short bas;
|
||||||
unsigned short wid;
|
unsigned short wid;
|
||||||
|
unsigned signed_flag : 1;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -85,7 +86,7 @@ static int vthr_vec_get(int code, vpiHandle ref)
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
||||||
case vpiSigned:
|
case vpiSigned:
|
||||||
return 0;
|
return rfp->signed_flag;
|
||||||
|
|
||||||
case vpiSize:
|
case vpiSize:
|
||||||
return rfp->wid;
|
return rfp->wid;
|
||||||
|
|
@ -115,51 +116,11 @@ static char buf[4096];
|
||||||
|
|
||||||
static void vthr_vec_DecStrVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
|
static void vthr_vec_DecStrVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
|
||||||
{
|
{
|
||||||
unsigned long val = 0;
|
unsigned char*bits = new unsigned char[rfp->wid];
|
||||||
unsigned count_x = 0, count_z = 0;
|
for (unsigned idx = 0 ; idx < rfp->wid ; idx += 1)
|
||||||
|
bits[idx] = get_bit(rfp, idx);
|
||||||
|
|
||||||
for (unsigned idx = 0 ; idx < rfp->wid ; idx += 1) {
|
vpip_bits_to_dec_str(bits, rfp->wid, buf, sizeof buf, rfp->signed_flag);
|
||||||
val *= 2;
|
|
||||||
switch (get_bit(rfp, rfp->wid-idx-1)) {
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
val += 1;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
count_x += 1;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
count_z += 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count_x == rfp->wid) {
|
|
||||||
buf[0] = 'x';
|
|
||||||
buf[1] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count_x > 0) {
|
|
||||||
buf[0] = 'X';
|
|
||||||
buf[1] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count_z == rfp->wid) {
|
|
||||||
buf[0] = 'z';
|
|
||||||
buf[1] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count_z > 0) {
|
|
||||||
buf[0] = 'Z';
|
|
||||||
buf[1] = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(buf, "%lu", val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vthr_vec_StringVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
|
static void vthr_vec_StringVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
|
||||||
|
|
@ -370,13 +331,14 @@ static const struct __vpirt vpip_vthr_const_rt = {
|
||||||
* Construct a vpiReg object. Give the object specified dimensions,
|
* Construct a vpiReg object. Give the object specified dimensions,
|
||||||
* and point to the specified functor for the lsb.
|
* and point to the specified functor for the lsb.
|
||||||
*/
|
*/
|
||||||
vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid)
|
vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid, bool signed_flag)
|
||||||
{
|
{
|
||||||
struct __vpiVThrVec*obj = (struct __vpiVThrVec*)
|
struct __vpiVThrVec*obj = (struct __vpiVThrVec*)
|
||||||
malloc(sizeof(struct __vpiVThrVec));
|
malloc(sizeof(struct __vpiVThrVec));
|
||||||
obj->base.vpi_type = &vpip_vthr_const_rt;
|
obj->base.vpi_type = &vpip_vthr_const_rt;
|
||||||
obj->bas = base;
|
obj->bas = base;
|
||||||
obj->wid = wid;
|
obj->wid = wid;
|
||||||
|
obj->signed_flag = signed_flag? 1 : 0;
|
||||||
obj->name = "T<>";
|
obj->name = "T<>";
|
||||||
|
|
||||||
return &obj->base;
|
return &obj->base;
|
||||||
|
|
@ -385,6 +347,9 @@ vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_vthr_vector.cc,v $
|
* $Log: vpi_vthr_vector.cc,v $
|
||||||
|
* Revision 1.6 2002/04/14 02:56:19 steve
|
||||||
|
* Support signed expressions through to VPI.
|
||||||
|
*
|
||||||
* Revision 1.5 2002/01/10 01:54:04 steve
|
* Revision 1.5 2002/01/10 01:54:04 steve
|
||||||
* odd width thread vectors as strings.
|
* odd width thread vectors as strings.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue