Add support for text macros with arguments.
[iverilog.git] / libveriuser / a_object_of_type.c
blob09299f1375a1e88e90eec75e2dfb011e5354d7c6
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_object_of_type.c,v 1.6 2004/02/18 02:51:59 steve Exp $"
21 #endif
23 #include <assert.h>
24 #include <vpi_user.h>
25 #include <acc_user.h>
26 #include "priv.h"
29 * acc_object_of_type implemented using VPI interface
31 int acc_object_of_type(handle object, PLI_INT32 type)
33 int vtype;
34 int rtn = 0; /* false */
36 if (pli_trace) {
37 fprintf(pli_trace, "acc_object_of_type(%p \"%s\", %d)",
38 object, vpi_get_str(vpiName, object), type);
39 fflush(pli_trace);
42 /* get VPI type of object */
43 vtype = vpi_get(vpiType, object);
45 switch (type) {
46 case accModule: rtn = vtype == vpiModule; break;
48 case accScope:
49 if (vtype == vpiModule || vtype == vpiNamedBegin ||
50 vtype == vpiNamedFork || vtype == vpiTask ||
51 vtype == vpiFunction) rtn = 1;
52 break;
54 case accNet: rtn = vtype == vpiNet; break;
55 case accReg: rtn = vtype == vpiReg; break;
57 case accRealParam:
58 if (vtype == vpiNamedEvent &&
59 vpi_get(vpiConstType, object) == vpiRealConst)
60 rtn = 1;
61 break;
63 case accParameter: rtn = vtype == vpiParameter; break;
64 case accNamedEvent: rtn = vtype == vpiNamedEvent; break;
65 case accIntegerVar: rtn = vtype == vpiIntegerVar; break;
66 case accRealVar: rtn = vtype == vpiRealVar; break;
67 case accTimeVar: rtn = vtype == vpiTimeVar; break;
69 case accScalar:
70 if (vtype == vpiReg || vtype == vpiNet)
71 rtn = vpi_get(vpiSize, object) == 1;
72 break;
74 case accVector:
75 if (vtype == vpiReg || vtype == vpiNet)
76 rtn = vpi_get(vpiSize, object) > 1;
77 break;
79 default:
80 vpi_printf("acc_object_of_type: Unknown type %d\n", type);
81 rtn = 0;
84 if (pli_trace) fprintf(pli_trace, " --> %d\n", rtn);
86 return rtn;
89 int acc_object_in_typelist(handle object, PLI_INT32*typelist)
91 while (typelist[0] != 0) {
92 int rtn = acc_object_of_type(object, typelist[0]);
93 if (rtn)
94 return rtn;
96 typelist += 1;
99 return 0;
103 * $Log: a_object_of_type.c,v $
104 * Revision 1.6 2004/02/18 02:51:59 steve
105 * Fix type mismatches of various VPI functions.
107 * Revision 1.5 2003/06/04 01:56:20 steve
108 * 1) Adds configure logic to clean up compiler warnings
109 * 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and
110 * tf_isetrealdelay, acc_handle_scope
111 * 3) makes acc_next reentrant
112 * 4) adds basic vpiWire type support
113 * 5) fills in some acc_object_of_type() and acc_fetch_{full}type()
114 * 6) add vpiLeftRange/RigthRange to signals
116 * Revision 1.4 2003/05/30 04:18:31 steve
117 * Add acc_next function.
119 * Revision 1.3 2003/02/17 06:39:47 steve
120 * Add at least minimal implementations for several
121 * acc_ functions. Add support for standard ACC
122 * string handling.
124 * Add the _pli_types.h header file to carry the
125 * IEEE1364-2001 standard PLI type declarations.
127 * Revision 1.2 2002/08/12 01:35:02 steve
128 * conditional ident string using autoconfig.
130 * Revision 1.1 2002/06/07 02:58:58 steve
131 * Add a bunch of acc/tf functions. (mruff)