Clean up warnings for round() function declaration.
[iverilog.git] / libveriuser / a_fetch_tfarg.c
blob4962ce467912dd1d242d912d35833dc6e3939dbe
1 /* vi:sw=6
2 * Copyright (c) 2002,2003 Michael Ruff (mruff at chiaro.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_tfarg.c,v 1.10 2004/10/04 01:10:56 steve Exp $"
21 #endif
23 #include <vpi_user.h>
24 #include <acc_user.h>
25 #include "priv.h"
28 * acc_fetch_tfarg and friends implemented using VPI interface
30 double acc_fetch_itfarg(PLI_INT32 n, handle obj)
32 vpiHandle iter, hand = 0;
33 s_vpi_value value;
34 int idx = n;
35 double rtn;
37 iter = vpi_iterate(vpiArgument, obj);
39 /* scan to nth argument */
40 while (idx > 0 && (hand = vpi_scan(iter))) idx--;
42 if (hand) {
43 value.format=vpiRealVal;
44 vpi_get_value(hand, &value);
45 rtn = value.value.real;
46 vpi_free_object(iter);
47 } else {
48 rtn = 0.0;
51 if (pli_trace) {
52 fprintf(pli_trace, "%s: acc_fetch_itfarg(%d, %p) --> %f\n",
53 vpi_get_str(vpiName, obj), n, obj, rtn);
56 return rtn;
59 double acc_fetch_tfarg(PLI_INT32 n)
61 return acc_fetch_itfarg_int(n, vpi_handle(vpiSysTfCall,0));
65 PLI_INT32 acc_fetch_itfarg_int(PLI_INT32 n, handle obj)
67 vpiHandle iter, hand = 0;
68 s_vpi_value value;
69 int idx = n;
70 int rtn;
72 iter = vpi_iterate(vpiArgument, obj);
74 /* scan to nth argument */
75 while (idx > 0 && (hand = vpi_scan(iter))) idx--;
77 if (hand) {
78 value.format=vpiIntVal;
79 vpi_get_value(hand, &value);
80 rtn = value.value.integer;
81 vpi_free_object(iter);
82 } else {
83 rtn = 0;
86 if (pli_trace) {
87 fprintf(pli_trace, "%s: acc_fetch_itfarg_int(%d, %p) --> %d\n",
88 vpi_get_str(vpiName, obj), n, obj, rtn);
91 return rtn;
94 PLI_INT32 acc_fetch_tfarg_int(PLI_INT32 n)
96 return acc_fetch_itfarg_int(n, vpi_handle(vpiSysTfCall,0));
100 char *acc_fetch_itfarg_str(PLI_INT32 n, handle obj)
102 vpiHandle iter, hand = 0;
103 s_vpi_value value;
104 int idx = n;
105 char *rtn;
107 iter = vpi_iterate(vpiArgument, obj);
109 /* scan to nth argument */
110 while (idx > 0 && (hand = vpi_scan(iter))) idx -= 1;
112 if (hand) {
113 value.format=vpiStringVal;
114 vpi_get_value(hand, &value);
115 rtn = __acc_newstring(value.value.str);
116 vpi_free_object(iter);
117 } else {
118 rtn = (char *) 0;
121 if (pli_trace) {
122 fprintf(pli_trace, "%s: acc_fetch_itfarg_str(%d, %p) --> \"%s\"\n",
123 vpi_get_str(vpiName, obj),
124 n, obj, rtn? rtn : "");
127 return rtn;
130 char *acc_fetch_tfarg_str(PLI_INT32 n)
132 return acc_fetch_itfarg_str(n, vpi_handle(vpiSysTfCall,0));
136 * $Log: a_fetch_tfarg.c,v $
137 * Revision 1.10 2004/10/04 01:10:56 steve
138 * Clean up spurious trailing white space.
140 * Revision 1.9 2004/02/18 02:51:59 steve
141 * Fix type mismatches of various VPI functions.
143 * Revision 1.8 2003/06/14 01:16:17 steve
144 * ihand is system task, not scope.
146 * Revision 1.7 2003/06/13 19:23:42 steve
147 * Add a bunch more PLI1 routines.
149 * Revision 1.6 2003/05/18 00:16:35 steve
150 * Add PLI_TRACE tracing of PLI1 modules.
152 * Add tf_isetdelay and friends, and add
153 * callback return values for acc_vcl support.
155 * Revision 1.5 2003/03/14 04:58:50 steve
156 * Free the iterator when Im done.
158 * Revision 1.4 2003/03/13 04:35:09 steve
159 * Add a bunch of new acc_ and tf_ functions.
161 * Revision 1.3 2003/02/17 06:39:47 steve
162 * Add at least minimal implementations for several
163 * acc_ functions. Add support for standard ACC
164 * string handling.
166 * Add the _pli_types.h header file to carry the
167 * IEEE1364-2001 standard PLI type declarations.
169 * Revision 1.2 2002/08/12 01:35:02 steve
170 * conditional ident string using autoconfig.
172 * Revision 1.1 2002/06/07 02:58:58 steve
173 * Add a bunch of acc/tf functions. (mruff)