1 |
54 |
alirezamon |
/* -*- C -*-
|
2 |
|
|
*
|
3 |
|
|
* svdpi.h
|
4 |
|
|
*
|
5 |
|
|
* SystemVerilog Direct Programming Interface (DPI).
|
6 |
|
|
*
|
7 |
|
|
* This file contains the constant definitions, structure definitions,
|
8 |
|
|
* and routine declarations used by SystemVerilog DPI.
|
9 |
|
|
*
|
10 |
|
|
* This file is from the SystemVerilog IEEE 1800-2012 Annex I.
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
|
|
#ifndef INCLUDED_SVDPI
|
14 |
|
|
#define INCLUDED_SVDPI
|
15 |
|
|
|
16 |
|
|
#ifdef __cplusplus
|
17 |
|
|
extern "C" {
|
18 |
|
|
#endif
|
19 |
|
|
|
20 |
|
|
/* Define size-critical types on all OS platforms. */
|
21 |
|
|
#if defined (_MSC_VER)
|
22 |
|
|
typedef unsigned __int64 uint64_t;
|
23 |
|
|
typedef unsigned __int32 uint32_t;
|
24 |
|
|
typedef unsigned __int8 uint8_t;
|
25 |
|
|
typedef signed __int64 int64_t;
|
26 |
|
|
typedef signed __int32 int32_t;
|
27 |
|
|
typedef signed __int8 int8_t;
|
28 |
|
|
#elif defined(__MINGW32__)
|
29 |
|
|
#include <stdint.h>
|
30 |
|
|
#elif defined(__APPLE__)
|
31 |
|
|
#include <stdint.h>
|
32 |
|
|
#elif defined(__linux)
|
33 |
|
|
#include <inttypes.h>
|
34 |
|
|
#else
|
35 |
|
|
#include <sys/types.h>
|
36 |
|
|
#endif
|
37 |
|
|
|
38 |
|
|
/* Use to import a symbol into dll */
|
39 |
|
|
#ifndef DPI_DLLISPEC
|
40 |
|
|
#if (defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__))
|
41 |
|
|
#define DPI_DLLISPEC __declspec(dllimport)
|
42 |
|
|
#else
|
43 |
|
|
#define DPI_DLLISPEC
|
44 |
|
|
#endif
|
45 |
|
|
#endif
|
46 |
|
|
|
47 |
|
|
/* Use to export a symbol from dll */
|
48 |
|
|
#ifndef DPI_DLLESPEC
|
49 |
|
|
#if (defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__))
|
50 |
|
|
#define DPI_DLLESPEC __declspec(dllexport)
|
51 |
|
|
#else
|
52 |
|
|
#define DPI_DLLESPEC
|
53 |
|
|
#endif
|
54 |
|
|
#endif
|
55 |
|
|
|
56 |
|
|
/* Use to mark a function as external */
|
57 |
|
|
#ifndef DPI_EXTERN
|
58 |
|
|
#define DPI_EXTERN
|
59 |
|
|
#endif
|
60 |
|
|
|
61 |
|
|
#ifndef DPI_PROTOTYPES
|
62 |
|
|
#define DPI_PROTOTYPES
|
63 |
|
|
/* object is defined imported by the application */
|
64 |
|
|
#define XXTERN DPI_EXTERN DPI_DLLISPEC
|
65 |
|
|
/* object is exported by the application */
|
66 |
|
|
#define EETERN DPI_EXTERN DPI_DLLESPEC
|
67 |
|
|
#endif
|
68 |
|
|
|
69 |
|
|
/* canonical representation */
|
70 |
|
|
#define sv_0 0
|
71 |
|
|
#define sv_1 1
|
72 |
|
|
#define sv_z 2
|
73 |
|
|
#define sv_x 3
|
74 |
|
|
|
75 |
|
|
/* common type for 'bit' and 'logic' scalars. */
|
76 |
|
|
typedef uint8_t svScalar;
|
77 |
|
|
typedef svScalar svBit; /* scalar */
|
78 |
|
|
typedef svScalar svLogic; /* scalar */
|
79 |
|
|
|
80 |
|
|
/*
|
81 |
|
|
* DPI representation of packed arrays.
|
82 |
|
|
* 2-state and 4-state vectors, exactly the same as PLI's avalue/bvalue.
|
83 |
|
|
*/
|
84 |
|
|
#ifndef VPI_VECVAL
|
85 |
|
|
#define VPI_VECVAL
|
86 |
|
|
typedef struct t_vpi_vecval {
|
87 |
|
|
uint32_t aval;
|
88 |
|
|
uint32_t bval;
|
89 |
|
|
} s_vpi_vecval, *p_vpi_vecval;
|
90 |
|
|
#endif
|
91 |
|
|
|
92 |
|
|
/* (a chunk of) packed logic array */
|
93 |
|
|
typedef s_vpi_vecval svLogicVecVal;
|
94 |
|
|
|
95 |
|
|
/* (a chunk of) packed bit array */
|
96 |
|
|
typedef uint32_t svBitVecVal;
|
97 |
|
|
|
98 |
|
|
/* Number of chunks required to represent the given width packed array */
|
99 |
|
|
#define SV_PACKED_DATA_NELEMS(WIDTH) (((WIDTH) + 31) >> 5)
|
100 |
|
|
|
101 |
|
|
/*
|
102 |
|
|
* Because the contents of the unused bits is undetermined,
|
103 |
|
|
* the following macros can be handy.
|
104 |
|
|
*/
|
105 |
|
|
#define SV_MASK(N) (~(-1 << (N)))
|
106 |
|
|
|
107 |
|
|
#define SV_GET_UNSIGNED_BITS(VALUE, N) \
|
108 |
|
|
((N) == 32 ? (VALUE) : ((VALUE) & SV_MASK(N)))
|
109 |
|
|
|
110 |
|
|
#define SV_GET_SIGNED_BITS(VALUE, N) \
|
111 |
|
|
((N) == 32 ? (VALUE) : \
|
112 |
|
|
(((VALUE) & (1 << (N))) ? ((VALUE) | ~SV_MASK(N)) : ((VALUE) & SV_MASK(N))))
|
113 |
|
|
|
114 |
|
|
/*
|
115 |
|
|
* Implementation-dependent representation.
|
116 |
|
|
*/
|
117 |
|
|
/*
|
118 |
|
|
* Return implementation version information string ("1800-2005" or "SV3.1a").
|
119 |
|
|
*/
|
120 |
|
|
XXTERN const char* svDpiVersion();
|
121 |
|
|
|
122 |
|
|
/* a handle to a scope (an instance of a module or interface) */
|
123 |
|
|
XXTERN typedef void* svScope;
|
124 |
|
|
|
125 |
|
|
/* a handle to a generic object (actually, unsized array) */
|
126 |
|
|
XXTERN typedef void* svOpenArrayHandle;
|
127 |
|
|
|
128 |
|
|
/*
|
129 |
|
|
* Bit-select utility functions.
|
130 |
|
|
*
|
131 |
|
|
* Packed arrays are assumed to be indexed n-1:0,
|
132 |
|
|
* where 0 is the index of LSB
|
133 |
|
|
*/
|
134 |
|
|
|
135 |
|
|
/* s=source, i=bit-index */
|
136 |
|
|
XXTERN svBit svGetBitselBit(const svBitVecVal* s, int i);
|
137 |
|
|
XXTERN svLogic svGetBitselLogic(const svLogicVecVal* s, int i);
|
138 |
|
|
|
139 |
|
|
/* d=destination, i=bit-index, s=scalar */
|
140 |
|
|
XXTERN void svPutBitselBit(svBitVecVal* d, int i, svBit s);
|
141 |
|
|
XXTERN void svPutBitselLogic(svLogicVecVal* d, int i, svLogic s);
|
142 |
|
|
|
143 |
|
|
/*
|
144 |
|
|
* Part-select utility functions.
|
145 |
|
|
*
|
146 |
|
|
* A narrow (<=32 bits) part-select is extracted from the
|
147 |
|
|
* source representation and written into the destination word.
|
148 |
|
|
*
|
149 |
|
|
* Normalized ranges and indexing [n-1:0] are used for both arrays.
|
150 |
|
|
*
|
151 |
|
|
* s=source, d=destination, i=starting bit index, w=width
|
152 |
|
|
* like for variable part-selects; limitations: w <= 32
|
153 |
|
|
*/
|
154 |
|
|
XXTERN void svGetPartselBit(svBitVecVal* d, const svBitVecVal* s, int i, int w);
|
155 |
|
|
XXTERN void svGetPartselLogic(svLogicVecVal* d, const svLogicVecVal* s, int i, int w);
|
156 |
|
|
|
157 |
|
|
XXTERN void svPutPartselBit(svBitVecVal* d, const svBitVecVal s, int i, int w);
|
158 |
|
|
XXTERN void svPutPartselLogic(svLogicVecVal* d, const svLogicVecVal s, int i, int w);
|
159 |
|
|
|
160 |
|
|
/*
|
161 |
|
|
* Open array querying functions
|
162 |
|
|
* These functions are modeled upon the SystemVerilog array
|
163 |
|
|
* querying functions and use the same semantics.
|
164 |
|
|
*
|
165 |
|
|
* If the dimension is 0, then the query refers to the
|
166 |
|
|
* packed part of an array (which is one-dimensional).
|
167 |
|
|
* Dimensions > 0 refer to the unpacked part of an array.
|
168 |
|
|
*/
|
169 |
|
|
/* h= handle to open array, d=dimension */
|
170 |
|
|
XXTERN int svLeft(const svOpenArrayHandle h, int d);
|
171 |
|
|
XXTERN int svRight(const svOpenArrayHandle h, int d);
|
172 |
|
|
XXTERN int svLow(const svOpenArrayHandle h, int d);
|
173 |
|
|
XXTERN int svHigh(const svOpenArrayHandle h, int d);
|
174 |
|
|
XXTERN int svIncrement(const svOpenArrayHandle h, int d);
|
175 |
|
|
XXTERN int svSize(const svOpenArrayHandle h, int d);
|
176 |
|
|
XXTERN int svDimensions(const svOpenArrayHandle h);
|
177 |
|
|
|
178 |
|
|
/*
|
179 |
|
|
* Pointer to the actual representation of the whole array of any type
|
180 |
|
|
* NULL if not in C layout
|
181 |
|
|
*/
|
182 |
|
|
XXTERN void *svGetArrayPtr(const svOpenArrayHandle);
|
183 |
|
|
|
184 |
|
|
/* total size in bytes or 0 if not in C layout */
|
185 |
|
|
XXTERN int svSizeOfArray(const svOpenArrayHandle);
|
186 |
|
|
|
187 |
|
|
/*
|
188 |
|
|
* Return a pointer to an element of the array
|
189 |
|
|
* or NULL if index outside the range or null pointer
|
190 |
|
|
*/
|
191 |
|
|
XXTERN void *svGetArrElemPtr(const svOpenArrayHandle, int indx1, ...);
|
192 |
|
|
|
193 |
|
|
/* specialized versions for 1-, 2- and 3-dimensional arrays: */
|
194 |
|
|
XXTERN void *svGetArrElemPtr1(const svOpenArrayHandle, int indx1);
|
195 |
|
|
XXTERN void *svGetArrElemPtr2(const svOpenArrayHandle, int indx1, int indx2);
|
196 |
|
|
XXTERN void *svGetArrElemPtr3(const svOpenArrayHandle, int indx1, int indx2,
|
197 |
|
|
int indx3);
|
198 |
|
|
|
199 |
|
|
/*
|
200 |
|
|
* Functions for copying between simulator storage and user space.
|
201 |
|
|
* These functions copy the whole packed array in either direction.
|
202 |
|
|
* The user is responsible for allocating an array to hold the
|
203 |
|
|
* canonical representation.
|
204 |
|
|
*/
|
205 |
|
|
|
206 |
|
|
/* s=source, d=destination */
|
207 |
|
|
/* From user space into simulator storage */
|
208 |
|
|
XXTERN void svPutBitArrElemVecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
209 |
|
|
int indx1, ...);
|
210 |
|
|
XXTERN void svPutBitArrElem1VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
211 |
|
|
int indx1);
|
212 |
|
|
XXTERN void svPutBitArrElem2VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
213 |
|
|
int indx1, int indx2);
|
214 |
|
|
XXTERN void svPutBitArrElem3VecVal(const svOpenArrayHandle d, const svBitVecVal* s,
|
215 |
|
|
int indx1, int indx2, int indx3);
|
216 |
|
|
|
217 |
|
|
XXTERN void svPutLogicArrElemVecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
218 |
|
|
int indx1, ...);
|
219 |
|
|
XXTERN void svPutLogicArrElem1VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
220 |
|
|
int indx1);
|
221 |
|
|
XXTERN void svPutLogicArrElem2VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
222 |
|
|
int indx1, int indx2);
|
223 |
|
|
XXTERN void svPutLogicArrElem3VecVal(const svOpenArrayHandle d, const svLogicVecVal* s,
|
224 |
|
|
int indx1, int indx2, int indx3);
|
225 |
|
|
|
226 |
|
|
/* From simulator storage into user space */
|
227 |
|
|
XXTERN void svGetBitArrElemVecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
228 |
|
|
int indx1, ...);
|
229 |
|
|
XXTERN void svGetBitArrElem1VecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
230 |
|
|
int indx1);
|
231 |
|
|
XXTERN void svGetBitArrElem2VecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
232 |
|
|
int indx1, int indx2);
|
233 |
|
|
XXTERN void svGetBitArrElem3VecVal(svBitVecVal* d, const svOpenArrayHandle s,
|
234 |
|
|
int indx1, int indx2, int indx3);
|
235 |
|
|
XXTERN void svGetLogicArrElemVecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
236 |
|
|
int indx1, ...);
|
237 |
|
|
XXTERN void svGetLogicArrElem1VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
238 |
|
|
int indx1);
|
239 |
|
|
XXTERN void svGetLogicArrElem2VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
240 |
|
|
int indx1, int indx2);
|
241 |
|
|
XXTERN void svGetLogicArrElem3VecVal(svLogicVecVal* d, const svOpenArrayHandle s,
|
242 |
|
|
int indx1, int indx2, int indx3);
|
243 |
|
|
|
244 |
|
|
XXTERN svBit svGetBitArrElem(const svOpenArrayHandle s, int indx1, ...);
|
245 |
|
|
XXTERN svBit svGetBitArrElem1(const svOpenArrayHandle s, int indx1);
|
246 |
|
|
XXTERN svBit svGetBitArrElem2(const svOpenArrayHandle s, int indx1, int indx2);
|
247 |
|
|
XXTERN svBit svGetBitArrElem3(const svOpenArrayHandle s, int indx1, int indx2,
|
248 |
|
|
int indx3);
|
249 |
|
|
XXTERN svLogic svGetLogicArrElem(const svOpenArrayHandle s, int indx1, ...);
|
250 |
|
|
XXTERN svLogic svGetLogicArrElem1(const svOpenArrayHandle s, int indx1);
|
251 |
|
|
XXTERN svLogic svGetLogicArrElem2(const svOpenArrayHandle s, int indx1, int indx2);
|
252 |
|
|
XXTERN svLogic svGetLogicArrElem3(const svOpenArrayHandle s, int indx1, int indx2,
|
253 |
|
|
int indx3);
|
254 |
|
|
XXTERN void svPutLogicArrElem(const svOpenArrayHandle d, svLogic value, int indx1,
|
255 |
|
|
...);
|
256 |
|
|
XXTERN void svPutLogicArrElem1(const svOpenArrayHandle d, svLogic value, int indx1);
|
257 |
|
|
XXTERN void svPutLogicArrElem2(const svOpenArrayHandle d, svLogic value, int indx1,
|
258 |
|
|
int indx2);
|
259 |
|
|
XXTERN void svPutLogicArrElem3(const svOpenArrayHandle d, svLogic value, int indx1,
|
260 |
|
|
int indx2, int indx3);
|
261 |
|
|
XXTERN void svPutBitArrElem(const svOpenArrayHandle d, svBit value, int indx1, ...);
|
262 |
|
|
XXTERN void svPutBitArrElem1(const svOpenArrayHandle d, svBit value, int indx1);
|
263 |
|
|
XXTERN void svPutBitArrElem2(const svOpenArrayHandle d, svBit value, int indx1,
|
264 |
|
|
int indx2);
|
265 |
|
|
XXTERN void svPutBitArrElem3(const svOpenArrayHandle d, svBit value, int indx1,
|
266 |
|
|
int indx2, int indx3);
|
267 |
|
|
|
268 |
|
|
/* Functions for working with DPI context */
|
269 |
|
|
|
270 |
|
|
/*
|
271 |
|
|
* Retrieve the active instance scope currently associated with the executing
|
272 |
|
|
* imported function. Unless a prior call to svSetScope has occurred, this
|
273 |
|
|
* is the scope of the function's declaration site, not call site.
|
274 |
|
|
* Returns NULL if called from C code that is *not* an imported function.
|
275 |
|
|
*/
|
276 |
|
|
XXTERN svScope svGetScope();
|
277 |
|
|
|
278 |
|
|
/*
|
279 |
|
|
* Set context for subsequent export function execution.
|
280 |
|
|
* This function must be called before calling an export function, unless
|
281 |
|
|
* the export function is called while executing an import function. In that
|
282 |
|
|
* case the export function shall inherit the scope of the surrounding import
|
283 |
|
|
* function. This is known as the "default scope".
|
284 |
|
|
* The return is the previous active scope (per svGetScope)
|
285 |
|
|
*/
|
286 |
|
|
XXTERN svScope svSetScope(const svScope scope);
|
287 |
|
|
|
288 |
|
|
/* Gets the fully qualified name of a scope handle */
|
289 |
|
|
XXTERN const char* svGetNameFromScope(const svScope);
|
290 |
|
|
|
291 |
|
|
/*
|
292 |
|
|
* Retrieve svScope to instance scope of an arbitrary function declaration.
|
293 |
|
|
* (can be either module, program, interface, or generate scope)
|
294 |
|
|
* The return value shall be NULL for unrecognized scope names.
|
295 |
|
|
*/
|
296 |
|
|
XXTERN svScope svGetScopeFromName(const char* scopeName);
|
297 |
|
|
|
298 |
|
|
/*
|
299 |
|
|
* Store an arbitrary user data pointer for later retrieval by svGetUserData()
|
300 |
|
|
* The userKey is generated by the user. It must be guaranteed by the user to
|
301 |
|
|
* be unique from all other userKey's for all unique data storage requirements
|
302 |
|
|
* It is recommended that the address of static functions or variables in the
|
303 |
|
|
* user's C code be used as the userKey.
|
304 |
|
|
* It is illegal to pass in NULL values for either the scope or userData
|
305 |
|
|
* arguments. It is also an error to call svPutUserData() with an invalid
|
306 |
|
|
* svScope. This function returns -1 for all error cases, 0 upon success. It is
|
307 |
|
|
* suggested that userData values of 0 (NULL) not be used as otherwise it can
|
308 |
|
|
* be impossible to discern error status returns when calling svGetUserData()
|
309 |
|
|
*/
|
310 |
|
|
XXTERN int svPutUserData(const svScope scope, void *userKey, void* userData);
|
311 |
|
|
|
312 |
|
|
/*
|
313 |
|
|
* Retrieve an arbitrary user data pointer that was previously
|
314 |
|
|
* stored by a call to svPutUserData(). See the comment above
|
315 |
|
|
* svPutUserData() for an explanation of userKey, as well as
|
316 |
|
|
* restrictions on NULL and illegal svScope and userKey values.
|
317 |
|
|
* This function returns NULL for all error cases, 0 upon success.
|
318 |
|
|
* This function also returns NULL in the event that a prior call
|
319 |
|
|
* to svPutUserData() was never made.
|
320 |
|
|
*/
|
321 |
|
|
XXTERN void* svGetUserData(const svScope scope, void* userKey);
|
322 |
|
|
|
323 |
|
|
/*
|
324 |
|
|
* Returns the file and line number in the SV code from which the import call
|
325 |
|
|
* was made. If this information available, returns TRUE and updates fileName
|
326 |
|
|
* and lineNumber to the appropriate values. Behavior is unpredictable if
|
327 |
|
|
* fileName or lineNumber are not appropriate pointers. If this information is
|
328 |
|
|
* not available return FALSE and contents of fileName and lineNumber not
|
329 |
|
|
* modified. Whether this information is available or not is implementation-
|
330 |
|
|
* specific. Note that the string provided (if any) is owned by the SV
|
331 |
|
|
* implementation and is valid only until the next call to any SV function.
|
332 |
|
|
* Applications must not modify this string or free it
|
333 |
|
|
*/
|
334 |
|
|
XXTERN int svGetCallerInfo(const char** fileName, int *lineNumber);
|
335 |
|
|
|
336 |
|
|
/*
|
337 |
|
|
* Returns 1 if the current execution thread is in the disabled state.
|
338 |
|
|
* Disable protocol must be adhered to if in the disabled state.
|
339 |
|
|
*/
|
340 |
|
|
XXTERN int svIsDisabledState();
|
341 |
|
|
|
342 |
|
|
/*
|
343 |
|
|
* Imported functions call this API function during disable processing to
|
344 |
|
|
* acknowledge that they are correctly participating in the DPI disable protocol.
|
345 |
|
|
* This function must be called before returning from an imported function that is
|
346 |
|
|
* in the disabled state.
|
347 |
|
|
*/
|
348 |
|
|
XXTERN void svAckDisabledState();
|
349 |
|
|
|
350 |
|
|
/*
|
351 |
|
|
**********************************************************
|
352 |
|
|
* DEPRECATED PORTION OF FILE STARTS FROM HERE.
|
353 |
|
|
* IEEE-1800-compliant tools may not provide
|
354 |
|
|
* support for the following functionality.
|
355 |
|
|
**********************************************************
|
356 |
|
|
*/
|
357 |
|
|
|
358 |
|
|
/*
|
359 |
|
|
* Canonical representation of packed arrays
|
360 |
|
|
* 2-state and 4-state vectors, modeled upon PLI's avalue/bvalue
|
361 |
|
|
*/
|
362 |
|
|
#define SV_CANONICAL_SIZE(WIDTH) (((WIDTH)+31)>>5)
|
363 |
|
|
typedef unsigned int svBitVec32;/* (a chunk of) packed bit array */
|
364 |
|
|
typedef struct { unsigned int c; unsigned int d;}
|
365 |
|
|
svLogicVec32; /* (a chunk of) packed logic array */
|
366 |
|
|
|
367 |
|
|
/* reference to a standalone packed array */
|
368 |
|
|
typedef void* svBitPackedArrRef;
|
369 |
|
|
typedef void* svLogicPackedArrRef;
|
370 |
|
|
|
371 |
|
|
/*
|
372 |
|
|
* total size in bytes of the simulator's representation of a packed array
|
373 |
|
|
* width in bits
|
374 |
|
|
*/
|
375 |
|
|
XXTERN int svSizeOfBitPackedArr(int width);
|
376 |
|
|
XXTERN int svSizeOfLogicPackedArr(int width);
|
377 |
|
|
|
378 |
|
|
/* Translation between the actual representation and the canonical representation */
|
379 |
|
|
|
380 |
|
|
/* s=source, d=destination, w=width */
|
381 |
|
|
/* actual <-- canonical */
|
382 |
|
|
XXTERN void svPutBitVec32(svBitPackedArrRef d, const svBitVec32* s, int w);
|
383 |
|
|
XXTERN void svPutLogicVec32(svLogicPackedArrRef d, const svLogicVec32* s, int w);
|
384 |
|
|
|
385 |
|
|
/* canonical <-- actual */
|
386 |
|
|
XXTERN void svGetBitVec32(svBitVec32* d, const svBitPackedArrRef s, int w);
|
387 |
|
|
XXTERN void svGetLogicVec32(svLogicVec32* d, const svLogicPackedArrRef s, int w);
|
388 |
|
|
|
389 |
|
|
/*
|
390 |
|
|
* Bit-select functions
|
391 |
|
|
* Packed arrays are assumed to be indexed n-1:0,
|
392 |
|
|
* where 0 is the index of LSB
|
393 |
|
|
*/
|
394 |
|
|
|
395 |
|
|
/* s=source, i=bit-index */
|
396 |
|
|
XXTERN svBit svGetSelectBit(const svBitPackedArrRef s, int i);
|
397 |
|
|
XXTERN svLogic svGetSelectLogic(const svLogicPackedArrRef s, int i);
|
398 |
|
|
|
399 |
|
|
/* d=destination, i=bit-index, s=scalar */
|
400 |
|
|
XXTERN void svPutSelectBit(svBitPackedArrRef d, int i, svBit s);
|
401 |
|
|
XXTERN void svPutSelectLogic(svLogicPackedArrRef d, int i, svLogic s);
|
402 |
|
|
|
403 |
|
|
/*
|
404 |
|
|
* functions for part-select
|
405 |
|
|
*
|
406 |
|
|
* a narrow (<=32 bits) part-select is copied between
|
407 |
|
|
* the implementation representation and a single chunk of
|
408 |
|
|
* canonical representation
|
409 |
|
|
* Normalized ranges and indexing [n-1:0] are used for both arrays:
|
410 |
|
|
* the array in the implementation representation and the canonical array.
|
411 |
|
|
*
|
412 |
|
|
* s=source, d=destination, i=starting bit index, w=width
|
413 |
|
|
* like for variable part-selects; limitations: w <= 32
|
414 |
|
|
*/
|
415 |
|
|
|
416 |
|
|
/* canonical <-- actual */
|
417 |
|
|
XXTERN void svGetPartSelectBit(svBitVec32* d, const svBitPackedArrRef s,
|
418 |
|
|
int i, int w);
|
419 |
|
|
XXTERN svBitVec32 svGetBits(const svBitPackedArrRef s, int i, int w);
|
420 |
|
|
XXTERN svBitVec32 svGet32Bits(const svBitPackedArrRef s, int i); /* 32-bits */
|
421 |
|
|
|
422 |
|
|
XXTERN uint64_t svGet64Bits(const svBitPackedArrRef s, int i);
|
423 |
|
|
|
424 |
|
|
/* 64-bits */
|
425 |
|
|
XXTERN void svGetPartSelectLogic(svLogicVec32* d, const svLogicPackedArrRef s,
|
426 |
|
|
int i, int w);
|
427 |
|
|
/* actual <-- canonical */
|
428 |
|
|
XXTERN void svPutPartSelectBit(svBitPackedArrRef d, const svBitVec32 s,
|
429 |
|
|
int i, int w);
|
430 |
|
|
XXTERN void svPutPartSelectLogic(svLogicPackedArrRef d, const svLogicVec32 s,
|
431 |
|
|
int i, int w);
|
432 |
|
|
|
433 |
|
|
/*
|
434 |
|
|
* Functions for open array translation between simulator and canonical
|
435 |
|
|
* representations. These functions copy the whole packed array in either
|
436 |
|
|
* direction. The user is responsible for allocating an array in the
|
437 |
|
|
* canonical representation.
|
438 |
|
|
*/
|
439 |
|
|
|
440 |
|
|
/* s=source, d=destination */
|
441 |
|
|
/* actual <-- canonical */
|
442 |
|
|
XXTERN void svPutBitArrElemVec32(const svOpenArrayHandle d, const svBitVec32* s,
|
443 |
|
|
int indx1, ...);
|
444 |
|
|
XXTERN void svPutBitArrElem1Vec32(const svOpenArrayHandle d, const svBitVec32* s,
|
445 |
|
|
int indx1);
|
446 |
|
|
XXTERN void svPutBitArrElem2Vec32(const svOpenArrayHandle d, const svBitVec32* s,
|
447 |
|
|
int indx1, int indx2);
|
448 |
|
|
XXTERN void svPutBitArrElem3Vec32(const svOpenArrayHandle d, const svBitVec32* s,
|
449 |
|
|
int indx1, int indx2, int indx3);
|
450 |
|
|
XXTERN void svPutLogicArrElemVec32(const svOpenArrayHandle d, const svLogicVec32* s,
|
451 |
|
|
int indx1, ...);
|
452 |
|
|
XXTERN void svPutLogicArrElem1Vec32(const svOpenArrayHandle d, const svLogicVec32* s,
|
453 |
|
|
int indx1);
|
454 |
|
|
XXTERN void svPutLogicArrElem2Vec32(const svOpenArrayHandle d, const svLogicVec32* s,
|
455 |
|
|
int indx1, int indx2);
|
456 |
|
|
XXTERN void svPutLogicArrElem3Vec32(const svOpenArrayHandle d, const svLogicVec32* s,
|
457 |
|
|
int indx1, int indx2, int indx3);
|
458 |
|
|
|
459 |
|
|
/* canonical <-- actual */
|
460 |
|
|
XXTERN void svGetBitArrElemVec32(svBitVec32* d, const svOpenArrayHandle s,
|
461 |
|
|
int indx1, ...);
|
462 |
|
|
XXTERN void svGetBitArrElem1Vec32(svBitVec32* d, const svOpenArrayHandle s,
|
463 |
|
|
int indx1);
|
464 |
|
|
XXTERN void svGetBitArrElem2Vec32(svBitVec32* d, const svOpenArrayHandle s,
|
465 |
|
|
int indx1, int indx2);
|
466 |
|
|
XXTERN void svGetBitArrElem3Vec32(svBitVec32* d, const svOpenArrayHandle s,
|
467 |
|
|
int indx1, int indx2, int indx3);
|
468 |
|
|
XXTERN void svGetLogicArrElemVec32(svLogicVec32* d, const svOpenArrayHandle s,
|
469 |
|
|
int indx1, ...);
|
470 |
|
|
XXTERN void svGetLogicArrElem1Vec32(svLogicVec32* d, const svOpenArrayHandle s,
|
471 |
|
|
int indx1);
|
472 |
|
|
XXTERN void svGetLogicArrElem2Vec32(svLogicVec32* d, const svOpenArrayHandle s,
|
473 |
|
|
int indx1, int indx2);
|
474 |
|
|
XXTERN void svGetLogicArrElem3Vec32(svLogicVec32* d, const svOpenArrayHandle s,
|
475 |
|
|
int indx1, int indx2, int indx3);
|
476 |
|
|
|
477 |
|
|
/*
|
478 |
|
|
**********************************************************
|
479 |
|
|
* DEPRECATED PORTION OF FILE ENDS HERE.
|
480 |
|
|
**********************************************************
|
481 |
|
|
*/
|
482 |
|
|
|
483 |
|
|
#undef DPI_EXTERN
|
484 |
|
|
|
485 |
|
|
#ifdef DPI_PROTOTYPES
|
486 |
|
|
#undef DPI_PROTOTYPES
|
487 |
|
|
#undef XXTERN
|
488 |
|
|
#undef EETERN
|
489 |
|
|
#endif
|
490 |
|
|
|
491 |
|
|
#ifdef __cplusplus
|
492 |
|
|
}
|
493 |
|
|
#endif
|
494 |
|
|
|
495 |
|
|
#endif
|