Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

Interfacing to C

Altera_Forum
Honored Contributor II
1,113 Views

Has anybody managed to successfully interface to C in Modelsim? 

 

I have a function or procedure in VHDL which I want to farm out to a bit of C code: 

 

function my_function (input : integer) return real; attribute foreign of my_function : function is "my_function path_to_my_package.dll";The C code looks like: 

__declspec( dllexport ) double my_function (int input) { double temp = 1E15; return temp; }__declspec( dllexport ) is just to get Visual C to make the function visible to the outside world. 

 

I've tried this as a procedure too: 

 

procedure my_proc (input : in integer; real_output : out real); attribute foreign of my_proc : function is "my_proc path_to_my_package.dll";And two alternatives for the C (neither of which work): 

 

__declspec( dllexport ) void my_proc (int input, double output) { output = 1E15; return; } __declspec( dllexport ) void my_proc (int input, double *output) { *output = 1E15; return; }Everything compiles and Modelsim loads everything without complaint but I can't get the C code to modify the variable in VHDL. I don't get any errors when I run a simulation but the VHDL variable remains unchanged. 

 

I've scoured the Modelsim FLI document and I can't find any suggestion of what I'm doing wrong. 

 

Does anybody have any ideas? 

 

Cheers
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
407 Views

Don't worry - sorted

0 Kudos
Reply