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)
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
20 #ident "$Id: putp.c,v 1.7 2004/09/10 23:13:05 steve Exp $"
24 # include <veriuser.h>
25 # include <vpi_user.h>
29 * tf_putp and friends implemented using VPI interface
31 PLI_INT32
tf_iputp(PLI_INT32 n
, PLI_INT32 value
, void *obj
)
33 vpiHandle sys_h
, sys_i
, arg_h
= 0;
39 /* get task/func handle */
40 sys_h
= (vpiHandle
)obj
;
41 type
= vpi_get(vpiType
, sys_h
);
43 /* Special case, we are putting the return value. */
44 if ((type
== vpiSysFuncCall
) && (n
== 0)) {
45 val
.format
= vpiIntVal
;
46 val
.value
.integer
= value
;
47 vpi_put_value(sys_h
, &val
, 0, vpiNoDelay
);
50 fprintf(pli_trace
, "tf_iputp(<return>, value=%d, func=%s) "
51 "--> %d\n", value
, vpi_get_str(vpiName
, obj
), 0);
57 if ((n
== 0) && (type
!= vpiSysFuncCall
)) {
59 fprintf(pli_trace
, "tf_iputp(<ERROR>, value=%d, func=%s) "
60 "--> %d\n", value
, vpi_get_str(vpiName
, obj
), 1);
66 sys_i
= vpi_iterate(vpiArgument
, sys_h
);
70 if (!(arg_h
= vpi_scan(sys_i
))) { rtn
= 1; goto out
; }
74 /* fill in vpi_value */
75 val
.format
= vpiIntVal
;
76 val
.value
.integer
= value
;
77 vpi_put_value(arg_h
, &val
, 0, vpiNoDelay
);
80 vpi_free_object(sys_i
);
84 fprintf(pli_trace
, "tf_iputp(n=%d, value=%d, obj=%p) --> %d\n",
91 PLI_INT32
tf_putp(PLI_INT32 n
, PLI_INT32 value
)
93 int rtn
= tf_iputp(n
, value
, vpi_handle(vpiSysTfCall
, 0));
99 PLI_INT32
tf_iputrealp(PLI_INT32 n
, double value
, void *obj
)
101 vpiHandle sys_h
, sys_i
, arg_h
= 0;
107 /* get task/func handle */
108 sys_h
= (vpiHandle
)obj
;
109 sys_i
= vpi_iterate(vpiArgument
, sys_h
);
111 type
= vpi_get(vpiType
, sys_h
);
113 /* verify function */
114 if (n
== 0 && type
!= vpiSysFuncCall
) { rtn
= 1; goto free
; }
118 if (!(arg_h
= vpi_scan(sys_i
))) { rtn
= 1; goto out
; }
121 if (!arg_h
) arg_h
= sys_h
;
123 /* fill in vpi_value */
124 val
.format
= vpiRealVal
;
125 val
.value
.real
= value
;
126 vpi_put_value(arg_h
, &val
, 0, vpiNoDelay
);
129 vpi_free_object(sys_i
);
133 fprintf(pli_trace
, "tf_iputrealp(n=%d, value=%f, obj=%p) --> %d\n",
140 PLI_INT32
tf_putrealp(PLI_INT32 n
, double value
)
142 int rtn
= tf_iputrealp(n
, value
, vpi_handle(vpiSysTfCall
, 0));
148 * Revision 1.7 2004/09/10 23:13:05 steve
149 * Compile cleanup of C code.
151 * Revision 1.6 2003/06/26 03:20:24 steve
152 * Correct handle of put to function return value.
154 * Revision 1.5 2003/06/17 16:55:08 steve
155 * 1) setlinebuf() for vpi_trace
156 * 2) Addes error checks for trace file opens
157 * 3) removes now extraneous flushes
158 * 4) fixes acc_next() bug
160 * Revision 1.4 2003/05/29 03:46:21 steve
161 * Add tf_getp/putp support for integers
162 * and real valued arguments.
164 * Add tf_mipname function.
166 * Revision 1.3 2003/03/15 05:42:39 steve
167 * free argument iterators.
169 * Revision 1.2 2002/08/12 01:35:02 steve
170 * conditional ident string using autoconfig.
172 * Revision 1.1 2002/06/07 16:21:13 steve
173 * Add tf_putlongp and tf_putp.