Code covered by the BSD License  

Highlights from
Real-Time Workshop Targeting Tips and Scripts

from Real-Time Workshop Targeting Tips and Scripts by Tom Erkkinen
Has best practices and scripts to configure embedded code generation for any production target.

ert_rtw_info_hook(varargin)
function varargout = ert_rtw_info_hook(varargin)
% ERT_RTW_INFO_HOOK - ERT hook file for providing Real-Time Workshop
% Embedded Coder with the necessary target specific information regarding
% your target.
%
% During its build process, Real-Time Workshop checks for the existence
% of <target>_rtw_info_hook.m, where <target> is the base file name of
% the active system target file.  For example, if your system target file
% is grt.tlc, then the hook file name is grt_rtw_info_hook.m.  If the
% hook file is present (i.e., on the MATLAB path), the target specific
% information is extracted via the API found in this file.  Otherwise,
% the host computer is the assumed target.
%
% Word lengths (case 'wordlengths')
% =================================
%
% CharNumBits  : Number of bits for C 'char'  type
% ShortNumBits : Number of bits for C 'short' type
% IntNumBits   : Number of bits for C 'int'   type
% LongNumBits  : Number of bits for C 'long'  type
%
% Implementation specific properties (case 'cImplementation')
% ===========================================================
%
% ShiftRightIntArith:
%
%   Set true if shift right on a signed integer is implemented as arithmetic
%   shift, and false otherwise.  For example,
%
%   int a = -8;
%   int b;
%   b = a >> 1;
%
%   In the ANSI-C standard states the above example has undefined behavior.
%   If the result of 'b' is -4 it is safe to assume that shift right on
%   signed integers is implemented as arithmetic shift right, and you should
%   set the option true.
%
% Float2IntSaturates:
%  
%   Conversion from float to integer automatically saturates, therefore do
%   not generate software saturation code.
%
% IntPlusIntSaturates:
%
%   Integer addition automatically saturates, therefore do not generate
%   software saturation code.
%
% IntTimesIntSaturates:
%
%   Integer multiplication automatically saturates, therefore do not generate
%   software saturation code.
%
% Optional implementation specific properties (case 'cImplementation')
% ====================================================================
%
% TypeEmulationWarnSuppressLevel:
%
%   Supresses warnings about the emulation of word sizes.  The default, 0,
%   is the highest warning level, and is the preferred setting when generating
%   code for the production target.  Increased values provide less warnings.
%   When generating code for a rapid prototyping system, emulation may not
%   be a concern and a suppression level of 2 may be desireable.
%
% PreprocMaxBitsSint:
%
%   Specifies limitions in the target C preprocessor for doing math with
%   signed integers.  This option is used to prevent errors in the preprocessor
%   phase.  As an example, suppose the target has 64-bit longs.  Porting the
%   generated code to a machine that does not have 64-bit longs can lead to
%   errors in the processing of integer data types.  To protect against these
%   porting errors, RTW includes the following check in the generated code.
%
%   #if ( LONG_MAX != 0x7FFFFFFFFFFFFFFFL )
%   #error Code was generated for compiler with different sized longs.
%   #endif
%
%   However, this code requires the preprocessor to compare signed 64-bit
%   integers which some preprocessors do not handle properly (for example,
%   the preprocessor math may be limited to 32-bit signed integers).
%   To work around these limitations, you can set PreprocMaxBitsSint to 32,
%   thus generating code to skip the problematic size checks.
%
%   #if 0
%     /* Skip this size verification because of preprocessor limitation */
%     #if ( LONG_MAX != 0x7FFFFFFFFFFFFFFFL )
%       #error Code was generated for compiler with different sized longs.
%     #endif
%   #endif
%
% PreprocMaxBitsUint:
%  
%   Specifies limitions in the target C preprocessor for doing math with
%   unsigned integers.  The behavior is the same as PreprocMaxBitsSint except
%   it pertains to unsigned integer operations such as
%
%   #if ( ULONG_MAX != 0xFFFFFFFFFFFFFFFFUL )
%    :
%   #endif
%
% If you are not certain about the proper settings for your target,
% type 'rtwtargetsettings' in MATLAB for more details.

% Copyright 1994-2002 The MathWorks, Inc.
% $Revision: 1.3 $ $Date: 2002/08/26 15:52:18 $

Action    = varargin{1};
modelName = varargin{2};

switch Action
 case 'wordlengths'

  % specify the target word lengths
  
  value.CharNumBits  = 8;
  value.ShortNumBits = 16;
  value.IntNumBits   = 32;
  value.LongNumBits  = 32;
  varargout{1} = value;
  
 case 'cImplementation'
  
  % specify various C-language information
  
  value.ShiftRightIntArith   = true;
  value.Float2IntSaturates   = false;
  value.IntPlusIntSaturates  = false;
  value.IntTimesIntSaturates = false;

  % optional settings (uncomment to use)
  %
  % value.TypeEmulationWarnSuppressLevel = 0;
  % value.PreprocMaxBitsSint = 32;
  % value.PreprocMaxBitsUint = 32;

  varargout{1} = value;
  
 otherwise
  
  % Properly accommodate future releases of Real-Time Workshop
  
  varargout{1} = [];
  
end


Contact us at files@mathworks.com