Agenda
Agenda
T
T
H E
H E
W
W
O R L D
O R L D
L
L
E A D E R I N
E A D E R I N
D
D
S
S
P
P
S
S
O L U T I O N S
O L U T I O N S
Overview
Overview
Hello, TI DSP, ‘C6000
Hello, TI DSP, ‘C6000
DSK
DSK
Tour of ‘C6711 DSK
Tour of ‘C6711 DSK
C Code
C Code
Code Composer Studio
Code Composer Studio
System
System
McBSP, Interrupts
McBSP, Interrupts
EDMA, Cache
EDMA, Cache
DSP/BIOS
DSP/BIOS
Real-Time Tools
Real-Time Tools
VAB
VAB
Visual Design
Visual Design
Epilogue
Epilogue
What Next?
What Next?
Programming the ‘C6000
Programming the ‘C6000
* Typical efficiency vs. hand optimized assembly
* Typical efficiency vs. hand optimized assembly
Source
Source
Efficiency*
Efficiency*
Effort
Effort
80 - 100%
80 - 100%
C
C
C ++
C ++
Compiler
Compiler
Optimizer
Optimizer
Low
Low
95 - 100%
95 - 100%
Linear
Linear
ASM
ASM
Assembly
Assembly
Optimizer
Optimizer
Med
Med
100%
100%
High
High
ASM
ASM
Hand
Hand
Optimize
Optimize
Sample Compiler Benchmarks
Sample Compiler Benchmarks
TI C62x™ Compiler Performance Release 4.0: Execution Time in
TI C62x™ Compiler Performance Release 4.0: Execution Time in
s @
s @
300 MHz Versus hand-coded assembly based on cycle count
300 MHz Versus hand-coded assembly based on cycle count
Algorithm
Algorithm
Used In
Asm
Cycles
Assembly
Time (s)
C Cycles
(Rel
4.0)
C Time
(s)
%
Efficiency
vs
Hand
Coded
Block Mean Square
Error
MSE of a 20 column
image matrix
For motion
compensatio
n of image
data
348
1.16
402
1.34
87%
87%
Codebook Search
CELP based
voice coders
977
3.26
961
3.20
100%
100%
Vector Max
40 element input
vector
Search
Algorithms
61
0.20
59
0.20
100%
100%
All-zero FIR Filter
40 samples,
10 coefficients
VSELP based
voice coders
238
0.79
280
0.93
85%
85%
Minimum Error
Search
Table Size = 2304
Search
Algorithms
1185
3.95
1318
4.39
90%
90%
IIR Filter
16 coefficients
Filter
43
0.14
38
0.13
100%
100%
IIR – cascaded
biquads
10 Cascaded biquads
(Direct Form II)
Filter
70
0.23
75
0.25
93%
93%
MAC
Two 40 sample
vectors
VSELP based
voice coders
61
0.20
58
0.19
100%
100%
Vector Sum
Two 44 sample
vectors
51
0.17
47
0.16
100%
100%
MSE
MSE between two
256 element vectors
Mean Sq.
Error
Computation
in Vector
Quantizer
279
0.93
274
0.91
100%
100%
Great out-of-box experience
Great out-of-box experience
Completely natural C code (non ’C6000 specific)
Completely natural C code (non ’C6000 specific)
Code available at:
Code available at:
http://www.ti.com/sc/c6000compiler
http://www.ti.com/sc/c6000compiler
Great out-of-box experience
Great out-of-box experience
Completely natural C code (non ’C6000 specific)
Completely natural C code (non ’C6000 specific)
Code available at:
Code available at:
http://www.ti.com/sc/c6000compiler
http://www.ti.com/sc/c6000compiler
Outline
Outline
Programming Methods
Programming Methods
Code Composer Studio (CCS)
Code Composer Studio (CCS)
Projects
Projects
Working with C
Working with C
Code Composer Studio
Code Composer Studio
Code Composer Studio Includes:
Code Composer Studio Includes:
Integrated Edit / Debug GUI
Integrated Edit / Debug GUI
Simulator
Simulator
*
*
3
rd
P
a
rt
y
P
LU
G
I
N
S
3
rd
P
a
rt
y
P
LU
G
I
N
S
Edit
Edit
SIM
SIM
Compiler
Compiler
Asm Opt
Asm Opt
Asm
Asm
DSK
DSK
EVM
EVM
Third
Third
Party
Party
Stand
Stand
ard
ard
Runti
Runti
me
me
Librari
Librari
es
es
Code Generation Tools
Code Generation Tools
BIOS:
BIOS:
Real-time kernel
Real-time kernel
Real-time analysis
Real-time analysis
Plug-ins
Plug-ins
RTDX
RTDX
DSP/BIOS
DSP/BIOS
Libraries
Libraries
DSP/BIOS
DSP/BIOS
Config
Config
Tool
Tool
Debug
Debug
.out
.out
Link
Link
* Simulator not included with DSK, only with full version of CCS.
* Simulator not included with DSK, only with full version of CCS.
Outline
Outline
Programming Methods
Programming Methods
Code Composer Studio (CCS)
Code Composer Studio (CCS)
Projects
Projects
Define
Define
and
and
Manage
Manage
Build Options
Build Options
and
and
Build
Build
Configurations
Configurations
Config Tool
Config Tool
(CDB file)
(CDB file)
Working with C
Working with C
What is a Project?
What is a Project?
Project (
Project (
.PJT
.PJT
) file
) file
contains
contains
Project files (
Project files (
by
by
reference
reference
):
):
Source
Source
Libraries
Libraries
Linker, etc …
Linker, etc …
Project settings:
Project settings:
Build configurations
Build configurations
(compiler, asm
(compiler, asm
options)
options)
DSP/BIOS
DSP/BIOS
Linking, etc …
Linking, etc …
Project Menu
Project Menu
Create new
Create new
projects
projects
Open projects
Open projects
Manage projects
Manage projects
Project Menu
Project Menu
Add files… to
Add files… to
project
project
Add drag-n-drop files
Add drag-n-drop files
onto .PJT
onto .PJT
Export Makefile
Export Makefile
New
New
Export project
Export project
details
details
to a standard
to a standard
.mak file
.mak file
Set as Active
Set as Active
Project
Project
New
New
Keep multiple
Keep multiple
projects open
projects open
Open for Editing
Open for Editing
New
New
Opens PJT with
Opens PJT with
text editor
text editor
Configurations…
Configurations…
New
New
Keep multiple sets
Keep multiple sets
of build options
of build options
Options…
Options…
Set build options
Set build options
Right-Click
Right-Click
Menu
Menu
Outline
Outline
Programming Methods
Programming Methods
Code Composer Studio (CCS)
Code Composer Studio (CCS)
Projects
Projects
Define and Manage
Define and Manage
Build Options
Build Options
and
and
Build
Build
Configurations
Configurations
Common compiler options and default
Common compiler options and default
configurations
configurations
Build Options GUI
Build Options GUI
Linker Options
Linker Options
Config Tool (CDB file)
Config Tool (CDB file)
Working with C
Working with C
Nearly one-hundred compiler options
Nearly one-hundred compiler options
available to tune your code's performance,
available to tune your code's performance,
size, etc.
size, etc.
Following table lists most commonly used
Following table lists most commonly used
options:
options:
Compiler Build Options
Compiler Build Options
Options
Options
Description
Description
-mv6700
-mv6700
Generate ‘C67x code (‘C62x is default)
Generate ‘C67x code (‘C62x is default)
-mv6400
-mv6400
Generate 'C64x code
Generate 'C64x code
-fr <dir>
-fr <dir>
Directory for object/ouput files
Directory for object/ouput files
-q
-q
Quiet mode (display less info while
Quiet mode (display less info while
compiling)
compiling)
-g
-g
Enables src-level symbolic debugging
Enables src-level symbolic debugging
-s
-s
Interlist C statements into assembly listing
Interlist C statements into assembly listing
-o3
-o3
Invoke optimizer (-o0, -o1, -o2/-o, -o3)
Invoke optimizer (-o0, -o1, -o2/-o, -o3)
-gp
-gp
Enable function-level profiling
Enable function-level profiling
-k
-k
Keep asm files, but don't interlist
Keep asm files, but don't interlist
debug
debug
optimize
optimize
(release)
(release)
To make options easier, TI recommends using …
To make options easier, TI recommends using …
Two Default Build Configurations
Two Default Build Configurations
For new projects, CCS
For new projects, CCS
automatically creates
automatically creates
two build
two build
configurations:
configurations:
Debug
Debug
(
(
unoptimized
unoptimized
)
)
Release
Release
(optimized)
(optimized)
-g -q -fr"c:\modem\
-g -q -fr"c:\modem\Debug
Debug
"
" -d"_DEBUG"
-d"_DEBUG"
-mv6700
-mv6700
-q
-q -o3
-o3
-fr"c:\modem\
-fr"c:\modem\Release
Release
" -mv6700
" -mv6700
Two Default Build Configurations
Two Default Build Configurations
For new projects, CCS
For new projects, CCS
automatically creates
automatically creates
two build
two build
configurations:
configurations:
Debug
Debug
(
(
unoptimized
unoptimized
)
)
Release
Release
(optimized)
(optimized)
Use the drop-down to
Use the drop-down to
quickly select
quickly select
build
build
config.
config.
-g -q -fr"c:\modem\
-g -q -fr"c:\modem\Debug
Debug
"
" -d"_DEBUG"
-d"_DEBUG"
-mv6700
-mv6700
-q
-q -o3
-o3
-fr"c:\modem\
-fr"c:\modem\Release
Release
" -mv6700
" -mv6700
Two Default Build Configurations
Two Default Build Configurations
For new projects, CCS
For new projects, CCS
automatically creates
automatically creates
two build
two build
configurations:
configurations:
Debug
Debug
(
(
unoptimized
unoptimized
)
)
Release
Release
(optimized)
(optimized)
Use the drop-down to
Use the drop-down to
quickly select
quickly select
build
build
config.
config.
Add/Remove build
Add/Remove build
config's with
config's with
Project
Project
Configurations
Configurations
dialog
dialog
(on project menus)
(on project menus)
-g -q -fr"c:\modem\
-g -q -fr"c:\modem\Debug
Debug
"
" -d"_DEBUG"
-d"_DEBUG"
-mv6700
-mv6700
-q
-q -o3
-o3
-fr"c:\modem\
-fr"c:\modem\Release
Release
" -mv6700
" -mv6700
Two Default Build Configurations
Two Default Build Configurations
For new projects, CCS
For new projects, CCS
automatically creates
automatically creates
two build
two build
configurations:
configurations:
Debug
Debug
(
(
unoptimized
unoptimized
)
)
Release
Release
(optimized)
(optimized)
Use the drop-down to
Use the drop-down to
quickly select
quickly select
build
build
config.
config.
Add/Remove build
Add/Remove build
config's with
config's with
Project
Project
Configurations
Configurations
dialog
dialog
(on project menus)
(on project menus)
Edit a configuration:
Edit a configuration:
1.
1.
Set it active
Set it active
2.
2.
Modify build
Modify build
options (shown
options (shown
next)
next)
3.
3.
Save project
Save project
-g -q -fr"c:\modem\
-g -q -fr"c:\modem\Debug
Debug
"
" -d"_DEBUG"
-d"_DEBUG"
-mv6700
-mv6700
-q
-q -o3
-o3
-fr"c:\modem\
-fr"c:\modem\Release
Release
" -mv6700
" -mv6700
-g
-g
-q -fr
-q -fr
"c:\modem\Debug"
"c:\modem\Debug"
-d
-d
"_DEBUG"
"_DEBUG"
-mv6700
-mv6700
Build Options GUI (Debug)
Build Options GUI (Debug)
GUI has 8 pages
GUI has 8 pages
of options for
of options for
code generation
code generation
tools
tools
Default build
Default build
options for a new
options for a new
project are
project are
shown
shown
Basic
Basic
page
page
defaults are
defaults are
-g
-g
-mv6700
-mv6700
-g -q -fr
-g -q -fr
"c:\modem\Debug"
"c:\modem\Debug" -d
-d
"_DEBUG"
"_DEBUG"
-mv6700
-mv6700
Build Options GUI (Debug)
Build Options GUI (Debug)
Preprocessor
Preprocessor
page
page
-d
-d
option allows
option allows
symbols to be
symbols to be
defined
defined
_DEBUG
_DEBUG
used by
used by
CCS enviroment
CCS enviroment
during debug
during debug
Options
Options
Description
Description
-o<filename>
-o<filename>
Output file name
Output file name
-m<filename>
-m<filename>
Map file name
Map file name
-c
-c
Auto-initialize global/static C
Auto-initialize global/static C
variables
variables
-x
-x
Exhaustively read libs (resolve back
Exhaustively read libs (resolve back
ref's)
ref's)
Linker Options
Linker Options
-q
-q -c
-c
-o".\Debug\lab3.out"
-o".\Debug\lab3.out"
-x
-x
.\Debug\lab3.out
.\Debug\lab3.out
Run-time Autoinitialization
Run-time Autoinitialization
Like Compiler
Like Compiler
Options,
Options,
Build
Build
Configurations
Configurations
also contain
also contain
Linker Options
Linker Options
Default linker
Default linker
options are
options are
shown for the
shown for the
Debug
Debug
configuration of a
configuration of a
project name
project name
lab3.pjt
lab3.pjt
".\Debug\"
".\Debug\"
indicates one
indicates one
subfolder level
subfolder level
below project
below project
(.pjt) location
(.pjt) location
Linking discussed
Linking discussed
in detail during
in detail during
four-day
four-day
workshop
workshop
Outline
Outline
Programming Methods
Programming Methods
Code Composer Studio (CCS)
Code Composer Studio (CCS)
Projects
Projects
Define and Manage
Define and Manage
Build Options and Build
Build Options and Build
Configurations
Configurations
Config Tool
Config Tool
(CDB file)
(CDB file)
Where To Go for More C
Where To Go for More C
Information
Information
Configuration Tool
Configuration Tool
Simplifies system design
Simplifies system design
Automatically includes the
Automatically includes the
appropriate runtime support
appropriate runtime support
libraries
libraries
Automatically handles interrupt
Automatically handles interrupt
vectors and system reset
vectors and system reset
MEM handles system memory
MEM handles system memory
configuration (builds CMD file)
configuration (builds CMD file)
Many other capabilities will be
Many other capabilities will be
discussed later …
discussed later …
Simplifies system design
Simplifies system design
Automatically includes the
Automatically includes the
appropriate runtime support
appropriate runtime support
libraries
libraries
Automatically handles interrupt
Automatically handles interrupt
vectors and system reset
vectors and system reset
MEM handles system memory
MEM handles system memory
configuration (builds CMD file)
configuration (builds CMD file)
Many other capabilities will be
Many other capabilities will be
discussed later …
discussed later …
Outline
Outline
Programming Methods
Programming Methods
Code Composer Studio (CCS)
Code Composer Studio (CCS)
Projects
Projects
Working with C
Working with C
‘
‘
C6000 C Data Types
C6000 C Data Types
Type
Type
Size
Size
Representation
Representation
char, signed char
char, signed char
8 bits
8 bits
ASCII
ASCII
unsigned char
unsigned char
8 bits
8 bits
ASCII
ASCII
short
short
16 bits
16 bits
2’s complement
2’s complement
unsigned short
unsigned short
16 bits
16 bits
binary
binary
int, signed int
int, signed int
32 bits
32 bits
2s complement
2s complement
unsigned int
unsigned int
32 bits
32 bits
binary
binary
long, signed long
long, signed long
40 bits
40 bits
2’s complement
2’s complement
unsigned long
unsigned long
40 bits
40 bits
binary
binary
enum
enum
32 bits
32 bits
2’s complement
2’s complement
float
float
32 bits
32 bits
IEEE 32-bit
IEEE 32-bit
double
double
64 bits
64 bits
IEEE 64-bit
IEEE 64-bit
long double
long double
64 bits
64 bits
IEEE 64-bit
IEEE 64-bit
pointers
pointers
32 bits
32 bits
binary
binary
Optimizing C Performance
Optimizing C Performance
Compiler Tutorial in CCS online help
Compiler Tutorial in CCS online help
http://www.ti.com/sc/c6000compiler
http://www.ti.com/sc/c6000compiler
C6000 Programmer’s Guide
C6000 Programmer’s Guide
(SPRU198)
(SPRU198)
Chapter 4:
Chapter 4:
“Optimizing C Code”
“Optimizing C Code”
C6000 Optimizing C Compiler UG
C6000 Optimizing C Compiler UG
(SPRU187)
(SPRU187)
Lab 3 Objectives
Lab 3 Objectives
Code Composer Studio
Code Composer Studio
Setup
Setup
Create Project
Create Project
Add
Add
config file
config file
(.CDB) to
(.CDB) to
project
project
Compile
Compile
Lab3.c
Lab3.c
Watch
Watch
variables
variables
Stepping
Stepping
thru code
thru code
Profile
Profile
code using different
code using different
build configurations
build configurations
Convert
Convert
integer
integer
to
to
float
float
math
math
Stop
Stop
and do lab
and do lab
Finishing Module 3
Finishing Module 3
Lab Debrief
Lab Debrief
Program Level Optimization
Program Level Optimization
CCS Automation
CCS Automation
Volatile
Volatile
Profile Based Compiler
Profile Based Compiler
Lab 3 Results
Lab 3 Results
Does the optimizer improve the code performance?
Does the optimizer improve the code performance?
How do the Integer & Float compare?
How do the Integer & Float compare?
Can the float be made faster?
Can the float be made faster?
Cycles*
Cycles*
Build
Build
Configuration
Configuration
Debug
Debug
Optimize
Optimize
Lab
Lab
lab3.c
lab3.c
Integer
Integer
lab3.c
lab3.c
Integer
Integer
Debug
Debug
lab3a.c
lab3a.c
Float
Float
Lab Step
Lab Step
Step
Step
42
42
Step
Step
60
60
Take Home
Take Home
Step
Step
10
10
Optimize
Optimize
lab3a.c
lab3a.c
Float
Float
Take Home
Take Home
Step
Step
19
19
7992
7992
168
168
9272
9272
308
308
* Page 3-33
* Page 3-33
Take Home Lab 3b
Take Home Lab 3b
Lab 3c uses the data align pragma
Lab 3c uses the data align pragma
to further optimize the compiler's
to further optimize the compiler's
performance
performance
Optimized
Optimized
Step
Step
19
19
Lab 3a
Lab 3a
308
308
Optimized
Optimized
DATA_ALIGN pragma
DATA_ALIGN pragma
Step
Step
13
13
Lab 3b
Lab 3b
206
206
click for lab 3c details
click for lab 3c details
Take Home Lab 3b
Take Home Lab 3b
To gain extra performance from C,
To gain extra performance from C,
make sure you check out the
make sure you check out the
following references ...
following references ...
CCS online help: Compiler Tutorial
CCS online help: Compiler Tutorial
C6000 Programmer’s Guide
C6000 Programmer’s Guide
(SPRU198)
(SPRU198)
Chapter 4:
Chapter 4:
“Optimizing C Code”
“Optimizing C Code”
C6000 Optimizing C Compiler UG
C6000 Optimizing C Compiler UG
(SPRU187)
(SPRU187)
The whole book
The whole book
Optimized
Optimized
Step
Step
19
19
Lab 3a
Lab 3a
308
308
Optimized
Optimized
DATA_ALIGN pragma
DATA_ALIGN pragma
Step
Step
13
13
Lab 3b
Lab 3b
206
206
Take Home Lab 3c
Take Home Lab 3c
Custom Keyboard
Custom Keyboard
Assignments
Assignments
Assign
Assign
F4
F4
to
to
Debug:Restart
Debug:Restart
Customizing the Default
Customizing the Default
Workspace
Workspace
Change
Change
Toolbar Locations
Toolbar Locations
Set defaults for:
Set defaults for:
File:Open/New
File:Open/New
Project:Open/New
Project:Open/New
Finishing Module 3
Finishing Module 3
Lab Debrief
Lab Debrief
Program Level Optimization
Program Level Optimization
CCS Automation
CCS Automation
Volatile
Volatile
Profile Based Compiler
Profile Based Compiler
Program Level Optimization (-pm)
Program Level Optimization (-pm)
-q
-q -pm -op2
-pm -op2
-mv6700
-mv6700
-pm is
-pm is
critical
critical
in compiling for maximum
in compiling for maximum
performance
performance
-pm creates a temp.c file which includes all C source
-pm creates a temp.c file which includes all C source
files, thus giving the optimizer a program-level
files, thus giving the optimizer a program-level
optimization context
optimization context
-op
-op
n
n
describes a program's external references
describes a program's external references
Finishing Module 3
Finishing Module 3
Lab Debrief
Lab Debrief
Program Level Optimization
Program Level Optimization
CCS Automation
CCS Automation
Command Window
Command Window
GEL Scripting
GEL Scripting
Volatile
Volatile
Profile Based Compiler
Profile Based Compiler
Command Window
Command Window
Some frequently used commands:
Some frequently used commands:
load
load
<filename.out>
<filename.out>
reload
reload
reset
reset
restart
restart
ba
ba
<label >
<label >
wa
wa
<label>
<label>
help
help
dlog
dlog
<filename>,a
<filename>,a
dlog
dlog
close
close
alias
alias
...
...
take
take
<filename.out>
<filename.out>
run
run
run
run
<cond>
<cond>
go
go
<label>
<label>
step
step
<number>
<number>
cstep
cstep
<number>
<number>
halt
halt
GEL Scripting
GEL Scripting
GEL:
GEL:
General
General
Extension
Extension
Language
Language
C style syntax
C style syntax
Large number of
Large number of
debugger
debugger
commands as GEL
commands as GEL
functions
functions
Write your own
Write your own
functions
functions
Create GEL menu
Create GEL menu
items
items
GEL:
GEL:
General
General
Extension
Extension
Language
Language
C style syntax
C style syntax
Large number of
Large number of
debugger
debugger
commands as GEL
commands as GEL
functions
functions
Write your own
Write your own
functions
functions
Create GEL menu
Create GEL menu
items
items
Finishing Module 3
Finishing Module 3
Lab Debrief
Lab Debrief
Program Level Optimization
Program Level Optimization
CCS Automation
CCS Automation
Volatile
Volatile
Profile Based Compiler
Profile Based Compiler
int *ctrl;
int *ctrl;
while (*ctrl == 0);
while (*ctrl == 0);
int *ctrl;
int *ctrl;
while (*ctrl == 0);
while (*ctrl == 0);
volatile
volatile
int *ctrl;
int *ctrl;
while (*ctrl == 0);
while (*ctrl == 0);
volatile
volatile
int *ctrl;
int *ctrl;
while (*ctrl == 0);
while (*ctrl == 0);
Volatile
Volatile
Finishing Module 3
Finishing Module 3
CCS Automation
CCS Automation
Volatile
Volatile
Profile Based Compiler (PBC)
Profile Based Compiler (PBC)
Note, this tool is only included in the full version of
Note, this tool is only included in the full version of
Code Composer Studio. It is not packaged with the
Code Composer Studio. It is not packaged with the
‘C6711 DSK.
‘C6711 DSK.
Profile Based Compiler (PBC)
Profile Based Compiler (PBC)
do
ub
le-
clic
k
do
ub
le-
clic
k
Note: PBC is only
Note: PBC is only
included with the full
included with the full
version of CCS.
version of CCS.
Note: PBC is only
Note: PBC is only
included with the full
included with the full
version of CCS.
version of CCS.
Module 3 -- Outline
Module 3 -- Outline
Programming Methods
Programming Methods
Code Composer Studio (CCS)
Code Composer Studio (CCS)
Projects
Projects
Working with C
Working with C