Support signed decimal display of variables.

This commit is contained in:
steve 2001-01-06 22:22:17 +00:00
parent cc18d065aa
commit ad0853d666
6 changed files with 63 additions and 21 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: t-vvm.cc,v 1.198 2001/01/01 01:41:09 steve Exp $"
#ident "$Id: t-vvm.cc,v 1.199 2001/01/06 22:22:17 steve Exp $"
#endif
# include <iostream>
@ -1270,7 +1270,7 @@ void target_vvm::signal(const NetNet*sig)
init_code << " vpip_make_reg(&" << net_name
<< ", \"" << sig->name() << "\", signal_bit_table+"
<< signal_bit_counter << ", " << sig->pin_count()
<< ");" << endl;
<< ", " << (sig->get_signed()? "1" : "0") << ");" << endl;
signal_bit_counter += sig->pin_count();
@ -3621,6 +3621,9 @@ extern const struct target tgt_vvm = {
};
/*
* $Log: t-vvm.cc,v $
* Revision 1.199 2001/01/06 22:22:17 steve
* Support signed decimal display of variables.
*
* Revision 1.198 2001/01/01 01:41:09 steve
* reg_assign into function ports. (PR#95)
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_user.h,v 1.24 2000/10/28 00:51:42 steve Exp $"
#ident "$Id: vpi_user.h,v 1.25 2001/01/06 22:22:17 steve Exp $"
#endif
@ -158,6 +158,7 @@ typedef struct t_vpi_value {
# define vpiOctConst 4
# define vpiHexConst 5
# define vpiStringConst 6
#define vpiSigned 65
/* DELAY MODES */
#define vpiNoDelay 1
@ -265,6 +266,9 @@ extern DLLEXPORT void (*vlog_startup_routines[])();
/*
* $Log: vpi_user.h,v $
* Revision 1.25 2001/01/06 22:22:17 steve
* Support signed decimal display of variables.
*
* Revision 1.24 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_const.c,v 1.15 2000/12/10 19:15:19 steve Exp $"
#ident "$Id: vpi_const.c,v 1.16 2001/01/06 22:22:17 steve Exp $"
#endif
# include "vpi_priv.h"
@ -25,13 +25,15 @@
# include <string.h>
# include <stdio.h>
unsigned vpip_bits_to_dec_str(const vpip_bit_t*bits, unsigned nbits,
char*buf, unsigned nbuf)
static unsigned vpip_bits_to_dec_str(const vpip_bit_t*bits, unsigned nbits,
char*buf, unsigned nbuf, int signed_flag)
{
unsigned idx, len;
unsigned count_x = 0, count_z = 0;
unsigned long val = 0;
assert( len <= 8*sizeof(val) );
for (idx = 0 ; idx < nbits ; idx += 1) {
val *= 2;
if (B_ISZ(bits[nbits-idx-1]))
@ -59,8 +61,17 @@ unsigned vpip_bits_to_dec_str(const vpip_bit_t*bits, unsigned nbits,
buf[0] = 'Z';
buf[1] = 0;
} else {
sprintf(buf, "%lu", val);
len = strlen(buf);
if (signed_flag && B_IS1(bits[nbits-1])) {
long tmp = -1;
assert(sizeof(tmp) == sizeof(val));
tmp <<= nbits;
tmp |= val;
sprintf(buf, "%ld", tmp);
len = strlen(buf);
} else {
sprintf(buf, "%lu", val);
len = strlen(buf);
}
}
return len;
}
@ -69,7 +80,8 @@ unsigned vpip_bits_to_dec_str(const vpip_bit_t*bits, unsigned nbits,
* This function is used in a couple places to interpret a bit string
* as a value.
*/
void vpip_bits_get_value(const vpip_bit_t*bits, unsigned nbits, s_vpi_value*vp)
void vpip_bits_get_value(const vpip_bit_t*bits, unsigned nbits,
s_vpi_value*vp, int signed_flag)
{
static char buff[1024];
static s_vpi_vecval vect[64];
@ -98,7 +110,8 @@ void vpip_bits_get_value(const vpip_bit_t*bits, unsigned nbits, s_vpi_value*vp)
break;
case vpiDecStrVal:
cp += vpip_bits_to_dec_str(bits, nbits, cp, 1024-(cp-buff));
cp += vpip_bits_to_dec_str(bits, nbits, cp,
1024-(cp-buff), signed_flag);
break;
case vpiOctStrVal:
@ -401,7 +414,7 @@ static void number_value(vpiHandle ref, p_vpi_value vp)
{
struct __vpiNumberConst*rfp = (struct __vpiNumberConst*)ref;
assert(ref->vpi_type->type_code == vpiConstant);
vpip_bits_get_value(rfp->bits, rfp->nbits, vp);
vpip_bits_get_value(rfp->bits, rfp->nbits, vp, 0);
}
static const struct __vpirt vpip_string_rt = {
@ -443,6 +456,9 @@ vpiHandle vpip_make_number_const(struct __vpiNumberConst*ref,
/*
* $Log: vpi_const.c,v $
* Revision 1.16 2001/01/06 22:22:17 steve
* Support signed decimal display of variables.
*
* Revision 1.15 2000/12/10 19:15:19 steve
* vpiStringVal handles leding nulls as blanks. (PR#62)
*

View File

@ -26,7 +26,7 @@
* Picture Elements, Inc., 777 Panoramic Way, Berkeley, CA 94704.
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_memory.c,v 1.8 2000/06/28 18:38:00 steve Exp $"
#ident "$Id: vpi_memory.c,v 1.9 2001/01/06 22:22:17 steve Exp $"
#endif
# include "vpi_priv.h"
@ -151,7 +151,7 @@ static void memory_word_get_value(vpiHandle ref, s_vpi_value*vp)
assert(ref->vpi_type->type_code==vpiMemoryWord);
vpip_bits_get_value(rfp->mem->bits+rfp->index*rfp->mem->width,
rfp->mem->width, vp);
rfp->mem->width, vp, 0);
}
static const struct __vpirt vpip_memory_rt = {
@ -201,6 +201,9 @@ vpiHandle vpip_make_memory(struct __vpiMemory*ref, const char*name,
}
/*
* $Log: vpi_memory.c,v $
* Revision 1.9 2001/01/06 22:22:17 steve
* Support signed decimal display of variables.
*
* Revision 1.8 2000/06/28 18:38:00 steve
* Initialize memories as they are create.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_priv.h,v 1.30 2000/11/11 01:52:09 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.31 2001/01/06 22:22:17 steve Exp $"
#endif
/*
@ -127,7 +127,7 @@ extern vpip_bit_t vpip_bits_resolve(const vpip_bit_t*bits, unsigned nbits);
extern void vpip_bits_get_value(const vpip_bit_t*bits, unsigned nbits,
s_vpi_value*vp);
s_vpi_value*vp, int signed_flag);
extern void vpip_bits_set_value(vpip_bit_t*bits, unsigned nbits,
s_vpi_value*vp);
@ -250,6 +250,9 @@ struct __vpiSignal {
/* The signal has a value and dimension. */
vpip_bit_t*bits;
unsigned nbits;
unsigned signed_flag : 1;
/* monitors are added here. */
struct __vpiCallback*mfirst;
struct __vpiCallback*mlast;
@ -313,7 +316,8 @@ struct __vpiNumberConst {
*/
extern vpiHandle vpip_make_iterator(unsigned nargs, vpiHandle*args);
extern vpiHandle vpip_make_net(struct __vpiSignal*ref, const char*name,
vpip_bit_t*bits, unsigned nbits);
vpip_bit_t*bits, unsigned nbits,
int signed_flag);
extern vpiHandle vpip_make_scope(struct __vpiScope*ref,
int type_code,
const char*name);
@ -325,7 +329,8 @@ extern vpiHandle vpip_make_number_const(struct __vpiNumberConst*ref,
extern vpiHandle vpip_make_memory(struct __vpiMemory*ref, const char*name,
unsigned width, unsigned size);
extern vpiHandle vpip_make_reg(struct __vpiSignal*ref, const char*name,
vpip_bit_t*bits, unsigned nbits);
vpip_bit_t*bits, unsigned nbits,
int signed_flag);
extern vpiHandle vpip_make_time_var(struct __vpiTimeVar*ref,
const char*val);
@ -407,6 +412,9 @@ extern int vpip_finished();
/*
* $Log: vpi_priv.h,v $
* Revision 1.31 2001/01/06 22:22:17 steve
* Support signed decimal display of variables.
*
* Revision 1.30 2000/11/11 01:52:09 steve
* change set for support of nmos, pmos, rnmos, rpmos, notif0, and notif1
* change set to correct behavior of bufif0 and bufif1

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_signal.c,v 1.11 2000/08/20 17:49:05 steve Exp $"
#ident "$Id: vpi_signal.c,v 1.12 2001/01/06 22:22:17 steve Exp $"
#endif
# include "vpi_priv.h"
@ -32,6 +32,9 @@ static int signal_get(int code, vpiHandle ref)
|| (ref->vpi_type->type_code==vpiReg));
switch (code) {
case vpiSigned:
return rfp->signed_flag;
case vpiSize:
return rfp->nbits;
@ -62,7 +65,7 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
assert((ref->vpi_type->type_code==vpiNet)
|| (ref->vpi_type->type_code==vpiReg));
vpip_bits_get_value(rfp->bits, rfp->nbits, vp);
vpip_bits_get_value(rfp->bits, rfp->nbits, vp, rfp->signed_flag);
}
static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
@ -87,12 +90,13 @@ static const struct __vpirt vpip_net_rt = {
};
vpiHandle vpip_make_net(struct __vpiSignal*ref, const char*name,
vpip_bit_t*b, unsigned nb)
vpip_bit_t*b, unsigned nb, int signed_flag)
{
ref->base.vpi_type = &vpip_net_rt;
ref->name = name;
ref->bits = b;
ref->nbits = nb;
ref->signed_flag = signed_flag? 1 : 0;
ref->mfirst = 0;
ref->mlast = 0;
return &(ref->base);
@ -109,12 +113,13 @@ static const struct __vpirt vpip_reg_rt = {
};
vpiHandle vpip_make_reg(struct __vpiSignal*ref, const char*name,
vpip_bit_t*b, unsigned nb)
vpip_bit_t*b, unsigned nb, int signed_flag)
{
ref->base.vpi_type = &vpip_reg_rt;
ref->name = name;
ref->bits = b;
ref->nbits = nb;
ref->signed_flag = signed_flag? 1 : 0;
ref->mfirst = 0;
ref->mlast = 0;
return &(ref->base);
@ -122,6 +127,9 @@ vpiHandle vpip_make_reg(struct __vpiSignal*ref, const char*name,
/*
* $Log: vpi_signal.c,v $
* Revision 1.12 2001/01/06 22:22:17 steve
* Support signed decimal display of variables.
*
* Revision 1.11 2000/08/20 17:49:05 steve
* Clean up warnings and portability issues.
*