iverilog/libveriuser/a_fetch_value.c

102 lines
2.6 KiB
C
Raw Normal View History

2003-04-12 20:57:13 +02:00
/*
* 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
2003-04-24 04:02:37 +02:00
#ident "$Id: a_fetch_value.c,v 1.3 2003/04/24 02:02:37 steve Exp $"
2003-04-12 20:57:13 +02:00
#endif
# include <acc_user.h>
# include <vpi_user.h>
# include "priv.h"
# include <assert.h>
2003-04-24 04:02:37 +02:00
# include <string.h>
2003-04-12 20:57:13 +02:00
static char* fetch_struct_value(handle obj, s_acc_value*value)
{
struct t_vpi_value val;
switch (value->format) {
case accScalarVal:
val.format = vpiScalarVal;
vpi_get_value(obj, &val);
value->value.scalar = val.value.scalar;
break;
case accIntVal:
val.format = vpiIntVal;
vpi_get_value(obj, &val);
value->value.integer = val.value.integer;
break;
case accRealVal:
val.format = vpiRealVal;
vpi_get_value(obj, &val);
value->value.real = val.value.real;
break;
default:
vpi_printf("XXXX acc_fetch_value(..., \"%%%%\", <%d>);\n",
value->format);
value->value.str = "<string value>";
break;
}
return 0;
}
static char* fetch_strength_value(handle obj)
{
struct t_vpi_value val;
2003-04-20 04:49:07 +02:00
char str[4];
2003-04-12 20:57:13 +02:00
val.format = vpiStrengthVal;
vpi_get_value(obj, &val);
2003-04-20 04:49:07 +02:00
vpip_format_strength(str, &val);
return __acc_newstring(str);
2003-04-12 20:57:13 +02:00
}
char* acc_fetch_value(handle obj, const char*fmt, s_acc_value*value)
{
if (strcmp(fmt, "%%") == 0)
return fetch_struct_value(obj, value);
2003-04-20 04:49:07 +02:00
if (strcmp(fmt, "%v") == 0)
return fetch_strength_value(obj);
2003-04-12 20:57:13 +02:00
vpi_printf("XXXX acc_fetch_value(..., \"%s\", ...)\n", fmt);
return "<acc_fetch_value>";
}
/*
* $Log: a_fetch_value.c,v $
2003-04-24 04:02:37 +02:00
* Revision 1.3 2003/04/24 02:02:37 steve
* Clean up some simple warnings.
*
2003-04-20 04:49:07 +02:00
* Revision 1.2 2003/04/20 02:49:07 steve
* acc_fetch_value support for %v format.
*
2003-04-12 20:57:13 +02:00
* Revision 1.1 2003/04/12 18:57:14 steve
* More acc_ function stubs.
*
*/