Support writing scalars and vectors to signals.

This commit is contained in:
steve 2000-05-18 03:27:32 +00:00
parent a96fa80ccc
commit 0f13af2ea1
4 changed files with 95 additions and 7 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_user.h,v 1.16 2000/05/07 18:20:08 steve Exp $"
#ident "$Id: vpi_user.h,v 1.17 2000/05/18 03:27:32 steve Exp $"
#endif
#ifdef __cplusplus
@ -86,7 +86,7 @@ typedef struct t_vpi_value {
#define vpiOctStrVal 2
#define vpiDecStrVal 3
#define vpiHexStrVal 4
#define vpiScalerVal 5
#define vpiScalarVal 5
#define vpiIntVal 6
#define vpiReadVal 7
#define vpiStringVal 8
@ -97,6 +97,16 @@ typedef struct t_vpi_value {
#define vpiSuppressVal 13
/* SCALAR VALUES */
#define vpi0 0
#define vpi1 1
#define vpiZ 2
#define vpiX 3
#define vpiH 4
#define vpiL 5
#define vpiDontCare 6
/* OBJECT CODES */
#define vpiConstant 7
#define vpiFunction 20
@ -236,6 +246,9 @@ extern void (*vlog_startup_routines[])();
/*
* $Log: vpi_user.h,v $
* Revision 1.17 2000/05/18 03:27:32 steve
* Support writing scalars and vectors to signals.
*
* Revision 1.16 2000/05/07 18:20:08 steve
* Import MCD support from Stephen Tell, and add
* system function parameter support to the IVL core.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_const.c,v 1.8 2000/05/07 18:20:08 steve Exp $"
#ident "$Id: vpi_const.c,v 1.9 2000/05/18 03:27:32 steve Exp $"
#endif
# include "vpi_priv.h"
@ -223,6 +223,60 @@ void vpip_bits_get_value(vpip_bit_t*bits, unsigned nbits, s_vpi_value*vp)
}
}
void vpip_bits_set_value(vpip_bit_t*bits, unsigned nbits, s_vpi_value*vp)
{
switch (vp->format) {
case vpiScalarVal:
switch (vp->value.scalar) {
case vpi0:
bits[0] = St0;
break;
case vpi1:
bits[0] = St1;
break;
case vpiX:
bits[1] = StX;
break;
case vpiZ:
bits[0] = HiZ;
break;
default:
assert(0);
}
break;
case vpiVectorVal: {
unsigned long aval = vp->value.vector->aval;
unsigned long bval = vp->value.vector->bval;
int idx;
for (idx = 0 ; idx < nbits ; idx += 1) {
int bit = (aval&1) | ((bval<<1)&2);
switch (bit) {
case 0:
bits[idx] = St0;
break;
case 1:
bits[idx] = St1;
break;
case 2:
bits[idx] = HiZ;
break;
case 3:
bits[idx] = StX;
break;
}
aval >>= 1;
bval >>= 1;
}
break;
}
default:
assert(0);
}
}
static int string_get(int code, vpiHandle ref)
{
struct __vpiStringConst*rfp = (struct __vpiStringConst*)ref;
@ -317,6 +371,9 @@ vpiHandle vpip_make_number_const(struct __vpiNumberConst*ref,
/*
* $Log: vpi_const.c,v $
* Revision 1.9 2000/05/18 03:27:32 steve
* Support writing scalars and vectors to signals.
*
* Revision 1.8 2000/05/07 18:20:08 steve
* Import MCD support from Stephen Tell, and add
* system function parameter support to the IVL core.

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_priv.h,v 1.20 2000/05/11 01:37:33 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.21 2000/05/18 03:27:32 steve Exp $"
#endif
/*
@ -113,6 +113,8 @@ extern vpip_bit_t vpip_bits_resolve(const vpip_bit_t*bits, unsigned nbits);
extern void vpip_bits_get_value(vpip_bit_t*bits, unsigned nbits,
s_vpi_value*vp);
extern void vpip_bits_set_value(vpip_bit_t*bits, unsigned nbits,
s_vpi_value*vp);
/*
* This structure is the very base of a vpiHandle. Every handle
@ -377,6 +379,9 @@ extern int vpip_finished();
/*
* $Log: vpi_priv.h,v $
* Revision 1.21 2000/05/18 03:27:32 steve
* Support writing scalars and vectors to signals.
*
* Revision 1.20 2000/05/11 01:37:33 steve
* Calculate the X output value from drive0 and drive1
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_signal.c,v 1.9 2000/03/31 07:08:39 steve Exp $"
#ident "$Id: vpi_signal.c,v 1.10 2000/05/18 03:27:32 steve Exp $"
#endif
# include "vpi_priv.h"
@ -65,12 +65,22 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
vpip_bits_get_value(rfp->bits, rfp->nbits, vp);
}
static void signal_put_value(vpiHandle ref, s_vpi_value*vp,
p_vpi_time when, int flags)
{
struct __vpiSignal*rfp = (struct __vpiSignal*)ref;
assert((ref->vpi_type->type_code==vpiNet)
|| (ref->vpi_type->type_code==vpiReg));
vpip_bits_set_value(rfp->bits, rfp->nbits, vp);
}
static const struct __vpirt vpip_net_rt = {
vpiNet,
signal_get,
signal_get_str,
signal_get_value,
0,
signal_put_value,
0,
0
};
@ -92,7 +102,7 @@ static const struct __vpirt vpip_reg_rt = {
signal_get,
signal_get_str,
signal_get_value,
0,
signal_put_value,
0,
0
};
@ -111,6 +121,9 @@ vpiHandle vpip_make_reg(struct __vpiSignal*ref, const char*name,
/*
* $Log: vpi_signal.c,v $
* Revision 1.10 2000/05/18 03:27:32 steve
* Support writing scalars and vectors to signals.
*
* Revision 1.9 2000/03/31 07:08:39 steve
* allow cancelling of cbValueChange events.
*