Skip to content

Commit

Permalink
Implement vpi_put_value for signals.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Apr 25, 2001
1 parent c997c09 commit aec5841
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 9 deletions.
37 changes: 32 additions & 5 deletions vpi_user.h
Expand Up @@ -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.2 2001/03/22 02:23:17 steve Exp $"
#ident "$Id: vpi_user.h,v 1.3 2001/04/25 04:45:52 steve Exp $"
#endif


Expand All @@ -30,9 +30,15 @@
#endif

#ifdef __cplusplus
extern "C" {
# define EXTERN_C_START extern "C" {
# define EXTERN_C_END }
#else
# define EXTERN_C_START
# define EXTERN_C_END
#endif

EXTERN_C_START

typedef struct __vpiHandle *vpiHandle;

/*
Expand Down Expand Up @@ -253,6 +259,26 @@ extern void vpi_get_time(vpiHandle obj, s_vpi_time*t);
extern int vpi_get(int property, vpiHandle ref);
extern char* vpi_get_str(int property, vpiHandle ref);
extern void vpi_get_value(vpiHandle expr, p_vpi_value value);

/*
* This function puts a value into the object referenced by the
* handle. This assumes that the value supports having its value
* written to. The time parameter specifies when the assignment is to
* take place. This allows you to schedule an assignment to happen in
* the future.
*
* The flags value specifies the delay model to use in assigning the
* value. This specifies how the time value is to be used.
*
* vpiNoDelay -- Set the value immediately. The p_vpi_time parameter
* may be NULL, in this case. This is like a blocking assignment
* in behavioral code.
*
* vpiInertialDelay -- Set the value using the transport delay. The
* p_vpi_time parameter is required and specifies when the
* assignment is to take place. This is like a non-blocking
* assignment in behavioral code.
*/
extern vpiHandle vpi_put_value(vpiHandle obj, p_vpi_value value,
p_vpi_time when, int flags);

Expand All @@ -263,12 +289,13 @@ extern int vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p);
/* This is the table of startup routines included in each module. */
extern DLLEXPORT void (*vlog_startup_routines[])();

#ifdef __cplusplus
}
#endif
EXTERN_C_END

/*
* $Log: vpi_user.h,v $
* Revision 1.3 2001/04/25 04:45:52 steve
* Implement vpi_put_value for signals.
*
* Revision 1.2 2001/03/22 02:23:17 steve
* fgetc patch from Peter Monta.
*
Expand Down
68 changes: 64 additions & 4 deletions vvp/vpi_signal.cc
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_signal.cc,v 1.7 2001/04/05 01:34:26 steve Exp $"
#ident "$Id: vpi_signal.cc,v 1.8 2001/04/25 04:45:52 steve Exp $"
#endif

/*
Expand Down Expand Up @@ -246,15 +246,72 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
* equivilent instruction would cause.
*/
static vpiHandle signal_put_value(vpiHandle ref, s_vpi_value*vp,
p_vpi_time when, int flags)
p_vpi_time when, int flags)
{
assert((ref->vpi_type->type_code==vpiNet)
|| (ref->vpi_type->type_code==vpiReg));

struct __vpiSignal*rfp = (struct __vpiSignal*)ref;

/* XXXX Not implemented yet. */
assert(0);
/* XXXX delays are not yet supported. */
assert(flags == vpiNoDelay);

unsigned wid = (rfp->msb >= rfp->lsb)
? (rfp->msb - rfp->lsb + 1)
: (rfp->lsb - rfp->msb + 1);

switch (vp->format) {

case vpiScalarVal:
switch (vp->value.scalar) {
case vpi0:
functor_set(rfp->bits, 0, true);
break;
case vpi1:
functor_set(rfp->bits, 1, true);
break;
case vpiX:
functor_set(rfp->bits, 2, true);
break;
case vpiZ:
functor_set(rfp->bits, 3, true);
break;
default:
assert(0);
}
break;

case vpiVectorVal: {
assert(wid <= sizeof (unsigned long));

unsigned long aval = vp->value.vector->aval;
unsigned long bval = vp->value.vector->bval;
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
int bit = (aval&1) | ((bval<<1)&2);
switch (bit) {
case 0: /* zero */
functor_set(ipoint_index(rfp->bits,idx), 0, true);
break;
case 1: /* one */
functor_set(ipoint_index(rfp->bits,idx), 1, true);
break;
case 2: /* z */
functor_set(ipoint_index(rfp->bits,idx), 3, true);
break;
case 3: /* x */
functor_set(ipoint_index(rfp->bits,idx), 2, true);
break;
}
aval >>= 1;
bval >>= 1;
}
break;
}

default:
assert(0);

}

return ref;
}
Expand Down Expand Up @@ -326,6 +383,9 @@ vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,

/*
* $Log: vpi_signal.cc,v $
* Revision 1.8 2001/04/25 04:45:52 steve
* Implement vpi_put_value for signals.
*
* Revision 1.7 2001/04/05 01:34:26 steve
* Add the .var/s and .net/s statements for VPI support.
*
Expand Down

0 comments on commit aec5841

Please sign in to comment.