Does the Shift Arithmetic block support tunable expressions for code generation in Real-Time Workshop 7.1 (R2008a)?

I have a Shift Arithmetic block in my model whose "Number of bits to shift right" parameter is set to a variable "Shift" which is defined as follows:
Shift = mpt.Parameter;
Shift.RTWInfo.StorageClass = 'ExportedGlobal';
Shift.Value = 2;
In the generated code, the arithmetic shift statement contains a constant rather than a variable. For example, the statement appears as follows:
out = in >> 2;
Setting the Storage class of the parameter to 'ImportedExtern' or using Custom Storage classes did not help.

 Accepted Answer

This enhancement has been incorporated in Release 2011a (R2011a). For previous product releases, read below for any possible workarounds:
The support for tunable expressions with code generation and arithmetic shifting is not available in Real-Time Workshop 7.1. To find a list of limitations, enter the following command in the MATLAB Command Window (in R2008a):
web([docroot,'/toolbox/rtw/ug/f1023655.html#bqm1y7d-14'])
As mentioned in the documentation, the Arithmetic Shift block breaks a number of the limitations: Non-Double, Fcn Block, and casting. So, you cannot achieve the task with this block.
To work around the issue, use a Stateflow chart or an EML function block. You can find the Stateflow model (Stateflowmdl.mdl) in the resolution documents. This produces the cleanest code. You can also find the EML model (EMLmdl.mdl) in the resolution documents. However, for this case, the shift expression is wrapped in an IF statement which cannot be removed very easily.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Release

R2008a

Community Treasure Hunt

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

Start Hunting!