Matlab HDL cosimulation for Lattice CPLD
20 views (last 30 days)
Show older comments
I regularly develop VHDL code for controllers that is supposed to run on FPGAs/CPLDs and I'm looking for possibilities to co-simulate this code in a closed-loop simulation environment that mimics the behavior of the controlled system. So what I would like to have is that I can define a dyamic model in Matlab (e.g., as a state-space model or a transfer function) and to simulate this model together with the controller's HDL implementation using the outputs of the models as stimuli for the controller and the output of the controller as input for the dynamic model. Is there any way I can accomplish this with Matlab? If so, what do I have to look for?
What I found so far is apparently called HDL verifier and seems to be pretty much what I want. However, I'm currently using Lattice MachXO2 CPLDs and Lattice diamond comes with "ModelSim Lattice FPGA Edition" as a simulator. According to this post
HDL verifier requires a FLI (foreign language interface), which the Lattice Edition of ModelSim does not provide. Is there any way I can use HDL verifier, e.g., by using a different simulator?
1 Comment
Marc Erickson
on 6 Aug 2024
Yes, as you surmised, our product requires a PLI to integrate the HDL simulation kernel with the Simulink simulation kernel. We support four major simulators: ModelSim/Questa, Xcelium, VCS, and Vivado Simulator.
Answers (1)
Ayush
on 6 Aug 2024
Edited: Ayush
on 6 Aug 2024
As you have clearly mentioned and found out that ModelSim Lattice FPGA Edition is not support by the HDL verifier as they do not provide a FLI (foreign language interface). The best way forward as a workaround is to try out popular supported simulators like the ModelSIM Special Edition, Questa Prime or the others mentioned in the MATLAB Answer community post.
As a workaround, you could try to manually create a co-simulation bridge that interfaces between ModelSim for simulation and MATLAB/Simulink for the analysis of the data fetched from the simulation. This could be complex and would require a good understanding of both environments, but can be done using socket programming where you can host a MATLAB server and a ModelSim client. You can refer to the following documentation to know more about socket programming in MATLAB:
Hope it helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!