Main Content

target.upgrade

Upgrade existing definitions of hardware devices

Description

target.upgrade(upgraderForRegistrationMechanism, pathToRegistrationFile) uses an upgrade procedure to create objects from data definitions in current artifacts. The function creates registerUpgradedTargets.m in the current working folder.

To register the upgraded data definitions with MATLAB®, run registerUpgradedTargets().

For persistence across MATLAB sessions, run registerUpgradedTargets('UserInstall', true).

example

target.upgrade(___, Name,Value) specifies additional options using one or more name-value pair arguments.

Examples

collapse all

To upgrade existing hardware device definitions that are specified through rtwTargetInfo.m file or sl_customization.m file (only applies to Simulink Coder and Embedded Coder), use the target.upgrade function.

rtwTargetInfo.m File

Suppose you have the hardware device definition in an rtwTargetInfo.m file:

function rtwTargetInfo(tr)
    % Add registration function handle to the Target Registry
    tr.registerTargetInfo(@loc_register_hardware);
end
  
function hw = loc_register_hardware
    hw = RTW.HWDeviceRegistry;
    hw.Vendor = 'MyManufacturer';
    hw.Type = 'MyDevice';
    hw.Alias = {};
    hw.Platform = {'Prod', 'Target'};
    hw.setWordSizes([8 16 32 64 64 64 64 64 64 64 64]);
    hw.Endianess = 'Little';
    hw.IntDivRoundTo = 'Zero';
    hw.ShiftRightIntArith = true;
    hw.LargestAtomicInteger = 'Long';
    hw.LargestAtomicFloat = 'Double';
end

To upgrade the data definitions contained in the file, enter:

target.upgrade("rtwTargetInfo","myPathTo/rtwTargetInfo.m");

In the current folder, the function creates this registerUpgradedTargets.m file:

function processor = registerUpgradedTargets(varargin)
% This function was generated using target data export.
  
    % Create target.LanguageImplementation 'MyManufacturer-MyDevice'
    languageimplementation = target.create('LanguageImplementation');
    languageimplementation.AtomicFloatSize = 64;
    languageimplementation.AtomicIntegerSize = 64;
    languageimplementation.DataTypes.Char.Size = 8;
    languageimplementation.DataTypes.Double.Size = 64;
    languageimplementation.DataTypes.Float.Size = 64;
    languageimplementation.DataTypes.Half.IsSupported = false;
    languageimplementation.DataTypes.Half.Size = 16;
    languageimplementation.DataTypes.Int.Size = 32;
    languageimplementation.DataTypes.Long.Size = 64;
    languageimplementation.DataTypes.LongLong.IsSupported = false;
    languageimplementation.DataTypes.LongLong.Size = 64;
    languageimplementation.DataTypes.Pointer.Size = 64;
    languageimplementation.DataTypes.PtrDiffT.Size = 64;
    languageimplementation.DataTypes.Short.Size = 16;
    languageimplementation.DataTypes.SizeT.Size = 64;
    languageimplementation.Name = 'MyManufacturer-MyDevice';
    languageimplementation.WordSize = 64;
  
    % Create target.Processor 'MyManufacturer-MyDevice'
    processor = target.create('Processor');
    processor.LanguageImplementations(1) = languageimplementation;
    processor.Manufacturer = 'MyManufacturer';
    processor.Name = 'MyDevice';
  
    % Add the target objects to MATLAB memory
    target.add(processor, varargin{:});
end

To register the hardware device with MATLAB, enter:

registerUpgradedTargets()

If you want the registration to persist across MATLAB sessions, enter:

registerUpgradedTargets(UserInstall=true)

sl_customization.m File (only applies to Simulink Coder and Embedded Coder)

Suppose you have multiple hardware device definitions in an sl_customization.m file:

function sl_customization(cm)
  % sl_customization function to register a device
  % vendor and type with Simulink.
  % Copy or rename this file to sl_customization.m.
  cm.registerTargetInfo(@loc_register_device);
  cm.registerTargetInfo(@loc_register_device2);
  cm.registerTargetInfo(@loc_createConfig);
     
  cm.registerTargetInfo(@locRegisterTfl);
  cm.CodeCoverageTools.add('DummyCoverageToolForTesting',...
                           'HDummyCovTool',...
                           'A Coverage Tool Vendor');
end
 
function thisDev = loc_register_device
  thisDev = RTW.HWDeviceRegistry;
  thisDev.Vendor = 'MyDevVendor';
  thisDev.Type = 'MyDevType';
  thisDev.Alias = {};
  thisDev.Platform = {'Prod', 'Target'};
  thisDev.setWordSizes([8 16 32 32 32]);
  thisDev.LargestAtomicInteger = 'Char';
  thisDev.LargestAtomicFloat = 'None';
  thisDev.Endianess = 'Unspecified';
  thisDev.IntDivRoundTo = 'Undefined';
  thisDev.ShiftRightIntArith = true;
  thisDev.setEnabled({'IntDivRoundTo'});
end
 
function thisDev = loc_register_device2
  thisDev = RTW.HWDeviceRegistry;
  thisDev.Vendor = 'MyDevVendor';
  thisDev.Type = 'MyDevType2';
  thisDev.Alias = {};
  thisDev.Platform = {'Prod', 'Target'};
  thisDev.setWordSizes([8 16 32 32 32]);
  thisDev.LargestAtomicInteger = 'Char';
  thisDev.LargestAtomicFloat = 'None';
  thisDev.Endianess = 'Unspecified';
  thisDev.IntDivRoundTo = 'Undefined';
  thisDev.ShiftRightIntArith = true;
  thisDev.setEnabled({'IntDivRoundTo'});
end
 
% local function
function config = loc_createConfig
  config = rtw.connectivity.ConfigRegistry;
  config.ConfigName = 'Infineon->C16x, XC16x';
  config.ConfigClass = 'pil_slcust.HostDemoConfig1';
  config.SystemTargetFile = {'custom_target.tlc'};
  config.TemplateMakefile = {'custom_target.tmf'};
  config.TargetHWDeviceType = {'Infineon->C16x, XC16x'};
end
 
function thisTfl = locRegisterTfl
  thisTfl(1) = RTW.TflRegistry;
  thisTfl(1).Name = 'myTFL1';
  thisTfl(1).Description = 'Test';
  thisTfl(1).TableList = {'tfl_table_Sum',...
                          'tfl_table_Product',...
                         }; % Sum includes Add and Subtract
  thisTfl(1).BaseTfl = 'ANSI_C';
  thisTfl(1).TargetHWDeviceType = {'*'};
end

To upgrade the RTW.HWDeviceRegistry data definitions in the file, enter:

target.upgrade("sl_customization","myPathTo/sl_customization.m")

In the current folder, the function creates this registerUpgradedTargets.m file:

function targetObjects = registerUpgradedTargets(varargin)
% This function was generated using target data export.
 
    % Create target.LanguageImplementation 'MyDevVendor-MyDevType'
    languageimplementation = target.create('LanguageImplementation');
    languageimplementation.AtomicIntegerSize = 8;
    languageimplementation.DataTypes.Char.Size = 8;
    languageimplementation.DataTypes.Double.Size = 64;
    languageimplementation.DataTypes.Float.Size = 32;
    languageimplementation.DataTypes.Half.IsSupported = false;
    languageimplementation.DataTypes.Half.Size = 16;
    languageimplementation.DataTypes.Int.Size = 32;
    languageimplementation.DataTypes.Long.Size = 32;
    languageimplementation.DataTypes.LongLong.IsSupported = false;
    languageimplementation.DataTypes.LongLong.Size = 64;
    languageimplementation.DataTypes.Pointer.Size = 32;
    languageimplementation.DataTypes.PtrDiffT.Size = 32;
    languageimplementation.DataTypes.Short.Size = 16;
    languageimplementation.DataTypes.SizeT.Size = 32;
    languageimplementation.Endianess = target.Endianess.Unspecified;
    languageimplementation.Name = 'MyDevVendor-MyDevType';
    languageimplementation.WordSize = 32;
 
    % Create target.Processor 'MyDevVendor-MyDevType'
    processor = target.create('Processor');
    processor.LanguageImplementations(1) = languageimplementation;
    processor.Manufacturer = 'MyDevVendor';
    processor.Name = 'MyDevType';
 
    % Create target.LanguageImplementation 'MyDevVendor-MyDevType2'
    languageimplementation2 = target.create('LanguageImplementation');
    languageimplementation2.AtomicIntegerSize = 8;
    languageimplementation2.DataTypes.Char.Size = 8;
    languageimplementation2.DataTypes.Double.Size = 64;
    languageimplementation2.DataTypes.Float.Size = 32;
    languageimplementation2.DataTypes.Half.IsSupported = false;
    languageimplementation2.DataTypes.Half.Size = 16;
    languageimplementation2.DataTypes.Int.Size = 32;
    languageimplementation2.DataTypes.Long.Size = 32;
    languageimplementation2.DataTypes.LongLong.IsSupported = false;
    languageimplementation2.DataTypes.LongLong.Size = 64;
    languageimplementation2.DataTypes.Pointer.Size = 32;
    languageimplementation2.DataTypes.PtrDiffT.Size = 32;
    languageimplementation2.DataTypes.Short.Size = 16;
    languageimplementation2.DataTypes.SizeT.Size = 32;
    languageimplementation2.Endianess = target.Endianess.Unspecified;
    languageimplementation2.Name = 'MyDevVendor-MyDevType2';
    languageimplementation2.WordSize = 32;
 
    % Create target.Processor 'MyDevVendor-MyDevType2'
    processor2 = target.create('Processor');
    processor2.LanguageImplementations(1) = languageimplementation2;
    processor2.Manufacturer = 'MyDevVendor';
    processor2.Name = 'MyDevType2';
 
    targetObjects = [processor, processor2];
 
    % Add the target objects to MATLAB memory
    target.add(targetObjects, varargin{:});
end

To register the hardware device definitions with MATLAB, enter:

registerUpgradedTargets()

If you want the registration to persist across MATLAB sessions, enter:

registerUpgradedTargets(UserInstall=true)

Input Arguments

collapse all

Select upgrade procedure for current registration mechanism.

Specify file that contains current registration mechanism.

Example: target.upgrade('rtwTargetInfo', 'myPath/mySubfolder/rtwTargetInfo.m')

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: target.upgrade('rtwTargetInfo', 'myPath/mySubfolder/rtwTargetInfo.m','ExportFileName','myNewFile')

  • true –– Generate a MATLAB function that registers the upgraded definitions using target.add.

  • false –– Do not generate a function.

If ExportToMATLABFunction is true, the argument specifies the file name of the generated MATLAB function. Otherwise, the argument is ignored.

  • true –– If the file specified by ExportFileName exists, overwrite the file.

  • false –– If the file specified by ExportFileName exists, the function produces an error.

If ExportToMATLABFunction is false, the argument is ignored.

Version History

Introduced in R2019b