[DSP homepage]

Lab Exercise:

Fixed Point Operations on the 'C542

This exercise introduces fixed point arithmetic using the algebraic assembly language of the TI TMS320C542 ( 'C542). You will need to use the 'C542 kits in the lab along with the C54x Code Explorer software. You will also need to use the dskplasm assembler to generate .obj files that could be downloaded to the 'C542 kit thru Code Explorer.

Fixed Point Representation

Begin by noting that each location in the 'C542 is 16 bits. A 16-bit value may be used to represent nonnegative integers in the range 0 to 65535 (which is 2^16 - 1). 16-bit values may also be used to represent signed integers. One possibility is to use the 16 bits to represent integers in the range -32768 to 32767 ( 32768 is 2^15). The 16-bit value 0x8000 would represent -32768; 0xFFFF would represent -1; 0x0000 would represent 0; 0x0001 would represent 1; 0x7FFF would represent 32767. This representation is also known as 2's complement format. If we were using the 16-bit value to represent nonnegative integers, 0x8000 might represent 32768 instead, while 0xFFFF might represent 65535.

In this exercise, 16-bit values will be used to represent real numbers in the range [ -1, 1). Of course, not all real numbers could be represented exactly. We can only represent 2^16 distinct real values. Note however that the interval (-1, 1) is closed under multiplication. If we multiply two numbers in the range (-1, 1), the result would be another number in the range (-1, 1). The result could be approximated by another 16-bit value. We will use 0x8000 to represent -1; 0xFFFF to represent -1/(2^15); 0x0000 would represent 0; 0x0001 would represent 1/(2^15); 0x7FFF would represent 32767/32768. The 16-bit values would be used to represent the values they would represent in 2's complement format divided by 2^15.

In effect we have simply moved the binary point from a fixed location at the right of the least significant bit, bit 0, to another fixed location at the right of bit 15. The resulting representation is also known as Q15 format.

Multiplication Exercise

The difference equation

y(n) = 2 cos (2 pi f1 / Fs) y(n-1) - y(n-2)

subject to initial conditions

y(-1) = 0.5 sin ( - 2 pi f1 / Fs - phi)
y(-2) = 0.5 sin( - 4 pi f1 / Fs - phi)

produces as output

y(n) = 0.5 sin( 2 pi f1 n / Fs - phi), for n = 0,1,2,... .

In particular, for n = 0, we have

0.5 sin( - phi) = [2 cos(2 pi f1 / Fs)] y(-1) - y(-2)

For compatibility with the settings possible on the 'C542 kits, use a sampling frequency Fs = 9259 Hz. Use the values previously assigned to you for f1 and phi. [frequency and phase assignments] Note that the sampling frequency is different for this exercise.

Determine the Q15 representations of cos(2 pi f1 / Fs), y(-1), and -y(-2). Write assembly language code to calculate 0.5 sin( - phi) from these values. Be able to step through your code to verify that the computation yields the proper 16-bit value representing 0.5 sin( - phi).

Note, however, that the accumulators are 40 bit registers, and allow accumulation of values outside the range [-1,1).

 


 

This page has been accessed
Counter
times since December 10, 2002.

Last updated: December 10, 2002
lui_agustin@yahoo.com

 

 

 

1