Technical data
Using the VHDL FLI with foreign subprograms
462
-
VHDL Foreign Language Interface and Verilog PLI ModelSim EE/PLUS Reference Manual
/* Convert a VHDL String array into a NULL terminated string */
static char *get_string(varID id)
{
static char buf[1000];
typeID type;
int len;
mti_GetArrayVarValue(id, buf);
type = mti_GetVarType(id);
len = mti_TickLength(type);
buf[len] = 0;
return buf;
}
Package (pkg) example
The declared FOREIGN attribute links the C functions (declared above) to VHDL
procedures (
in_params
and
out_params
) in
pkg
.
package pkg is
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 : procedure is "in_params test.sl";
procedure out_params(
vhdl_integer : OUT integer;
vhdl_enum : OUT severity_level;
vhdl_real : OUT real;
vhdl_array : OUT string);
attribute foreign of out_params : procedure is "out_params test.sl";
end;
package body pkg is
procedure in_params(
vhdl_integer : IN integer;
vhdl_enum : IN severity_level;
vhdl_real : IN real;
vhdl_array : IN string) is
begin
report "ERROR: foreign subprogram in_params not called";
end;
procedure out_params(