Formal arguments
in SystemVerilog can be specified as open arrays solely in import declarations;
exported SystemVerilog functions can not have formal arguments specified as
open arrays. A formal argument is an open array when a range of one or more of
its dimensions is unspecified (denoted in SystemVerilog by using empty square
brackets ([])).
This corresponds to a relaxation of the DPI argument-matching rules (section 1.5.1 26.5.1). An actual argument shall match the corresponding formal
argument regardless of the range(s) for its corresponding dimension(s), which
facilitates writing generalized C code that can handle SystemVerilog arrays of
different sizes.
Editor’s Note: What is the correct cross reference, above?
Note that the
constraints expressed here merely restate those expressed in section 26.4.1 1.4.1.
Editor’s Note: What is the correct cross reference, above?
Also refer to section 26.4.3 1.4.3.
Editor’s Note: What is the correct cross reference, above?
See also 26.4.2 1.4.2.
Editor’s Note: What is the correct cross reference, above?
See also
section 26.4.1.4 1.4.1.4.
Editor’s Note: What is the correct cross reference, above?
1) If a packed
part of an array has more than one dimension, it is linearized as specified by
the equivalence of packed types (see section 4.2 ??).
Editor’s Note: What is the correct cross reference, above?
There is no
difference in argument passing between calls from SystemVerilog to C and calls from
C to SystemVerilog. Functions exported from SystemVerilog can not have open
arrays as arguments. Apart from this restriction, the same types of formal
arguments can be declared in SystemVerilog for exported functions and imported
functions. A function exported from SystemVerilog shall have the same function
header in C as would an imported function with the same function result type
and same formal argument list. In the case of arguments passed by reference, an
actual argument to SystemVerilog function called from C shall be allocated
using the same layout of data as SystemVerilog uses for that type of argument;
the caller is responsible for the allocation. It can be done while preserving
the binary compatibility, see Annex D.11.5 and section D.11.11 A.11.11.
Editor’s Note: What is the correct cross reference, above?
Sometimes
binary compatibility can be achieved by using dynamic allocation functions. The
functions svSizeOfLogicPackedArr() and svSizeOfBitPackedArr() provide the size of the actual
representation of a packed array, which can be used for the dynamic allocation
of an actual argument without compromising the portability (see section D.11.11 A.11.11). Such a technique does not work if a
packed array is a part of another type.
Editor’s Note: What is the correct cross reference, above?
—
byte, shortint, int, longint, real, shortreal
— handle, string
—
bit (i.e.,
2-state) packed arrays up to 64 (previously 32) bit (canonical
representation shall be used, like for a function result)
[There is a problem here: ‘int’ is the same as svBitVec32, long long
is not the snae as svBitVect32[2],
so how to return a value in
the canonical representation as a function result, if this value is between
33 and 64 bits?]
Editor’s Note: Has the preceding note been taken care of?
Unpacked
arrays, with the exception of formal arguments specified as open arrays, shall
have the same layout as used by a C compiler; they are accessed using C
indexing (see section D.6.6 A.6.6).
Editor’s Note: What is the correct cross reference, above?
To avoid any
unnecessary overhead, imported function calls in SystemVerilog code are not
instrumented unless the imported function is specified as context in its
SystemVerilog import declaration. A small set of DPI utility functions are is available to
assist programmers when working with context functions (see section D.8.3 A.8.3). If those utility functions are used
with any non-context function, a system error will result.
Editor’s Note: Has the preceding note been taken care of?
In the former case,
all indices are normalized on the C side (i.e., 0 and up) and the programmer needs to know
the size of an array and be capable of determining how the ranges of the actual
argument map onto C-style ranges (see section D.6.6 A.6.6).
Editor’s Note: What is the correct cross reference, above?