Modeling Concurrent Execution on Multicore Targets

These examples illustrate how you can use Simulink® and Simulink® Coder™ to realize concurrent execution of a model. These examples also attempt to generate HDL code using HDL Coder™. You can generate HDL code if:

  • You have an HDL Coder license,

  • You are generating on Windows or Linux operating systems.

You cannot generate HDL code on Macintosh systems.

Example Requirements

If you want to generate code for this model, install Simulink® Coder™. Note that when you simulate the example, Simulink® and Simulink® Coder™ might generate code in the current working folder. If you do not want to (or cannot) generate files in this folder, changechange the current working folder.


We illustrate two examples.

topmdl1 = 'sldemo_concurrent_execution';
topmdl2 = 'slexFFTConcurrentExecutionExample';
curDir = pwd;

Generating Code and Profile Report

Generate code and profile reportcode and profile report from the model.

The profile report shows how generated code executes on a host computer. For the example profile report illustrated below, the generated code was run on a four core processor host computer. The Task Execution Time section lists the times in microseconds. The Task Affinitization to Processor Cores section shows how the tasks execute concurrently on the different cores. For details of how concurrent execution is achieved, examine the code illustrated in the Code Generation report or see the documentationdocumentation.

Closing the Models

close_system(topmdl1, 0);
close_system([topmdl1,'_plant'], 0);
close_system([topmdl1,'_compensator'], 0);
close_system([topmdl1,'_controller_A'], 0);
close_system([topmdl1,'_controller_B'], 0);
close_system(topmdl2, 0);
close_system('slexFFTConcurrentExecutionButterflyMdlRef', 0);
close_system('slexFFTConcurrentExecutionInputMdlRef', 0);
Was this topic helpful?