From 9b7341889da9b446926b0933fff327d1e62bd2b5 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 4 Apr 2001 05:07:19 +0000 Subject: [PATCH] Get intval from a binary constant. --- vvp/vpi_const.cc | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index b468e483e..b080649f7 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_const.cc,v 1.3 2001/04/04 04:33:08 steve Exp $" +#ident "$Id: vpi_const.cc,v 1.4 2001/04/04 05:07:19 steve Exp $" #endif # include "vpi_priv.h" @@ -122,6 +122,27 @@ static void binary_value(vpiHandle ref, p_vpi_value vp) vp->format = vpiBinStrVal; break; + case vpiIntVal: { + unsigned val = 0; + int isx = 0; + + for (unsigned idx = 0 ; idx < rfp->nbits ; idx += 1) { + unsigned nibble = idx/4; + unsigned shift = 2 * (idx%4); + unsigned bit_val = (rfp->bits[nibble] >> shift) & 3; + val *= 2; + if (bit_val > 1) + isx = 1; + else + val |= bit_val; + } + if (isx) + vp->value.integer = 0; + else + vp->value.integer = val; + break; + } + default: fprintf(stderr, "vvp error: format %d not supported " "by vpiBinaryConst\n", vp->format); @@ -180,6 +201,9 @@ vpiHandle vpip_make_binary_const(unsigned wid, char*bits) /* * $Log: vpi_const.cc,v $ + * Revision 1.4 2001/04/04 05:07:19 steve + * Get intval from a binary constant. + * * Revision 1.3 2001/04/04 04:33:08 steve * Take vector form as parameters to vpi_call. *