Pad Octal string value correctly.
This patch changes the base oct to string converter to correctly pad the top digit. x or xx should display as a single lower case x when they are located in the top bits. Before these were being interpreted as 00x or 0xx and displayed X. Also modified the hex conversion to use this same scheme instead of a loop.
This commit is contained in:
parent
69ba009439
commit
6321fb6a92
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2002-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -16,9 +16,6 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpip_hex.cc,v 1.4 2006/02/21 02:39:27 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -140,21 +137,24 @@ void vpip_vec4_to_hex_str(const vvp_vector4_t&bits, char*buf,
|
|||
}
|
||||
}
|
||||
|
||||
if (slen > 0) {
|
||||
unsigned padd = 0;
|
||||
/* Fill in X or Z if they are the only thing in the value. */
|
||||
switch (bits.size() % 4) {
|
||||
case 1:
|
||||
if (val == 2) val = 170;
|
||||
else if (val == 3) val = 255;
|
||||
break;
|
||||
case 2:
|
||||
if (val == 10) val = 170;
|
||||
else if (val == 15) val = 255;
|
||||
break;
|
||||
case 3:
|
||||
if (val == 42) val = 170;
|
||||
else if (val == 63) val = 255;
|
||||
break;
|
||||
}
|
||||
|
||||
if (slen > 0) {
|
||||
slen -= 1;
|
||||
buf[slen] = hex_digits[val];
|
||||
switch(buf[slen]) {
|
||||
case 'X': padd = 2; break;
|
||||
case 'Z': padd = 3; break;
|
||||
}
|
||||
if (padd) {
|
||||
for (unsigned idx = bits.size() % 4; idx < 4; idx += 1) {
|
||||
val = val | padd << 2*idx;
|
||||
}
|
||||
buf[slen] = hex_digits[val];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2002-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -16,9 +16,6 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpip_oct.cc,v 1.4 2006/02/21 02:39:27 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -120,9 +117,20 @@ void vpip_vec4_to_oct_str(const vvp_vector4_t&bits, char*buf, unsigned nbuf,
|
|||
}
|
||||
}
|
||||
|
||||
/* Fill in X or Z if they are the only thing in the value. */
|
||||
switch (bits.size() % 3) {
|
||||
case 1:
|
||||
if (val == 2) val = 42;
|
||||
else if (val == 3) val = 63;
|
||||
break;
|
||||
case 2:
|
||||
if (val == 10) val = 42;
|
||||
else if (val == 15) val = 63;
|
||||
break;
|
||||
}
|
||||
|
||||
if (slen > 0) {
|
||||
slen -= 1;
|
||||
buf[slen] = oct_digits[val];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue