From 6321fb6a92f2434aa7c7a9268c4271b9baff8dd6 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 16 Jun 2008 10:43:17 -0700 Subject: [PATCH] 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. --- vvp/vpip_hex.cc | 34 +++++++++++++++++----------------- vvp/vpip_oct.cc | 18 +++++++++++++----- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/vvp/vpip_hex.cc b/vvp/vpip_hex.cc index 3ef3056cd..9c6a6a2e4 100644 --- a/vvp/vpip_hex.cc +++ b/vvp/vpip_hex.cc @@ -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]; - } } } - diff --git a/vvp/vpip_oct.cc b/vvp/vpip_oct.cc index e8a1ac057..f60e87b24 100644 --- a/vvp/vpip_oct.cc +++ b/vvp/vpip_oct.cc @@ -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]; } } -