How to restart ModelSim simulation after each iteration from MATLAB script co-simulation?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bilal MEJMAA
le 30 Mai 2023
Commenté : Bilal MEJMAA
le 20 Août 2023
I am working on a vhdl model that is simulated using hdl cosimulator app from simulink. The control and initialization steps are described as MATLAB script. The data is sent from matlab to simulink using from workspace blocks, then simulink fed the hdl function (Modelsim) using shared memory. After simulation process in Modelsim the data sent back to MATLAB. Currently I am facing the problem of timing, in the first iteration the ModelSim output is fine but in the 2nd and on, they delayed by a specific timing.
What I would like to do is how to restart simulation in modelsim from matlab script or from simulink after each iteration process ?
2 commentaires
Marc Erickson
le 2 Juin 2023
Within the HDL simulator, one can invoke a simulator restart which will reset all simulator state and reload the application that communicates with Simulink.
Unfortunately, there is no way to invoke this restart from within our application because doing so will hang the HDL simulator.
For each run of Simulink, it is safest to reinvoke the HDL simulator. For non-interactive use, using the "-c" option to vsim will ensure a faster startup and run time.
Réponse acceptée
Bharath Venkataraman
le 15 Juin 2023
I believe Marc's suggestion is to close ModelSim after every run of Simulink and reopen it.
To start ModelSim, you typically use the vsim command from MATLAB. This may be something you do manually, or it may be executed in the model PreLoad, PostLoad or InitFcn (see Model callbacks). Move it to the StartFcn or InitFcn instead - this will start a new ModelSim each time you simulate (make sure you close ModelSim after you each simulation).
3 commentaires
Marc Erickson
le 22 Juin 2023
Yes, great, the most convenient way to start the co-simulation is through vsim.m like you discovered!
If you desire to shut down ModelSim after each iteration, my suspicion is that you are not interested in interactively debugging the HDL simulation. In that case, you can likely get the behavior you are looking for by running the HDL simulation in the background--it will close the HDL simulator automatically.
Try the 'runmode' flag to vsim.m to specify running in batch mode.
'runmode' - Specify how to start the HDL simulator. One of the following strings:
'Batch' : On Windows, run in a non-interactive command window
On Linux, run in background with no window
'CLI' : Run in an interactive command-line window
'GUI' : Run with ModelSim graphical user interface
Default: 'GUI'
So your command would look like:
vsim('tclstart',tclcmd,'runmode','Batch')
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!