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
Agenda
Agenda
Overview
Overview
Hello, TI DSP,
Hello, TI DSP,
‘C6000
‘C6000
DSK
DSK
Tour of ‘C6711 DSK
Tour of ‘C6711 DSK
C Code
C Code
Code Composer
Code Composer
System
System
1. McBSP,
1. McBSP,
Interrupts
Interrupts
2. EDMA, Cache
2. EDMA, Cache
DSP/BIOS
DSP/BIOS
Real-Time Tools
Real-Time Tools
VAB
VAB
Visual Design
Visual Design
Epilogue
Epilogue
What Next?
What Next?
DSP/BIOS
DSP/BIOS
Real-time Scheduling
Real-time Scheduling
Simple example of real-time
Simple example of real-time
problem
problem
HWI, SWI, and TSK
HWI, SWI, and TSK
Scheduler
Scheduler
DSP/BIOS II adds multi-tasking
DSP/BIOS II adds multi-tasking
Real-time analysis (RTA)
Real-time analysis (RTA)
To:
To:
Engineering
Engineering
From:
From:
Marketing
Marketing
Re:
Re:
Design Spec
Design Spec
Change
Change
Due to customer
Due to customer
request, we need to
request, we need to
add DTMF functions to
add DTMF functions to
the Audio Player
the Audio Player
ASAP!!!
ASAP!!!
Cannot increase
Cannot increase
system cost !!!
system cost !!!
TI DSP
TI DSP
New System Requirement -
New System Requirement -
Abstract
Abstract
DTMF
DTMF
Filter
Filter
Previous Requirement
Previous Requirement
DSP filters audio signal
DSP filters audio signal
New Requirement
New Requirement
Add DTMF function
Add DTMF function
DTMF is independent of filter
DTMF is independent of filter
Issues:
Issues:
Do we have enough bandwidth (MIPS)?
Do we have enough bandwidth (MIPS)?
Will one routine conflict with the other?
Will one routine conflict with the other?
How do we create the compound system?
How do we create the compound system?
Interrupt Driven System
Interrupt Driven System
TI DSP
TI DSP
main
main
{
{
while(1);
while(1);
}
}
Timer1_ISR
Timer1_ISR
{
{
}
}
Timer2_ISR
Timer2_ISR
{
{
}
}
B
B
A
A
The choice of most designers:
The choice of most designers:
Put each routine in it’s own ISR
Put each routine in it’s own ISR
Interrupt Driven System
Interrupt Driven System
A
A
running
running
idle
idle
Time
Time
1
1
2
2
3
3
5
5
4
4
6
6
7
7
0
0
B
B
Only one can run at a time...
Only one can run at a time...
TI DSP
TI DSP
main
main
{
{
while(1);
while(1);
}
}
Timer1_ISR
Timer1_ISR
{
{
}
}
Timer2_ISR
Timer2_ISR
{
{
}
}
B
B
A
A
Period
Period
Compute
Compute
CPU Usage
CPU Usage
Routine
Routine
A
A
:
:
22
22
s
s
11
11
s
s
(50%)
(50%)
Routine
Routine
B
B
:
:
125
125
s
s
33
33
s
s
(26%)
(26%)
76%
76%
Interrupt Driven System - Problem
Interrupt Driven System - Problem
Period
Period
Compute
Compute
CPU Usage
CPU Usage
Routine
Routine
A
A
:
:
22
22
s
s
11
11
s
s
(50%)
(50%)
Routine
Routine
B
B
:
:
125
125
s
s
33
33
s
s
(26%)
(26%)
76%
76%
Time
Time
1
1
2
2
3
3
5
5
4
4
6
6
7
7
0
0
B
B
A
A
running
running
idle
idle
y
y
1
1
y
y
2
2
y
y
3
3
y
y
4
4
Missed !
Missed !
TI DSP
TI DSP
main
main
{
{
while(1);
while(1);
}
}
Timer1_ISR
Timer1_ISR
{
{
}
}
Timer2_ISR
Timer2_ISR
{
{
}
}
B
B
A
A
There are
There are
two
two
elements of CPU loading:
elements of CPU loading:
average & instantaneous
average & instantaneous
Nested Interrupts
Nested Interrupts
A common solution is to allow
A common solution is to allow
hardware interrupts to preempt each
hardware interrupts to preempt each
other - called
other - called
'nesting'
'nesting'
interrupts
interrupts
Problem is, the user must handle all
Problem is, the user must handle all
context save and restore
context save and restore
While reasonable for 1-2 interrupts, it
While reasonable for 1-2 interrupts, it
becomes tedious and trouble-prone for
becomes tedious and trouble-prone for
more
more
Can become near impossible when
Can become near impossible when
using object-coded algorithms or
using object-coded algorithms or
libraries
libraries
(thus, making it difficult to purchase
(thus, making it difficult to purchase
algo's)
algo's)
DSP/BIOS handles this for you with
DSP/BIOS handles this for you with
simple drag -n- drop editing
simple drag -n- drop editing
TI DSP
TI DSP
main
main
{
{
while(1);
while(1);
}
}
Timer1_ISR
Timer1_ISR
{
{
}
}
Timer2_ISR
Timer2_ISR
{
{
}
}
B
B
A
A
A
A
running
running
idle
idle
Time
Time
1
1
2
2
3
3
5
5
4
4
6
6
7
7
0
0
B
B
The DSP/BIOS Solution
The DSP/BIOS Solution
B
B
A
A
main
main
{
{
return;
return;
}
}
DSP/BIOS
DSP/BIOS
A
A
running
running
idle
idle
Time
Time
1
1
2
2
3
3
5
5
4
4
6
6
7
7
0
0
B
B
DSP/BIOS provides scheduling:
DSP/BIOS provides scheduling:
You needn’t build a custom (inflexible)
You needn’t build a custom (inflexible)
state-machine for each DSP design
state-machine for each DSP design
Instead, you can leverage 1000’s of
Instead, you can leverage 1000’s of
hours of development, proven in 100’s
hours of development, proven in 100’s
of systems!
of systems!
Easy to write
Easy to write
- Modules written
- Modules written
independently
independently
Easy to maintain
Easy to maintain
- Module interaction
- Module interaction
minimized
minimized
Built-in Scheduling
Built-in Scheduling
- Managed by
- Managed by
DSP/BIOS
DSP/BIOS
DSP/BIOS
DSP/BIOS
Real-time Scheduling
Real-time Scheduling
Simple example of real-time
Simple example of real-time
problem
problem
HWI, SWI, and TSK
HWI, SWI, and TSK
Scheduler
Scheduler
DSP/BIOS II adds multi-tasking
DSP/BIOS II adds multi-tasking
Real-time analysis (RTA)
Real-time analysis (RTA)
DSP/BIOS Thread Types
DSP/BIOS Thread Types
P
ri
o
ri
ty
P
ri
o
ri
ty
HWI
HWI
Hardware Interrupts
Hardware Interrupts
Used to implement 'urgent' part
Used to implement 'urgent' part
of real-time event
of real-time event
Triggered by hardware interrupt
Triggered by hardware interrupt
HWI priorities set by hardware
HWI priorities set by hardware
SWI
SWI
Software Interrupts
Software Interrupts
Use SWI to perform HWI '
Use SWI to perform HWI '
follow-
follow-
up
up
' activity
' activity
SWI's are '
SWI's are '
posted
posted
' by HWI's or
' by HWI's or
SWI's
SWI's
Multiple SWIs at each of 14
Multiple SWIs at each of 14
priority levels
priority levels
IDL
IDL
Background
Background
Multiple IDL functions
Multiple IDL functions
Run round-robin
Run round-robin
DSP/BIOS Scheduler
DSP/BIOS Scheduler
h/w INT
h/w INT
HWI:
HWI:
urgent code
urgent code
post SWI
post SWI
SWI (or TSK)
SWI (or TSK)
ints disabled
ints disabled
rather than all this time
rather than all this time
read
read
serial port
serial port
run filter with new data
run filter with new data
HWI
HWI
Fast response to
Fast response to
interrupts
interrupts
Minimal context
Minimal context
switching
switching
High priority only
High priority only
Can post SWI or TSK
Can post SWI or TSK
Danger of missing an
Danger of missing an
interrupt while
interrupt while
executing ISR
executing ISR
SWI or TSK
SWI or TSK
Latency in response
Latency in response
time
time
Context switch
Context switch
performed
performed
Selectable priority
Selectable priority
levels
levels
Can post another SWI
Can post another SWI
Execution managed by
Execution managed by
scheduler
scheduler
Let’s look at a scheduling example...
Let’s look at a scheduling example...
HWI
HWI
SWI 2
SWI 2
SWI 1
SWI 1
main()
main()
IDL
IDL
HWI with SWI & IDL
HWI with SWI & IDL
interrupt
interrupt
return
return
return
return
return
return
post swi2
post swi2
Skip Slide Animation
Skip Slide Animation
return
return
return
return
interrupt
interrupt
post swi1
post swi1
SWI Properties
SWI Properties
Managing SWI Priority
Managing SWI Priority
Drag and Drop SWIs to
Drag and Drop SWIs to
change priority
change priority
Equal priority SWIs run
Equal priority SWIs run
round-robin
round-robin
Drag and Drop SWIs to
Drag and Drop SWIs to
change priority
change priority
Equal priority SWIs run
Equal priority SWIs run
round-robin
round-robin
DSP/BIOS Thread Types
DSP/BIOS Thread Types
P
ri
o
ri
ty
P
ri
o
ri
ty
HWI
HWI
Hardware Interrupts
Hardware Interrupts
Used to implement 'urgent' part
Used to implement 'urgent' part
of real-time event
of real-time event
Triggered by hardware interrupt
Triggered by hardware interrupt
HWI priorities set by hardware
HWI priorities set by hardware
SWI
SWI
Software Interrupts
Software Interrupts
Use SWI to perform HWI '
Use SWI to perform HWI '
follow-
follow-
up
up
' activity
' activity
SWI's are '
SWI's are '
posted
posted
' by HWI's or
' by HWI's or
SWI's
SWI's
Multiple SWIs at each of 14
Multiple SWIs at each of 14
priority levels
priority levels
TSK
TSK
Tasks
Tasks
Use TSK to run different programs
Use TSK to run different programs
concurrently under separate
concurrently under separate
contexts
contexts
TSK's are usually enabled to run
TSK's are usually enabled to run
by setting a flag, called a
by setting a flag, called a
'
'
semaphore
semaphore
'
'
IDL
IDL
Background
Background
Multiple IDL functions
Multiple IDL functions
Run round-robin
Run round-robin
SWI vs. TSK
SWI vs. TSK
Similar to hardware
Similar to hardware
interrupt, but
interrupt, but
triggered by
triggered by
SWI_post() function
SWI_post() function
call
call
All SWI's share system
All SWI's share system
software stack (along
software stack (along
with HWI's)
with HWI's)
SWI
SWI
SWI_post
SWI_post
start
start
end
end
“
“
run to
run to
completion”
completion”
Each TSK has its own
Each TSK has its own
stack, which allows
stack, which allows
them to pause
them to pause
Usually implemented as
Usually implemented as
loop
loop
Executed conditionally
Executed conditionally
based on a semaphore
based on a semaphore
(condition, flag)
(condition, flag)
SEM_post function call
SEM_post function call
set’s flag to trigger
set’s flag to trigger
execution
execution
TSK
TSK
start
start
end
end
Pause
Pause
SEM_post
SEM_post
(blocked
(blocked
state)
state)
SEM_pend
SEM_pend
TSK Preemption Example
TSK Preemption Example
HWI
HWI
SWI 2
SWI 2
SWI 1
SWI 1
IDL
IDL
main()
main()
TSK 2
TSK 2
TSK 1
TSK 1
interrupt
interrupt
pend
pend
sem2
sem2
return
return
interrupt
interrupt
interrupt
interrupt
pend
pend
sem2
sem2
pend
pend
sem1
sem1
return
return
return
return
post
post
swi1
swi1
return
return
return
return
post
post
sem2
sem2
return
return
post
swi2
How do you set priorities ...
How do you set priorities ...
DSP/BIOS
DSP/BIOS
Real-time Scheduling
Real-time Scheduling
Simple example problem
Simple example problem
HWI, SWI, and TSK
HWI, SWI, and TSK
Scheduler
Scheduler
Real-time analysis (RTA)
Real-time analysis (RTA)
printf() and LOG_printf
printf() and LOG_printf
Statistics
Statistics
Visual Instrumentation
Visual Instrumentation
Why is printf() used?
Why is printf() used?
printf is widely used for logical debug
printf is widely used for logical debug
(checking
(checking
your answer)
your answer)
What’s wrong with printf?
What’s wrong with printf?
30,000+ cycles to perform printf
30,000+ cycles to perform printf
Requires extensive prog & data memory
Requires extensive prog & data memory
DSP has to format the text string
DSP has to format the text string
Worse yet, it's Non-Deterministic
Worse yet, it's Non-Deterministic
The DSP must stop and wait for MS Windows
The DSP must stop and wait for MS Windows
to send string back to debugger (is Windows
to send string back to debugger (is Windows
real-time?)
real-time?)
Bottom Line
Bottom Line
Not Deterministic
Not Deterministic
Why waste DSP's MIPS and Mbytes
Why waste DSP's MIPS and Mbytes
Real-time code can fail due to printf
Real-time code can fail due to printf
printf (“I'm a wasteful function = %d\n”,i++);
printf (“I'm a wasteful function = %d\n”,i++);
printf (“I'm a wasteful function = %d\n”,i++);
printf (“I'm a wasteful function = %d\n”,i++);
DSP/BIOS: Real-Time
DSP/BIOS: Real-Time
Instrumentation
Instrumentation
DSP
DSP
Real-Time Capture
Real-Time Capture
Host (CCS)
Host (CCS)
Analysis & Display
Analysis & Display
Two main printf real-time issues are …
Two main printf real-time issues are …
1.
1.
Not Deterministic
Not Deterministic
2.
2.
Why waste DSP's MIPS and Mbytes
Why waste DSP's MIPS and Mbytes
If captured in real-time, how is debug data transferred?
If captured in real-time, how is debug data transferred?
LOG_printf
LOG_printf
LOG_printf is answer to real-time issues
LOG_printf is answer to real-time issues
Data is captured to a buffer on the DSP
Data is captured to a buffer on the DSP
Data is transferred to buffer in background (IDL)
Data is transferred to buffer in background (IDL)
How is LOG_printf used in code?
How is LOG_printf used in code?
External
External
reference to
reference to
LOG object
LOG object
defined using
defined using
the
the
configuration
configuration
tool
tool
Call LOG_printf
Call LOG_printf
#include <std.h>
#include <std.h>
#include <log.h>
#include <log.h>
extern far LOG_Obj myLog;
extern far LOG_Obj myLog;
#include <std.h>
#include <std.h>
#include <log.h>
#include <log.h>
extern far LOG_Obj myLog;
extern far LOG_Obj myLog;
LOG_printf(&myLog, “New load = %d000 instructions”, loadVal);
LOG_printf(&myLog, “New load = %d000 instructions”, loadVal);
LOG_printf(&myLog, “New load = %d000 instructions”, loadVal);
LOG_printf(&myLog, “New load = %d000 instructions”, loadVal);
Call the
Call the
function
function
Run-time
Run-time
display of
display of
user-defined
user-defined
LOG
LOG
DSP/BIOS
DSP/BIOS
Real-time Scheduling
Real-time Scheduling
Real-time analysis (RTA)
Real-time analysis (RTA)
printf() and LOG_printf
printf() and LOG_printf
Statistics
Statistics
Visual Instrumentation
Visual Instrumentation
Built-in Statistics Tools
Built-in Statistics Tools
Execution Graph
Execution Graph
is useful for visualization of thread scheduling
is useful for visualization of thread scheduling
Statistics
Statistics
give you finer detail to profile thread execution
give you finer detail to profile thread execution
Is the thread meeting its real-time deadline?
Is the thread meeting its real-time deadline?
The number of
The number of
times the SWI has
times the SWI has
run
run
Max and Average
Max and Average
number of instructions
number of instructions
from SWI_post to
from SWI_post to
completion (can also
completion (can also
display as milliseconds
display as milliseconds
or microseconds)
or microseconds)
User-Defined STS example
User-Defined STS example
Reference the
Reference the
STS object
STS object
#include <std.h>
#include <std.h>
#include <sts.h>
#include <sts.h>
extern far STS_Obj myStat;
extern far STS_Obj myStat;
#include <std.h>
#include <std.h>
#include <sts.h>
#include <sts.h>
extern far STS_Obj myStat;
extern far STS_Obj myStat;
STS_add(&myStat, your_variable);
STS_add(&myStat, your_variable);
STS_add(&myStat, your_variable);
STS_add(&myStat, your_variable);
Monitor a
Monitor a
variable
variable
Insert STS object
Insert STS object
in configuration
in configuration
tool,
tool,
rename to
rename to
“myStat”
“myStat”
What does deterministic, low-overhead RTA mean to
What does deterministic, low-overhead RTA mean to
you?
you?
LOG, STS, and TRC module operations are very fast
LOG, STS, and TRC module operations are very fast
and execute in a consistent time, as shown in the
and execute in a consistent time, as shown in the
following list:
following list:
LOG_printf:
LOG_printf:
approximately 32 cycles
approximately 32 cycles
STS_add:
STS_add:
approximately 18 cycles
approximately 18 cycles
STS_delta:
STS_delta:
approximately 21 cycles
approximately 21 cycles
TRC_enable & _disable:
TRC_enable & _disable:
approximately 6 cycles
approximately 6 cycles
* (exact timing depends upon processor type)
* (exact timing depends upon processor type)
STS and LOG - low overhead
STS and LOG - low overhead
Each STS object uses only four words of data memory.
Each STS object uses only four words of data memory.
Therefore, only four words need to be uploaded from a
Therefore, only four words need to be uploaded from a
statistics object
statistics object
LOG functions only need to capture 4 words per
LOG functions only need to capture 4 words per
invocation
invocation
Low Instrumentation Overhead
Low Instrumentation Overhead
You can leave RTA in your code and get:
You can leave RTA in your code and get:
1.
1.
What you test is "exactly" what you ship
What you test is "exactly" what you ship
2.
2.
When (if) field problems arise, debug
When (if) field problems arise, debug
instrumentation is already in place!
instrumentation is already in place!
DSP/BIOS
DSP/BIOS
Real-time Scheduling
Real-time Scheduling
Real-time analysis (RTA)
Real-time analysis (RTA)
printf() and LOG_printf
printf() and LOG_printf
Statistics
Statistics
Visual Instrumentation
Visual Instrumentation
Execution Graph
Execution Graph
CPU Load Graph
CPU Load Graph
Viewing System Events
Viewing System Events
System Log is an
System Log is an
Event “Logic Analyzer”
Event “Logic Analyzer”
The HWI and SWI routines are on the left axis,
The HWI and SWI routines are on the left axis,
and the bottom axis are event ticks
and the bottom axis are event ticks
…
…
This makes it easy to follow the action
This makes it easy to follow the action
CPU Load Meter
CPU Load Meter
CPU load meter acts like a MIPs calculator
CPU load meter acts like a MIPs calculator
Basically, it keeps track of the IDLE time
Basically, it keeps track of the IDLE time
DSP/BIOS - API Modules
DSP/BIOS - API Modules
Instrumentation/Real-Time Analysis
Instrumentation/Real-Time Analysis
LOG
LOG
Message Log manger
Message Log manger
STS
STS
Statistics accumulator manager
Statistics accumulator manager
TRC
TRC
Trace manager
Trace manager
RTDX
RTDX
Real-Time Data Exchange manager
Real-Time Data Exchange manager
Thread Types
Thread Types
HWI
HWI
Hardware interrupt manager
Hardware interrupt manager
SWI
SWI
Software interrupt manager
Software interrupt manager
TSK
TSK
Multitasking manager
Multitasking manager
IDL
IDL
Idle function & processing loop manager
Idle function & processing loop manager
Clock and Periodic Functions
Clock and Periodic Functions
CLK
CLK
System clock manager
System clock manager
PRD
PRD
Periodic function manger
Periodic function manger
Comm/Synch between threads
Comm/Synch between threads
SEM
SEM
Semaphores manager
Semaphores manager
MBX
MBX
Mailboxes manager
Mailboxes manager
LCK
LCK
Resource lock manager
Resource lock manager
Input/Output
Input/Output
PIP
PIP
Data pipe manager
Data pipe manager
HST
HST
Host input/output manager
Host input/output manager
SIO
SIO
Stream I/O manager
Stream I/O manager
DEV
DEV
Device driver interface
Device driver interface
Memory and Low-level Primitives
Memory and Low-level Primitives
MEM
MEM
Memory manager
Memory manager
SYS
SYS
System services manager
System services manager
QUE
QUE
Queue manager
Queue manager
ATM
ATM
Atomic functions
Atomic functions
GBL
GBL
Global setting manager
Global setting manager
#include’s
#include’s
extern far SWI_Obj
extern far SWI_Obj
global variables
global variables
main( ) {
main( ) {
CSL_Init();
CSL_Init();
BSL_init();
BSL_init();
codec_init();
codec_init();
init_HWI();
init_HWI();
AD535_write(hAD53
AD535_write(hAD53
5, 0);
5, 0);
return;
return;
}
}
// HWI routines
// HWI routines
init_HWI();
init_HWI();
XINT0_HWI;
XINT0_HWI;
// Codec Routines
// Codec Routines
codec_init();
codec_init();
codec_out();
codec_out();
lab6.c
lab6.c
HWI
HWI
9: _XINT0_HWI
9: _XINT0_HWI
SWI
SWI
codec_swi:
codec_swi:
_codec_out
_codec_out
lab6.cdb
lab6.cdb
sineGen( )
sineGen( )
sine_float.c
sine_float.c
Lab 6
Lab 6
You get to
You get to
complete these
complete these