Mathworks EMBEDDED IDE LINK 4 user guide

Embedded IDE Link™
User’s Guide
4
For Use with Altium®TASKING
®
How to Contact The MathWorks
www.mathworks. comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html T echnical Support
suggest@mathworks.com Product enhancement suggestions
bugs@mathwo doc@mathworks.com Documentation error reports service@mathworks.com Order status, license renewals, passcodes
info@mathwo
rks.com
rks.com
Web
Bug reports
Sales, prici
ng, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
Embedded IDE Link™ User’s Guide
© COPYRIGHT 2006–2010 by The Math W orks , Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the term s and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
May 2006 Online only New for Version 1.0 (Release 2006a+) September 2006 Online only Version 1.0.1 (Release 2006b) March 2007 Online only Version 1.1 (Release 2007a) September 2007 Online only Revised for Version 1.2 (Release 2007b) March 2008 Online only Revised for Version 1.3 (Release 2008a) October 2008 Online only Revised for Version 1.3.1 (Release 2008b) March 2009 Online only Revised for Version 1.4 (Release 2009a) September 2009 Online only Revised for Version 4.0 (Release 2009b) March 2010 Online only Revised for Version 4.1 (Release 2010a)
Getting Started
1
Product Overview ................................. 1-2
Introduction Project Generator Automation Interface Verification Optimization
...................................... 1-2
................................. 1-3
.............................. 1-3
...................................... 1-4
..................................... 1-5
Contents
Software Requirements
Supported Altium TASKING Toolsets
Supported Versions Support for Other Versions
Using This Guide
Setting Target Preferences
Procedure Target Preference Fields
Working with Configuration Sets
Adding the Embedded IDE Link Configuration Set
Component Configuration Set Options Using Configuration Sets to Specify Your Target Setting Build Action
Accessing Utilities for TASKING
Embedded IDE Link Utilities for Use w ith TASKING
dialog Tools Menu Items
........................................ 1-10
......................................... 1-27
.................................. 1-9
.................................... 1-16
............................ 1-6
................ 1-7
................................ 1-7
.......................... 1-7
......................... 1-10
............................ 1-13
................... 1-16
.......................... 1-16
............................... 1-23
.................... 1-27
................................. 1-29
........ 1-19
Option Sets
....................................... 1-30
v
What Are Option Sets? ............................. 1-30
Supported DAS Software
........................... 1-32
Components
2
Project Generator ................................. 2-2
Overview of the Project Generator Component Project-Based Build Process Template Projects Shared Libraries Build Proces s — Folder Structure
................................. 2-4
.................................. 2-6
......................... 2-4
.................... 2-9
.......... 2-2
Automation Interface
Overview o f Automation Interface Component Classes Using Objects List of Methods Details of Particular Methods
.......................................... 2-14
..................................... 2-15
.............................. 2-13
.......... 2-13
................................... 2-22
....................... 2-25
Verification
3
Processor-in-the-Loop (PIL) Cosimulation ........... 3-2
Processor-in-the-Loop Overview PIL Workflow Creating a PIL Block Building, Running, and Debugging PIL Block
Applications
PIL Metrics
C Code Coverage Reports
.................................... 3-3
............................... 3-5
.................................... 3-8
...................................... 3-11
...................... 3-2
.......................... 3-13
vi Contents
Execution Profiling
CrossView Pro Execution Profiling
................................ 3-15
................... 3-15
Task Execution Profiling Kit for R eal-Time Workshop
Targets
........................................ 3-18
Stack Profiling
What Is Stack Profiling? PIL Applications Non-PIL Applications Infineon
Bidirectional T ra ce ability Between C od e and Model
Using Traceability Enabling Traceability
MISRA C Rule Checking
®
.................................... 3-19
............................ 3-19
.................................. 3-19
.............................. 3-20
TriCore Stack Depth Analyzer .............. 3-21
................................. 3-22
.............................. 3-23
............................ 3-25
Optimization
4
Compiler / Linker Optimiza tion Settings ............. 4-2
Target Memory Placement / Mapping
................ 4-3
.. 3-22
Execution and Stack Profiling
Execution Profiling Stack Profiling
Target Specific Optimizations
C Language Extensions / Intrinsics Target Optimized Libraries for Infineon XC166 and
Infineon
Target Optimized FIR / FFT Blocks for the Infineon
TriCore ........................................ 4-8
Model Advisor
®
TriCore ............................... 4-7
................................ 4-4
.................................... 4-4
..................................... 4-9
...................... 4-4
...................... 4-5
................... 4-5
®
vii
Tutorials
5
Tutorial: Using Option Sets ......................... 5-2
Tutorial: Creating New Template Projects
Creating New Template Projects Creating a New Config uration
Tutorial: Configuring an Existing Model for Embedded
IDE Link Software
............................... 5-9
..................... 5-4
....................... 5-7
........... 5-4
Configuration Parameters
6
Embedded IDE Link Pane .......................... 6-2
Overview Build Action Target Preference Configuration Add build directory suffix Build directory suffix Export EDE handle to MATLAB base workspace EDE handle name Export CrossView Pro handle to MATLAB base
workspace CrossView Pro handle name Configure model to build PIL algorithm object code PIL block action
........................................ 6-3
...................................... 6-4
..................... 6-6
........................... 6-7
.............................. 6-8
........ 6-9
................................. 6-9
..................................... 6-11
......................... 6-11
...... 6-13
................................... 6-14
viii Contents
Limitations and Tips
A
General Issues ..................................... A-2
Problems with InstallationsinRead-OnlyLocations Simulink Configuration Set Reference Not Supported
..... A-2
.... A-2
Serialization of Embedded IDE Link Objects Not
Supported
..................................... A-3
Debugger Issues
ARM CrossView Pro Debugger Fails with File | Open
Source Content
On-Chip Debugging/On-Chip PIL Not Supported on ARM
Hardware
Build Process Issues
Linker Errors Due to Limited Memory EDE Is Slow, Unrespo n sive, or Crashes Signal Processing Blockset Library Build Failures Memory Block Freed Twice Error 8051 EDE Cannot Compile Files with Long Names DSP563xx Toolset Support Limitations “Create, Build and Execute Application Project” Build
Action Fails C166 Toolset W arnings Build Error From Root Drive Location Limited Support for Nonfinite Values Memory Warning/Error Messages in the CrossView Pro
Command Window When Using the Instruction Set
Simulator C++ Co de Generation Not Supported Video and Image Pro cessing Blockset Library Not
Supported Noninlined S-functions Calling rt_matrx.c Not
Supported “Compiler optimization level” Configuration Parameter Has
No Effect Configuration Changes Cause Build Errors With Referenced
Models
................................... A-4
................................. A-4
...................................... A-4
............................... A-6
................ A-6
............... A-7
...... A-7
.................... A-8
...... A-8
................ A-8
................................... A-9
............................. A-10
................ A-10
................. A-10
...................................... A-13
................. A-13
..................................... A-14
..................................... A-14
...................................... A-14
........................................ A-15
Processor-in-the-Loop Issues
Generic P IL Issues On-Chip PIL Not Supported on ARM Hardware 10-Second Pause on Termination of the CrossView Pro
Debugger DSP563xx Link-Order Issue Can Cause PIL Application
Failure No Support for TASKING Feature “Treat double as
float”
...................................... A-16
........................................ A-17
......................................... A-17
................................ A-16
....................... A-16
........ A-16
ix
TASKING Optimization Settings May Cause Incorrect
Cosimulation Results
............................ A-18
Issues Using Real-Time Workshop Software Without
Real-Time Workshop
Real-Time Workshop grt.tlc-Based Targets Not Supported
for PIL "Save data to workspace" Causes Error DSP563xx Toolset Support Limitations Use ERT Target for Memory-Constrained Targets 8051 GRT Limitations
........................................ A-19
®
Embedded Coder Software .. A-19
................ A-19
................ A-19
....... A-20
............................. A-20
Index
x Contents
Getting Started
“Product Overview” on page 1-2
“Softw are Requirements” on page 1-6
“Supported Altium TASKING Toolsets” on page 1-7
“U sing This Guide” on page 1-9
“Setting Target Preferences” on page 1-10
“W orking with Configuration Sets” on page 1-16
“Accessing Utilities for TASKING” on page 1-27
1
“Option Sets” on page 1-30
1 Getting Started
Product Overview
Introduction
Embedded IDE Link™ software lets you build, test, and verify automatically generated code using the MATLAB products, and the Altium®TASKING®integrated development environment. Embedded IDE Link software makes it easy to verify code executing within the TASKING environment using a test harness model in Simulink. This processor-in-the-loop testing environment uses code automatically generated from Simulink models by the Real-Time Workshop product. A wide range of DSPs and 8-, 16- and 32-bit microprocessors and microcontrollers are supported including devices from the Infineon Renesas provides customizable templates for configuring hardware variants, automating MISRA C
In this section...
“Introduction” on page 1-2
“Project Generator” on page 1-3
“Automation Interface” on page 1-3
“Verification” on page 1-4
“Optimization” on page 1-5
®
, and Freescale™ product families. Embedded IDE Link software
®
code checking, and controlling the build process.
®
, Simulink®,andReal-TimeWorkshop
®
Embedded Coder™
®
®
,
1-2
With Embedded IDE Link software, you can use MATLAB and Simulink to interactively analyze, profile and debug target-specific code execution behavior within TASKING software. In this way, Embedded ID E Link software automates deployment of the complete embedded software application and makes it easy for you to assess possible differences between the model simulation and target code execution results.
Embedded IDE Link software consists of a Project Generator component, an Automation Interface component, and features for code verification and optimization. The following sections summarize these components and features.
Product Overview
Project Generator
A u tomated project-based build p roces s
Automatically create and build projects f or code generatedbytheReal-Time Workshop or Real-Time Workshop Embedded Coder products.
Highly customizable code generation
Use Embedded IDE Link software with any Real-Time Workshop System Target File (STF) to generate target-specific and optimized code.
Highly customizable build process
Support for multiple TASKING Toolsets provides a route to a large number of different target hardware platforms. Further customization is possible by using custom project templates, giving access to all options supported by the TASKING Toolset.
Automated download and debugging
Rapidly and effortlessly debug generated code in the CrossView Pro debugger, using either the instruction set simulator or real hardware.
Automation Inter face
M ATLA B API for TASKING EDE (IDE)
Automate complex tasks in the TASKING ED E by writing MATLAB scripts to communicate with the EDE.
For example, you could
- Automate project creation, including adding source files, include paths,
and preprocessor defines.
- Configure batch building of projects.
- Launch a debugging session.
- Execute CodeWright API Library commands.
M ATLA B API for TASKING CrossView Pro (Debugger)
Automate complex tasks in the TA SKING CrossView Pro debugger by writing MATLAB scripts to communicate with the CrossView Pro application, or debug and analyze interactively in a live MATLAB session.
1-3
1 Getting Started
For example, you could
- Automate debugging by executing commands from the powerful
CrossView Pro command language.
- Exchange data between MATLAB and the target running in the
CrossView Pro application.
- Set breakpoints, step through code, set parameters and retrieve profiling
reports
Verification
Processor-in-the-loop (PIL) cosimulation
Use cosimulation techniques to verify generated code running in an instruction set simulator or real target environment.
C Code Coverage
Use C code instruction coverage metrics from the CrossView Pro instruction set s imulator during PIL cosimulation to refine test cases.
1-4
Execution Profiling
Use execution profiling metrics from the CrossView Pro instruction set simulator during PIL cosimulation to establish the timing requirements of your algorithm.
Stack Profiling
Use s tack profiling metrics for PIL cosimulation or real-time applications to verify the amount of memory allocated for stack usage is sufficient.
Bi-Directional Traceability Between Model and Code
Navigate to the generated code for a given Simulink block or, vice versa, to the Simulink block corresponding to a section of generated code.
®
MISRA
Use the TASKING compiler generated MISRA report to check for an appropriate level of MISRA compliance for your application.
Checker
Product Overview
Optimization
Compiler / Linker Optimization Settings
Use Template Projects to fully control compiler and linker optimization settings.
T arget Memory Placement / Mapping
Use T emplate Projects to fully configure the target memory map.
Execution Profiling
Use execution profiling metrics from the CrossView Pro instruction set simulator during PIL cosimulation to guide optimization of your algorithms.
Stack Profiling
Use s tack profiling metrics for PIL cosimulation or real-time applications to optimize the amount of stack memory required for an application.
®
T arget Optimized FIR / FFT Blocks for the Infineon
TriCore
Use example F I R / FFT blocks that call target optimized Infineon TriLib routines. These blocks can be over a hundred times faster than the regular blocks in the Signal Processing Blockset™ product. Additionally, create your own optimized blocks to provide m ore functionality.
®
1-5
1 Getting Started
Software Requirements
You must have the correct softw are installed. For example, the Simulink menu item Tools > Utilities for Use with TASKING(R) IDE is enabled only if Real-Time Workshop is installed in addition to MATLAB, Simulink, andEmbeddedIDELink.
For detailed information about the software and hardware required to use Embedded IDE Link with Altium TASKING, refer to www.mathworks.com/products/ide-link/requirements.html and www.mathworks.com/products/ide-link/altium-adaptor.html.
1-6
Supported Altium TASKING Toolsets
Supported Versions
Embedded IDE Link software includes at least one reference template project for each supported toolset. The reference projects were created for specific versions of each Altium TASKING toolset and were used by The M athWorks for qualification testing. The supported toolset versions are:
Infineo n TriCore: TASKING VX-toolset for TriCore v2.5 r2
See a lso “Regenerate Template Projects to Use Selected Toolset Versions” on page 1-8.
Infineon
Renesas M16C: TASKING Tools for M16C v3.1 r1 patch 2
ARM
Simulator only, see “On-Chip Debugging/On-Chip PIL Not Supported on ARM Hardware” on page A-4.
®
C166®: TASKING Tools for C166/ST10 v8.7 r1
®
: TASKING C Compiler for ARM v2.0 r2
Supported Altium®TASKING®Tool s ets
F reescale DSP563xx: TASKING Tools for DSP563xx v3.5 r3 patch 2
8051: TASKING Tools for 8051 v7.2 r1
The Renesas R8C family is supported by the Renesas M16C TASKING Toolset.
The Freescale DSP566xx family is supported by the Freescale DSP563xx Toolset.
Support for Other Versions
Check the Embedded IDE Link Product Support page for patches and additional toolchain version information.
For minor release increments it may be sufficient to create new default template projects. To do this,
1 Specify the location of your TASKING toolset in the Target Preferences
(see “Setting Target Preferences” on page 1-10).
1-7
1 Getting Started
2 Close all projects/project spaces in the EDE, and close the EDE.
3 Move to a clean work folder or clean out the ex isting one.
4 Run the tasking_generate_templates co mmand. You must specify your
configuration description string, e.g.:
tasking_generate_templates('C166', true)
or
tasking_generate_templates('TriCore', true)
Note Make sure you check the Embedded IDE Link Product Support page for the latest information about toolchains qualified with the product. You may be able to obtain patches in order to use other toolsets.
1-8
Regenerate Template Projects to Use Selected Toolset Versions
The following toolsets should work after regenerating the template projects:
TASKING VX-toolset for TriCore and PCP v2.5 r2
As TASKING VX-toolset for TriCore v2.5 r2 but without On-Chip Debug
Support (OCDS)
"TASKING C/C++ Compiler for ARM v2.0 r2"
Some TASKING packages do not include O n-Chip Debug Support (OCDS). For example, "TASKING C/C++, CrossView Pro SIM" does not include OCDS support, but "TASKING VX-Toolset" does. To use a package w ithout OCDS support you must regenerate the template projects as previously described.
Using This Guide
To get started with Embedded IDE Link software:
1 Follow the instructions in “Setting Target Preferences” on page 1-10.
2 After you set target preferences, follow the instructions in “Working with
Configuration Sets” on page 1-16 to see how to set up configurations using an example model.
Using This Guide
3 Try the demos
Access the d
IDE Link > De
4 See “Accessing Utilities for T A S KING” on pa ge 1-27 for a quick guide to the
to gain experience using Embedded IDE Link software.
emos by selecting Start > Links and Targets > Embedded
mos.
functionality available in the menus, with links to more information.
See the following chapters to learn about Embedded IDE Link software features:
C h apter 2, “Components” explains the Embedded IDE Link software
components: the Project Generator build process, and the Automation Interface objects.
C h apter 3, “Verification” describes how to use PIL cosimulation and other
product features for verification.
Chapter 4, “Op timization” describes how to use product features for
optimization.
Chapter 5, “Tutorials” contains instructions to show you how to create
new c onfigurations and tem plate projects, how to use Embedded IDE Link software with existing models, and how to use different bui ld actions.
1-9
1 Getting Started
Setting Target Preferences
Procedure
You must configure your target preferences to use Embedded IDE Link software.
Note Target preferences are persistent across MATLAB sessions. If you have used a previous version of Embedded IDE Link software, click Reset to Default before setting up your new preferences, to ensure you use the latest values for all fields.
1 Enter taskingutils in the Command Window.
The Embedded IDE Link Utilities for Use with TASKING dialog box appears.
1-10
2
ct
Sele
The Target Preferences Configuration Selection dialog box appears.
Target Preferences from the list in the dialog box, and click OK.
Setting Target Preferences
3 Select or create a configuration:
C h oose a predefined configuration from the list that matches your target.
A lternatively, select
Create new configuration to create a new
configuration, and click OK. For new configurations, see the tutorial section “Creating a New Configuration” on page 5-7.
The E mbedded IDE Link Target Preferences dialog box appears. You can use this dialog box to configure the location of your Altium TASKING toolchain executable and other files.
4 Click the plus to expand Configuration Options. Similarly, expand
CrossView_Pro_Configuration and EDE_Configuration,asshownin
the example. This example is set up for the
Infineon C166 Simulator
configuration.
1-11
1 Getting Started
5 Replace the string <ENTER_TASKING_PATH> to complete the path to the
CrossView_Pro_Executable,theDOL_File,andtheEDE_Executable.
See the next section, “Target Preference Fields” on page 1-13, for details on each field. The following example is set up for the
Simulator
configuration.
Infineon TriCore
1-12
Setting Target Preferences
If you have multiple configurations, you have to set them up in your target preferences only once, and then it is simple to switch between them. See the tutorial example “Working with Configuration Sets” on page 1-16.
6 Click OK to dismiss the Embedded IDE Link Target Preferences dialog box.
The next section explains each target preference field.
Target Preference Fields
Enter tasking_edit_prefs in the Command Window.
Configuration
Select a configuration from the drop-down list. There are preconfigured configurations for
- C166
- TriCore
- M16C
- ARM
- DSP563xx
- 8051
If you have multiple configurations, you have to set them up in your target preferences only once, and then it is simple to switch between them. You can switch between them using this target preference field.
Select a free configuration number to set up a new configuration from scratch. See “Creating a New Configuration” on page 5-7.
Configuration_Description
The title of the configuration. After it is created, this title is the name that appears in the Target Preferences Configuration drop-downlistinthe Configuration Param eters dialog box. Edit this field to change the name of the configuration. These names are predefined for the preconfigured configurations. For a new configuration enter a descriptive name (do not include spaces).
CrossView_Pro_Executable
1-13
1 Getting Started
Enter the full path to your TASKING CrossView Pro installation to replace the string
Infineon C166 Simulator:
D:\Applications\TASKING\c166\bin\xfw166.exe
Initialization
This setting determines what the CrossView Pro Debugger e xecutes when it first starts. There are three options.
<ENTER_TASKING_PATH>. For example, for Configuration_1 for
- Use .st Initialization_File This option is the default setting.
.st” files are i n an internal file format used by The MathWorks
to provide initialization options to CrossView Pro software during debugger start up. For example, a configuration file ( of the option sets shipped with Embedded IDE Link software specifies a corresponding the
c166_default.st file, which includes basic initialization commands
for the C166 CrossView Pro Simulator. See “Option Sets” on page 1-30 for related information. To customize your CrossView Pro configuration, you should use one of the
.cfg) and target type for CrossView Pro to use. Each
.st file. For example, the c166_sim option set specifies
.ini initialization options.
.st file may specify a CrossView Pro
1-14
- Use .ini Initialization_File Use this option if you have a
custom initialization file for your custom configuration. Refer to your CrossView Pro application documentation for details.
.ini initialization file. The file should be a valid CrossView Pro
- Use CrossView Pro Default .ini File Use this option if you want
to run CrossView Pro Default Pro Debugger. When launching CrossView Pro software you may be prompted to make configuration selections. Refer to your CrossView Pro application documentation to find the location of this details of CrossVi ew Pro initialization files.
Initialization_File
Full path of the initialization file corresponding to the Initialization field.
DOL_File
The full path to the TASKING EDE DOL file. For example, the
Infineon_C166_Simulator Configuration has the <ENTER_TASKING
.ini file when launching the CrossView
.ini file, and for
Setting Target Preferences
PATH>_\etc\c166.dol as the dol file. You need to replace <ENTER_TASKING_PATH> with your real TASKING installation path.
EDE_Executable
Enter the full path to your TASKING EDE installation to replace the string
Infineon C166 Simulator,enter
D:\Applications\TASKING\c166\bin\ede.exe
<ENTER_TASKING_PATH>. For example, for Configuration_1 for
Target_Project_Space
When you build models, new projects in the TASKING EDE will be created. These projects belong to the project space defined in this entry. The default setting is process expands the
$(DEFAULT_LOCATION)\projspace.psp. The code generation
$(DEFAULT_LOCATION) token based on the build folder
of the model, the model name, and model configuration settings, including the name of the template applicatio n project. You should avoid changing this default setting.
Template_Application_Project
When you build a Simulink model with Embedded IDE Link software, th e generated projects for your applicationintheTASKINGEDEhavethe same project settings as the template application project. This template project provides a centric place to manage the project options (e.g., compiler settings, linker settings, etc.) your Simulink models use during code generation. You can modify the project settings of the default template projects or create new ones. See “Accessing U tilities for TASKING” on page 1-27 for information on creating or opening template projects, and see “Template Projects” on page 2-4.
Template_Library_Project
ThesameastheTemplate_Application_Project field, but this is applicable for Library projects.
Use_State_File
Opens the TASKING EDE in its last saved state. For more information, refer to your TASKING EDE documentation.
1-15
1 Getting Started
Working with Configuration Sets
In this section...
“Adding the Embedded IDE Link Configuration Set Component” on page 1-16
“Configuration Set Options” on page 1-16
“Using Configuration Sets to Specify Your Target” on page 1-19
“Setting Build Action” on page 1-23
Adding the Embedded IDE Link Configuration Set Component
To add Embedded IDE Link configuration options to a model, select the menu item Tools > Embedded IDE Link > Add Embedded IDE Link Configuration to Model.
Similarly, you can use the menu item Remove Em bedded IDE Link
Configuration from Model to remove the configuration set component.
1-16
The following sections explain how to use the Embedded IDE Link configuration set component.
See also “Setting Up Configuration Sets” in the Simulink documentation for more information.
Configuration Set Options
To see Embedded IDE Link configuration options, navigate to the configuration parameters by any of the following paths:
Simulation > Configuration Parameters in a model
T ools > Embedded IDE Link > Options in a model
View > Model Explorer in a model
Click Embed ded IDE Link to see the following option s .
Working with Configuration Sets
The following options are available under Build Configuration:
Build action
Set w hat action to take after the Real-Time Workshop build proces s. You can create application and library projects in the Altium TASKING EDE and then stop, or you can also choose to build, execute, or debug. See “Setting Build Action” on page 1-23 for more details.
Target Preferences Configuration
Select target preference configurations. The names correspond to the
Configuration Description for each configuration in the Target
Preferences dialog box. Click Edit Configuration to open the Target Preferences dialog box for the currently selected configuration. See “Using Configuration Sets to Specify Your Target” on page 1-19.
1-17
1 Getting Started
A dd build subdirectory suffix
Select the check box to specify a model-specific suffix to be added the regular Real-Time Workshop build folder suffix. This setting is useful to avoid shared utility function code generation errors which occur because of conflicts over Real-Time Workshop utility functions shared between different models.
Clear this check box to use the default Real-Time Workshop build folder suffix. Not using an additional suffix may result in reb uilding shared libraries unnecessarily. See “Shared Libraries” on page 2-6 and particularly “Supporting Multiple Shared Utility Function Locations: Build Folder Suffix” on page 2-7 for details.
Build subdirectory suffix
Enter in the edit box a model-specific suffix to be added the regular Real-Time Workshop build folder suffix.
The following options are available under Export Handles:
1-18
E xport EDE handle to MATLAB base workspace
Select this check box to export the EDE object handle to the workspace.
EDE handle name
EnteraMATLABvariablenamefortheexportedhandle.
Export CrossView Pro handle to MATLAB base workspace
Select this check box to export the CrossView Pro object handle to the workspace.
CrossV iew Pro handle name
EnteraMATLABvariablenamefortheexportedhandle.
See “Auto mation Interface” on page 2-13 for information on using these object handles.
The following options are available under Processor-in-the-Loop (PIL) Verification:
Configure model to build PIL algorithm object code
Working with Configuration Sets
Select this bo x to build PIL algorith m code.
PIL block action
Select one of the following PIL block actions
- Create PIL block, then build and download PIL application
Select this option to automatically build and download the PIL application after creating the PIL block. This option is the default when you s elect the option to configure the model for PIL.
- Create PIL block
Choose this to create the PIL block and then stop without building. You can build manually from the PIL block.
- None
Choose this to avoid creating a PIL block, for instance if you have already built a PIL block and do not want to repeat the action.
See “Processor-in-the-Loop (PIL) Cosimulation” on page 3-2 for more information on using PIL settings.
Using Configuration Sets to Specify Your Target
FollowthestepsinthisexampletoseewheretofindandchangeEmbedded IDE Link software settings. These steps are described to help you find the settings you need to get started using the demo models. To use the demos, you need to specify your target by working with configuration sets.
This example describes how to use Embedded IDE Link software to build a project from a demo model using two different toolchains. The instructions refer to C166 your toolchain as appropriate.
Finding the Embedded IDE Link Software Settings
1 Open the model tasking_demo_enginewc.
2 Double-click the Active Configuration Set block to op en the Model
Explorer (or select View > Model Explorer).
®
and T riCore®TASKING toolchains; adapt the instructions to
1-19
1 Getting Started
Under TASKING_demo_enginewc is a list of configuration sets you can review. The currently selected set is labeled
(Active).
1-20
Reviewing and Changing the Configuration Settings
Inspect the active configuration set.
1 The default active configuration set for this model is C166.Ifyouwantto
use a different target, right-click the configuration set that matches your target, and select Activate.
2 Click Embedded IDE Link to see the configuration settings, as shown in
the following figure.
Working with Configuration Sets
3 The Target Preferences Configuration drop-down list shows all
available target preference configurations. After you have set up target preferences for particular configurations, you can switch between them here (or in the Target Preferences dialog box).
a Click Edit Configuration to inspect your current target preferences.
b Before building, you must replace the string <ENTER TASKING
PATH> CrossView_Pro_Executable,theDOL_File,andtheEDE_Executable.
to set up the correct paths to the target preferences
See “Setting Target Preferences” on page 1-10.
c Click OK to dismiss the Target Preferences dialog box.
In the E mbedded IDE Link demos, when you activate a configuration (e.g.,
C166), the appropriate Target Preferences Configuration is
automatically selected. You may want to select a different target preference configuration description, e.g., if you have set up a custom configuration (such as
C167_user_hardware). For an example, see “Creating a New
Configuration” on page 5-7.
See “Adding the Embedded IDE Link Configuration Set Component” on page 1-16 for information on other Embedded IDE Link software settings in the Configuration Parameters.
1-21
1 Getting Started
4 Click Real-Time Workshop to see the selected system target file.
Note You can use a configuration set specifying any system target file
with Embedded IDE Link software.
5 Click Hardware Implementation to see the C166 settings. If you
are using a different target, make sure the settings match your device. Select from the Device type list. There are custom configurations and preconfigured settings that include the following processors:
Infineon C16x, XC16x
Infineon TriCore
ARM 7/8/9
Renesas M16C
8051 Compatible
1-22
Freescale DSP563xx (16-bit mode)
Close the M odel Explorer.
6 In the model tasking_demo_enginewc, right-click the t_eng_speed
subsystem, and select Real-Time Workshop > Build Subsystem.Click Build in the dialog box to continue.
Watch the output messages in the MATLAB Command Window as co de is generated, your TASKING toolchain EDE is launched, and a new project created.
Switching Target Preference Configurations
If you have multiple toolchains, you only have to set up your target preferences once. After this initial setup, it is simple to switch between different configu rations. For example, to switch configurations from C166 to TriCore targets:
1 In the model tasking_demo_enginewc, double-click the Active
Configuration Set
block to open the Model Explorer.
Working with Configuration Sets
2 Right-click TriCore and select Activate. Close the Model Explorer.
3 To rebuild the subsystem with the new settings, right-click the t_eng_speed
subsystem, and select Real-Time Workshop > Build Subsystem.
Watch the output in the MATLAB Command Window as code is generated, the TASKING C16 6 EDE is closed, the TA S KIN G TriCore EDE is launched, and the new project created.
You can follow similar steps to specify your target in the other demo models. To view the demos, select Start > Links and Targets > Embedded IDE Link > Demos.
To switch between simulator and hardware implementations for the same target configuration, you can use option sets. See “Option Sets” on page 1-30.
The n ext section describes using the build action setting in this example.
Setting Build Action
In this example, the model tasking_demo_enginewc is set up so the project is created but not built in the TASKING EDE.
To view this setting:
1 In the model tasking_demo_enginewc, select
Simulation > Configuration Parameters.
2 Click Embedded IDE Link to see the Build Configuration parameters.
3 Look at the Build A ction drop-down list.
1-23
1 Getting Started
1-24
Using this drop-down list, you can set wh at action to take after the Real-Time Workshop build process completes. You can create application and l ibrary projects in the TASKING EDE and then stop, or you can also choose to build, execute, or debug.
Ifyouchoosetobuild,execute,ordebug,theCrossViewProapplication will be launched.
Note The first time you build this model it will take a few minutes to compile the required Real-Time Workshop floating point library. This library is not rebuilt on subsequent builds unless necessary.
You can use the Build Action setting to do the following:
Create Application Project
Generates code for the model or subsystem, creates a TASKING application project for the selected TASKING configuration, connects to the TASKING EDE, and opens the application project (in addition to the required Real-Time Wo rkshop and Signal Processing Blockset Library
Working with Configuration Sets
projects, if required) in the TASKING EDE. This option does not build or execute the application.
An
EDE_Obj object handle is exported to the MATLAB workspace (if
the option E xport EDE handle to MATLAB base workspace is selected). This object allows you to interact with the TASKING EDE from MATLAB. For more information, see the section on using object handles, “Automation Interface” on page 2-13.
Note To manually build the generated project in the TASKING EDE, right-click on the application project (starts with the same name as the model name), and select Build.
Create Library Project
Performs the same actions as Create Application Project,butthis option archives the generated code into a library in the TASKING EDE. No
main.c file is generated.
Create and Build Application Project
Performs the same actions as Create Application Project,butalso instructs theTASKING EDE to build the application project.
Note To manually debug the executable from the application project, click the Debug Application icon in the TASKING EDE.
Create and Build Library Project
PerformsthesameactionsasCreate Library Project,butalso instructs the TASKING EDE to build the Library project.
Create, Build and Execute Application Project
PerformsthesameactionsasCreate and Build Application Project andalsodownloadstheexecutablefiletoyourCrossViewTargetand runs the executable. No debugging information is downloaded into the target with this option.
1-25
1 Getting Started
A CrossView Pro object handle is exported to the MATLAB workspace (if the option Export CrossView Pro hand le to MATLA B base workspace is selected). This object allows you to interact with the CrossView Pro debugger from MATLAB. For more information, see the section on using object handles, “Automation Interface” on page 2-13.
Create, Build and Debug Application Project
PerformsthesameactionsasCreate, Build and Execute
Application Project
target. This option behaves the same way as the Debug Application icon in the TASKING EDE.
but also downloads debugging information to the
1-26
Accessing Utilities for TASKING
In this section...
“Embedded IDE Link Utilities for Use with TASKING dialog” on page 1-27
“Tools Menu Items” on page 1-29
Embedded IDE Link Utilities for Use with TASKING dialog
Open the Embedded IDE Link Utilities for Use with TASKING dialog box by entering TASKING Utilities in the Simulink block library.
You see the following options:.
Target Preferences
taskingutils in the Command Window or double-clicking Launch
Opens the Target Preferences Configuration Selection dialog box, and afte r you choose a configuration to match your target (e.g., edit the Target Preferences dialog box. In this dialog box, you can modify your TASKING preferences configurations. You can also open this dialog box from the MATLAB prompt by typing
Accessing Utilities for TASKING
TriCore), you can
tasking_edit_prefs.
®
You must set up your target preferences before you can use Embedded IDE Link software. See “Setting Target Preferences” on page 1-10.
Select Preconfigured Target Preference Settings
Opens the Target Preferences Configuration Selection dialog box. Choose a configuration to matchyourtargetandclickOK.Thenyoucanselect a preconfigured option set. Your target preferences are automatically updated according to the option set y ou select, for example, specifying either hardware or simulator settings. See “Option Sets” on page 1-30.
Launch and Test Communication with TASKING EDE
Opens the Target Preferences Configuration Selection dialog box. Choose a configuration and click OK, and Embedded IDE Lin k software tests whether MATLAB can communicate successfully with the Altium TASKING EDE for the selected configuration. You see messages at the command line to confirm whether communication is successful.
1-27
1 Getting Started
C r ea te a New Model (configured for use with TASKING)
Creates a new untitled Simulink model, with Embedded IDE Link configuration set options already added. You can also configure an existing model by selecting the Simulink model menu item Tools > Utilities
for Use with TASKING(R) IDE > Add Embedded IDE Link Configuration to Model.
View, Modify, and Copy Configuration Sets via Model Explorer
Opens the Model Explorer where y ou can edit all configuration sets available for each currently open model.
Create New Template Projects
The Embedded IDE Link product ships with preconfigured application and library template projects for the default configurations in the Target Preferences dialog b ox . Y o u might, however, create your own template projects (using preconfigured options as a starting point), and use them with any configuration. See “Tutorial: Creating New Template Projects” on page 5-4 for an example, and “Template Projects” on page 2-4 for more information.
1-28
This option opens the Target Preferences Configuration Selection dialog box. Choose a configuration and click OK,andEmbeddedIDELink software launches the appropriate TASKING EDE and creates new template projects for a specific Tasking Configuration.Whenyouare prompted, choose a project folder, a template name, and an option set. See “Option Sets” on page 1-30 for more details.
lib_template_name.pjt are created for the configuration you selected.
Open Existing Template Projects
Opens existing application and library template projects in the TASKING EDE for the selected Tasking Configuration.Youcanmodifythese options; however, it is preferable to do this by first creating new template projects, which avoids overwriting the default template projects. If you modify the default template projects, you can use the following function to recreate the defaults: You must specify your configuration description string, e.g.:
tasking_generate_templates('C166', true).
tasking_generate_templates.
app_template_name.pjt and
Accessing Utilities for TASKING
Note Opening or editing template projects causes the regeneration of application and library projects. When making any cha n ges to template projects, it is important to make sure your changes are saved. To do this, remove the project from the project space; otherwise the changes may not be applied immediately. To remove a current project from the project space, right-click on it and choose Remove from Project Space.
Demos
Opens the Embedded IDE Link Demos page in the Help browser.
Tools Menu Items
In a Simulink model, you can access Embedded IDE Link menu items in the Tools menu. Select Tools > Utilities for Use with TASKING(R) IDE to see the following submenu items.
Target Preferences
®
As it does in the Start menu, this menu choice opens the Target Preferences Configuration Selection dialog box. After you choose a configuration, you can edit the Target Preferences Setup dialog box. You must set up your target preferences before you can use Embedded IDE Link software. See “Setting Target Preferences” on page 1-10.
A dd Embedded IDE Link Configuration to Model
Adds Embedded IDE Link configuration options to the model configuration parameters.
To see exactly which configuration parameter settings are changed, refer to
tasking_addto_configset.m.Enteredit tasking_addto_configset.
Remove Embedded IDE Link Configuration from Model
Removes Embedded IDE Link configuration options from the model’s configuration parameters.
Options
Opens the Configuration Parameters dialog box to show Embedded IDE Link software options. See “Configuration Set Options” on page 1-16.
1-29
1 Getting Started
Option Sets
In this section...
“What Are Option Sets?” on page 1-30
“Supported DAS Software” on page 1-32
What Are Option Sets?
Option sets are preconfigured settings to specify the target configuration for the Altium TASKING tools. For example, after you set u p your target preferences for a TriCore configuration, you can use option sets to switch between using an instruction set simulator configuration, two hardware board configurations, or a simulator with some MISRA C rule checking.
You can use option sets either:
To switch between default target configurations, or
1-30
When creating new template projects, to set up an initial configuration
that you can choose to modify later
See “Tutorial: Using Option Sets” o n page 5 -2 for instructions.
The following preconfigured option sets are available.
A notation of “*” indicates the de fault in the Target Preferences. The processor type for the default configurations below is defined by your TASKING toolchain.
Infineo n TriCore:
- * tricore_sim: Default instruction set simulator c onfiguration.
- tricore_sim_misra:Astricore_sim,butwithsomeexampleMISRA
C rule checking enabled. See also the TriCore MISRA C demo example,
tasking_demo_misra.m, with instructions under Embedded IDE Link
Demos.
- tricore_1796b: Infineon TriCore 1796b hardware configuration.
- tricore_1766b: Infineon TriCore 1766b hardware configuration.
Infineon C166:
- c166_sim : Default instruction set simulator configuration.
- c167cr : Phytec kitCON-C167CR serial connection to hardware (_hw)
and simulator (
_sim)configurations.
- *c167cs : Phytec phyCORE-C167CS serial connection to hardware (_hw)
and simulator (
_sim*) configurations.
- st10f252 : STMicrolectronics MB449 ST10F25x EVA Board serial
connection to hardware (
_hw)andsimulator(_sim) configurations.
- st10f269 : Phytec phyCORE-ST10F269 serial connection to hardware
(
_hw)andsimulator(_sim)configurations.
- xc164cm : Infineon XC164CM U CAN start kit USB connection to
hardware ( “Supported DAS Software” on page 1-32.
_hw_u_can)andsimulator(_sim_u_can)configurations. See
- xc167ci: On-board parallel port wiggler connection to the Infineon
XC167CI Starter Kit hardware (
_hw)andsimulator(_sim)configurations.
Option Sets
xc167ci_hw_usb : USB wiggler connection to the XC167CI
Note For xc167ci targets, you must change jumper 501 when switching between USB wiggler and on-board parallel port wiggler. See your board manual for details.
Renesas M16C
- * m16c_sim: Default instruction set simulator configuration.
- r8ctiny_sim: Renesas R8C Tiny instructi on set simulator configuration.
ARM:
- * arm_sim: Default instruction set simulator configuration.
- arm_sim_big_endian: As arm_sim, but in big-endian mode.
Freescale DSP563xx:
- * dsp563xx_sim: DSP563xx Family, 16-bit memory model, instruction
set simulator configuration.
1-31
1 Getting Started
- dsp566xx_sim: DSP566xx Family instruction set simulator
configuration.
8051:
- * i8051_sim: Default, large memory model, no language extensions,
floating point, instruction set simulator configuration.
Supported DAS Software
For the XC164CM and certain TriCore hardware like TC1766 and TC1796, you need to download and install the supported DAS software. If your installation of the TASKING toolset did not come with DAS, then you can download the late st DAS software from this URL:
http://www.infineon.com/das.
At the time of writing, the latest tested DAS versions are:
DAS Edition v2.6.2
1-32
JTAG JDRV LPT Server v2.4.0
Make sure you res tart your computer as instructed after DAS installation.
Components
“Project Generator” on page 2-2
“Automation Interface” on page 2-13
2
2 Components
Project Generator
In this section...
“Overview of the Project Generator Component” on page 2-2
“Project-Based Build Process” on page 2-4
“Template Projects” on page 2-4
“Shared Libraries” on page 2-6
“Build Process — Folder Structure” on page 2-9
Overview of the Project Generator Component
The Embedded IDE Link Project Generator Component provides a customizable build process that is designed to work with the highly customizable code generation process provided by Real-Time Workshop. See “Project Generator” on page1-3forasummary.
2-2
To explain the separation of duties between Real-Time Workshop and Embedded IDE Link, the following sections discuss the terms code generation process and build process.
Code Generation Process
The co de generation process is performed by the Real-Time Workshop family of products and is the process of translating a Simulink model into C code.
Customized code generation, perhaps to create target-s pecific device drivers or target-optimized code, is often a key requirement for users who want to generate code from Simulink models.
Real-Time Workshop and Real-Time Workshop Embedded Coder provide a variety of mechanisms for users to customize the code generation process. For example, the standard code generation process, using the regular system target files (like to the model’s configuration parameters. Alternatively,foranevengreater level of custom ization, including the ability to define cu stom Real-Time Workshop options, you can use a user created sys tem target file.
grt.tlc and ert.tlc) can be customized by making changes
Project Generator
The demos that come with Embedded IDE Link make use of the first type of customization with regular system target files. That is, the standard code generation process has been tailored for the appropriate target platform simply by changing the model’s configuration parameters.
For greater flexibility, you should use a custom system target file. For further details on customizing the code generation process, see the Real-Time Workshop and Real-Time Workshop Embedded Coder documentation.
Build Process
The build process is performed by Embedded IDE Link and is the process of taking the C code produced by the code generation process and building (assembling, compiling, and linking) it for the target platform.
A customized build process, perhaps to use optimized compiler and linker settings, or perhaps to produce a MISRA compliance report, is often a key requirement for users wishing to build code produced from S imulink models.
Embedded IDE Link provides access to the full build process customization capabilities of the TASKING tools by allowing the user to set up the exact required configuration in TASKING. Embedded IDE Link then uses this configuration as a template for the build process.
Memory Placement Example
As an example, to consolidate the descriptions above of code generation and the build process, consider the common task of placing program data into a particular area of memory on a target platform.
Usually, this is achieved by using compiler-specific notati ons (like #pragmas) to define special memory sections and to assign data definitions to those sections. Additionally, a link er command file defines the different available memory regions on the target, and where in these regions the different memory sections should be located.
Splitting this task between the processes of code generation and building couldbedoneasfollows:
1 Customized code generation defines memory sections and assign s data.
2-3
2 Components
2 Customized build process defines memory regions and assigns memory
sections.
Project-Based Build Process
The Embedded IDE Link build process automatically creates TASKING EDE projects representing the application and libraries to be built.
A Real-Time Workshop application usually consists of some application code that makes references to modules that are part of libraries like the Real-Time Workshop library. Another common library is the Signal Processing Blockset library, used with the Signal Processing Blockset.
Embedded IDE Link creates separate projects for the main application code and each required library. The required libraries are included in the main application projects as subprojects.
Although the build process is project-based, underlying the projects are “makefiles” that can be used independently of the EDE. For an example of howtoobtaintheappropriatemakecommand,seethedemoinstructionsin
tasking_demo_objects.m .
2-4
Target Project Space
Embedded IDE Link places projects in a project space known as the target project space. The location of the target project space is controlled by the
Target_Project_Space setting in the Target Preferences, and usually
depends on the current folder at the time the build process is invoked, the model name, and model configuration settings, including the name of the template application project.
$(DEFAULT_LOCATION) token, which is expanded based on the
Template Projects
Template projects are regular TASKING EDE projects that are used by Embedded IDE Link to allow customization of the build process. Template projects are tied to particular TASKING Configurations as set up in the Target Preferences.
There are two types of template projects: application, and library template projects.
Project Generator
The application template project is used as the template for application projects and the library template project is used as the template for library projects.
Relocation of Template Projects
During the build process, the template project is copied to a target project location, and is then populated w ith the information relating to how to build the generated code.
Therefore, the project options of the template project become the project options of the target project, and hence the build process is customized according to the template project.
On subsequent build processes, Embedded IDE Link determines whether the template project has been updated since it was last copied to the target project location. If it has, then the target project is updated with a new copy of the template project. Otherwise, the target project is not updated from the template project.
Note Project options should be updated in the template project and not in the target project.
2-5
2 Components
How the Build Process Modifies the Relocated Template Project
The Embedded IDE Link build process determines if any changes (preprocessor defines, include paths and source files) to the target project are required to build the code associated with a particular model, and updates the target project only if required. Thus, unnecessary project rebuilding is avoided.
Any include paths and preprocessor defines in the template project are alw ays maintained in the target project. Maintaining this information is useful for keeping the include path to the compiler’s standard header files, and setting global defines.
Additionally, the optional startup code file automatically generated by the EDE is also maintained.
Note Adding any other source files to your template project is not supported and will result in errors. Instead, you should add source files to the project by adding them to the Real-Time Workshop Build Info object by using either the Real-Time Workshop Custom Code settings in the configuration parameters, the
rtwmakecfg.m mechanism, or by writing your own post code generation
command (taking care not to overwrite any existing commands). See the Real-Time Workshop documentation for details.
2-6
Shared Libraries
Embedded IDE Link models that share the same target project space share required libraries such as the Real-Time Workshop library. Sharing of libraries means that a library is only built the f irst time a model that requires it is built.
Theadvantagesofthisshared library approach are
No unnecessary per-model building of libraries; models with similar library
requirements (e.g., integer code only) can share libraries.
Libraries are built with the project options specified in the corresponding
template project.
Project Generator
Multiple sets of libraries, each with custom model, project options, or both
can coexist.
Utility Function Generation: Shared Location
The s hared library approach uses the Real-Time Workshop “Utility Function Generation” feature.
By setting utility function generation to use a shared location, rather than the model-specific default, you can ensure that the library projects created have no dependence on model-specific generated code. This feature is the key to allowing library projects to be shared between models.
As an example, consider the generated header file,
rtwtypes.h,thatcontains
the set of Real-Time Workshop data types availa ble for compiling code modules, including any libraries.
With the utility function generation set to the default, individu a l
rtwtypes.h
files are generated into each code generation folder. Therefore, multiple definitions of models. The problem is, how can one of these
rtwtypes.h would exist for a library shared between these
rtwtypes.h files be chosen
to build the library?
Setting the utility function generationtouseasharedlocationprovidesa solution. In this case, a single
rtwtypes.h file is ge nerated into a folder
shared between a set of models. This single file can be used to build the library without any dependence on the model-specific generated code.
Supporting Multiple Shared Utility Function Locations: Build Folder Suffix
The approach outlined in the previous section works well for a single set of models that have the same shared utility requirements.
However, w h at happens if you have tw o sets of models, each set with different shared utility requirements?
Normally, the Real-Time Workshop code generation process uses the current working folder as the location for generated files. In this location, it supports
2-7
2 Components
only a single shared utilities folder for each system target file. Therefore, it is possible for conflicts over the contents of the shared utility folder to occur.
Example 1. For example, conflicts would occur if the Hardware Implementation settings were different for two models using the same system target file. If the standard is customized by changing configuration set parameters, this situation is highly likely to occur.
grt.tlc or ert.tlc code generation process
To work around this problem, when using a in the Target Preferences) containing the Embedded IDE Link automatically appends the name of the current template application project to the regular Real-Time Workshop build folder suffix. This creates code generation and project folders that are specific to the current template application project , and so also specific to the current Hardware Implementation settings. Different Hardware Implementation settings always have different template projects.
Example 2. Another common example of this conflict, for two models sharing the same system target file, would be if one model was configured to support floating-point numbers and the other was configured to support integer code only.
To work around this conflict, use the Embedded IDE Link options Add build subdirectory suffix and Build subdirectory suffix.
If you select the Add build subdirectory suffix check box, then the Build subdirectory suffix you enter is appended to the regular Real-Time Workshop build folder suffix (before the name of the template application project discussed earlier, see “Template Projects” on page 2-4). This creates code generation and project fold ers that are specific to both the Build subdirectory suffix setting and the template projects.
For example, you can add non-floating-point models.
fp for floating point models and int for
Target_Project_Space (specified
$(DEFAULT_LOCATION) token,
2-8
Project Generator
Note Using the same build subfolder suffix for a similar set of models allows them to generate code into their own working folder, avoiding conflict with other models, while still allowing a shared utilities folder.
This feature of Embedded IDE Link removes the need for the user to manually manage changing folders to avoid shared utility folder conflicts.
See the demo models for examples of using this setting: E mbedded IDE Link for use with Altium TASKING Demos.
Build Process — Folder Structure
The following table shows the typical folders that are created, relative to the current working folder, during the Real-Time Workshop code generation process and the Embedded IDE Link build process.
Folder
$(REG_SUFFIX)_$(MODEL_SUFFIX)_$(TEMPLATE_NAME)\pjt_$(MODEL)
e.g,
ert_rtw_int_tricore_sim\pjt_fuelsys0
$(REG_SUFFIX)_$(MODEL_SUFFIX)_$(TEMPLATE_NAME)\pjt_rtwlib
$(REG_SUFFIX)_$(MODEL_SUFFIX)_$(TEMPLATE_NAME)\pjt_rtwshared
(if required)
$(MODEL)_$(REG_SUFFIX)_$(MODEL_SUFFIX)_$(TEMPLATE_NAME)
e.g.,
fuelsys0_ert_rtw_int_tricore_sim
Contents
Main project:
$(MODEL).pjt
and associated files.
Real-Time Workshop library project:
rtwlib.pjt
and associated files.
Shared utilities library project:
rtwshared.pjt
and associated files.
Real-Time Workshop code generation folder.
2-9
2 Components
Key
$(MODEL)
$(TEMPLATE_NAME)
$(REG_SUFFIX)
$(MODEL_SUFFIX)
Real-Time Workshop code generation model name (e.g.,
fuelsys0).
Token expanded from the name of the template application project in the target preferences (e.g., project name is prefixed with “
app_” this token is removed.
tricore_sim). If the
Regular Real-Time Workshop build folder suffix (e.g.,
ert_rtw).
Model-specific build folder suffix (e.g., int).
See the next details ab
section, “Command Line Project Information” on page 2-10, for
out finding file names, paths, and other build information.
Command Line Project Information
When you b the MATLA such as p and thei
The foll
### Building the PIL Application... ### Updating EDE projects according to BuildInfo object. Please wait... Creating project: t_shift_alg_ert_rtw_pil.pjt Updating preprocessor defines in project: t_shift_alg_ert_rtw_pil.pjt Updating include paths in project: t_shift_alg_ert_rtw_pil.pjt Adding source files to project: t_shift_alg_ert_rtw_pil.pjt
uild an application you can see information containing links at B command line. You can use these links to get further details
aths to projects, preprocessor defines, include paths, added files
rlocations.
owing example shows a typical output:
2-10
can click the hyperlinks within these messages to get more information.
You
build messages are more readable wi th this information hidden, and the
The
nks provide access when you require more details.
li
Project Generator
Click the project file name (e.g., t_shift_alg_ert_rtw_pil.pjt)toseethe full path to the project being built, like the following example:
Project path: D:\MATLAB\\work\tricore_fp\tricore_sim\ pjt_t_shift_alg_ert_rtw_pil\t_shift_alg_ert_rtw_pil.pjt
Click preprocessor defines to see a list of preprocessor defines similar to the one in the following example:
t_shift_alg_ert_rtw_pil.pjt preprocessor defines:
INTEGER_CODE=0 MAT_FILE=0 MODEL=t_shift_alg MT=0 MULTI_INSTANCE_CODE=0 NCSTATES=0 NUMST=1 ONESTEPFCN=1 TERMFCN=1 TID01EQ=0
Click include paths toseealistofincludepathssimilartotheoneinthe following example:
t_shift_alg_ert_rtw_pil.pjt include paths:
$(PRODDIR)\include D:\MATLAB\work\tricore_fp\t_shift_alg_ert_rtw D:\MATLAB\work\tricore_fp D:\MATLAB\matlab\toolbox\rtw\targets\tasking\taskingdemos D:\MATLAB\matlab\extern\include D:\MATLAB\matlab\simulink\include D:\MATLAB\matlab\rtw\c\src D:\MATLAB\matlab\rtw\c\libsrc D:\MATLAB\matlab\rtw\c\ert D:\MATLAB\work\tricore_fp\slprj\ert\_sharedutils D:\MATLAB\matlab\toolbox\rtw\targets\tasking\tasking\pil D:\MATLAB\work\tricore_fp\t_shift_alg_ert_rtw_pil
Click source files to see a list of files added and their full paths.
2-11
2 Components
t_shift_alg_ert_rtw_pil.pjt added files:
D:\MATLAB\toolbox\rtw\targets\tasking\tasking\pil\ pil_interface.h D:\MATLAB\toolbox\rtw\targets\tasking\tasking\pil\ pil_interface_common.h D:\MATLAB\toolbox\rtw\targets\tasking\tasking\pil\ pil_interface_lib.c D:\MATLAB\toolbox\rtw\targets\tasking\tasking\pil\ pil_interface_lib.h D:\MATLAB\toolbox\rtw\targets\tasking\tasking\ tasking_pil_main.c D:\MATLAB\work\tricore_fp\t_shift_alg_ert_rtw_pil\ pil_interface.c D:\MATLAB\work\tricore_fp\t_shift_alg_ert_rtw_pil\ pil_interface_data.h D:\MATLAB\work\tricore_fp\tricore_sim\ pjt_exp_t_shift_alg_ert_rtw\exp_t_shift_alg_ert_rtw.pjt D:\MATLAB\work\tricore_fp\tricore_sim\pjt_rtwlib\rtwlib.pjt
2-12
Automation Inter face
In this section...
“Overview of Automation Interface Component” on page 2-13
“Classes” on page 2-14
“Using Objects” on page 2-15
“List of Methods” on page 2-22
“Details of Particular Methods” on page 2-25
Overview of Automation Interface Component
The Embedded IDE Link Automation Interface Component provides powerful MATLAB API’s for automating interaction with the TASKING EDE and CrossView Pro Debugger. See “Automation Interface” on page 1-3 for a summary.
Automation Interface
Objects for Embedded IDE Link
Embedded IDE Link uses object-oriented programming techniques and requires a basic knowledge of some object-oriented terminology. The following are some fundamental terms you should understand:
O bject — Something you can operate on. An object is an instance of a class,
created by calling the class constructor.
C lass — A class defines the properties and methods common to all objects
of the class.
C onstructor — A function that creates an object, based on the class
definition, and initializes it.
Method — An operation o n an object, defined as part of the class definition.
P roperty — Part of an object, treated as a variable at times, that is defined
as part of the class definition.
Handle — A mechanism to access any object that Embedded IDE Link
creates. Used in this guide to refer to the object. Often the handle is the name you assign when you create the object.
2-13
2 Components
The following sections describe howtouseandgethelpforEmbeddedIDE Linkobjects. See“ObjectsDemoExample”onpage2-22foranexample demonstrating some basic capabilities of Embedded IDE Link objects.
Classes
The following table shows the different classes that are provided with Embedded IDE L in k for use with Altium TASKING.
Class
tasking.edeapi
tasking.edeprojectspace
tasking.edeproject
tasking.xviewapi
tasking.Tasking_Configuration
tasking.EDE_Configuration
tasking.CrossView_Pro_Configuration
Description
Represents the TASKING EDE.
Represents a project space in the TASKING EDE.
Represents a project in the TASKING EDE.
Represents the TASKING CrossView Pro debugger.
Property of a tasking.edeapi class representing TASKING configuration details.
Property of a
tasking.tasking_Configuration
representing EDE configuration details.
Property of a
tasking.tasking_Configuration
representing CrossView Pro configuration details.
2-14
Using Objects
The topics in thi
s section are:
Automation Interface
1 “Using the alti
2 “Creating an Object Directly” on page 2-19
3 “Determining the Available Me tho ds for a Class” on page 2-20
4 “Obtaining H
5 “Calling a Method” on page 2-21
6 “Determining the Available Properties for a Class” on page 2-21
7 “Accessin
8 “Objects Demo Example” on page 2-22
umtasking Function” on page 2-15
elp for a Class Method” on page 2-20
g a Property” on page 2-21
Using the altiumtasking Function
You can use altiumtasking to create Embedded IDE Link objects for Altium TASKING. The command
[ede,xview,projspc,proj] = altiumtasking
returns the follow ing results:
ede — A handle to the TASK ING EDE application.
xview — A handle to the TAS K ING CrossView Pro application.
projspc — A handle to the project space currently open in the EDE.
proj — A handle to the active project in the EDE.
Note You can only run altiumtasking after you configure your target
preferences. See “Setting Target Preferences” on page 1-10 in the Embedded IDE Link for Use with Altium TASKING documentation.
2-15
2 Components
x
s
When you first run altiumtasking, the Target Preferences Configuration Selection dialog box opens. Select your required configuration (for example,
TriCore), and click OK.
If you supplied a valid project space file when you configured the target
preferences,
altiumtasking opens that project space in the EDE window
and returns a handle to it. However, if no valid project space file exists, then
altiumtasking returns an empty project space handle.
If one or more projects are defined in the project space, and opened,
altiumtasking returns a handle to the active project. If no project is
opened,
altiumtasking returns an empty project handle.
You can also run
[ede,xview,projspc] = altiumtasking does not create and return the
altiumtasking in the following ways:
project handle.
[ede,xview] = altiumtasking does not create and return the project space
and project handles.
ede = altiumtasking does not create and return the Cross View Pro
application, project space and project handles.
altiumtasking(Property, Value) enables you to specify parameters that
control the behavior of the function. For example:
altiumtasking('configDesc','TriCore')
specifies the us e of the TriCore configuration in the function.
Create EDE and CrossView Pro Handles. This example generates EDE and CrossView Pro handles.
>>[ede, xview] = altiumtasking;
Registering COM object: "D:\share\apps\BuildTools\win32\TASKING\apps\tricore\v2.5r2\ctc\bin\
Creating COM object: xfwtc.CommandLine
Initializing COM object: -G "C:\Temp" -ini "C:\Temp\tricore_default.ini" -tcfg "D:\share\app
Testing COM communications with CrossView Pro by sending command: "echo MATLABLinkTest"
2-16
Automation Interface
[Test timeout is 60 seconds, to allow hardware setup - use "Ctrl-C" to terminate]
Test successful.
Note You must save preferences to the CrossView Pro .ini file. The link software overwrites the temporary file, ( when it creates a new
1 In CrossView Pro, se lect File > Exit. The Options dialog box opens.
2 On the Save tab, select the Save desktop and target settings check box.
3 Click Exit. CrossView Pro exits after a few moments, saving your
preferences in the
xviewapi object. ):
.ini file.
C:\Temp\tricore_default.ini,
You can view the handles CrossView Pro created.
>> ede
tasking.edeapi (handle)
configuration: [1x1 tasking.Tasking_Configuration]
"configuration" property:
Configuration_Description: 'TriCore'
EDE_Configuration: [1x1 tasking.EDE_Configuration]
CrossView_Pro_Configuration: [1x1 tasking.CrossView_Pro_Configuration]
Connected to EDE: 0
>> xview
tasking.xviewapi (handle)
configuration: [1x1 tasking.CrossView_Pro_Configuration]
"configuration" property:
CrossView_Pro_Executable: [1x76 char]
Initialization: [1x29 char]
Initialization_File: [1x107 char]
2-17
2 Components
]
Status:
Current executable: None
Current project: None
isRunning: 0
eventReporting: 1
Create an EDE handle for TriCore . This example creates an EDE handle for
TriCore.
>> obj = altiumtasking('configDesc', 'TriCore')
tasking.edeapi (handle)
configuration: [1x1 tasking.Tasking_Configuration]
"configuration" property:
Configuration_Description: 'TriCore'
EDE_Configuration: [1x1 tasking.EDE_Configuration]
CrossView_Pro_Configuration: [1x1 tasking.CrossView_Pro_Configuration
2-18
Connected to EDE: 0
Automation Interface
Creating an O b ject Directly
Embedded IDE Link allows you to create objects directly. To find o ut how to create an object of a particular class you can use the for the constructor. At the M ATLAB command prompt, enter
help <classname>.<constructorname>
For example, for the tasking.edeapi class, enter
help tasking.edeapi.edeapi
For the tasking.edeprojectspace class, enter
help tasking.edeprojectspace.edeprojectspace
help function to find help
Follow t
1 To crea
hese steps to create example objects.
te a
tasking.edeapi object, you call the constructor as follows :
Ede = tasking.edeapi
Thenameontheleftsideofthe“=” could be any valid MATLAB identifier and is the handle to the object.
You must choose a configuration, then communication is tested with the TASKING EDE. At the command line you see the configuration target preferences.
2 To create a tasking.edeprojectspace object, you call the constructor as
follows:
tasking.edeprojectspace(projspace, edeapi)
where projspace is the absolute path of the TASKING Project Space this object will relate to, and
edeapi is a tasking.edeapi object, as shown in
the following example:
ps = tasking.edeprojectspace('D:\MATLAB\work\
myprojspace.psp', Ede)
3 To create a tasking.edeproject object, you call the constructor as follows:
tasking.edeproject(proj, edeprojspace)
2-19
2 Components
where proj istheabsolutepathoftheTASKING Project this object relates to, and
edeapiprojspace is a tasking.edeprojectspace object, as shown
in the following example:
proj = tasking.edeproject('D:\MATLAB\work\myproj.pjt', ps)
4 To create a tasking.xviewapi object, you call the constructor as follows
xv = tasking.xviewapi
You must choose a configuration, then communication is tested with CrossView Pro. At the command line, you see the configuration target preferences.
Determining the Available Methods for a Class
After you create an object, you can find the available methods by running the “methods” function.
1 For exam ple, to find the methods available on the tasking.edeapi object
created above (in “Creating an Object Directly” on page 2-19), enter
methods(Ede).
2-20
2 To find the methods available on the tasking.edeprojectspace object
previously created, enter
3 To find the methods available on the tasking.edeproject object previously
created, enter
4 To find the methods available on the tasking.xviewapi object previously
created, enter
methods(proj).
methods(xv).
methods(ps).
To see the methods available, refer to the tables in “List of Methods” on page 2-22.
Obtaining Help for a Class Method
To get help for a class method, you can use the help function.
For example, to find out more about the
tasking.edeapi class, you could enter the following command:
getProject method of the
Automation Interface
help tasking.edeapi.getProject
MATLAB returns the following output:
GETPROJECT - get the active Project in the EDE project = getProject project: edeproject object representing the active Project
in the EDE
project will be empty if there is no open project
To see the methods available, refer to the tables in “List of Methods” on page 2-22.
Calling a Method
When you know the details of a class method, you can call it using dot (.) notation.
For example, to get a
tasking.edeproject object representing the active
project, run the following command:
project = Ede.getProject
Determining the Available Properties for a Class
After you create an object, you can find the available propertie s by running the
get function.
For example, to find the properties available on the
tasking.edeapi object
created above, enter
get(Ede)
Accessing a Property
You can access a property of a class using dot (.) notation.
For example, to get the “configuration” property of the created above, enter:
config = Ede.configuration
tasking.edeapi object
2-21
2 Components
tasking.Tasking_Configuration (handle)
Configuration_Description: 'C166'
EDE_Configuration: [1x1 tasking.EDE_Configuration]
CrossView_Pro_Configuration: [1x1 tasking.CrossView_Pro_
Configuration]
Objects Demo Example
For experience using objects, you can work through the demo example,
tasking_demo_objects.m, found under Embedded IDE Link for use with
Altium TASKING Demos.
This example provides step-by-step instructions for using Embedded IDE Link objects to communicate with the TASKING EDE and CrossView Pro debugger from the MATLAB command line. You can use any command available in the powerful CrossView Pro command language. The demo illustrates using objects during the process of building and debugging projects.
List of Methods
See the following tables for lists of available methods:
2-22
“Methods for Class tasking.edeapi” on page 2-22
“Methods for Class tasking.edeprojectspace” on page 2-24
“Methods for Class tasking.edeproject” on page 2-24
“M ethods for Class tasking.xviewapi” on page 2-24
The public methods are shown in the tables (methods beginning with “ “
p_” are private methods and should not be used).
Methods for Class tasking.edeapi
close getOptionSetNames
disp getProject
display getProjectSpace
edeapi getTargetProject
p”or
Automation Interface
exec getToolchainInfo
execApiMacro newProject
execRetNumeric newProjectSpace
execRetString newProjectTemplates
getCreatedEDEProcess newProjectTemplatesViaUI
getOptionSet newTempProjectSpaceIfNoneOpen
openProjectTemplates processTemplateProject
pwd validateToolchainDirectory
hilite_system connect
isconnected
2-23
2 Components
Methods for Class tasking.edeprojectspace
add deleteParentDir
getEDE isopen
checkValid disp
getOriginalPath new
checkValidProject display
getPath open
close edeprojectspace
isequal remove
Methods for Class tasking.edeproject
add getEDE isopen
build getFiles new
checkValid getHyperlink open
close getIncludes rebuild
debug getMakeCmd remove
disp getOriginalPath run
display getPath setCDefines
edeproject getProjectSpace setIncludes
getBuildOutput getTarget setPerformToolchainName-
Check
getCDefines hasFile
getDir isequal
2-24
Methods for Class tasking.xviewapi
addBreakpointCallback getEventReporting
getFunctionConfiguration debug
Automation Interface
disp halt
removeBreakpointCallbacks display
isRunning setEventReporting
downloadAndRun execute
xviewapi executeAndWait
getCommandResponse getExecutable
getProject hilite_system
readMemoryUnits writeMemoryUnits
reset stackProfile
stackProfileReset
Details of Particular Methods
The following methods of the tasking.xviewapi object simplify reading from and writing to target memory units (the smallest addressable unit in the memory o f the target).
readMemoryUnits
To see help for this function, enter
help tasking.xviewapi.readMemoryUnits
at the MATLAB command line.
writeMemoryUnits
To see help for this function, enter
help tasking.xviewapi.writeMemoryUnits
at the MATLAB command line.
Use these functions with the MATLAB functions,
typecast and swapbytes,
for reading and writing data of different datatypes.
To see examples of syntax, see the demo example,
tasking_demo_objects.m,
found under Embedded IDE Link for use with Altium TASKING Demos.
2-25
2 Components
2-26
Verification
“Processor-in-the-Loop (PIL)Cosimulation”onpage3-2
“C Code Coverage Reports” on page 3-13
“E xecution Profiling” on page 3-15
“Stack Profiling” on page 3-19
“Bidirectional Tracea bi li ty Between Code and Model” on page 3-22
“M ISRA C Rule Checking” on page 3-25
3
3 Verificati on
Processor-in-the-Loop (PIL) Cosimulation
In this section...
“Processor-in-the-Loop Overview” on page 3-2
“PIL Workflow” on page 3-3
“Creating a PIL Block” on page 3-5
“Building, Running, and Debugging PIL Block Applications” on page 3-8
“PIL Metrics” on page 3-11
Processor-in-the-Loop Overview
Overview of PIL Cosimulation
Processor-in-the-loop (PIL) cosimulation is a verification technique designed to help you evaluate how well a candidate algorithm (e.g., a control system) operates on the actual target processor selected for the application.
3-2
When using Embedded IDE Link software, you have the following options for PIL cosimulation:
T op-mo de l PIL simulation mode — you can run a complete model as a PlL
simulation on your target processor or instruction set simulato r.
M odel block PIL simulation mode — use PIL cosimulation for a model
reference component.
P IL block — you can create a PIL block from one of several Simulink
components including a model, a subsystem in a model, or subsystem in a library.
For information on processor-in-the-loop and how to use these different options, see“Verifying Compiled Object Code with Processor-in-the-Loop Simulation” in the Real-Time Workshop Embedded Coder documentation:
Processor-in-the-Loop (PIL) Cosimulation
Note All options (i.e. Top-model PIL, Model block PIL, and PIL block) are available when you use Embedded IDE Link software with Altium TASKING tools.
To learn how to use the top-model and Model block PIL simulation modes, refer to the Real-Time Worksho p Embedded Coder documentation linked above.
The following sections describe demos and detailed inf ormation on using the PIL block with Embedded IDE Link software and Altium TASKING tools.
PIL Workflow
You can work through the PIL block verification workflow demo for a hands-on example illustrating using SIL and PIL for system and unit testing:
tasking_demo_system_simulation.mdl.
By running this demo you will learn how to:
U se Software-in-the-Loop (SIL) to verify correct behavior of source
code, generated by Real-Time Workshop Embedded Coder software and executing o n the host processor
Use Processor-in-the-Loop (PIL) to verify correct behavior of object code
and generate metrics; the object code is cross-compiled from source code generated by Real-Time Workshop Embedded Coder software and executes on a target embedded processor
Create system and unit test models
Work with multiple heterogeneous target processors
Include existing / legacy algorithms for SIL and PIL verification
E xport a generated algorithm for inclusion in an existing project
Generate a fully deployable model-based application
3-3
3 Verificati on
Using target_block_verify
The function target_block_verify is used in the PIL Verification Workflow demo,
tasking_demo_system_simulation.mdl.
You can use
target_block_verify to verify a generated PIL or SIL block and
compare the results with the simulation or algorithm b lock.
[LOG_SIGS1, LOG_SIGS2] = target_block_verify('BLOCK1', 'BLOCK2')
turns on signal logging for the outports of BLOCK1,themodelcontaining
BLOCK1 is simulated and the logged signals are returned in LOG_SIGS1.
Next,
BLOCK1 and BLOCK2 are swapped, the same model is simulated again,
and the logged signals for
To verify a SIL or PIL block, set and set
BLOCK2 to the generated PIL or SIL block for BLOCK1.
Use full path names of Simulink blocks for
BLOCK2 may be in the same model as BLOCK1,orinitsownmodel. The
model(s) containing
LOG_SIGS1 and LOG_SIGS2 are ModelDataLogs objects containing all the
loggedsignalsfortheoutportsof
BLOCK2 are returned in LOG_SIGS2.
BLOCK1 to the simulation or algorithm block,
BLOCK1 and BLOCK2.
BLOCK1 and BLOCK2 are loaded.
BLOCK1 and BLOCK2 respectively. The data
returned for each outport is a Timeseriesobjectthatallowscomparisonand plotting capabilities.
If
BLOCK1 and BLOCK2 are in the same model, then one LOG_SIGS output is
returned containing the data for both
BLOCK1 and BLOCK2.
3-4
Caution target_block_verify makes temporary changes to the model by swapping Although
BLOCK1 and BLOCK2 in addition to setting some logging options.
target_block_verify restores the original settings of the model, it
is recommended that you save a copy of your model first.
Processor-in-the-Loop (PIL) Cosimulation
Creating a PIL Bl
The PIL settings under the Embedd
can be found in the Configuration Parameters dialog box
ed IDE Link settings.
ock
The following options are available under Processor-in-the-Loop (PIL) Verification
Configure model to build PIL algorithm object code
Select this box to create PIL algorithm object code as part of the Real-Time Workshop code generation process.
PIL block action
Select one of the following PIL block actions:
- Create PIL block, then build and download PIL application
3-5
3 Verificati on
Select this option to automatically build and download the PIL application after creating the PIL block. This option is the default when you s elect the option to configure the model for PIL.
3-6
Processor-in-the-Loop (PIL) Cosimulation
- Create PIL block
Choose this option to create the PIL block and then stop without building. You can build manually from the PIL block.
- None
Choose this option to avoid creating a PIL block, for instance if you have already built a PIL block and do not want to repeat the action.
After you create and build a PIL block, you can either:
Copy it into your model to replace the original subsystem (save the original
subsystem in a different model so it can be resto red), or
Add it to your model to compare with the original subsystem during
cosimulation.
See “Building, Running, and Debugging PIL Block Applications” on page 3-8 for more details.
3-7
3 Verificati on
Building, R unni
ng, and Debugging PIL Block
Applications
This section inc
“B uilding and
“PIL Debuggin
Building and Downloading PIL Applications
After you cre use it for co Configurat applicatio
build and do
you can use
To build an
1 Double-c
2 Click Build. Wait until the Application name in the mask is updated and
you see the “build complete” message.
3 Click Download.
ludes the following topics:
Downloading PIL Applica tion s ” on page 3-8
g” on page 3-10
ate a PIL block, you must build and download it before you can
simulation. You can use the PIL Block Action setting in the
ion Parameters to automatically build and download the PIL
n after the PIL block is created (select
wnload PIL application
the P IL block to build and download manually.
d download the PIL application manually:
lickthePILblocktoopenthemask.
). If you choose not to use this option,
Create PIL block, then
3-8
4 Wait un
the “do close
The PI the PI or in
mulation.
cosi
r the test, Embedded IDE Link software returns execution profiling, code
Afte
erage, and stack profiling reports to MATLAB for your rev iew. See “PIL
cov
rics” on page 3-11 for more information.
Met
til the output in the MATLAB command window stops and you see
wnload complete” message in the PIL block, and then click OK to
the block mask.
L Application is now ready. To cosimulate with it, you must copy
L block into your model, either to replace the original subsystem
addition to it for comparison. Click Start Simulation to run a PIL
Processor-in-the-Loop (PIL) Cosimulation
Note When copying PIL blocks to be used in the same model or in different models that simulate simultaneously, you must click the Download button in the PIL block mask in the new block after copying.
Clicking Download creates new connections (handles) to the TASKING EDE and CrossView Pro debugger. Otherwise, the same debugger handle may be used by multiple PIL blocks simultaneously and cosimulation errors or incorrect results may occur. This concern does not apply when copying PIL blocks created automatically as part of the build process because the untitled model and test harness are typically not simulated together.
See the Embedded IDE Link demos for examples with instructions to enable you to build and download PIL blocks and use them in cosimulation.
PIL Block Parameters. For generic PIL block information, see “Setting Up PIL Simulations With the Embedded IDE Link Product PIL Block” in the Real-Time Workshop Embedded Coder documentation.
Embedded IDE Link software creates PIL blocks with both the Simulink system path and Configuration properties automatically configured.
The available Configurations correspond to the TASKING Configuration descriptions in the Target Preferences.
Some guidelines for choosing a valid configuration:
1 The configuration must generate debugging information because Embedded
IDE Link software requires this information to communicate with the PIL application.
2 The configuration must be compatible with the Target Pref erences
Configuration that was used to build the PIL algorithm. The fact that
these two configurations need not match exactly allows the flexibility for thePILalgorithmtobecompiledasifforaproductionenvironment,for example, without generating debugging information. However, you must be careful to ensure that the configurations are compatible in terms of linking, otherwise build errors occur when building the PIL application. In many cases, it is appropriate to use exactly the same configuration f or
3-9
3 Verificati on
building both the PIL algorithm and PIL application and therefore no errors can ever occur because of incompatibilities between configurations.
PIL Debugging
Prior to PIL cosimulation you can use the CrossView Pro debugger to set breakpoints, so that you can step through the code and watch variables during cosimulation. To do this, you must set breakpoints in CrossView Pro prior to starting the cosimulation as follows:
1 When the build process completes, a minimized CrossView Pro window
should appear on your Windows Start menu. Maximize the CrossView Pro window.
2 In CrossView Pro, select File > Open Source, and choose a source file to
open. A typical choice would be to open the main generated file associated with the algorithm, e.g.
3 Choose a location in the file to set a breakpoint and click the “breakpoint”
button to the left of the line. A typical location for setting a breakpoint in the
model.c file would be one of the step functions.
model.c.
3-10
Note You can set multiple breakpoints in multiple files if you wish.
4 To add a variable to the watch, double-click the variable, and then click
Add Watch in the Expression Eva luation wind ow. A typical variable to add to the watch would be either the e xternal inputs or external outputs structures, which usually represent all of the inputs and outputs of the algorithm.
5 Start the PIL cosimulation in Simulink. When the breakpoint is
hit, Simulink pauses. CrossView Pro is available for debugging, and watch variables are updated. You can step through the code, set more breakpoints, and analyze data.
6 When you are finished debugging, you can continue running by clicking the
“play” button in CrossView Pro. This will allow the PIL cosimulation to continue. If you left the breakpoint in place then the cosimulation stops
Processor-in-the-Loop (PIL) Cosimulation
at that point again. To return to uninterrupted cosimulation, remove the breakpoints.
Caution Never remove the PIL synchronization breakpoint (set on the
pilDataBreakpoint function). This breakpoint is used to maintain
synchronization between Simulink and CrossView Pro.
As an alternative to manual configuration in CrossView Pro, you can obtain a handle to the the
tasking_pil_crossview_handle command as follows:
crossview = tasking_pil_crossview_handle('block')
tasking.xviewapi object associated with a PIL block by using
where block is the full Simulink system path to the PIL block. You can use
gcb to obtain the system path after clicking on the PIL block.
This handle can be used prior to PIL cosimulation to configure breakpoints, etc., by using the CrossView Pro command language.
Caution This handle should not be used during PIL cosimulation as this could lead to incorrect PIL results or termination of the PIL cosi mulation.
10-Second Pause on Termination of the CrossView Pro Debugger.
When terminating an instance of the CrossView Pro debugger application that was launched by Embedded IDE Link software, there is a pause of about 10 seconds before the CrossView Pro window closes. This 10-second pause is the intended behavior of CrossView Pro w hen acting as a COM server; CrossView Pro pauses for the 10 seconds to wait for clients such as MATLAB to release their COM references.
PIL Metrics
The following metrics provide ve rification information to be used in conjunction with the m ain “signal level” cosimulation results:
3-11
3 Verificati on
C Code Coverage reports
Execution profiling
Stack profiling
3-12
C Code Coverage Reports
After you download a PIL application and run a cosimulation, you can view reports in MATLAB. The reports available depend on the target configuration. For the C166 Simulator, a hyperlink is provided for each report in the MATLAB command window towards the end of the Real-Time Workshop build log (as shown in the following example):
PIL reports available from CrossView Pro for block: fuelsys Coverage ("covinfo"): Yes (pil_coverage_ repo rt) Profiling ("proinfo"): Yes (pil_profiling_report) Cumulative profiling ("cproinfo"): Yes (pil_cumulative_profiling_report)
CCodeCoverageReports
To view the C
pil_coverage_report =
Module: temp 0% Module: ..\..\fuelsys1_ert_rtw_int_c167cs_sim_pil... \pil_interface.c 74% Function: pilInitialize 75% Function: pilGetUDataSymbol 75% Function: pilStep 71% Function: pilGetYDataSymbol 75% Function: pilTerminate 75% Module: ..\..\..\..\..\matlab\toolbox\rtw\targets\common... \tgtcommon\pilsrc\pil_ide_data_stream.c 93% Function: pilDataBreakpoint 100% Function: pilReadData 90% Function: pilWriteData 94% Function: pilDataInit 100% Module: ..\..\..\..\..\matlab\toolbox\rtw\targets\common... \tgtcommon\pilsrc\pil_interface_lib.c 97% Function: getNextSymbol 100% Function: processData 93% Function: pilCommandLoop 99% Module: ..\..\..\..\..\matlab\toolbox\rtw\targets\common... \tgtcommon\pilsrc\pil_main.c 83% Function: main 83%
code coverage report, click the hyperlink
pil_coverage_report:
3-13
3 Verificati on
Module: ..\..\fuelsys1_ert_rtw_int_c167cs_sim\fuelsys1.c
61% Function: Sens_Failure_Counter 13% Function: Fueling_Mode 24% Function: Init_controllogic 100% Function: controllogic 47% Function: fuelsys1_step 79% Function: fuelsys1_initialize 100% Function: fuelsys1_terminate 100% Module: MEMCPY_C 100% Module: MEMSET_C 100% Module: MUL 100% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils... \binarysearch_s16.c 89% Function: BINARYSEARCH_S16 89% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils... \dotproduct_s32s16.c 100% Function: DotProduct_s32s16 100% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils... \interpolate_even_s16_s16_sat.c 84% Function: INTERPOLATE_EVEN_S16_S16_SAT 84% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils... \interpolate_s16_s16_sat.c 83% Function: INTERPOLATE_S16_S16_SAT 83% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils... \look2d_s16_s16_s16_sat.c 100% Function: Look2D_S16_S16_S16_SAT 100% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils... \div_s32_sat_floor.c 77% Function: div_s32_sat_floor 77% Module: UDIL 29% Module: UMOL 24% Module: fuelsys1_pil 0% Module: CSTART 0% Module: ..\..\fuelsys1_ert_rtw_int_c167cs_sim\fuelsys1_data.c
0%
3-14
Execution Profiling
In this section...
“CrossView Pro Execution Profiling” on page 3-15
“Task Execution Profiling Kit for Real-Time Workshop Targets” on page 3-18
CrossView Pro Execution Profiling
After you download a PIL application and run a cosimulation, you can view reports in MATLAB. The reports available depend on the target configuration. For the C166 Simulator, a hyperlink is provided for each report in the MATLAB command window towards the end of the Real-Time Workshop build log (as shown in the following example):
PIL reports available from CrossView Pro for block: fuelsys Coverage ("covinfo"): Yes (pil_coverage_ repo rt) Profiling ("proinfo"): Yes (pil_profiling_report) Cumulative profiling ("cproinfo"): Yes (pil_cumulative_profiling_report)
Execution Profiling
Maximum stack usage during PIL (including the PIL test framework overhead):
C166 User Stack: 59/109 (54.13%) words used.
To view the profiling report, click the hyperlink pil_profiling_report:
pil_profiling_report =
Total Execution Time: 4447016
Cycles %Cycles Function: pilInitialize 16 0.000% Function: pilGetUDataSymbol 22428 0.504% Function: pilStep 20826 0.468% Function: pilGetYDataSymbol 22428 0.504% Function: pilTerminate 16 0.000% Function: pilDataBreakpoint 14454 0.325% Function: pilReadData 549878 12.37%
3-15
3 Verificati on
Function: pilWriteData 166816 3.751% Function: pilDataInit 4 0.000% Function: getNextSymbol 80100 1.801% Function: processData 288360 6.484% Function: pilCommandLoop 137966 3.102% Function: main 6432 0.145% Function: Sens_Failure_Counter 22400 0.504% Function: Fueling_Mode 54740 1.231% Function: Init_controllogic 58 0.001% Function: controllogic 121744 2.738% Function: fuelsys1_step 677674 15.24% Function: fuelsys1_initialize 48 0.001% Function: fuelsys1_terminate 4 0.000% Function: BINARYSEARCH_S16 372458 8.375% Function: DotProduct_s32s16 37642 0.846% Function: INTERPOLATE_EVEN_S16_S16_SAT 51678 1.162% Function: INTERPOLATE_S16_S16_SAT 528118 11.88% Function: Look2D_S16_S16_S16_SAT 256320 5.764% Function: div_s32_sat_floor 406596 9.143% Module: temp 0 0.000% Module: ..\..\fuelsys1_ert_rtw_int_c167cs_sim_pil\pil_interface.c
65714 1.478% Module: ..\..\..\..\..\sandbox\targets with spaces\matlab... \toolbox\rtw\targets\common\tgtcommon\pilsrc\... pil_ide_data_stream.c 731152 16.44% Module: ..\..\..\..\..\sandbox\targets with spaces\matlab... \toolbox\rtw\targets\common\tgtcommon\pilsrc\... pil_interface_lib.c 506426 11.39% Module: ..\..\..\..\..\sandbox\targets with spaces\matlab... \toolbox\rtw\targets\common\tgtcommon\... pilsrc\pil_main.c 6432 0.145% Module: ..\..\fuelsys1_ert_rtw_int_c167cs_sim\... fuelsys1.c 876668 19.71% Module: MEMCPY_C 357522 8.040% Module: MEMSET_C 792 0.018% Module: MUL 13398 0.301% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils\... binarysearch_s16.c 372458 8.375% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils\... dotproduct_s32s16.c 37642 0.846%
3-16
Execution Profiling
Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils\... interpolate_even_s16_s16_sat.c 51678 1.162% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils\... interpolate_s16_s16_sat.c 528118 11.88% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils\... look2d_s16_s16_s16_sat.c 256320 5.764% Module: ..\..\slprj\ert_int_c167cs_sim\_sharedutils\... div_s32_sat_floor.c 406596 9.143% Module: UDIL 147648 3.320% Module: UMOL 85064 1.913% Module: fuelsys1_pil 0 0.000% Module: CSTART 0 0.000% Module: ..\..\fuelsys1_ert_rtw_int_c167cs_sim\... fuelsys1_data.c 0 0.000% 27: readDataPtr = & pil_ide_data_buffer[0];
For cumulative profiling, command line messages like the following inform you that you must configure CrossView Pro to specify which functions to collect data for. Select Tools > Cumulative Profiling Setup,specify functions, and then run the cosimulation again to get the report.
NOTE: Cumulative profiling requires manual setup in CrossView Pro. See Tools->Cumulative Profiling Setup DO NOT add the function pilDataBreakpoint to the list of functions to profile.
You must then run the PIL simulation again to generate the report.
pil_cumulative_profiling_report =
CrossView Cumulative Profiling Report
------------------------------------­Total Execution Time: 4447016 Function Calls Recursive Min.Time Max.Time Avg.Time Total Time %Time
For i nformation on build messages containing links at the command line, see “Command Line Project Information” on page 2-10.
3-17
3 Verificati on
Task Execution Profiling Kit for Real-Time Workshop Targets
This kit, available on MATLAB Central, provides instructions and examples on how to implement real-time task based execution profiling on a custom target. A graphical representation of on-target execution and a HTML report are provided for analysis. You can implement this for your own custom system target file that uses the Embedded IDE Link project generator.
For details, see http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=12731
3-18
Stack Profiling
In this section...
“What Is Stack Profiling?” on page 3-19
“PIL Applications” on page 3-19
“Non-PIL Applications” on page 3-20
“Infineon®TriCore Stack Depth Analyzer” on page 3-21
What Is Stack Profiling?
Stack profiling gives you a maximum bound on the stack usage of an application. The stack profiling feature works by fir st writing a signature to the s tack memory region, then when the application executes normally, the signature pattern is overwritten by the application s tack data. Finally the stack memory is read into MATLAB and analyzed to determine how much of the stack memory w as used during execution.
Stack Profiling
PIL Applications
Stack profiling is automatically reported after PIL cosimulation. The report gives you a maximum bound on the stack usage of the algorithm under test.
OutputatendofPIL(boldindicateshyperlinks):
Maximum stack usage during PIL (including the PIL test framework overhead): TriCore User Stack: 24/2048 (1%) words used. TriCore Interrupt Stack: 0/256 (0%) words used.
The hyperlinks for the individual stacks expand to more information about that stack, as shown in the following example.
3-19
3 Verificati on
The hyperlink for "including the PIL test framework overhead" expands to show this explanation:
PIL Test Framework Overhead: The maximum stack usage reported after PIL is the stack usage of the entire PIL application, which includes a small amount of stack used by the PIL test framework. The stack usage reported is therefore a maximum bound on the stack usage of the algorithm under test.
3-20
To more accurately determine the stack usage of the algorithm it is possible to use the Embedded IDE Link CrossView Pro stack profiling feature on an application that is not configured for PIL. This will allow the stack usage to be determined without the stack overhead of the PIL test framework.
Non-PIL Applications
Non-PIL applications (perhaps with stimulus signals coming from target I/O drivers) can be profiled using the CrossView Pro API commands
stackProfileReset and stackProfile.
1 Call stackProfileReset to reset the application you are debugging, and
write a signature pattern to the stack memory region. Use the following syntax:
xview.stackProfileReset
where xview is a tasking.xviewapi object. See “Methods for Class tasking.xviewapi” on page 2-24.
Stack Profiling
2 Call stackProfile immediatelyafterresettingtoview0%stackusage
profiling results.
3 Execute the application (e.g., xview.execute('C')).
4 After the amount of time you want to profile for, stop the application using
xview.halt
5 Call stackProfile to get the profiling results for the execution period.
An example of this procedure is shown following.
Infine
The In analy dynam
It ca ther
Cli cli
on TriCore Stack Depth Analyzer
fineon TriCoreStack Depth A nalyzer (SDA) tool is a static stack depth
zer for the TASKING TriCore toolset. This is an alternative to the
ic stack profiling provided with Embedded IDE Link software.
nbefoundattheInfineonTriCoreSoftware Downloads page. Navigate
efromthisURL:
http://www.infineon.com/tricore
ck the link on the right: “Development Tools, Software and Training”, then
ck “Software Downloads”.
3-21
3 Verificati on
Bidirectional Traceability Between Code and Model
In this section...
“Using Traceability” on page 3-22
“Enabling Traceability” on page 3-23
Using Traceability
Context menu items and command-line methods allow you to navigate bidirectionally between Simulink blocks and the corresponding generated source files in the TASKING EDE or the CrossView Pro debugger.
See the demo tasking_demo_objects to try this feature. This is a command line demo that you can run from the Help brow ser.
To find the generated code for any block in the model, right click on the block and select: Embedded IDE Link > See Generated Code in EDE or
Embedded IDE Link > See Generated Code in CrossView Pro.
3-22
This opens the source file which contains the ge nerate d code for the block, and highlights the Real-Time Workshop tag for that block. T he Real-Time Workshop tag is usually found in the block’s generated comments preceding the block’s code.
There are command-line alternatives to the right-click context menu items — see
tasking_demo_objects for an example.
To find the block which corresponds to some generated code in the EDE or CrossView Pro:
1 Click to place the cursor at the line of code containing the Real-Time
Workshop Tag for the given block. Here is an example:
/* Outputs for atomic SubSystem: '<Root>/SS2'
2 Enter at the MATLAB command prompt:
EDE_Obj.hilite_system
Bidirectional Traceability Between Code and Model
or
XView_Obj.hilite_system
Enabling Traceability
To use the Traceability feature, you must configure your model as follows:
1 Enable the generation of traceability information by adding
targets_trace_enable(gcs) to the PostLoadFcn callback of the model.
a Select File > Model Properties > Callbacks.’
b Click PostLoadFcn.
c Enter targets_trace_enable(gcs),asshown.
Click OK.
3-23
3 Verificati on
Note targets_trace_enable also selects the check box options Create
Code Generation report and Code-to-model under Report in the Configuration Parameters dialog box.
2 The model must use an ERT based Target.
3-24
MISRA C Rule Checking
The TASKING C compiler supports MISRA C rule checking and can be easily configured to check the code generated by Real-Time Workshop software.
You can switch on MISRA C rule checking in your application and/or library template projects. When you build using these template projects, the TASKING compiler will provide warnings about MISRA C violations. Embedded IDE Link software returns these warnings to the MATLAB command line for your review.
Embedded IDE Link software provides an example application project template, pre-configured for MISRA C rule checking, for the TASKING TriCore Toolset. For instructions, see the MISRA C Rule Checking demo,
tasking_demo_misra.m.
MISRA C®Rule Checking
3-25
3 Verificati on
3-26
Optimization
“C ompiler / Linker Optimization Settings” on page 4-2
“Target Memory Placement / Mapping” on page 4-3
“E xecution and Stack Profiling” on page 4-4
“Target Specific Optimizations” on page 4-5
“Model Advisor” on page 4-9
4
4 Optimization
Compiler / Linker Optimization Settings
Template projects allow you to fully control the optimization settings used by the compiler and linker.
Se e “Template Projects” on page 2-4 for details of using template projects.
See “PIL Block Parameters” on page 3-9 for information about optimization
setting requirements for Processor-in-the-Loop.
See the TASKING documentation for details of available optimization
settings.
4-2
Target Memory Placement / Mapping
Template projects allow you to fully control the target memory map used foryourapplication.
Se e “Overview of the Project Gene rato r Component” on page 2-2 for a
general discussion of how the code generation process and subsequent build process w ork together, including a memory placement example.
See “Template Projects” on page 2-4 for details of using template projects.
See the TASKING d ocumentation for details of memo ry map settings.
Target Memory Placement / Mapping
4-3
4 Optimization
Execution and Stack Profiling
In this section...
“Execution Profiling” on page 4-4
“Stack Profiling” on page 4-4
Execution Profiling
Execution profiling metrics from the CrossView Pro instruction set simulator during PIL cosimulation can be used to identify areas of your algorithms that can be further optimized.
See “Execution Profiling” on page 3-15 for details.
Stack Profiling
Stack profiling metrics for PI L cosimulation or real-time applications can be used to optimize the amount of stack memory required for an application.
4-4
See “Stack Profiling” on page 3-19 for details.
Target Specific Optimizations
In this section...
“C Language Extensions / Intrinsics” on page 4-5
“Target Optimized Libraries for Infineon XC166 and Infineon®TriCore” on page 4-7
“Target Optimized FIR / FFT Blocks for the Infineon®TriCore” on page 4-8
C Language Extensions / Intrinsics
Infineon TriCore
Target Specific Optimizations
Support
ANSI Support
ISO S upport
Saturated Arithmetic Support
ISO/IEC 9899:1999 Math Library. The target function library Infineon
TriCore ISO
implement floating-point mathematical function blocks (e.g. trigonometric functions, log functions). Using these target optimizations improves the performance of applications performing floating-point mathematical operations.
When using these target optimizations, the regular Real-Time Workshop implementation for many ANSI floating-point mathematical operations is replaced by the ISO equivalent. These functions behave identically to the regular Real-Time Workshop implementation and can be verified using processor-in-the-loop cosimulation.
uses the TASKING ISO/IEC 9899:1999 Math Library to
C89/C90 ANSI Targ et Function Library
Yes Yes Yes
Infineon TriCore ISO Targ et Function Library
Yes Yes
Infineon TriCore Target Function Library (ERT Only)
Yes
4-5
4 Optimization
You can use the Infineon TriCore ISO target function library with ERT or GRT system target files.
To enable the math library for the optimization of floating-point mathematical operations, select Target function library (on the Interface pane of the Configuration Parameters dialog box).
Infineon TriCore ISO for the Real-Time Workshop option
Saturated A rith metic. The target function library includes all ISO optimizations and also saturated arithmetic optimizations. The target function library system target files.
You can use T ASKING compiler extensions and intrinsic functions for saturated arithmetic. These target optimizations can increase execution speed up to 18 times for saturated arithmetic operations. The use of these target optimizations w ill improve the performance of most applications performing saturated arithmetic operations. It is therefore recommended to enable the optimizations.
When using these target optimizations, the regular Real-Time Workshop implementation for many saturated arithmetic operations are replaced by calls to target optimized inlined functions. The behavior of these functions is identical to the regular Rea l- Time Workshop implementation and can be verified using processor-in-the-loop cosimulation (see “Processor-in-the-Loop (PIL) Cosimulation” on page 3-2).
To enable TASKING compiler extensions and intrinsic functions for the optimization of saturated arithmetic, select Real-Time Workshop option Target function library (on the Interface pane of the Configuration Parameters dialog box).
Infineon TriCore is only available for ERT
Infineon TriCore for the
Infineon TriCore
4-6
General
Depending on your toolset, your the TASKING compiler may support C language extensions or intrinsics to help optimize in some of the following areas:
D ata Types (eg. Fractional Arithmetic, Bit Addressable Memory)
Memory Qualifiers (eg. Near, far address space)
Loading...