How to restart ModelSim simulation after each iteration from MATLAB script co-simulation?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Marc Erickson
2023-6-2
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.
采纳的回答
Bharath Venkataraman
2023-6-15
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 个评论
Marc Erickson
2023-6-22
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')
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!