hdlset_param question

As part of an automated HDL coder script, I need to check for all Reference Models used within the design that the 'ReferenceModelPrefix' which is accessed as 'HDL Block Properties' is clear. The script sets 'ReferenceModelPrefix' using the following:-
hdlset_param(refModelsFullPath{i}, 'ReferenceModelPrefix', '')
refModelsFullPath{i} is an array that I use to generate the absolute hierarchy path for each Reference Model in my design.
This works perfectly for a hierarchical path such as the following:-
SubSystem_Top/SubSystel_level1/RefModel_a
If I have a Reference model embedded inside RefModel_a giving me the following hierarchy:-
SubSystem_Top/SubSystel_level1/RefModel_a/RefModel_b
Then the hdlset_param command fails with an error:-
In this case ' mss_rx_ss' is equivalent to my 'RefModel_a'
I'm assuming that I can't use an absolute path that contains multiple hierarchical levels of Model Reference, is there an equvalent command or alternative that I could use to set the 'ReferenceModelPrefix' parameter this way?
Many thanks in advance.

6 commentaires

GLW
GLW le 30 Juil 2024
Can anyone help me with this question?
Umar
Umar le 30 Juil 2024

Hi @GLW,

Consider using relative paths instead of absolute paths. By navigating the hierarchy step by step, you can set the 'ReferenceModelPrefix' parameter effectively without encountering errors related to nested levels. To modify the code to handle nested Reference Models, try using my example code snippet below as a reference,

% Example code snippet to set 'ReferenceModelPrefix' for nested Reference Models

for i = 1:numel(refModelsFullPath)

    % Extract the relative path from the current Reference Model to its parent
    relativePath = strrep(refModelsFullPath{i}, 'SubSystem_Top/', '');
    % Set the 'ReferenceModelPrefix' using the relative path
    hdlset_param(refModelsFullPath{i}, 'ReferenceModelPrefix', relativePath)

end

Hope this will help resolve your problem.

GLW
GLW le 30 Juil 2024
Hi @Umar,
many thanks for your suggestion.
I apologise as I didn't explain well enough what I'm trying to achieve. For the hdlset_param command that I'm using:-
hdlset_param(refModelsFullPath{i}, 'ReferenceModelPrefix', '')
I want to clear the ReferenceModelPrefix parameter for all Reference Models within my design, hence why the 3rd field is set to ''.
The issue (I beleive) is with the first field, 'refModelsFullPath{i}' when I access nested Referenced Models in this way, the command issues the error that the nested Reference Model path is an 'Invalid Simulink object name'.
I can't see how replacing the 3rd field with the 'relativePath' would give me what I need?
thanks again
GLW
Umar
Umar le 30 Juil 2024

@GLW,

So,to address this issue, you should ensure that refModelsFullPath{i} resolves to a valid Simulink object name or path. If refModelsFullPath is a cell array containing paths, then make sure that i indexes the correct path to the Reference Model you want to modify.Here is an example of how you can iterate over all paths in refModelsFullPath and clear the ReferenceModelPrefix parameter for each Reference Model:

for i = 1:numel(refModelsFullPath)

    try
        hdlset_param(refModelsFullPath{i}, 'ReferenceModelPrefix', '');
        disp(['Cleared ReferenceModelPrefix for: ', refModelsFullPath{i}]);
    catch
        disp(['Error clearing ReferenceModelPrefix for: ', refModelsFullPath{i}]);
    end

end

By iterating over each path in refModelsFullPath, this code snippet will attempt to clear the ReferenceModelPrefix parameter for each Reference Model and the try-catch block helps in handling any errors that may occur during the process.

GLW
GLW le 2 Août 2024
Hi @Umar,
many thanks for your time helping me out with this issue.
I was putting together a test case to demonstrate what my issue was here, when I realised the problem was that the:-
hdlset_param(refModelsFullPath{i}, 'ReferenceModelPrefix', '')
will only work if all the Referenced Models are loaded. In my case they weren't, that's what was causing the issue of the 'Invalid Simulink object name'.
All sorted now.
thanks again.
GLW
Umar
Umar le 2 Août 2024
Modifié(e) : Umar le 2 Août 2024
@GLW,
Glad your problem is resolved. Also, don’t hesitate to ask for help or any questions you still have.

Connectez-vous pour commenter.

Réponses (0)

Produits

Version

R2021b

Question posée :

GLW
le 25 Juil 2024

Modifié(e) :

le 2 Août 2024

Community Treasure Hunt

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

Start Hunting!

Translated by