MATLAB: Does Embedded Coder support instance-specific parameters for top model when generating C++ code

cdefaultEmbedded Coderglobainstance-specificmodelstaticstoragetop

I am using tunable Simulink.Parameter in R2019a, which has a "Model default" storage class. In R2019a, the generated code of this tunable parameter has the keyword "static", it is declared as static class members. Thus, these "tunable parameters" are no longer linked to a particular instance. I expected the "Tunable parameters" links to a certain instance in the generated code.
In R2018b, with the same setting, you will not get "static" for it.
What causes this change? And how can I generate code for tunable parameters without "static"?

Best Answer

After discussing the issue with our developers, we came to the conclusion: essentially, the R2018b behavior was a bug. R2019a fixed the issue.
With the keyword "static", tunable parameters are declared as static class members. A static member has only one memory location for any number of instances for the class. So, the R2019a behavior is the intended behavior.
In general, parameters defined by workspace variables are shared across all instances of models / code, and Model Default for Simulink.Parameter should result in a shared parameter.
There is no way to generate instance-specific parameters for top model C++ code generation in R2019a. However, our developers would like to add support for instance-specific parameters for top model code generation in a future release.