Take numbers as system task parameters.
This commit is contained in:
parent
ce66498c88
commit
003f103408
11
vvp/parse.y
11
vvp/parse.y
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: parse.y,v 1.15 2001/04/01 06:40:45 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.16 2001/04/02 00:24:30 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -256,10 +256,10 @@ argument_list
|
|||
argument
|
||||
: T_STRING
|
||||
{ $$ = vpip_make_string_const($1); }
|
||||
| T_NUMBER
|
||||
{ $$ = vpip_make_binary_const($1); }
|
||||
| T_SYMBOL
|
||||
{ $$ = compile_vpi_lookup($1);
|
||||
free($1);
|
||||
}
|
||||
{ $$ = compile_vpi_lookup($1); free($1); }
|
||||
;
|
||||
|
||||
|
||||
|
|
@ -308,6 +308,9 @@ int compile_design(const char*path)
|
|||
|
||||
/*
|
||||
* $Log: parse.y,v $
|
||||
* Revision 1.16 2001/04/02 00:24:30 steve
|
||||
* Take numbers as system task parameters.
|
||||
*
|
||||
* Revision 1.15 2001/04/01 06:40:45 steve
|
||||
* Support empty statements for hanging labels.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,11 +17,12 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_const.cc,v 1.1 2001/03/18 04:35:18 steve Exp $"
|
||||
#ident "$Id: vpi_const.cc,v 1.2 2001/04/02 00:24:31 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
# include <malloc.h>
|
||||
# include <string.h>
|
||||
# include <assert.h>
|
||||
|
||||
static int string_get(int code, vpiHandle ref)
|
||||
|
|
@ -82,8 +83,74 @@ vpiHandle vpip_make_string_const(char*text)
|
|||
}
|
||||
|
||||
|
||||
static int binary_get(int code, vpiHandle ref)
|
||||
{
|
||||
struct __vpiBinaryConst*rfp = (struct __vpiBinaryConst*)ref;
|
||||
assert(ref->vpi_type->type_code == vpiConstant);
|
||||
|
||||
switch (code) {
|
||||
case vpiConstType:
|
||||
return vpiBinaryConst;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void binary_value(vpiHandle ref, p_vpi_value vp)
|
||||
{
|
||||
struct __vpiStringConst*rfp = (struct __vpiStringConst*)ref;
|
||||
assert(ref->vpi_type->type_code == vpiConstant);
|
||||
|
||||
switch (vp->format) {
|
||||
|
||||
default:
|
||||
vp->format = vpiSuppressVal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const struct __vpirt vpip_binary_rt = {
|
||||
vpiConstant,
|
||||
binary_get,
|
||||
0,
|
||||
binary_value,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
vpiHandle vpip_make_binary_const(long val)
|
||||
{
|
||||
struct __vpiBinaryConst*obj;
|
||||
|
||||
obj = (struct __vpiBinaryConst*)
|
||||
malloc(sizeof (struct __vpiBinaryConst));
|
||||
obj->base.vpi_type = &vpip_binary_rt;
|
||||
|
||||
obj->nbits = 8*sizeof(long);
|
||||
obj->bits = (unsigned char*)malloc(obj->nbits / 4);
|
||||
memset(obj->bits, 0, obj->nbits / 4);
|
||||
|
||||
for (unsigned idx = 0 ; idx < obj->nbits ; idx += 1) {
|
||||
unsigned nibble = idx / 4;
|
||||
|
||||
if (val & 1)
|
||||
obj->bits[nibble] |= 1 << 2 * (idx%4);
|
||||
|
||||
val >>= 1;
|
||||
}
|
||||
|
||||
return &(obj->base);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log: vpi_const.cc,v $
|
||||
* Revision 1.2 2001/04/02 00:24:31 steve
|
||||
* Take numbers as system task parameters.
|
||||
*
|
||||
* Revision 1.1 2001/03/18 04:35:18 steve
|
||||
* Add support for string constants to VPI.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.h,v 1.8 2001/03/31 19:00:44 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.9 2001/04/02 00:24:31 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -145,6 +145,13 @@ struct __vpiStringConst {
|
|||
|
||||
vpiHandle vpip_make_string_const(char*text);
|
||||
|
||||
struct __vpiBinaryConst {
|
||||
struct __vpiHandle base;
|
||||
unsigned nbits;
|
||||
unsigned char*bits;
|
||||
};
|
||||
|
||||
vpiHandle vpip_make_binary_const(long val);
|
||||
|
||||
/*
|
||||
* This function is called before any compilation to load VPI
|
||||
|
|
@ -184,6 +191,9 @@ vpiHandle vpip_sim_time(void);
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.9 2001/04/02 00:24:31 steve
|
||||
* Take numbers as system task parameters.
|
||||
*
|
||||
* Revision 1.8 2001/03/31 19:00:44 steve
|
||||
* Add VPI support for the simulation time.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue