Understanding Basic DSPBIOS Features
Understanding Basic DSPBIOS Features
ABSTRACT
DSP/BIOS is a small firmware that runs on digital signal processor (DSP) chips. It provides
the software components that allow application developers to have the following two basic
capabilities:
• Real-time monitoring and control – monitor and control program execution and program
variables in real time
• Real-time scheduling – real-time multi-threaded system scheduling and communication
Texas Instruments TMS320C6000 DSP/BIOS User’s Guide (Literature Number SPRU303)
provides a detailed description of the DSP/BIOS features and the application program
interface. This application report is intended to give the user a short overview of the basic
TMS320C6000 DSP/BIOS features so that one can have some idea on how to implement
a complete DSP system using DSP/BIOS.
Contents
1 What is DSP/BIOS? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Software Design Using Block Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Checking for Real-Time Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
List of Figures
Figure 1. Block Diagram of the AUDIO DEMO Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 2. Block Diagram and Code of the audio() DSP Function in the AUDIO DEMO Example . . . . . 6
Figure 3. Block Diagram and Code of the audio() DSP Function in the AUDIO DEMO Example . . . . . 8
Figure 4. Block Diagram and Code of the load() DSP Function in the AUDIO DEMO Example . . . . . . 9
Figure 5. Execution Graph of the AUDIO DEMO Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
List of Tables
Table 1. DSP/BIOS Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 2. AUDIO DEMO Maximum audioSwi Ready-to-Complete Time Versus Loading . . . . . . . . . . . . 11
Table 3. AUDIO DEMO Occurrence of Real-Time Problem Versus Loading,
Where audioSwi is Lower Priority Than PRD_swi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1
SPRA653
1 What is DSP/BIOS?
For most system developers today, more time is spent on software design than on hardware
design. This is mainly due to the fact that most of the complex hardware functions are already
integrated into standard integrated circuits. System developers simply need to select the right
chip to do the right job.
System designers can use either dedicated hardware integrated circuits or programmable DSPs
to implement DSP functions. The advantages of programmable DSPs are:
• Scalability – Designers can first decide how much processing power (or MIPS—million
instructions per second), memories, and other resources are required to do a certain job,
then select the DSP with enough processing resources. If one DSP is not enough, more
DSPs can be added until the required processing resources are met.
• Upgradability – Even after the hardware design is fixed, any change in DSP functions can be
implemented easily by making changes in software, and downloading to the DSP in
seconds.
• CPU-sharing – In most system, the number of DSP functions is much larger than the
available number of CPUs. Thus, each CPU must be time-shared among DSP functions. But
time-sharing the CPU may cause a critical DSP function to miss its real-time deadline.
DSP/BIOS and Code Composer Studio are the tools to make time-sharing CPU much
easier and avoid real-time deadline problems.
With DSP/BIOS, system designers can develop their DSP systems on programmable DSPs
using block diagrams to block out each DSP function, similar to designing using dedicated DSP
hardware integrated circuits.
As mentioned earlier, DSP/BIOS allows system designers to do two major tasks: real-time
monitoring and control, and real-time scheduling and communication. DSP/BIOS provides
modules to accomplish these tasks (see Table 1).
The modules for system configuration (GBL and MEM) define the hardware and system
environments. These settings should match the actual target hardware environment.
The modules for real-time monitoring and control (LOG, STS, and TRC) provide a mean to send
information to the host while the target program executes. LOG is used to send messages, such
as using a LOG_printf statement. STS is used to gather statistical information of a value, such
as average, maximum, and count of occurrence of the value. TRC controls the on and off of
information capture. It also provides two bits (TRC_USER0 and TRC_USER1) to allow the host
to control the flow of the target program in real time.
The modules for real-time scheduling contain three basic items called threads: HWI, SWI, and
IDL. These objects contain routines to handle a particular task in a real-time environment. These
routines could be the DSP functions that the system designer would like to implement on the
programmable DSP. HWI sets the interrupt service routines for the interrupt vector table and
provides some functions to manage hardware interrupts. The HWI object is the hardware
interrupt service routine triggered by hardware. SWI manages software interrupt service routines
with SWI objects. The SWI service routines are triggered by a call to the SWI_post() function.
IDL manages the background tasks, and it is triggered whenever no SWI and HWI services
routines are pending. HWI objects are highest-priority threads. SWI objects are next in the
priority. IDL objects are lowest in priority.
CLK objects run in the context of the timer hardware interrupt (HWI_INT14) service routine. PRD
objects are a special type of SWI, running in the context of the period software interrupt
(PRD_swi) service routine. The PRD_swi object can be selected so that it is triggered by one of
the CLK object (PRD_clock) or by a call to the PRD_tick() API function.
The modules for real-time communication (PIP, HST, and RTDX) manage communication
channels between threads, and between the target and the host. The PIP and HST objects are
single contiguous buffers similar to hardware FIFOs. For communication synchronization
purpose, these buffers can be set so that when the buffer has just been written or has just been
read, any function is called automatically. For instance, when the buffer is read, a call to
SWI_post() can be used to trigger a SWI interrupt service routine to put data into the buffer. This
triggering method is called to notify the reader or the writer.
HWI SWI
HWI_INT14 PRD_swi
CLK_F_ isr () PRD_F_swi () = Created by Config
SWI_post tools by default
at period
Call of N Call at period of M
CLK
PRD MxN=8
PRD_clock loadPrd
PRD_F_tick() load()
SWI
PIP PIP
DSS_rxPipe audioSwi DSS_txPipe
audio()
AND
Notify Reader Notify Writer
SWI_post SWI_post
HWI
HWI_INT11
DRR DSS_isr () DXR
HST
IDL IDL IDL RTA_fromHost
LNK_dataPump IDL_ cpuLoad RTA_dispatcher
HST
LNK_F_ dataPump() IDL_F_busy() RTA_F_dispatch()
RTA_ toHost
Figure 2, Figure 3, and Figure 4 depict the inner operation of the function of each thread object.
The system designer can usually start writing code without drawing these diagrams. It is shown
here to improve readability and to make the code easier to understand. The audio() function
uses two variables to control its operation: noise_sw and filter_sw. When the Code Composer
GEL modifies these variables, it is not done in real time since the target program must be halted
before variables can be modified. To control program operation in real time, one needs to use
the TRC modules.
Note that we use a DSS_isr assembly routine to call the C interrupt service routine. This is
necessary so that we can call the HWI_enter and HWI_exit assembly macros. These macros
disable software interrupts, thus, ensuring that the audioSwi is run only after the HWI has exited.
audio()
noise1_c
noise_ sw
filter_ sw
* src * dst
in out
fltr _c
input output
Figure 2. Block Diagram and Code of the audio() DSP Function in the AUDIO DEMO Example
PIP_alloc(out);
/* get data buffer pointer and frame size */
src = PIP_getReaderAddr(in);
dst = PIP_getWriterAddr(out);
size = PIP_getReaderSize(in);
PIP_setWriterSize(out,size);
/* noise switch */
switch (noise_sw)
{
case 0:
break;
case 1:
noise1_c (src, size);
break;
default:
break;
}
/* filter switch */
switch (filter_sw)
{
case 0:
cpy(dst, src, size);
break;
case 1:
fltr_c (dst, src, size);
break;
default:
cpy(dst, src, size);
break;
}
Figure 2. Block Diagram and Code of the audio() DSP Function in the AUDIO DEMO Example
(Continued)
load()
loadVal
AUDIO_load
Run loadVal
* 1000 NOPs
if (loadVal)
{
AUDIO_load(loadVal);
}
}
N .set 1000
_AUDIO_load:
mv a4, b0 ; use b0 as loop counter
mvk N, b1
mpy b1, b0, b0
nop
shru b0, 3, b0 ; (loop counter)= (# loops)/8
loop:
sub b0, 1, b0
nop
[b0] b loop
nop 5
b b3
nop 5 ; return
Figure 3. Block Diagram and Code of the audio() DSP Function in the AUDIO DEMO Example
DSS_ cisr ( )
3 frames
96
words
DRR
DSS_rxPipe
PIP_put when 96
words (one frame)
are received and
at least one empty frame
is available in the pipe
3 frames
96
words
DXR
DSS_txPipe
PIP_get when 96
words (one frame)
are transmitted and
at least one filled frame
is available in the pipe
Figure 4. Block Diagram and Code of the load() DSP Function in the AUDIO DEMO Example
void DSS_cisr(void)
{
volatile int dummy;
if (DSS_rxCnt == 0 && PIP_getWriterNumFrames(&DSS_rxPipe) > 0) {
PIP_alloc(&DSS_rxPipe);
DSS_rxPtr = PIP_getWriterAddr(&DSS_rxPipe);
DSS_rxCnt = PIP_getWriterSize(&DSS_rxPipe);
}
if (DSS_rxCnt) {
*DSS_rxPtr++ = DRR;
DSS_rxCnt––;
if (DSS_rxCnt == 0) {
PIP_put(&DSS_rxPipe);
}
}
else {
dummy = DRR;
DSS_error |= 0x1;
}
if (DSS_txCnt == 0 && PIP_getReaderNumFrames(&DSS_txPipe) > 0) {
PIP_get(&DSS_txPipe);
DSS_txPtr = PIP_getReaderAddr(&DSS_txPipe);
DSS_txCnt = PIP_getReaderSize(&DSS_txPipe);
}
if (DSS_txCnt) {
DXR = *DSS_txPtr++;
DSS_txCnt––;
if (DSS_txCnt == 0) {
PIP_free(&DSS_txPipe);
}
}
else {
DXR = 0;
DSS_error |= 0x2;
}
}
_DSS_isr:
HWI_enter C62_ABTEMPS, 0, 0xffff, 0
b _DSS_cisr
mvk diss,b3
mvkh diss,b3
nop 3
diss:
HWI_exit C62_ABTEMPS, 0, 0xffff, 0
Figure 4. Block Diagram and Code of the load() DSP Functionin the AUDIO DEMO Example
(Continued)
In the AUDIO DEMO example, we know that the input and output audio data is coming from and
going to an audio codec on the TMS320C6201 EVM. It is set up to run at 48-kHz stereo 16-bit
format. Each sample of the stereo data is packed into a 32-bit word. The DSS_cisr() function
collects 96 words before it is passed to the pipe as one frame. Since the audio() function
processes one frame at a time, the nominal frequency of the audio() function should be 48 kHz /
96 = 500 Hz. Therefore, if the maximum ready-to-complete time of the audioSwi object does not
exceed the period of 1 / 500 Hz = 2 ms, then it is most likely that there should not be a real-time
problem. By adjusting the loadVal variable, we can see the effect of loadVal to the maximum
ready-to-complete time of the audioSwi object. As seen in Table 2, when audioSwi has a lower
priority than PRD_swi and loadVal exceeds about 100, then the maximum ready-to-complete
time is over 2 ms.
Although the audioSwi processes one frame of data at a time, it does not mean that its period
has to be less than the frame period to avoid real-time problem. For example, one can increase
the length of the PIP objects so that the audio() function can wait for more frames to be available
before it processes several of them at once. This is possible since the frequency of the PRD_swi
is at 125 Hz, which is four times less than the data frame rate of 500 Hz. Therefore, as before,
the definition of what is real time depends on the application.
In the case of the AUDIO DEMO example, we can define real time to be: all data received from
the DRR is processed and sent back to the DXR, with no loss of data. If this is the definition, we
can check it by checking the DSS_error variable to see if it is non-zero. This variable is set in the
DSS_cisr() function when data received in the DRR cannot be placed into the receive pipe
because it is still full, or when no data is available at the transmit pipe when the DXR requests
data. This error occurs when the audio() function cannot process data fast enough.
One cannot halt the DSP in order to check the DSS_error variable. This is because the audio
codec hardware is still interrupting the DSP while the DSP is halted. A way to check the
DSS_error variable is to use a TRC module. The DSS_error is always set to zero until the user
click on the “USER0 trace” box in the RTA Control Panel. This My_idle() function can be set as
an IDL object to check for real-time problem.
Void My_idle()
{
if (TRC_query(TRC_USER0))
DSS_error = 0;
if (DSS_error & 0x1)
LOG_printf (&trace, ”DRR receive error”);
if (DSS_error & 0x2)
LOG_printf (&trace, ”DXR transmit error”);
}
To check for real-time problem, first uncheck the “USER0 trace” box, then run the AUDIO DEMO
program. Wait a few seconds until the flow of data is normal, and then check the “USER0 trace”
box. If no error is seen from the “trace” log after it has been running for a while (maybe a few
minutes), then the chance of a real-time problem is quite small. Since changing loadVal via
Code Composer GEL is not a real-time process, the “USER0 trace” box must be disabled
anytime loadVal is changed.
To use this method to check for real-time problems, refer to Table 3, which shows the effect of
the sizes of the transmit and receive pipes on the maximum loading before real-time problems
occur. Note that when the size of the pipes increases, the transmit pipe has to be pre-filled to a
certain degree. This allows the audioSwi to be slower than the HWI_INT11. Pre-filling can be
done easily in the main() routine by using the PIP_alloc() and PIP_put() API functions. The
following shows how to pre-fill one frame for the DSS_txPipe.
Void main()
{
DSS_init();
LOG_printf(&trace, ”Audio example started!!\n”);
PIP_alloc(&DSS_txPipe); /* Pre-fill one frame */
PIP_put(&DSS_txPipe);
/* fall into BIOS idle loop */
return;
}
It is proved here that for the AUDIO DEMO example, increasing pipe sizes reduces the chance
of real-time problem under loading.
4 Conclusion
This report provided a short overview of the basic features of the DSP/BIOS real-time kernel. A
system designer who wishes to develop DSP functions on a programmable DSP must be very
knowledgeable about each of the DSP functional block, its processing power requirement, what
resources are required, and how it is triggered to run. With the aid of the DSP/BIOS and Code
Composer real-time analysis tools, the system designer can check for any real-time problems
while the functional blocks are constructed. This will avoid any real-time glitches, which are very
difficult to fix once the system is fully built.
5 References
1. TMS320C6000 DSP/BIOS User’s Guide, TI Literature Number SPRU303, Texas Instruments,
May 1999.
Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to discontinue
any product or service without notice, and advise customers to obtain the latest version of relevant information
to verify, before placing orders, that information being relied on is current and complete. All products are sold
subject to the terms and conditions of sale supplied at the time of order acknowledgment, including those
pertaining to warranty, patent infringement, and limitation of liability.
TI warrants performance of its semiconductor products to the specifications applicable at the time of sale in
accordance with TI’s standard warranty. Testing and other quality control techniques are utilized to the extent
TI deems necessary to support this warranty. Specific testing of all parameters of each device is not necessarily
performed, except those mandated by government requirements.
In order to minimize risks associated with the customer’s applications, adequate design and operating
safeguards must be provided by the customer to minimize inherent or procedural hazards.
TI assumes no liability for applications assistance or customer product design. TI does not warrant or represent
that any license, either express or implied, is granted under any patent right, copyright, mask work right, or other
intellectual property right of TI covering or relating to any combination, machine, or process in which such
semiconductor products or services might be or are used. TI’s publication of information regarding any third
party’s products or services does not constitute TI’s approval, warranty or endorsement thereof.