Get intval from a binary constant.
This commit is contained in:
parent
0653f859bc
commit
9b7341889d
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue