Code covered by the BSD License  

Highlights from
Address Specific Parameter Custom Storage Class

from Address Specific Parameter Custom Storage Class by Richard Ruff
MemMap: A custom storage class that allows the user to specify the memory addresses of parameters in

InstallNotes.m
%% Notes for using the MemMap parameter Custom Storage Class
%

%% Installing the new Package and corresponding Custom Storage Class
% Unzip the MemMap.zip file into the desired directory.
% Add the directory to the MATLAB path
% Run "slcustomize"
%   This will register the code generation hook contained in the
%   sl_customization.m file to check the model parameters during the build
%   process to insure no addresses overlap
%
% This will allow the user to create MemMap parameters from any directory

%% Using the new custom storage class
% Create a MemMap Variable:
%   aaa = MemMap.Parameter;
% Open the variables dialog and set the storage class to be "MemoryAddress"
% Type in the desired address in the resulting "Memory address" field
% Try "1234abcd"
%   Result: "X1234abcd"
% Try "TYUI"
%   Result: ""  : Empty with dialog warning of bad address

%% Example of Generating Code with MemMap parameters
% Open the MemMapExample model
%   "signaldefs.mat" and "memmap_good.mat" files automatically loaded
% Open the Model Explorer (daexplr) and examine the model parameters in
%   the base workspace (x, y, z, s,  longvariablenameplacedhere), all
%   defined to be MemMap parameters with specified addresses
% Generate code for the model (Ctrl-B)
% Show the memory map? (answer Yes to the dialog)
% Inspect the MemMapExample.c file for the resulting code:  
%   Pointers are initialized to the specified addresses:
%        23   /* Definition of Memory Address specific parameters */
%        24   static const uint16_T *longvariablenameplacedhere = (uint16_T *) 0Xf000;/* longvariablenameplacedhere[60] at Xf000  My definition stuff here plus the other:   */
%        25   static const real32_T *s = (real32_T *) 0Xc000;/* s at Xc000  My definition stuff here plus the other:   */
%        26   static const real_T *x = (real_T *) 0Xd000;/* x[2] at Xd000  My definition stuff here plus the other:   */
%        27   static const int32_T *y = (int32_T *) 0Xa000;/* y[4] at Xa000  My definition stuff here plus the other:   */
%        28   static const int8_T *z = (int8_T *) 0Xb000;/* z at Xb000  My definition stuff here plus the other:   */
%
%   Pointer incrementing is used for non-scalar parameters (i.e. *(y+2) ):
%       112       Out2[0] = mul_s32_s32_s32_sr28((*(y+0)), sig2);
%       113       Out2[1] = mul_s32_s32_s32_sr28((*(y+1)), sig2);
%       114       Out2[2] = mul_s32_s32_s32_sr28((*(y+2)), sig2);
%       115       Out2[3] = mul_s32_s32_s32_sr28((*(y+3)), sig2);

%% Memory Map
% Once the build completes, scroll back in the command window to inspect
%   the memory map.  The parameter variables are sorted by address.  The
%   memory map contains the names of the parameter variables, their data
%   type and corresponding word length, the available starting address for
%   the parameter, and the assigned addresses for the parameter.

% *****     Custom Storage Class MemMap Parameters: Memory Map     *****
%  
% Variable                          Data    Word      Available     Assigned 
%                                   Type    Length    Starting      Addresses
%                                                     Address    
% y(2,2)                            auto    64(0x40)  0x0000A000    0x0000A000 0x0000A040
%                                                                   0x0000A080 0x0000A0C0 
% z                                 int8     8(0x08)  0x0000A100    0x0000B000 
% s                                 single  32(0x20)  0x0000B008    0x0000C000 
% x(1,2)                            auto    64(0x40)  0x0000C020    0x0000D000 0x0000D040 
% longvariablenameplacedhere(5,12)  uint16  16(0x10)  0x0000D080    0x0000F000 0x0000F010 0x0000F020 0x0000F030 0x0000F040 0x0000F050 0x0000F060 0x0000F070 0x0000F080 0x0000F090  % Columns wrapped
%                                                                   0x0000F0A0 0x0000F0B0 0x0000F0C0 0x0000F0D0 0x0000F0E0 0x0000F0F0 0x0000F100 0x0000F110 0x0000F120 0x0000F130  % Columns wrapped
%                                                                   0x0000F140 0x0000F150 0x0000F160 0x0000F170 0x0000F180 0x0000F190 0x0000F1A0 0x0000F1B0 0x0000F1C0 0x0000F1D0  % Columns wrapped
%                                                                   0x0000F1E0 0x0000F1F0 0x0000F200 0x0000F210 0x0000F220 0x0000F230 0x0000F240 0x0000F250 0x0000F260 0x0000F270  % Columns wrapped
%                                                                   0x0000F280 0x0000F290 0x0000F2A0 0x0000F2B0 0x0000F2C0 0x0000F2D0 0x0000F2E0 0x0000F2F0 0x0000F300 0x0000F310  % Columns wrapped
%                                                                   0x0000F320 0x0000F330 0x0000F340 0x0000F350 0x0000F360 0x0000F370 0x0000F380 0x0000F390 0x0000F3A0 0x0000F3B0 

%% Invalid Memory Specification
% What happens if two or more parameters are attempting to use the same
%   memory address?  During the build process, the adresses are checked by
%   the same function that generates the memory map.
% Load  memmep_overlap.mat;
% Open the Model Explorer (daexplr) and examine the model parameters in
%   the base workspace (x, y, z, s,  longvariablenameplacedhere), all
%   defined to be MemMap parameters with specified addresses
% Generate code for the model (Ctrl-B)
% Show the memory map? (answer Yes to the dialog)
% An error dialog appears.  The dialog specifes that there is a conflict
%   between the "x" and "y" parameters.  See the Memory Map  below for
%   details on the conflict.
% The build process is terminated and no code is generated.
% Inspect the memory map to determine the conflict

% *****     Custom Storage Class MemMap Parameters: Memory Map     *****
%  
% Variable                          Data    Word      Available     Assigned 
%                                   Type    Length    Starting      Addresses
%                                                     Address    
% x(1,2)                            auto    64(0x40)  0x00000004    0x00000004 0x00000044 
% y(2,2)                            auto    64(0x40)  0x00000084    0x00000008 0x00000048
%                                                                   0x00000088 0x000000C8 
% s                                 single  32(0x20)  0x00000108    0x00000040 
% z                                 int8     8(0x08)  0x00000060    0x00000080 
% longvariablenameplacedhere(5,12)  uint16  16(0x10)  0x00000088    0x0000F000 0x0000F010 0x0000F020 0x0000F030 0x0000F040 0x0000F050 0x0000F060 0x0000F070 0x0000F080 0x0000F090  % Columns wrapped
%                                                                   0x0000F0A0 0x0000F0B0 0x0000F0C0 0x0000F0D0 0x0000F0E0 0x0000F0F0 0x0000F100 0x0000F110 0x0000F120 0x0000F130  % Columns wrapped
%                                                                   0x0000F140 0x0000F150 0x0000F160 0x0000F170 0x0000F180 0x0000F190 0x0000F1A0 0x0000F1B0 0x0000F1C0 0x0000F1D0  % Columns wrapped
%                                                                   0x0000F1E0 0x0000F1F0 0x0000F200 0x0000F210 0x0000F220 0x0000F230 0x0000F240 0x0000F250 0x0000F260 0x0000F270  % Columns wrapped
%                                                                   0x0000F280 0x0000F290 0x0000F2A0 0x0000F2B0 0x0000F2C0 0x0000F2D0 0x0000F2E0 0x0000F2F0 0x0000F300 0x0000F310  % Columns wrapped
%                                                                   0x0000F320 0x0000F330 0x0000F340 0x0000F350 0x0000F360 0x0000F370 0x0000F380 0x0000F390 0x0000F3A0 0x0000F3B0 

% For the bad memory map (addresses overlapping) note that the "x"
%   parameter and the "y" parameter are using the same address space (x
%   uses 0x00000004 to 0x00000083, and y is specified to start at address 
%   0x00000008)

Contact us at files@mathworks.com