EECS20: Introduction to Real-Time Digital Systems
Lab05: C50 Board/Architecture Introduction
EECS20: Introduction to Real-Time Digital Systems
©1996 Regents of the University of California.
By William T. Huang, K. H. Chiang, Brian L. Evans.
URL: http://www-inst.eecs.berkeley.edu/~ee20
News: ucb.class.ee20
In the previous four labs, you have generated music notes and experimented with sound effects using MATLAB. This lab introduces a faster way to do the same processing--using the digital signal processor (DSP). In this course, we will be using TMS320C50 ('C50) fixed-point DSP to implement real-time systems. You will get some hands-on experience with the 'C50 development environment before you learn about the 'C50 architecture and instructions. A list of the acronyms and abbreviations we will be using in the laboratory are given at the end of the lab.
The TMS320C5x DSP Starter Kit ('C5x DSK) is a stand-alone application board that lets you experiment with and use TMS3205x DSPs for real-time signal processing. Figure 2-2 on page 2-5 of TMS320C5x DSP Starter Kit User's Guide (available on the book shelf in room 117, Cory Hall) illustrates the components on the 'C5x DSK Board. The on-board analog interface circuit (AIC) converts analog voltage signals to and from some sequence of fixed point numbers processed by the DSP. The RCA jacks allow you to connect a microphone or function generator as inputs, and a speaker, earphones, or an oscilloscope as outputs. The DSK is connected to the PC through a RS-232 cable, so you can load your program into the DSP and monitor the status of the DSP. When you use the DSK, please make sure that all its I/O and power cables are connected correctly.
We will use two pieces of software in our DSK exercises. The DSK assembler assembles your assembly program into a .dsk file ready to be loaded onto the DSK. The DSK debugger allows you to load the .dsk files onto the DSK and to monitor the status of the DSP.
Now, you should complete the following walkthrough exercise:
sawtooth.asm
onto the diskette.
- a:
- c:\dsk\dsk5a sawtooth.asm -l
sawtooth.dsk
is created.
- c:\dsk\dsk5d
a:\sawtooth.dsk
.
The basic pattern of the above procedure will be used repeatedly in your experiments with the DSK.
Repeat the walkthrough exercise again. This time, connect the RCA output jack to an earphone or a speaker. Is the sound more interesting to listen to than a single tone?
Familiarize yourself with the TMS320C5x DSP Starter Kit User's Guide. Chapter 6 of the user's guide teach you how to use the DSK debugger. Using the 'C50 DSK Debugger, let's see how the 'C50 DSP work.
sawtooth.dsk
.
sawtooth.asm
and find the line begins with the label
"LOOP". Compare this line with the first line in the reverse assembly
window. Then, compare the three subsequent lines. These four lines
are the main loop of our program.
B
stands for the branch instruction.
The branch instruction explicitly tells the DSP the line to be excuted
next. The flow of the program then branches away from
its normal behavior
of executing lines one after the other.
ADD #80h
. Read ACC value again. What happens
to it? ACC stands for accumulator, the temporary storage for the
results of most DSP operations such as addition and multiplication.
In this case, hex number 80h is
added to the previous ACC value and the result is stored back into
the accumulator. Note that ACC stores a 32-bit number.
Why do you think that the accumulator is 32 bits long?
Look at Figure 3-12 on page 3-23 in TMS3205x User's Guide
(the thick one). Both the data bus and program bus are only
16-bit wide.
ADD
can carry 8-bit
information about its operand. When "#" is used, the 8 bits
carry the actual value of the number to be added. Then, it is called
short immediate mode.
For example, this mode can be used to add +1 or -1 to a number.
What is the largest value we can use
to replace 80h and still use the short immediate mode?
SACL DXR,3
. Read DXR value again. What happens
to it? DXR stands for data transmit register. The values stored in
DXR will eventually be converted to analog signals output from the
RCA jack on the DSK. SACL is the mnemonic for "Store Low Accumulator
With Shift". Low accumulator means the lower 16 bits of the ACC value.
Together with the operands, this instruction tells the DSP to shift
the ACC value left three bits and store the lower 16 bits to DXR.
Note that the ACC value is not changed by this instruction.
Convince yourself that the DXR value is incremented by the value
80h shifted to left by 3 bits.
IDLE
. This instruction put
the DSP to sleep (to save power) until some event wakes it up.
Other
portion of the sawtooth program has set such event to occur at a
7.7 kHz frequency. Once the DSP wakes up, it moves on to execute the
next instruction. What is the highest frequency sinusoid
we can generate by
writing one sample value to the DXR once every awakening?
'C50 is a fixed point processor. Although we can always implement
floating point arithmetic in software, that usually is not
performed on a fixed-point processor.
Instead, we can rephrase our problems to fit
the numbers we can use. 1.414V is the same as 1414mV. Of course,
we have to be very careful in tracking what each number represents.
When we add two numbers, we want to make sure that they are based
on the same scale just like we match the decimal points when we add
decimal numbers. Similary, we have to keep track of multiplications.
In the following poly.asm
example, we will use each 16-bit word to represent
a value between -1.0 and 1.0. Each representable value is
2-15 apart from the nearest representable values. When
we multiply two words, we should shift the product right 15 bits, so
the lower 16-bit of the result reprents a number between -1.0 and 1.0.
Now, read
poly.asm
to see how we can compute y = a * x + b.
Before you run this program on the debugger, you should
learn more a few more 'C50 instructions first.
LDP
to load the DP register.
ADD
: Add to ACC
SUB
: Substract from ACC
AND
: And with ACC
To load data from data memory to ACC, we use LACC
.
To store data from ACC to data memory, we use SACL
and SACH
.
LACC
: The contents of the specified data memory
address or a 16-bit constant are left-shifted (up to 16 bits)
and loaded into the accumulator. During shifting, low-order bits
are zero-filled. High-order bitrs are sign-extended. (If you
don't know what "sign-extended" means, ignore it. We will only
use signed numbers in this laboratory.)
SACL
: The low-order bits of the accumulator are
shifted left from 0 to 7 bits, as specified by the shift code,
and stored in data memory. The low-order bits are filled
with zeros on the shift, and the high-order bits are lost.
The accumulator itself remains unaffected.
SACH
: This instruction copies the entire
accumulator into a shifter, where it left-shifts the entire
32-bit number from 0 to 7 bits. It then copies the upper 16
bits of the shifted value into data memory. The
accumulator itself remains unaffected.
LT
:
Load the T-register from data memory with the first multiplicand.
MPY
:
The second multiplicand is loaded from data memory and
the multiplication is performed.
APAC
.
Single-step through the program and see how values are loaded, shifted, multiplied and accumulated. The data memory window on the lower left corner of the debugger screen should display the data memory starting from address 1000h. The result is stored at 1000h when the program enters the infinite loop.
Hint: Storing the higher bits in a 32 bit accumulator into a 16-bit data word is equivalent to a right-shift by 16 bits.
poly.asm
, write
a program to compute y = a * x2
+ b * x + c for any set of {a,b,c,x: |x| < 1}
such that |y| < 1.