Put strings for reg objects.

This commit is contained in:
steve 2006-02-21 05:31:54 +00:00
parent 170e57d662
commit 9c16c34422
3 changed files with 45 additions and 153 deletions

View File

@ -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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_priv.h,v 1.65 2006/02/21 02:39:27 steve Exp $" #ident "$Id: vpi_priv.h,v 1.66 2006/02/21 05:31:54 steve Exp $"
#endif #endif
# include "vpi_user.h" # include "vpi_user.h"
@ -399,7 +399,7 @@ extern unsigned vpip_vec4_to_dec_str(const vvp_vector4_t&vec4,
char *buf, unsigned int nbuf, char *buf, unsigned int nbuf,
int signed_flag); int signed_flag);
extern void vpip_bin_str_to_bits(unsigned char*bits, unsigned nbits, extern void vpip_bin_str_to_vec4(vvp_vector4_t&val,
const char*buf, bool signed_flag); const char*buf, bool signed_flag);
extern void vpip_vec4_to_hex_str(const vvp_vector4_t&bits, char*buf, extern void vpip_vec4_to_hex_str(const vvp_vector4_t&bits, char*buf,
@ -429,6 +429,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
/* /*
* $Log: vpi_priv.h,v $ * $Log: vpi_priv.h,v $
* Revision 1.66 2006/02/21 05:31:54 steve
* Put strings for reg objects.
*
* Revision 1.65 2006/02/21 02:39:27 steve * Revision 1.65 2006/02/21 02:39:27 steve
* Support string values for memory words. * Support string values for memory words.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001-2005 Stephen Williams (steve@icarus.com) * Copyright (c) 2001-2006 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_signal.cc,v 1.73 2006/02/21 02:39:27 steve Exp $" #ident "$Id: vpi_signal.cc,v 1.74 2006/02/21 05:31:54 steve Exp $"
#endif #endif
/* /*
@ -599,94 +599,18 @@ static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp)
} }
break; break;
#endif #endif
#if 0 case vpiBinStrVal:
case vpiBinStrVal: { vpip_bin_str_to_vec4(val, vp->value.str, false);
unsigned char*bits = new unsigned char[(wid+3) / 4];
vpip_bin_str_to_bits(bits, wid, vp->value.str, false);
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
unsigned bb = idx / 4;
unsigned bs = (idx % 4) * 2;
unsigned val = (bits[bb] >> bs) & 0x03;
switch (val) {
case 0: /* zero */
functor_poke(rfp,idx, 0, St0, 0);
break; break;
case 1: /* one */ case vpiOctStrVal:
functor_poke(rfp,idx, 1, St1, 0); vpip_oct_str_to_vec4(val, vp->value.str);
break; break;
case 2: /* x */ case vpiDecStrVal:
functor_poke(rfp,idx, 2, StX, 0); vpip_dec_str_to_vec4(val, vp->value.str, false);
break; break;
case 3: /* z */ case vpiHexStrVal:
functor_poke(rfp,idx, 3, HiZ, 0); vpip_hex_str_to_vec4(val, vp->value.str);
break; break;
}
}
delete[]bits;
break;
}
#endif
#if 0
case vpiOctStrVal: {
unsigned char*bits = new unsigned char[(wid+3) / 4];
vpip_oct_str_to_bits(bits, wid, vp->value.str, false);
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
unsigned bb = idx / 4;
unsigned bs = (idx % 4) * 2;
unsigned val = (bits[bb] >> bs) & 0x03;
switch (val) {
case 0: /* zero */
functor_poke(rfp,idx, 0, St0, 0);
break;
case 1: /* one */
functor_poke(rfp,idx, 1, St1, 0);
break;
case 2: /* x */
functor_poke(rfp,idx, 2, StX, 0);
break;
case 3: /* z */
functor_poke(rfp,idx, 3, HiZ, 0);
break;
}
}
delete[]bits;
break;
}
#endif
#if 0
case vpiDecStrVal: {
unsigned char*bits = new unsigned char[wid];
vpip_dec_str_to_bits(bits, wid, vp->value.str, false);
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
switch (bits[idx]) {
case 0: /* zero */
functor_poke(rfp,idx, 0, St0, 0);
break;
case 1: /* one */
functor_poke(rfp,idx, 1, St1, 0);
break;
case 2: /* x */
functor_poke(rfp,idx, 2, StX, 0);
break;
case 3: /* z */
functor_poke(rfp,idx, 3, HiZ, 0);
break;
}
}
delete[]bits;
break;
}
#endif
case vpiStringVal: case vpiStringVal:
val = from_stringval(vp->value.str, wid); val = from_stringval(vp->value.str, wid);
break; break;
@ -793,6 +717,9 @@ vpiHandle vpip_make_net(const char*name, int msb, int lsb,
/* /*
* $Log: vpi_signal.cc,v $ * $Log: vpi_signal.cc,v $
* Revision 1.74 2006/02/21 05:31:54 steve
* Put strings for reg objects.
*
* Revision 1.73 2006/02/21 02:39:27 steve * Revision 1.73 2006/02/21 02:39:27 steve
* Support string values for memory words. * Support string values for memory words.
* *

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002 Stephen Williams (steve@icarus.com) * Copyright (c) 2002-2006 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: vpip_bin.cc,v 1.2 2002/08/12 01:35:09 steve Exp $" #ident "$Id: vpip_bin.cc,v 1.3 2006/02/21 05:31:54 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -31,99 +31,61 @@
#endif #endif
# include <assert.h> # include <assert.h>
void vpip_bin_str_to_bits(unsigned char*bits, unsigned nbits, void vpip_bin_str_to_vec4(vvp_vector4_t&vec4,
const char*buf, bool signed_flag) const char*buf, bool signed_flag)
{ {
const char*ebuf = buf + strlen(buf); const char*ebuf = buf + strlen(buf);
unsigned char last = 0x00; vvp_bit4_t last = BIT4_0;
unsigned pos = 0;
for (unsigned idx = 0 ; idx < (nbits+3)/4 ; idx += 1)
bits[idx] = 0;
unsigned idx = 0;
while (ebuf > buf) { while (ebuf > buf) {
unsigned val; vvp_bit4_t val;
if (nbits == 0) if (idx == vec4.size())
break; break;
ebuf -= 1; ebuf -= 1;
switch (*ebuf) { switch (*ebuf) {
case '0': val = 0x00; break; case '0': val = BIT4_0; break;
case '1': val = 0x01; break; case '1': val = BIT4_1; break;
case 'x': case 'x':
case 'X': val = 0x02; break; case 'X': val = BIT4_X; break;
case 'z': case 'z':
case 'Z': val = 0x03; break; case 'Z': val = BIT4_Z; break;
default: val = 0x00; break; default: val = BIT4_0; break;
} }
last = val; last = val;
switch (pos) { vec4.set_bit(idx, val);
case 0: idx += 1;
bits[0] = val;
pos = 1;
break;
case 1:
bits[0] |= val << 2;
pos = 2;
break;
case 2:
bits[0] |= val << 4;
pos = 3;
break;
case 3:
bits[0] |= val << 6;
bits += 1;
pos = 0;
}
nbits -= 1;
} }
/* Calculate the pad value based on the top bit and the signed /* Calculate the pad value based on the top bit and the signed
flag. We may sign extend or zero extend. */ flag. We may sign extend or zero extend. */
switch (last) { switch (last) {
case 0: case 0:
last = 0x00; last = BIT4_0;
break; break;
case 1: case 1:
last = signed_flag? 0x01 : 0x00; last = signed_flag? BIT4_1 : BIT4_0;
break; break;
case 2: case 2:
last = 0x02; last = BIT4_X;
break; break;
case 3: case 3:
last = 0x03; last = BIT4_Z;
break; break;
} }
while (nbits > 0) switch (pos) { while (idx < vec4.size())
case 0: vec4.set_bit(idx, last);
bits[0] = last;
nbits -= 1;
pos = 1;
break;
case 1:
bits[0] |= last << 2;
nbits -= 1;
pos = 2;
break;
case 2:
bits[0] |= last << 4;
bits -= 1;
pos = 3;
case 3:
bits[0] |= last << 6;
nbits -= 1;
bits += 1;
pos = 0;
}
} }
/* /*
* $Log: vpip_bin.cc,v $ * $Log: vpip_bin.cc,v $
* Revision 1.3 2006/02/21 05:31:54 steve
* Put strings for reg objects.
*
* Revision 1.2 2002/08/12 01:35:09 steve * Revision 1.2 2002/08/12 01:35:09 steve
* conditional ident string using autoconfig. * conditional ident string using autoconfig.
* *