1 code composer studio & dsp/bios integrated develop environment environment real time...
TRANSCRIPT
1
Code Composer Studio & DSP/BIOS
Integrated DevelopIntegrated Develop EnvironmentEnvironment
Real Time Scheduling,Real Time Scheduling,Debug & AnalysisDebug & Analysis
Time To MarketTime To MarketPerformancePerformance
ReliabilityReliability
2
HOST DEVELOPMENT COMPUTER
Code Composer Studio
Programming With DSP/BIOS
TARGET TMS320 DSP HARDWARE
DSP/BIOS Kernel Interface
target application program
BUILD
.c.asm .h
programsources
kernelheaders
.exeexecutableimage
DEBUG
JTAGEMULATION SERVER
RTDX
.lib
kernel modules
CONFIGURATION
VISUALIZATION
C- and ASM-callable functions
interactive configuration tool
kernel-aware debug support
on-the-fly program analysis
real-timecapture
3
Software Modules
DSP/BIOS™ contains a collection of modules
Each module is a coherent software package
Module viewed from two perspectives
interface — related set of constants, types, and
functions visible to client programs
body — algorithms and data structures chosen to implement
functionality of the interface
4real-time host link
Mix-and-Match Modules
TARGET TMS320 DSP HARDWARE
DSP/BIOS Kernel Interface
REAL-TIME CAPTURE
software event logs statistics accumulators host cmd/data channels
HARDWARE ABSTRACTION
real-time clock services device-independent I/O logical memory segments
MULTIPLE THREADS
HW+SW interrupts synchronized tasks background routines
SUM
COUNT
MAX
XXXX XXXX
XXXX XXXX
XXXX XXXX
put()
get()post()
post()
pend()
0000
FFFF
RAMdata port
streams
messagesperiodic
functions
wall-clocktime
fast slow
allocation
static
dynamic
timer
5
LOG - Event Log Manager
HostTarget
LOG object
LOG buffer
read &clear
• Logs reside in target memory• Fixed or circular buffer• Logs passed to host during idle• Set up with Config tool
6
Standard C function I/O
printf Function - data collection - I/O - data format & display
5,100+ cycles(200 cycles per
char)10,400 words
7
DSP/BIOS I/O
LOGprintf Function
- data collection28 cycles (C54x)
16 words
- I/Oapprox 100 cycles
- data format & display>1,000 cycles
THREAD
BIOS IDLE
HOST
8real-time host link
Mix-and-Match Modules
TARGET TMS320 DSP HARDWARE
DSP/BIOS Kernel Interface
REAL-TIME CAPTURE
software event logs statistics accumulators host cmd/data channels
HARDWARE ABSTRACTION
real-time clock services device-independent I/O logical memory segments
MULTIPLE THREADS
HW+SW interrupts synchronized tasks background routines
SUM
COUNT
MAX
XXXX XXXX
XXXX XXXX
XXXX XXXX
put()
get()post()
post()
pend()
0000
FFFF
RAMdata port
streams
messagesperiodic
functions
wall-clocktime
fast slow
allocation
static
dynamic
timer
9
STS - Statistics Manager
Capture Count, Maximum, and Total values for any variables in Real Time
HWI, SWI, PRD, and PIP captured automatically
STS statistics APIs for explicit statistics objects in your target program
10
Trace Manager
Real-time analysis: Turns on/off traces
Use only what you need
Target can start/stop acquiring data when anomaly discovered with fixed log:Store 1st n events since enabled
Store last n events until disabled
11real-time host link
Mix-and-Match Modules
TARGET TMS320 DSP HARDWARE
DSP/BIOS Kernel Interface
REAL-TIME CAPTURE
software event logs statistics accumulators host cmd/data channels
HARDWARE ABSTRACTION
real-time clock services device-independent I/O logical memory segments
MULTIPLE THREADS
HW+SW interrupts synchronized tasks background routines
SUM
COUNT
MAX
XXXX XXXX
XXXX XXXX
XXXX XXXX
put()
get()post()
post()
pend()
0000
FFFF
RAMdata port
streams
messagesperiodic
functions
wall-clocktime
fast slow
allocation
static
dynamic
timer
12
HST - Host Channel Manager
Real-time file I/O
AudioSWI
PIPE buffers
frame 1 frame 2
frame 2 frame 1
Host Channels
Host Computer
13real-time host link
Mix-and-Match Modules
TARGET TMS320 DSP HARDWARE
DSP/BIOS Kernel Interface
REAL-TIME CAPTURE
software event logs statistics accumulators host cmd/data channels
HARDWARE ABSTRACTION
real-time clock services device-independent I/O logical memory segments
MULTIPLE THREADS
HW+SW interrupts synchronized tasks background routines
SUM
COUNT
MAX
XXXX XXXX
XXXX XXXX
XXXX XXXX
put()
get()post()
post()
pend()
0000
FFFF
RAMdata port
streams
messagesperiodic
functions
wall-clocktime
fast slow
allocation
static
dynamic
timer
14
CLK Manager
CPU Clock
ex: 200 MHz
TimerRegister
•User sets us/interrupt• Tool sets PRD register
TimerInterrupt
• Calls PRD_Tick• Calls any CLK HWI functions
/4 ex:PRD = 49999
15
PRD - Periodic Function Manager
Use CLK Manager to drive PRD
Call PRD_Tick
Timer Interrupt
or Call PRD_tick yourself
Low Resolution ‘tick rate’ex: 1 ms
PostsPRD_SWI
Executesall ready
PRDs
ex: loadPRDevery 16 ms
(16 ticks)
16
PIP - Buffered Pipe Manager
Example: audio demo
AudioSWI
Codec IS
R
Reader
Reader Writer
Writer
Audio in/out
PIPE buffers
frame 1 frame 2
frame 2 frame 1
17
MEM - Memory Manager
Specify memory segments and locate code and data sections
DSP/BIOS generates linker.cmd file
Section Description Default.data Data IDRAM.text Program IPRAM.stack Stack IDRAM.bios BIOS code IPRAM
Examples:
18real-time host link
Mix-and-Match Modules
TARGET TMS320 DSP HARDWARE
DSP/BIOS Kernel Interface
REAL-TIME CAPTURE
software event logs statistics accumulators host cmd/data channels
HARDWARE ABSTRACTION
real-time clock services device-independent I/O logical memory segments
MULTIPLE THREADS
HW+SW interrupts synchronized tasks background routines
SUM
COUNT
MAX
XXXX XXXX
XXXX XXXX
XXXX XXXX
put()
get()post()
post()
pend()
0000
FFFF
RAMdata port
streams
messagesperiodic
functions
wall-clocktime
fast slow
allocation
static
dynamic
timer
19
Principal Software Requirements
Real Time System attributes...
Event DrivenEvent Drivensynchronous & synchronous &
asynchronousasynchronous
Time ConstrainedTime Constrainedhard & soft real timehard & soft real time
Require ConcurrencyRequire Concurrencypreemptionpreemption
multi-taskingmulti-tasking
JWL - TISB - 2/08/00
20
The Historical Problem
_IO_isr: ssbx intm stm #0, imr pshm st0
…. popm st0 rsbx intm rete
void main(void){/* enable end–of–frame interrupt */DMA0_SCNTL = SCNTL_ENABLE;while (*ping_rx_flag != 0) {/* ping_flag starts 1, toggles every int */if(ping_rx_flag == 1) ping_rx_flag = 0;else ping_rx_flag = 1; }
Hardware Only Scheduling !!
C main background functions !!
No Guarantee of ConcurrencyNo Guarantee of Concurrency
Ad Hoc AnalysisAd Hoc Analysis
Interrupts DisabledInterrupts Disabled
Unmanaged Interrupt Unmanaged Interrupt Context SwitchContext Switch
Non-deterministic timingNon-deterministic timing
No Software PreemptionNo Software Preemption
21
The Need for Preemption - Single Task
1 2 3 54 6 7
Arunning
idle
0Time
Brunning
idle
Task A: period 2 ms, compute 1 ms (50%)
Task A
Task B
Max
Headroom CPU Usage
Actual
100%
--
100%
50%
DR - TISB - 1/24/00
22
Cyclic Scheduling - Two Tasks
54 6 7
Arunning
idle
0Time
Brunning
idle
1 2 3
Task A: period 2 ms, compute 1 ms (50%)
Task B: period 30 ms, compute 2 ms (6.67%)
Task A
Task B
Max
Headroom CPU Usage
Actual
0%
0%
57%
57%
DR - TISB - 1/24/00
23
Preemptive Scheduling - Two Tasks
1 2 3 54 6 7
Arunning
idle
0Time
Brunning
idle
1 2 3
Task A: period 2 ms, compute 1 ms (50%)
Task B: period 30 ms, compute 2 ms (6.67%)
Task A
Task B
Max
Headroom CPU Usage
Actual
87%
650%
100%
57%DR - TISB - 1/24/00
24
The DSP/BIOS Solution
_IO_isr: HWI_enter pshm st0 pshm st1 …. popm st1 popm st0 HWI_exit
Managed Context SwitchManaged Context Switch
Very Low OverheadVery Low Overhead
HW Interrupt Scheduling
SW Interrupt Scheduling predictable thread control Real Time Analysis low overhead logging and statistics
Preemptive SW SchedulingPreemptive SW Scheduling
Time DeterminismTime Determinism
Foreground Level Scheduling !!
void main(void) {/* enable end–of–frame interrupt */DMA0_SCNTL = SCNTL_ENABLE;/* post SW interrupt swiProcessBuffer */
SWI_post(&swiProcessBuffer);/* ping_flag starts 1, toggles every int */if(ping_rx_flag == 1) ping_rx_flag = 0;else ping_rx_flag = 1;LOG_printf (&message, “Buffer 1 Avail”);
25
Real-time Multi-threaded Systems
Single-thread Approach:
arm() {for (;;) {if (shoulder needs moving)moveshoulder();if (wrist needs moving)movewrist();.....
Multi-thread Approach:
shoulder() {for(;;) {
wait for event;moveshoulder()}
wrist() {for(;;) {
wait for event;movewrist()}
Fundamental mechanism needed for an application to control and react to multiple, discrete real world events to produce a correct result within a specified time
Traditional Super-loopTraditional Super-loop(Cyclically Scheduled)(Cyclically Scheduled)
Independent ControlIndependent Control
26
Cyclically Scheduled Systems Are Problematic
INTsINTsINTsINTs
fxn 2fxn 2fxn 2fxn 2
fxn 1fxn 1fxn 1fxn 1
main()main()main()main()
fxn 3fxn 3fxn 3fxn 3
fxn 4fxn 4fxn 4fxn 4
INTsINTsINTsINTs
Time-Out?
CPU Load?
Time
... hence the need for preemptive Real Time SchedulingReal Time Scheduling
27
Thread Scheduling - HWI & Idle/ Background
INT 5INT 5INT 5INT 5
INT 1INT 1INT 1INT 1
main()main()main()main()
idleidle
INT 2INT 2INT 2INT 2
INT 3INT 3INT 3INT 3
INT 4INT 4INT 4INT 4
TimeJWL - TISB - 2/4/00
28
HWI - Hardware ISR Manager
Respond to external asynchronous events
HWIs run uninterrupted to completionIf posted multiple times, runs only once
Need to minimize time and code in Interrupt Service Routine
Move large processing needs by posting a SWI
HWI time is ‘Other Threads’ on Execution Graph
Set up with Config Tool
29
Priority Based Scheduling - DSP/BIOS
HWIsHWIsHWIsHWIs
SWI 1SWI 1SWI 1SWI 1
main ()main ()main ()main ()
idleidle
SWI 2SWI 2SWI 2SWI 2
SWI 3SWI 3SWI 3SWI 3
SWI 4SWI 4SWI 4SWI 4
TimeJWL - TISB - 1/24/00
Run
Post
Ready (post)
Run
Preempted
30
DSP/BIOS - Round Robin & Periodic Examples
INT 1INT 1INT 1INT 1
SWI 1SWI 1SWI 1SWI 1
main ()main ()main ()main ()
idleidle
SWI 2SWI 2SWI 2SWI 2
SWI 3SWI 3SWI 3SWI 3
SWI 5SWI 5SWI 5SWI 5
Time
Priority basedScheduling
Round robinScheduling
SWI 4SWI 4SWI 4SWI 4
PeriodicScheduling
31
DSP/BIOS - SW Interrupt Scheduling
DSP/BIOS Software Interrupt threads use an ‘Interrupt Service’DSP/BIOS Software Interrupt threads use an ‘Interrupt Service’scheduling model.scheduling model.
DSP/BIOS SWI threads are preemptable, and run to completion.DSP/BIOS SWI threads are preemptable, and run to completion.DSP/BIOS SWI threads cannot be suspended (blocked) and therefore DSP/BIOS SWI threads cannot be suspended (blocked) and therefore
must have required resources ready before they run.must have required resources ready before they run.DSP/BIOS SWI threads are an excellent scheduling mechanism for DSP/BIOS SWI threads are an excellent scheduling mechanism for
very low overhead, deterministic, ‘Hard Real Time’ systems.very low overhead, deterministic, ‘Hard Real Time’ systems.
INT 1INT 1INT 1INT 1
SWI 1SWI 1SWI 1SWI 1
SWI 2SWI 2SWI 2SWI 2
SWI 3SWI 3SWI 3SWI 3
SWI 5SWI 5SWI 5SWI 5
SWI 4SWI 4SWI 4SWI 4
JWL - TISB - 2/08/00
32
DSP/BIOS II - Beyond SW Interrupts
_IO_isr: ssbx intm stm #0, imr pshm st0
…. popm st0 rsbx intm rete
A need for Dynamic A need for Dynamic PrioritizationPrioritization
No Guarantee of No Guarantee of Resource Resource AvailabilityAvailability
What if our new design requiresconcurrent real time operation?
But there is...
JWL - TISB - 2/08/00
void main(void){/* enable end–of–frame interrupt */DMA0_SCNTL = SCNTL_ENABLE;/* post SW interrupt swiProcessBuffer */SWI_post(&swiProcessBuffer);/* ping_flag starts 1, toggles every int */if(ping_rx_flag == 1) ping_rx_flag = 0;else ping_rx_flag = 1;LOG_printf (&message, “Buffer 1 Avail”);
33
The DSP/BIOS II Solution
_IO_isr: HWI_enter pshm st0 pshm st1 …. popm st1 popm st0 HWI_exit
Void main()
{ TSK_create((ProcessBuffer)task,1); }/* ======== task ======== */Void task(Int id){SEM_pend(ping_rx_flag = 1);} LOG_printf(&trace, ”Buffer 1 Avail"); } Low OverheadLow Overhead
HW Interrupt Scheduling
SW Interrupt Scheduling
TASK Scheduling blocking semaphores dynamic prioritization dynamic creation & termination Real Time Analysis low overhead log & statistics
RTOS style ConcurrencyRTOS style Concurrency
Dynamic Resource SharingDynamic Resource Sharing
Dynamic SchedulingDynamic Scheduling
Then we need Synchronized TaskScheduling !!(Multi-Tasking) (SPOX)
JWL - TISB - 2/08/00
34
DSP/BIOS II Task Scheduling
idleidle
INT 1INT 1INT 1INT 1
SWI 1SWI 1SWI 1SWI 1
TSK 2TSK 2TSK 2TSK 2
TSK 1TSK 1TSK 1TSK 1
DSP/BIOS II adds “Multi-Tasking” scheduling to the “InterruptDSP/BIOS II adds “Multi-Tasking” scheduling to the “InterruptService” scheduling model.Service” scheduling model.
DSP/BIOS Tasks are dynamic, preemptable, and can be suspendedDSP/BIOS Tasks are dynamic, preemptable, and can be suspended(blocked) to wait for data or other tasks.(blocked) to wait for data or other tasks.
DSP/BIOS Tasks are an excellent scheduling mechanism for DSP/BIOS Tasks are an excellent scheduling mechanism for dynamic, shared resource, ‘Hard & Soft Real Time’ systems.dynamic, shared resource, ‘Hard & Soft Real Time’ systems.
preempted
blocked
Ready (post)
Run
Preempted
Blocked
Terminated
35
IDL - Idle Function Manager
DSP BIOS API
H/W Interrupts
SWI
Background• Host data pump• Idle CPU load• Your function
Program
• Insert functions to execute within idle• Lowest priority SWI thread• Set up with Config Tool• Continuous loop - round robin• Real-time analysis plug-ins updated
C main ()
36
Real-Time Analysis
Determine whether the system is:Operating within its design specifications
Meeting its performance targets
Showing any subtle timing problems
Analyze real-time operation:Software logic analyzer
CPU load
Thread timing and count statistics
37
How do I ‘BIOS-ize’ my Code?
Start a new project Set up objects with Configuration Tool Migrate interrupt vector table to the HWI
module Migrate memory sections from linker.cmd file
to MEM module Save and Add the .cdb file to your project Edit C source for #include headers and
declare variables Change C functions within your program
to DSP/BIOS APIs. Build the new project
Also… try the CC Studio Tutorial examplesAlso… try the CC Studio Tutorial examples……and study the DSP/BIOS by Degrees app note - SPRA591and study the DSP/BIOS by Degrees app note - SPRA591… … also Audio Example - DSP/BIOS app note - SPRA598also Audio Example - DSP/BIOS app note - SPRA598
Starting New ProjectsCNew Project (xxx.mak) Add source files Add linker command file Add Run-Time library
BIOSNew Project (xxx.mak) Setup new configuration Add configuration file (xxx.cbd) Add source files Add linker command file
Set Up System Easily with Configuration tool
Easy to visually configure run-time objects Set global run-time parameters Statically configures objects Detect errors early by validating properties before execution Calculate estimated data and minimal stack size Minimize target memory footprint by eliminating run-time code
Saves time by getting you started quickly
Adds basic Run Time services Add interrupt vector definitions Add memory section definitions Optionally add thread scheduling Optionally add low overhead instrumentation
objects Visually create run-time objects bound to the
executable program
40
Summary - DSP/BIOS Modules
ATM - Atomic Functions
CLK - Clock Manager
DEV - Device Driver Interface
GBL - Global Properties
HST - Host Channel Manager
HWI - HW Interrupt Manager
IDL - Idle Manager
LCK - Resource Lock Manager
LOG - Log Event Manager
MBX - Mailbox Manager
MEM - Memory Manager
PIP - Pipe Manager
PRD - Periodic Function Manager
QUE - Queue Function Manager
RTDX - Real Time Data Exchange
SEM - Semaphores
SIO - Stream I/O
STS - Statistics Accumulator
SWI - SW Interrupt Manager
SYS - System Services
TRC - Trace State
TSK - Multi-Tasking
Where do these fit?RT Capture, H/W Abstraction, or Multiple Threads
41
Sales and Support
Where will customers go for support on Code Composer Studio? TI Product Information Center
Recommended literature & source info?Code Composer Studio demo, tutorial, & docs:
http://www.ti.com/sc/docs/tools
Get your own copy!30 Day free Software TrialCode Composer Studio 1.11 release CDOrder through the TI Web or your local Distribution Representative