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)
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: a_fetch_value.c,v 1.5 2003/06/17 16:55:07 steve Exp $"
23 # include <acc_user.h>
24 # include <vpi_user.h>
29 static char* fetch_struct_value(handle obj
, s_acc_value
*value
)
31 struct t_vpi_value val
;
33 switch (value
->format
) {
36 val
.format
= vpiScalarVal
;
37 vpi_get_value(obj
, &val
);
38 switch (val
.value
.scalar
) {
40 value
->value
.scalar
= acc0
;
43 value
->value
.scalar
= acc1
;
46 value
->value
.scalar
= accX
;
49 value
->value
.scalar
= accZ
;
56 fprintf(pli_trace
, "acc_fetch_value(<%s>, "
57 "accScalarVal) --> %d\n",
58 vpi_get_str(vpiFullName
,obj
),
64 val
.format
= vpiIntVal
;
65 vpi_get_value(obj
, &val
);
66 value
->value
.integer
= val
.value
.integer
;
69 fprintf(pli_trace
, "acc_fetch_value(<%s>, "
70 "accIntVal) --> %d\n",
71 vpi_get_str(vpiFullName
,obj
),
72 value
->value
.integer
);
77 val
.format
= vpiRealVal
;
78 vpi_get_value(obj
, &val
);
79 value
->value
.real
= val
.value
.real
;
82 fprintf(pli_trace
, "acc_fetch_value(<%s>, "
83 "accRealVal) --> %g\n",
84 vpi_get_str(vpiFullName
,obj
),
90 vpi_printf("XXXX acc_fetch_value(..., \"%%%%\", <%d>);\n",
92 value
->value
.str
= "<string value>";
99 static char* fetch_strength_value(handle obj
)
101 struct t_vpi_value val
;
104 val
.format
= vpiStrengthVal
;
105 vpi_get_value(obj
, &val
);
107 vpip_format_strength(str
, &val
);
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.