Clean up warnings for round() function declaration.
[iverilog.git] / libveriuser / a_fetch_value.c
blobdc65ee007bdb879f62ce1a3ea1a9dfdf164e27c4
1 /*
2 * Copyright (c) 2003 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: a_fetch_value.c,v 1.5 2003/06/17 16:55:07 steve Exp $"
21 #endif
23 # include <acc_user.h>
24 # include <vpi_user.h>
25 # include "priv.h"
26 # include <assert.h>
27 # include <string.h>
29 static char* fetch_struct_value(handle obj, s_acc_value*value)
31 struct t_vpi_value val;
33 switch (value->format) {
35 case accScalarVal:
36 val.format = vpiScalarVal;
37 vpi_get_value(obj, &val);
38 switch (val.value.scalar) {
39 case vpi0:
40 value->value.scalar = acc0;
41 break;
42 case vpi1:
43 value->value.scalar = acc1;
44 break;
45 case vpiX:
46 value->value.scalar = accX;
47 break;
48 case vpiZ:
49 value->value.scalar = accZ;
50 break;
51 default:
52 assert(0);
55 if (pli_trace) {
56 fprintf(pli_trace, "acc_fetch_value(<%s>, "
57 "accScalarVal) --> %d\n",
58 vpi_get_str(vpiFullName,obj),
59 value->value.scalar);
61 break;
63 case accIntVal:
64 val.format = vpiIntVal;
65 vpi_get_value(obj, &val);
66 value->value.integer = val.value.integer;
68 if (pli_trace) {
69 fprintf(pli_trace, "acc_fetch_value(<%s>, "
70 "accIntVal) --> %d\n",
71 vpi_get_str(vpiFullName,obj),
72 value->value.integer);
74 break;
76 case accRealVal:
77 val.format = vpiRealVal;
78 vpi_get_value(obj, &val);
79 value->value.real = val.value.real;
81 if (pli_trace) {
82 fprintf(pli_trace, "acc_fetch_value(<%s>, "
83 "accRealVal) --> %g\n",
84 vpi_get_str(vpiFullName,obj),
85 value->value.real);
87 break;
89 default:
90 vpi_printf("XXXX acc_fetch_value(..., \"%%%%\", <%d>);\n",
91 value->format);
92 value->value.str = "<string value>";
93 break;
96 return 0;
99 static char* fetch_strength_value(handle obj)
101 struct t_vpi_value val;
102 char str[4];
104 val.format = vpiStrengthVal;
105 vpi_get_value(obj, &val);
107 vpip_format_strength(str, &val);
109 if (pli_trace) {
110 fprintf(pli_trace, "acc_fetch_value(<%s>, \"%%v\") --> %s\n",
111 vpi_get_str(vpiFullName,obj), str);
114 return __acc_newstring(str);
117 char* acc_fetch_value(handle obj, const char*fmt, s_acc_value*value)
119 if (strcmp(fmt, "%%") == 0)
120 return fetch_struct_value(obj, value);
122 if (strcmp(fmt, "%v") == 0)
123 return fetch_strength_value(obj);
125 vpi_printf("XXXX acc_fetch_value(..., \"%s\", ...)\n", fmt);
126 return "<acc_fetch_value>";
131 * $Log: a_fetch_value.c,v $
132 * Revision 1.5 2003/06/17 16:55:07 steve
133 * 1) setlinebuf() for vpi_trace
134 * 2) Addes error checks for trace file opens
135 * 3) removes now extraneous flushes
136 * 4) fixes acc_next() bug
138 * Revision 1.4 2003/05/18 00:16:35 steve
139 * Add PLI_TRACE tracing of PLI1 modules.
141 * Add tf_isetdelay and friends, and add
142 * callback return values for acc_vcl support.
144 * Revision 1.3 2003/04/24 02:02:37 steve
145 * Clean up some simple warnings.
147 * Revision 1.2 2003/04/20 02:49:07 steve
148 * acc_fetch_value support for %v format.
150 * Revision 1.1 2003/04/12 18:57:14 steve
151 * More acc_ function stubs.