acc_fetch_value support for %v format.
This commit is contained in:
parent
c75140592f
commit
299f6f8551
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: a_fetch_value.c,v 1.1 2003/04/12 18:57:14 steve Exp $"
|
#ident "$Id: a_fetch_value.c,v 1.2 2003/04/20 02:49:07 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include <acc_user.h>
|
# include <acc_user.h>
|
||||||
|
|
@ -62,12 +62,14 @@ static char* fetch_struct_value(handle obj, s_acc_value*value)
|
||||||
static char* fetch_strength_value(handle obj)
|
static char* fetch_strength_value(handle obj)
|
||||||
{
|
{
|
||||||
struct t_vpi_value val;
|
struct t_vpi_value val;
|
||||||
|
char str[4];
|
||||||
|
|
||||||
val.format = vpiStrengthVal;
|
val.format = vpiStrengthVal;
|
||||||
vpi_get_value(obj, &val);
|
vpi_get_value(obj, &val);
|
||||||
|
|
||||||
vpi_printf("XXXX acc_fetch_value(..., \"%%v\")\n");
|
vpip_format_strength(str, &val);
|
||||||
return __acc_newstring("StX");
|
|
||||||
|
return __acc_newstring(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* acc_fetch_value(handle obj, const char*fmt, s_acc_value*value)
|
char* acc_fetch_value(handle obj, const char*fmt, s_acc_value*value)
|
||||||
|
|
@ -75,6 +77,9 @@ char* acc_fetch_value(handle obj, const char*fmt, s_acc_value*value)
|
||||||
if (strcmp(fmt, "%%") == 0)
|
if (strcmp(fmt, "%%") == 0)
|
||||||
return fetch_struct_value(obj, value);
|
return fetch_struct_value(obj, value);
|
||||||
|
|
||||||
|
if (strcmp(fmt, "%v") == 0)
|
||||||
|
return fetch_strength_value(obj);
|
||||||
|
|
||||||
vpi_printf("XXXX acc_fetch_value(..., \"%s\", ...)\n", fmt);
|
vpi_printf("XXXX acc_fetch_value(..., \"%s\", ...)\n", fmt);
|
||||||
return "<acc_fetch_value>";
|
return "<acc_fetch_value>";
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +87,9 @@ char* acc_fetch_value(handle obj, const char*fmt, s_acc_value*value)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: a_fetch_value.c,v $
|
* $Log: a_fetch_value.c,v $
|
||||||
|
* Revision 1.2 2003/04/20 02:49:07 steve
|
||||||
|
* acc_fetch_value support for %v format.
|
||||||
|
*
|
||||||
* Revision 1.1 2003/04/12 18:57:14 steve
|
* Revision 1.1 2003/04/12 18:57:14 steve
|
||||||
* More acc_ function stubs.
|
* More acc_ function stubs.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: sys_display.c,v 1.56 2003/03/12 03:11:00 steve Exp $"
|
#ident "$Id: sys_display.c,v 1.57 2003/04/20 02:49:07 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -295,88 +295,11 @@ static void format_time_real(unsigned mcd, int fsize,
|
||||||
timeformat_info.suff);
|
timeformat_info.suff);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char str_char1_table[256] = {
|
|
||||||
".HS1M222" "W3333333" /* 00 0F */ "L4444444" "44444444" /* 10 1F */
|
|
||||||
"P5555555" "55555555" /* 20 2F */ "55555555" "55555555" /* 30 3F */
|
|
||||||
"S6666666" "66666666" /* 40 4F */ "66666666" "66666666" /* 50 5F */
|
|
||||||
"66666666" "66666666" /* 60 6F */ "66666666" "66666666" /* 70 7F */
|
|
||||||
"S7777777" "77777777" /* 80 8F */ "77777777" "77777777" /* 90 9F */
|
|
||||||
"77777777" "77777777" /* A0 AF */ "77777777" "77777777" /* B0 BF */
|
|
||||||
"77777777" "77777777" /* C0 CF */ "77777777" "77777777" /* D0 DF */
|
|
||||||
"77777777" "77777777" /* E0 EF */ "77777777" "77777777" /* F0 FF */ };
|
|
||||||
|
|
||||||
static const char str_char2_table[256] = {
|
|
||||||
".im0e010" "e0102010" /* 00 0F */ "a0102010" "30102010" /* 10 1F */
|
|
||||||
"u0102010" "30102010" /* 20 2F */ "40102010" "30102010" /* 30 3F */
|
|
||||||
"t0102010" "30102010" /* 40 4F */ "40102010" "30102010" /* 50 5F */
|
|
||||||
"50102010" "30102010" /* 60 6F */ "40102010" "30102010" /* 70 7F */
|
|
||||||
"u0102010" "30102010" /* 80 8F */ "40102010" "30102010" /* 90 9F */
|
|
||||||
"50102010" "30102010" /* A0 AF */ "40102010" "30102010" /* B0 BF */
|
|
||||||
"60102010" "30102010" /* C0 CF */ "40102010" "30102010" /* D0 DF */
|
|
||||||
"50102010" "30102010" /* E0 EF */ "40102010" "30102010" /* F0 FF */ };
|
|
||||||
|
|
||||||
static void format_strength(unsigned int mcd, s_vpi_value*value)
|
static void format_strength(unsigned int mcd, s_vpi_value*value)
|
||||||
{
|
{
|
||||||
char str[4];
|
char str[4];
|
||||||
|
vpip_format_strength(str, value);
|
||||||
str[0] = '.';
|
|
||||||
str[1] = '.';
|
|
||||||
str[2] = '.';
|
|
||||||
str[3] = 0;
|
|
||||||
|
|
||||||
|
|
||||||
switch (value->value.strength[0].logic) {
|
|
||||||
case vpi0:
|
|
||||||
str[0] = str_char1_table[value->value.strength[0].s0];
|
|
||||||
str[1] = str_char2_table[value->value.strength[0].s0];
|
|
||||||
str[2] = '0';
|
|
||||||
break;
|
|
||||||
case vpi1:
|
|
||||||
str[0] = str_char1_table[value->value.strength[0].s1];
|
|
||||||
str[1] = str_char2_table[value->value.strength[0].s1];
|
|
||||||
str[2] = '1';
|
|
||||||
break;
|
|
||||||
case vpiX:
|
|
||||||
if (value->value.strength[0].s0 == 1) {
|
|
||||||
str[0] = str_char1_table[value->value.strength[0].s1];
|
|
||||||
str[1] = str_char2_table[value->value.strength[0].s1];
|
|
||||||
str[2] = 'H';
|
|
||||||
} else if (value->value.strength[0].s1 == 1) {
|
|
||||||
str[0] = str_char1_table[value->value.strength[0].s0];
|
|
||||||
str[1] = str_char2_table[value->value.strength[0].s0];
|
|
||||||
str[2] = 'L';
|
|
||||||
} else if (value->value.strength[0].s1 ==
|
|
||||||
value->value.strength[0].s0) {
|
|
||||||
str[0] = str_char1_table[value->value.strength[0].s0];
|
|
||||||
str[1] = str_char2_table[value->value.strength[0].s0];
|
|
||||||
str[2] = 'X';
|
|
||||||
} else {
|
|
||||||
int ss;
|
|
||||||
|
|
||||||
str[0] = '0';
|
|
||||||
ss = value->value.strength[0].s0;
|
|
||||||
while (ss > 1) {
|
|
||||||
str[0] += 1;
|
|
||||||
ss >>= 1;
|
|
||||||
}
|
|
||||||
str[1] = '0';
|
|
||||||
ss = value->value.strength[0].s1;
|
|
||||||
while (ss > 1) {
|
|
||||||
str[1] += 1;
|
|
||||||
ss >>= 1;
|
|
||||||
}
|
|
||||||
str[2] = 'X';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case vpiZ:
|
|
||||||
str[0] = 'H';
|
|
||||||
str[1] = 'i';
|
|
||||||
str[2] = 'Z';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
vpi_mcd_printf(mcd, "%s", str);
|
vpi_mcd_printf(mcd, "%s", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1726,6 +1649,9 @@ void sys_display_register()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: sys_display.c,v $
|
* $Log: sys_display.c,v $
|
||||||
|
* Revision 1.57 2003/04/20 02:49:07 steve
|
||||||
|
* acc_fetch_value support for %v format.
|
||||||
|
*
|
||||||
* Revision 1.56 2003/03/12 03:11:00 steve
|
* Revision 1.56 2003/03/12 03:11:00 steve
|
||||||
* Donot rely on persistence of format string.
|
* Donot rely on persistence of format string.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
23
vpi_user.h
23
vpi_user.h
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: vpi_user.h,v 1.23 2003/03/13 18:26:12 steve Exp $"
|
#ident "$Id: vpi_user.h,v 1.24 2003/04/20 02:49:07 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -218,13 +218,12 @@ extern void vpi_register_systf(const struct t_vpi_systf_data*ss);
|
||||||
extern void vpi_printf(const char*fmt, ...)
|
extern void vpi_printf(const char*fmt, ...)
|
||||||
__attribute__((format (printf,1,2)));
|
__attribute__((format (printf,1,2)));
|
||||||
|
|
||||||
/* vpi_vprintf is non-standard. */
|
|
||||||
extern void vpi_vprintf(const char*fmt, va_list ap);
|
extern void vpi_vprintf(const char*fmt, va_list ap);
|
||||||
|
|
||||||
extern PLI_UINT32 vpi_mcd_close(unsigned int mcd);
|
extern PLI_UINT32 vpi_mcd_close(unsigned int mcd);
|
||||||
extern char *vpi_mcd_name(PLI_UINT32 mcd);
|
extern char *vpi_mcd_name(PLI_UINT32 mcd);
|
||||||
extern PLI_UINT32 vpi_mcd_open(char *name);
|
extern PLI_UINT32 vpi_mcd_open(char *name);
|
||||||
extern PLI_UINT32 vpi_mcd_open_x(char *name, char *mode);
|
extern PLI_UINT32 vpi_mcd_open_x(char *name, char *mode);
|
||||||
extern PLI_INT32 vpi_mcd_printf(unsigned int mcd, const char*fmt, ...)
|
extern PLI_INT32 vpi_mcd_printf(unsigned int mcd, const char*fmt, ...)
|
||||||
__attribute__((format (printf,2,3)));
|
__attribute__((format (printf,2,3)));
|
||||||
extern PLI_INT32 vpi_mcd_fputc(unsigned int mcd, unsigned char x);
|
extern PLI_INT32 vpi_mcd_fputc(unsigned int mcd, unsigned char x);
|
||||||
|
|
@ -370,10 +369,28 @@ extern PLI_INT32 vpi_chk_error(p_vpi_error_info info);
|
||||||
/* This is the table of startup routines included in each module. */
|
/* This is the table of startup routines included in each module. */
|
||||||
extern DLLEXPORT void (*vlog_startup_routines[])();
|
extern DLLEXPORT void (*vlog_startup_routines[])();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ICARUS VERILOG EXTENSIONS
|
||||||
|
*
|
||||||
|
* The vpip_* functions are Icarus Verilog extensions. They are not
|
||||||
|
* standard VPI functions, so use these at your own risk.
|
||||||
|
*
|
||||||
|
* The vpip_format_* functions format values in string format in the
|
||||||
|
* manner of the $display system task.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Format a scaler a la %v. The str points to a 4byte character
|
||||||
|
buffer. The value must be a vpiStrengthVal. */
|
||||||
|
extern void vpip_format_strength(char*str, s_vpi_value*value);
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_user.h,v $
|
* $Log: vpi_user.h,v $
|
||||||
|
* Revision 1.24 2003/04/20 02:49:07 steve
|
||||||
|
* acc_fetch_value support for %v format.
|
||||||
|
*
|
||||||
* Revision 1.23 2003/03/13 18:26:12 steve
|
* Revision 1.23 2003/03/13 18:26:12 steve
|
||||||
* Verilog 2001 standart types.
|
* Verilog 2001 standart types.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
# 59 Temple Place - Suite 330
|
# 59 Temple Place - Suite 330
|
||||||
# Boston, MA 02111-1307, USA
|
# Boston, MA 02111-1307, USA
|
||||||
#
|
#
|
||||||
#ident "$Id: Makefile.in,v 1.48 2003/03/13 04:36:57 steve Exp $"
|
#ident "$Id: Makefile.in,v 1.49 2003/04/20 02:49:07 steve Exp $"
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
@ -66,7 +66,7 @@ check: all
|
||||||
V = vpi_modules.o vpi_callback.o vpi_const.o vpi_event.o vpi_iter.o vpi_mcd.o \
|
V = vpi_modules.o vpi_callback.o vpi_const.o vpi_event.o vpi_iter.o vpi_mcd.o \
|
||||||
vpi_priv.o vpi_scope.o vpi_real.o vpi_signal.o vpi_tasks.o vpi_time.o \
|
vpi_priv.o vpi_scope.o vpi_real.o vpi_signal.o vpi_tasks.o vpi_time.o \
|
||||||
vpi_memory.o vpi_vthr_vector.o vpip_bin.o vpip_hex.o vpip_oct.o \
|
vpi_memory.o vpi_vthr_vector.o vpip_bin.o vpip_hex.o vpip_oct.o \
|
||||||
vpip_to_dec.o vvp_vpi.o
|
vpip_to_dec.o vpip_format.o vvp_vpi.o
|
||||||
|
|
||||||
O = main.o parse.o parse_misc.o lexor.o arith.o bufif.o compile.o \
|
O = main.o parse.o parse_misc.o lexor.o arith.o bufif.o compile.o \
|
||||||
functor.o fvectors.o npmos.o resolv.o stop.o symbols.o ufunc.o codes.o \
|
functor.o fvectors.o npmos.o resolv.o stop.o symbols.o ufunc.o codes.o \
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2003 Stephen Williams (steve@icarus.com)
|
||||||
|
*
|
||||||
|
* This source code is free software; you can redistribute it
|
||||||
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
* General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CVS_IDENT
|
||||||
|
#ident "$Id: vpip_format.c,v 1.1 2003/04/20 02:49:07 steve Exp $"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# include <vpi_user.h>
|
||||||
|
# include <assert.h>
|
||||||
|
|
||||||
|
static const char str_char1_table[256] = {
|
||||||
|
".HS1M222" "W3333333" /* 00 0F */ "L4444444" "44444444" /* 10 1F */
|
||||||
|
"P5555555" "55555555" /* 20 2F */ "55555555" "55555555" /* 30 3F */
|
||||||
|
"S6666666" "66666666" /* 40 4F */ "66666666" "66666666" /* 50 5F */
|
||||||
|
"66666666" "66666666" /* 60 6F */ "66666666" "66666666" /* 70 7F */
|
||||||
|
"S7777777" "77777777" /* 80 8F */ "77777777" "77777777" /* 90 9F */
|
||||||
|
"77777777" "77777777" /* A0 AF */ "77777777" "77777777" /* B0 BF */
|
||||||
|
"77777777" "77777777" /* C0 CF */ "77777777" "77777777" /* D0 DF */
|
||||||
|
"77777777" "77777777" /* E0 EF */ "77777777" "77777777" /* F0 FF */ };
|
||||||
|
|
||||||
|
static const char str_char2_table[256] = {
|
||||||
|
".im0e010" "e0102010" /* 00 0F */ "a0102010" "30102010" /* 10 1F */
|
||||||
|
"u0102010" "30102010" /* 20 2F */ "40102010" "30102010" /* 30 3F */
|
||||||
|
"t0102010" "30102010" /* 40 4F */ "40102010" "30102010" /* 50 5F */
|
||||||
|
"50102010" "30102010" /* 60 6F */ "40102010" "30102010" /* 70 7F */
|
||||||
|
"u0102010" "30102010" /* 80 8F */ "40102010" "30102010" /* 90 9F */
|
||||||
|
"50102010" "30102010" /* A0 AF */ "40102010" "30102010" /* B0 BF */
|
||||||
|
"60102010" "30102010" /* C0 CF */ "40102010" "30102010" /* D0 DF */
|
||||||
|
"50102010" "30102010" /* E0 EF */ "40102010" "30102010" /* F0 FF */ };
|
||||||
|
|
||||||
|
|
||||||
|
void vpip_format_strength(char*str, s_vpi_value*value)
|
||||||
|
{
|
||||||
|
str[0] = '.';
|
||||||
|
str[1] = '.';
|
||||||
|
str[2] = '.';
|
||||||
|
str[3] = 0;
|
||||||
|
|
||||||
|
assert(value->format == vpiStrengthVal);
|
||||||
|
|
||||||
|
switch (value->value.strength[0].logic) {
|
||||||
|
case vpi0:
|
||||||
|
str[0] = str_char1_table[value->value.strength[0].s0];
|
||||||
|
str[1] = str_char2_table[value->value.strength[0].s0];
|
||||||
|
str[2] = '0';
|
||||||
|
break;
|
||||||
|
case vpi1:
|
||||||
|
str[0] = str_char1_table[value->value.strength[0].s1];
|
||||||
|
str[1] = str_char2_table[value->value.strength[0].s1];
|
||||||
|
str[2] = '1';
|
||||||
|
break;
|
||||||
|
case vpiX:
|
||||||
|
if (value->value.strength[0].s0 == 1) {
|
||||||
|
str[0] = str_char1_table[value->value.strength[0].s1];
|
||||||
|
str[1] = str_char2_table[value->value.strength[0].s1];
|
||||||
|
str[2] = 'H';
|
||||||
|
} else if (value->value.strength[0].s1 == 1) {
|
||||||
|
str[0] = str_char1_table[value->value.strength[0].s0];
|
||||||
|
str[1] = str_char2_table[value->value.strength[0].s0];
|
||||||
|
str[2] = 'L';
|
||||||
|
} else if (value->value.strength[0].s1 ==
|
||||||
|
value->value.strength[0].s0) {
|
||||||
|
str[0] = str_char1_table[value->value.strength[0].s0];
|
||||||
|
str[1] = str_char2_table[value->value.strength[0].s0];
|
||||||
|
str[2] = 'X';
|
||||||
|
} else {
|
||||||
|
int ss;
|
||||||
|
|
||||||
|
str[0] = '0';
|
||||||
|
ss = value->value.strength[0].s0;
|
||||||
|
while (ss > 1) {
|
||||||
|
str[0] += 1;
|
||||||
|
ss >>= 1;
|
||||||
|
}
|
||||||
|
str[1] = '0';
|
||||||
|
ss = value->value.strength[0].s1;
|
||||||
|
while (ss > 1) {
|
||||||
|
str[1] += 1;
|
||||||
|
ss >>= 1;
|
||||||
|
}
|
||||||
|
str[2] = 'X';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case vpiZ:
|
||||||
|
str[0] = 'H';
|
||||||
|
str[1] = 'i';
|
||||||
|
str[2] = 'Z';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $Log: vpip_format.c,v $
|
||||||
|
* Revision 1.1 2003/04/20 02:49:07 steve
|
||||||
|
* acc_fetch_value support for %v format.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
@ -30,3 +30,5 @@ vpi_scan
|
||||||
vpi_sim_control
|
vpi_sim_control
|
||||||
vpi_sim_vcontrol
|
vpi_sim_vcontrol
|
||||||
vpi_vprintf
|
vpi_vprintf
|
||||||
|
|
||||||
|
vpip_format_strength
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue