Technical data
Using the VHDL FLI with foreign subprograms
458
-
VHDL Foreign Language Interface and Verilog PLI ModelSim EE/PLUS Reference Manual
• creates one or more processes (a C function that can be called when a signal
changes)
• sensitizes each process to a list of signals
The declaration of an initialization function is:
init_func(region, param, generics, ports)
regionID region;
char *param;
interface_list *generics;
interface_list *ports;
The function specified in the foreign attribute is called during elaboration. The
first parameter is a regionID that can be used to determine the location in the
design for this instance. The second parameter is the last part of the string in the
foreign attribute. The third parameter is a linked list of the generic values for this
instance. The list will be NULL if there are no generics. The last parameter is a
linked list of the ports for this instance. The typedef interface_list in
mti.h
describes the entries on these lists.
Restrictions on ports and generics
VSIM does not allow you to read or drive RECORD signals or RECORD generics
through the foreign language interface.
Using the VHDL FLI with foreign subprograms
Declarin
g
the subpro
g
ram in VHDL
To call a foreign C subprogram, you will need to write a VHDL subprogram
declaration that has the equivalent VHDL parameters and return type. Then use
the FOREIGN attribute to specify which C function and module to load. The
syntax of the FOREIGN attribute is almost identical to the syntax used for foreign
architectures.
Example
procedure in_params(
vhdl_integer : IN integer;
vhdl_enum : IN severity_level;
vhdl_real : IN real;
vhdl_array : IN string);
attribute FOREIGN of in_params : function is "in_params app.so";