VHDL C interaction
September 1st, 2003 at 5:28 pmI’m playing with some cool stuff at work: interaction of VHDL and C. The Modelsim VHDL simulator supports an API called VHDL FLI (Foreign Language Interface), which allows to link a DLL to some model and control the simulation from it. C is a higher-level language than VHDL and its interaction with the outer world is far better, so it’s a good way to write clever test-benches for designs.
The examples provided by Modeltech didn’t really work. I had to tinker with env vars here, linker options there (it’s all on Win2k, with MSVC++ 6) and got it to work eventually. Hey, it’s the first time I actually built a Windows DLL and got it to do something useful ! It wasn’t even hard
This FLI API is pretty heavy and Modelsim provides only a reference. Though it’s pretty good (explains exactly what each function does), it wouldn’t hurt to get my hands on some docs with tutorial-like material. Also, it would be nice to link it to C++. Shouldn’t be hard, they already took care of extern “C” clauses in their header files.
So, I’m going back to the fun (= work, whee !). Hopefully this will also turn useful for me, and I’ll be able to build nice testbenches and simulation environments in C++.
Related posts:

July 16th, 2008 at 1:02 pm
Dear Sir,
Hope you gone through FLI very well,If you have some example where you used the function which had following need please share with me..It will be great help for me to proceed my academic project work.Thanks
1.how to get the net handle by name. Or to create an array of handles to get all the nets in a module from Modelsim.
2.callback function at the end of the simulation to wrap-up.
3.A function to find the no. of nets in the Simulator.
4.A function to count the no. of times the net has toggled.
Regards,
Sathish
July 16th, 2008 at 6:46 pm
Hello Sathish,
Unfortunately I did not pursue this direction for much longer, so I don’t have the information you’re looking for.
July 18th, 2008 at 9:03 pm
Thats fine…
-Sathish