generated code from multiple model by using model referencing how to integrate in BSW

4 views (last 30 days)
we are generated code from multiple model by using model referencing . how to integrate that code to BSW and I want single output from both .slx files.

Accepted Answer

Purvaja
Purvaja on 2 May 2025
Edited: Purvaja on 2 May 2025
Hey Shital,
Understanding from your question, you want a single output from referenced models.
You can do this by making a parent model where you call these both models.
And then generate the C/C++ code using Simulink or Embedded Coder. Ensure that you have adjusted solver settings to generate code. You may refer to the below example:
I constructed two models and referenced them in a single “ParentModel Simulink model using “Model” block as:
On this single ‘ParentModel.slx’ use Simulink Coder or Embedded Coder to generate code. Before generating adjust the settings to generate single input and output endpoints.
Refer to the below links to Integrate the code in BSW:
  1. Model AUTOSAR Basic Software Service Calls: https://www.mathworks.com/help/autosar/ug/model-autosar-basic-software-bsw-service-calls.html
  2. AUTOSAR Blockset: https://www.mathworks.com/help/autosar/index.html
For more clarification on model referencing and code generation, refer to the following links:
  1. Model referencing: https://www.mathworks.com/help/simulink/model-reference.html
  2. Generate Code for Model Reference Hierarchy: https://www.mathworks.com/help/rtw/ug/generate-code-for-model-reference-hierarchy.html
  3. Combined Code generated for models: https://www.mathworks.com/help/rtw/ug/combined-models.html
For documentation specific links, access them using following commands in MATLAB command window respectively:
web(fullfile(docroot, '/autosar/ug/model-autosar-basic-software-bsw-service-calls.html'))
web(fullfile(docroot, '/autosar/index.html'))
web(fullfile(docroot, '/simulink/model-reference.html'))
web(fullfile(docroot, '/rtw/ug/generate-code-for-model-reference-hierarchy.html'))
web(fullfile(docroot, '/rtw/ug/combined-models.html'))
I hope this helps you. Do share more details if you have more doubts regarding this.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!