Get the $strobe task working.
This commit is contained in:
parent
3fe0344246
commit
8d806d538b
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: sys_display.c,v 1.6 1999/10/29 03:37:22 steve Exp $"
|
||||
#ident "$Id: sys_display.c,v 1.7 1999/11/06 22:16:50 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -236,9 +236,178 @@ static int sys_display_calltf(char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int format_str(char*fmt, int argc, vpiHandle*argv)
|
||||
{
|
||||
s_vpi_value value;
|
||||
char buf[256];
|
||||
char*cp = fmt;
|
||||
int idx;
|
||||
|
||||
assert(fmt);
|
||||
|
||||
idx = 0;
|
||||
|
||||
while (*cp) {
|
||||
size_t cnt = strcspn(cp, "%\\");
|
||||
if (cnt > 0) {
|
||||
if (cnt >= sizeof buf)
|
||||
cnt = sizeof buf - 1;
|
||||
strncpy(buf, cp, cnt);
|
||||
buf[cnt] = 0;
|
||||
vpi_printf("%s", buf);
|
||||
cp += cnt;
|
||||
|
||||
} else if (*cp == '%') {
|
||||
int fsize = -1;
|
||||
|
||||
cp += 1;
|
||||
if (isdigit(*cp))
|
||||
fsize = strtoul(cp, &cp, 10);
|
||||
|
||||
switch (*cp) {
|
||||
case 0:
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
value.format = vpiBinStrVal;
|
||||
vpi_get_value(argv[idx++], &value);
|
||||
vpi_printf("%s", value.value.str);
|
||||
cp += 1;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
value.format = vpiDecStrVal;
|
||||
vpi_get_value(argv[idx++], &value);
|
||||
vpi_printf("%s", value.value.str);
|
||||
cp += 1;
|
||||
break;
|
||||
case 'h':
|
||||
case 'H':
|
||||
case 'x':
|
||||
case 'X':
|
||||
value.format = vpiHexStrVal;
|
||||
vpi_get_value(argv[idx++], &value);
|
||||
vpi_printf("%s", value.value.str);
|
||||
cp += 1;
|
||||
break;
|
||||
case 'm':
|
||||
vpi_printf("%s",
|
||||
vpi_get_str(vpiFullName, argv[idx++]));
|
||||
cp += 1;
|
||||
break;
|
||||
case 'o':
|
||||
case 'O':
|
||||
value.format = vpiOctStrVal;
|
||||
vpi_get_value(argv[idx++], &value);
|
||||
vpi_printf("%s", value.value.str);
|
||||
cp += 1;
|
||||
break;
|
||||
case 't':
|
||||
case 'T':
|
||||
value.format = vpiDecStrVal;
|
||||
vpi_get_value(argv[idx++], &value);
|
||||
vpi_printf("%s", value.value.str);
|
||||
cp += 1;
|
||||
break;
|
||||
case '%':
|
||||
vpi_printf("%%");
|
||||
cp += 1;
|
||||
break;
|
||||
default:
|
||||
vpi_printf("%c", *cp);
|
||||
cp += 1;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
cp += 1;
|
||||
switch (*cp) {
|
||||
case 0:
|
||||
break;
|
||||
case 'n':
|
||||
vpi_printf("\n");
|
||||
cp += 1;
|
||||
break;
|
||||
default:
|
||||
vpi_printf("%c", *cp);
|
||||
cp += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*
|
||||
* The strobe implementation takes the parameter handles that are
|
||||
* passed to the calltf and puts them in to an array for safe
|
||||
* keeping. That array (and other bookkeeping) is passed, via the
|
||||
* struct_cb_info object, to the REadOnlySych function strobe_cb,
|
||||
* where it is use to perform the actual formatting and printing.
|
||||
*/
|
||||
struct strobe_cb_info {
|
||||
char*name;
|
||||
vpiHandle*items;
|
||||
unsigned nitems;
|
||||
};
|
||||
|
||||
static int strobe_cb(p_cb_data cb)
|
||||
{
|
||||
vpi_printf("%s NOT IMPLEMENTED YET\n", cb->user_data);
|
||||
s_vpi_value value;
|
||||
unsigned idx;
|
||||
struct strobe_cb_info*info = (struct strobe_cb_info*)cb->user_data;
|
||||
|
||||
|
||||
for (idx = 0 ; idx < info->nitems ; idx += 1) {
|
||||
vpiHandle item = info->items[idx];
|
||||
|
||||
switch (vpi_get(vpiType, item)) {
|
||||
|
||||
case 0:
|
||||
vpi_printf(" ");
|
||||
break;
|
||||
|
||||
case vpiConstant:
|
||||
if (vpi_get(vpiConstType, item) == vpiStringConst) {
|
||||
value.format = vpiStringVal;
|
||||
vpi_get_value(item, &value);
|
||||
idx += format_str(value.value.str,
|
||||
info->nitems-idx-1,
|
||||
info->items+1);
|
||||
} else {
|
||||
value.format = vpiBinStrVal;
|
||||
vpi_get_value(item, &value);
|
||||
vpi_printf("%s", value.value.str);
|
||||
}
|
||||
break;
|
||||
|
||||
case vpiNet:
|
||||
case vpiReg:
|
||||
value.format = vpiBinStrVal;
|
||||
vpi_get_value(item, &value);
|
||||
vpi_printf("%s", value.value.str);
|
||||
break;
|
||||
|
||||
case vpiTimeVar:
|
||||
value.format = vpiTimeVal;
|
||||
vpi_get_value(item, &value);
|
||||
vpi_printf("%u", value.value.time->low);
|
||||
break;
|
||||
|
||||
default:
|
||||
vpi_printf("?");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vpi_printf("\n");
|
||||
|
||||
free(info->name);
|
||||
free(info->items);
|
||||
free(info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -246,6 +415,27 @@ static int sys_strobe_calltf(char*name)
|
|||
{
|
||||
struct t_cb_data cb;
|
||||
struct t_vpi_time time;
|
||||
struct strobe_cb_info*info;
|
||||
|
||||
vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
|
||||
|
||||
vpiHandle argv = vpi_iterate(vpiArgument, sys);
|
||||
vpiHandle item;
|
||||
|
||||
vpiHandle*items;
|
||||
unsigned nitems = 1;
|
||||
items = malloc(sizeof(vpiHandle));
|
||||
items[0] = vpi_scan(argv);
|
||||
for (item = vpi_scan(argv) ; item ; item = vpi_scan(argv)) {
|
||||
items = realloc(items, (nitems+1)*sizeof(vpiHandle));
|
||||
items[nitems] = item;
|
||||
nitems += 1;
|
||||
}
|
||||
|
||||
info = calloc(1, sizeof(struct strobe_cb_info));
|
||||
info->name = strdup(name);
|
||||
info->items = items;
|
||||
info->nitems = nitems;
|
||||
|
||||
time.type = vpiSimTime;
|
||||
time.low = 0;
|
||||
|
|
@ -255,7 +445,7 @@ static int sys_strobe_calltf(char*name)
|
|||
cb.cb_rtn = strobe_cb;
|
||||
cb.time = &time;
|
||||
cb.obj = 0;
|
||||
cb.user_data = name;
|
||||
cb.user_data = (char*)info;
|
||||
vpi_register_cb(&cb);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -275,16 +465,6 @@ static int sys_monitor_calltf(char*name)
|
|||
|
||||
switch (vpi_get(vpiType, item)) {
|
||||
|
||||
case vpiNet:
|
||||
case vpiReg:
|
||||
cb.reason = cbValueChange;
|
||||
cb.cb_rtn = strobe_cb;
|
||||
cb.time = &time;
|
||||
cb.obj = item;
|
||||
cb.user_data = name;
|
||||
vpi_register_cb(&cb);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -334,6 +514,9 @@ void sys_display_register()
|
|||
|
||||
/*
|
||||
* $Log: sys_display.c,v $
|
||||
* Revision 1.7 1999/11/06 22:16:50 steve
|
||||
* Get the $strobe task working.
|
||||
*
|
||||
* Revision 1.6 1999/10/29 03:37:22 steve
|
||||
* Support vpiValueChance callbacks.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_const.c,v 1.3 1999/11/06 16:52:16 steve Exp $"
|
||||
#ident "$Id: vpi_const.c,v 1.4 1999/11/06 22:16:50 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
|
|
@ -225,6 +225,20 @@ void vpip_bits_get_value(enum vpip_bit_t*bits, unsigned nbits, s_vpi_value*vp)
|
|||
vp->value.str = buff;
|
||||
}
|
||||
|
||||
static int string_get(int code, vpiHandle ref)
|
||||
{
|
||||
struct __vpiStringConst*rfp = (struct __vpiStringConst*)ref;
|
||||
assert(ref->vpi_type->type_code == vpiConstant);
|
||||
|
||||
switch (code) {
|
||||
case vpiConstType:
|
||||
return vpiStringConst;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void string_value(vpiHandle ref, p_vpi_value vp)
|
||||
{
|
||||
|
|
@ -244,6 +258,21 @@ static void string_value(vpiHandle ref, p_vpi_value vp)
|
|||
}
|
||||
}
|
||||
|
||||
static int number_get(int code, vpiHandle ref)
|
||||
{
|
||||
struct __vpiNumberConst*rfp = (struct __vpiNumberConst*)ref;
|
||||
assert(ref->vpi_type->type_code == vpiConstant);
|
||||
|
||||
switch (code) {
|
||||
case vpiConstType:
|
||||
return vpiBinaryConst;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void number_value(vpiHandle ref, p_vpi_value vp)
|
||||
{
|
||||
struct __vpiNumberConst*rfp = (struct __vpiNumberConst*)ref;
|
||||
|
|
@ -253,7 +282,7 @@ static void number_value(vpiHandle ref, p_vpi_value vp)
|
|||
|
||||
static const struct __vpirt vpip_string_rt = {
|
||||
vpiConstant,
|
||||
0,
|
||||
string_get,
|
||||
0,
|
||||
string_value,
|
||||
0,
|
||||
|
|
@ -262,7 +291,7 @@ static const struct __vpirt vpip_string_rt = {
|
|||
|
||||
static const struct __vpirt vpip_number_rt = {
|
||||
vpiConstant,
|
||||
0,
|
||||
number_get,
|
||||
0,
|
||||
number_value,
|
||||
0,
|
||||
|
|
@ -288,6 +317,9 @@ vpiHandle vpip_make_number_const(struct __vpiNumberConst*ref,
|
|||
|
||||
/*
|
||||
* $Log: vpi_const.c,v $
|
||||
* Revision 1.4 1999/11/06 22:16:50 steve
|
||||
* Get the $strobe task working.
|
||||
*
|
||||
* Revision 1.3 1999/11/06 16:52:16 steve
|
||||
* complete value retrieval for number constants.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue