2 * Copyright (c) 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: a_next.c,v 1.4 2006/10/30 22:45:37 steve Exp $"
29 * acc_next and friends implemented using VPI
31 handle
acc_next(PLI_INT32
*type
, handle scope
, handle prev
)
33 vpiHandle iter
, hand
= 0;
38 fprintf(pli_trace
, "acc_next(%p <", type
);
39 for (ip
= type
; *ip
; ip
++) {
40 fprintf(pli_trace
, "%s%d", ip
!= type
? "," : "", *ip
);
42 fprintf(pli_trace
, ">, %p", scope
);
44 fprintf(pli_trace
, " \"%s\"", vpi_get_str(vpiName
, scope
));
45 fprintf(pli_trace
, ", %p", prev
);
47 fprintf(pli_trace
, " \"%s\"", vpi_get_str(vpiName
, prev
));
49 fprintf(pli_trace
, ")");
54 * The acc_next_* functions need to be reentrant, so we need to
55 * rescan all the items upto the previous one, then return
58 iter
= vpi_iterate(vpiScope
, scope
); // ICARUS extension
60 while ((hand
= vpi_scan(iter
))) {
61 if (hand
== prev
) break;
67 while ((hand
= vpi_scan(iter
))) {
68 if (acc_object_in_typelist(hand
, type
))
73 /* don't leak iterators */
74 if (hand
) vpi_free_object(iter
);
78 fprintf(pli_trace
, " --> %p", hand
);
80 fprintf(pli_trace
, " \"%s\"\n", vpi_get_str(vpiName
, hand
));
82 fprintf(pli_trace
, "\n");
89 handle
acc_next_scope(handle scope
, handle prev
)
91 PLI_INT32 type
[2] = {accScope
, 0};
92 return acc_next(type
, scope
, prev
);
97 * Revision 1.4 2006/10/30 22:45:37 steve
98 * Updates for Cygwin portability (pr1585922)
100 * Revision 1.3 2003/06/17 16:55:07 steve
101 * 1) setlinebuf() for vpi_trace
102 * 2) Addes error checks for trace file opens
103 * 3) removes now extraneous flushes
104 * 4) fixes acc_next() bug
106 * Revision 1.2 2003/06/04 01:56:20 steve
107 * 1) Adds configure logic to clean up compiler warnings
108 * 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and
109 * tf_isetrealdelay, acc_handle_scope
110 * 3) makes acc_next reentrant
111 * 4) adds basic vpiWire type support
112 * 5) fills in some acc_object_of_type() and acc_fetch_{full}type()
113 * 6) add vpiLeftRange/RigthRange to signals
115 * Revision 1.1 2003/05/30 04:18:31 steve
116 * Add acc_next function.