Is it possible to use matlab script for creating hdl verifier model?

2 次查看(过去 30 天)
Hi guys,
I use HDL verifier on different machines. One problem I meet now is how to run the same model smoothly. Because, the modelsim path and source code path is different on different machine. If I need to run a model which is created on another machine. I need to do a lot of manual changes, even re-create the model using cosimWizard. So, I wonder if there's a way to create the HDL verifier simulink model using matlab script, so when I switch the running machine, I just need to change the script.
I know the simulink model could be created using script or Matsim. I didn't the api to do so for hdl verifier. Please guide.
Thanks a lot!
Jeff

采纳的回答

Zinea
Zinea 2024-9-2
Hi Poorren,
While MathWorks doesn't provide a direct API specifically for HDL Verifier, you can use MATLAB scripting to automate the creation and configuration of Simulink models. Here's a general approach you can follow:
  1. MATLAB scripting can be used to create and configure Simulink models as follows:
% Create a new Simulink model
modelName = 'HDLVerifierModel';
new_system(modelName);
open_system(modelName);
% Add blocks to the model
add_block('built-in/Inport', [modelName '/In1']);
add_block('built-in/Outport', [modelName '/Out1']);
% Add a custom block (e.g., HDL Cosimulation block)
hdlBlock = add_block('hdlcoder/HDL Cosimulation', [modelName '/HDL Cosim']);
set_param(hdlBlock, 'SimulationCommand', 'Modelsim');
% Set parameters for the HDL Cosimulation block
set_param(hdlBlock, 'ModelSimPath', 'C:\Path\To\Modelsim'); % Update path as needed
set_param(hdlBlock, 'SourceCodePath', 'C:\Path\To\SourceCode'); % Update path as needed
% Connect blocks
add_line(modelName, 'In1/1', 'HDL Cosim/1');
add_line(modelName, 'HDL Cosim/1', 'Out1/1');
% Save the model
save_system(modelName);
2. To handle different paths on different machines, you may parameterize the paths in your script. You can use MATLAB’s ‘input’ function to prompt for paths or read from a configuration file:
% Example of reading paths from a configuration file
config = load('config.mat'); % Assume config.mat contains paths as variables
% Use the paths from the configuration file
set_param(hdlBlock, 'ModelSimPath', config.modelsimPath);
set_param(hdlBlock, 'SourceCodePath', config.sourceCodePath);
3. The MATLAB script that runs this setup automatically can be created so that when you switch machines, you only need to update the paths in the configuration file or script.
4. Model callbacks can be used to automate certain actions when the model is loaded or saved. This is useful for setting up environment-specific configurations.
You may refer to the following link for performing Simulink modelling basics programmatically using MATLAB scripts:
Hope this helps!
  2 个评论
Poorren
Poorren 2024-9-4
编辑:Poorren 2024-9-4
Hi Zinea,
I think that's what I want. Thanks a lot!
One more suggestion or feature request is to add "export build script". People could build this model using cosimWizard, and then export the script, and then parameterize what they want to change.
Cheers,
Jeff
Zinea
Zinea 2024-9-4
I'm glad, I could help you out!
Yes, addition of the 'export build script' would definitely be a great upgrade. Hope they do it in the future!

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by