File: libvpi.c

package info (click to toggle)
iverilog 12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,148 kB
  • sloc: cpp: 109,972; ansic: 62,713; yacc: 10,216; sh: 3,470; vhdl: 3,246; perl: 1,814; makefile: 1,774; python: 78; csh: 2
file content (303 lines) | stat: -rw-r--r-- 7,295 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/*
 * Copyright (c) 2019 Martin Whitaker (icarus@martin-whitaker.me.uk)
 *
 *    This source code is free software; you can redistribute it
 *    and/or modify it in source code form under the terms of the GNU
 *    General Public License as published by the Free Software
 *    Foundation; either version 2 of the License, or (at your option)
 *    any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#if defined(__MINGW32__) || defined (__CYGWIN__)

#include "vpi_user.h"
#include <assert.h>

static vpip_routines_s*vpip_routines = 0;

// callback related

vpiHandle vpi_register_cb(p_cb_data data)
{
      assert(vpip_routines);
      return vpip_routines->register_cb(data);
}
PLI_INT32 vpi_remove_cb(vpiHandle ref)
{
      assert(vpip_routines);
      return vpip_routines->remove_cb(ref);
}

vpiHandle vpi_register_systf(const struct t_vpi_systf_data*ss)
{
      assert(vpip_routines);
      return vpip_routines->register_systf(ss);
}
void vpi_get_systf_info(vpiHandle obj, p_vpi_systf_data data)
{
      assert(vpip_routines);
      vpip_routines->get_systf_info(obj, data);
}

// for obtaining handles

vpiHandle vpi_handle_by_name(const char*name, vpiHandle scope)
{
      assert(vpip_routines);
      return vpip_routines->handle_by_name(name, scope);
}
vpiHandle vpi_handle_by_index(vpiHandle ref, PLI_INT32 idx)
{
      assert(vpip_routines);
      return vpip_routines->handle_by_index(ref, idx);
}

// for traversing relationships

vpiHandle vpi_handle(PLI_INT32 type, vpiHandle ref)
{
      assert(vpip_routines);
      return vpip_routines->handle(type, ref);
}
vpiHandle vpi_iterate(PLI_INT32 type, vpiHandle ref)
{
      assert(vpip_routines);
      return vpip_routines->iterate(type, ref);
}
vpiHandle vpi_scan(vpiHandle iter)
{
      assert(vpip_routines);
      return vpip_routines->scan(iter);
}

// for processing properties

PLI_INT32 vpi_get(int property, vpiHandle ref)
{
      assert(vpip_routines);
      return vpip_routines->get(property, ref);
}
char*vpi_get_str(PLI_INT32 property, vpiHandle ref)
{
      assert(vpip_routines);
      return vpip_routines->get_str(property, ref);
}

// delay processing

void vpi_get_delays(vpiHandle expr, p_vpi_delay delays)
{
      assert(vpip_routines);
      vpip_routines->get_delays(expr, delays);
}
void vpi_put_delays(vpiHandle expr, p_vpi_delay delays)
{
      assert(vpip_routines);
      vpip_routines->put_delays(expr, delays);
}

// value processing

void vpi_get_value(vpiHandle expr, p_vpi_value value)
{
      assert(vpip_routines);
      vpip_routines->get_value(expr, value);
}
vpiHandle vpi_put_value(vpiHandle obj, p_vpi_value value, p_vpi_time when, PLI_INT32 flags)
{
      assert(vpip_routines);
      return vpip_routines->put_value(obj, value, when, flags);
}

// time processing

void vpi_get_time(vpiHandle obj, s_vpi_time*t)
{
      assert(vpip_routines);
      vpip_routines->get_time(obj, t);
}

// data processing

void*vpi_get_userdata(vpiHandle obj)
{
      assert(vpip_routines);
      return vpip_routines->get_userdata(obj);
}
PLI_INT32 vpi_put_userdata(vpiHandle obj, void*data)
{
      assert(vpip_routines);
      return vpip_routines->put_userdata(obj, data);
}

// I/O routines

PLI_UINT32 vpi_mcd_open(char*name)
{
      assert(vpip_routines);
      return vpip_routines->mcd_open(name);
}
PLI_UINT32 vpi_mcd_close(PLI_UINT32 mcd)
{
      assert(vpip_routines);
      return vpip_routines->mcd_close(mcd);
}
PLI_INT32 vpi_mcd_flush(PLI_UINT32 mcd)
{
      assert(vpip_routines);
      return vpip_routines->mcd_flush(mcd);
}
char*vpi_mcd_name(PLI_UINT32 mcd)
{
      assert(vpip_routines);
      return vpip_routines->mcd_name(mcd);
}
PLI_INT32 vpi_mcd_printf(PLI_UINT32 mcd, const char*fmt, ...)
{
      va_list ap;
      va_start(ap, fmt);
      assert(vpip_routines);
      PLI_INT32 rv = vpip_routines->mcd_vprintf(mcd, fmt, ap);
      va_end(ap);
      return rv;
}
PLI_INT32 vpi_mcd_vprintf(PLI_UINT32 mcd, const char*fmt, va_list ap)
{
      assert(vpip_routines);
      return vpip_routines->mcd_vprintf(mcd, fmt, ap);
}

PLI_INT32 vpi_flush(void)
{
      assert(vpip_routines);
      return vpip_routines->flush();
}
PLI_INT32 vpi_printf(const char*fmt, ...)
{
      va_list ap;
      va_start(ap, fmt);
      assert(vpip_routines);
      PLI_INT32 rv = vpip_routines->vprintf(fmt, ap);
      va_end(ap);
      return rv;
}
PLI_INT32 vpi_vprintf(const char*fmt, va_list ap)
{
      assert(vpip_routines);
      return vpip_routines->vprintf(fmt, ap);
}

// utility routines

PLI_INT32 vpi_chk_error(p_vpi_error_info info)
{
      assert(vpip_routines);
      return vpip_routines->chk_error(info);
}
PLI_INT32 vpi_compare_objects(vpiHandle obj1, vpiHandle obj2)
{
      assert(vpip_routines);
      return vpip_routines->compare_objects(obj1, obj2);
}
PLI_INT32 vpi_free_object(vpiHandle ref)
{
      assert(vpip_routines);
      return vpip_routines->free_object(ref);
}
PLI_INT32 vpi_get_vlog_info(p_vpi_vlog_info info)
{
      assert(vpip_routines);
      return vpip_routines->get_vlog_info(info);

}

// control routines

void vpi_control(PLI_INT32 operation, ...)
{
      va_list ap;
      va_start(ap, operation);
      assert(vpip_routines);
      vpip_routines->vcontrol(operation, ap);
      va_end(ap);
}
void vpi_sim_control(PLI_INT32 operation, ...)
{
      va_list ap;
      va_start(ap, operation);
      assert(vpip_routines);
      vpip_routines->vcontrol(operation, ap);
      va_end(ap);
}

// proposed standard extensions

PLI_INT32 vpi_fopen(const char*name, const char*mode)
{
      assert(vpip_routines);
      return vpip_routines->fopen(name, mode);
}
FILE*vpi_get_file(PLI_INT32 fd)
{
      assert(vpip_routines);
      return vpip_routines->get_file(fd);
}

// Icarus extensions

s_vpi_vecval vpip_calc_clog2(vpiHandle arg)
{
      assert(vpip_routines);
      return vpip_routines->calc_clog2(arg);
}
void vpip_count_drivers(vpiHandle ref, unsigned idx, unsigned counts[4])
{
      assert(vpip_routines);
      vpip_routines->count_drivers(ref, idx, counts);
}
void vpip_format_strength(char*str, s_vpi_value*value, unsigned bit)
{
      assert(vpip_routines);
      vpip_routines->format_strength(str, value, bit);
}
void vpip_make_systf_system_defined(vpiHandle ref)
{
      assert(vpip_routines);
      vpip_routines->make_systf_system_defined(ref);
}
void vpip_mcd_rawwrite(PLI_UINT32 mcd, const char*buf, size_t count)
{
      assert(vpip_routines);
      vpip_routines->mcd_rawwrite(mcd, buf, count);
}
void vpip_set_return_value(int value)
{
      assert(vpip_routines);
      vpip_routines->set_return_value(value);
}

DLLEXPORT PLI_UINT32 vpip_set_callback(vpip_routines_s*routines, PLI_UINT32 version)
{
      if (version != vpip_routines_version)
            return 0;

      vpip_routines = routines;
      return 1;
}

#else

void __libvpi_c_dummy_function(void)
{
}

#endif