Module 3
Module 3
Introduction
Leading manufacturers of integrated circuits such as Texas
varied complexity
The TMS320 family consists of two types of single chips DSPs: 16-
Right from the early eighties, when these devices began to appear in
commercially available, the three most popular ones are those from
Texas Instruments, Motorola, and Analog Devices
Texas Instruments was one of the first to come out with a
processors
They have one program and three data memory spaces with
consists of
1. A 40-bit arithmetic logic unit (ALU)
3. A barrel shifter
4. A 17x17 multiplier
5. A 40-bit adder
wait state generator, parallel I/O ports, and serial I/O ports, are also
provided on-chip
These peripherals make it convenient to interface the signal
1. The program bus pair (PAB, PB); which carries the instruction
code from the program memory
2. Three data bus pairs (CAB, CB; DAB, DB; and EAB, EB); which
interconnected the various units within the CPU
3. In Addition the pair CAB, CB and DAB, DB are used to read from
the data memory, while the pair EAB, EB; carries the data to be
written to the memory
The 54xx can generate up to two data-memory addresses per cycle
3. A barrel shifter
4. A 17 x 17-bit multiplier
5. A 40-bit adder
write
No overhead is required to implement the shift needed for the scaling
operations
The 54xx barrel shifter can produce a left shift of 0 to 31 bits or a
register T
Figure below shows the functional diagram of the barrel shifter of
TMS320C54xx processors
The barrel shifter and the exponent encoder normalize the values in
either zero filled or sign extended, depending on the state of the sign-
extension mode bit in the status register ST1
An additional shift capability enables the processor to perform
(SARAM)
The on-chip RAM for these processors is organized in pages having
the RAM
A part of on-chip ROM may contain a boot loader and look-up tables
Bits of ST0 & ST1 registers can be set or clear with the SSBX &
RSBX instructions
PMST: Contains memory-setup status & control information
C: Carry bit
CPL=0, the relative direct addressing mode using data page pointer
is selected
CPL=1,the relative direct addressing mode using stack pointer is
selected
HM: Hold mode, indicates whether the processor continues internal
0: Always read as 0
ASM: Accumulator Shift Mode. 5 bit field, & specifies the Shift
1. Immediate addressing
2. Absolute addressing
3. Accumulator addressing
4. Direct addressing
5. Indirect addressing
6. Memory mapped addressing
7. Stack addressing
1. Immediate addressing
The instruction contains the specific value of the operand
The operand can be short (3,5,8 or 9 bit in length) or long (16 bits in
length)
The instruction syntax for short operands occupies one memory
location,
Example: LD #20, DP
RPT #0FFFFh
2. Absolute Addressing
The instruction contains a specified address in the operand
(iii). PA addressing
PORTR PA, Smem
3. Accumulator Addressing
Accumulator content is used as address to transfer data between
address
A page of 128 locations can be accessed without change in DP or SP
If CPL =0 selects DP
CPL = 1 selects SP
AR0 register is used for indexed and bit reverse addressing modes
R
The circular buffer size register (BK): specifies the size of circular
buffer
Effective base address (EFB): By zeroing the N LSBs of a user
selected AR (ARx)
End of buffer address (EOB) : By replacing the N LSBs of ARx with
the N LSBs of BK
If 0 _ index + step < BK ; index = index +step;
Name Function
Opcode This field contains the operation code for the instruction
Xmod Defined the type of indirect addressing mode used for accessing the Xmem
Operand
XAR Xmem AR selection field defines the AR that contains the address of Xmem
Ymod Defines the type of indirect addressing mode used for accessing the Ymem
Operand
Yar Ymem AR selection field defines the AR that contains the address of Ymem
Block diagram of the Indirect addressing options with a dual data –memory
operand
6. Memory-Mapped Register Addressing
Used to modify the memory-mapped registers without affecting the
7. Stack Addressing
Used to automatically store the program counter during interrupts
and subroutines
Can be used to store additional items of context or to pass data
values
Uses a 16-bit memory-mapped register, the stack pointer (SP)
PSHD X2
Values of stack & SP before and after operation
Solution:
a. AR3 ←AR3 + AR0;
AR3 = 200h + 20h = 220h
b. AR3 ←AR3 - AR0;
AR3 = 200h - 20h = 1E0h
c. AR3 ← AR3 + 1;
AR3 = 200h + 1 = 201h
d. AR3 ← AR3 - 1;
AR3 = 200h - 1 = 1FFh
e. AR3 is not modified
AR3 = 200h
f. AR3 ←AR3 + 40h;
AR3 = 200 + 40h = 240h
g. AR3 ← AR3 - 40h;
AR3 = 200 - 40h = 1C0h
2. Assume that the register AR3 with contents 1020h is selected as
the pointer for the circular buffer. Let BK = 40h to specify the
circular buffer size as 40h. Determine the start and the end
addresses fort the buffer. What will be the contents of register
AR3 after the execution to the instruction LD*AR3 + 0%, A, if
the contents of register AR0 are 0025h?
Solution:
AR3 = 1020h means that currently it points to location 1020h
Masking the lower 6 bits zeros gives the start address of the buffer as
1000h
Replacing the same bits with the BK gives the end address as 1040h
The Instruction LD*AR3 + 0%, A modifies AR3 by adding AR0 to it
execution of programs
Organized into 128 pages, each of 64k word size
Table: Function of different pin PMST register
branch instruction
Subroutine call: The PC is loaded with the immediate value
interrupt vector
Instructions such as BACC, CALA, etc ;The PC is loaded with the
dst: A (accumulator A)
B (accumulator B)
–32 768 ≤ lk ≤32 767
Status Bits:
Affected by FRCT and OVM
Affects OVdst
MPYA: Multiply by Accumulator A
Syntax: Operation:
1:MPYA Smem (Smem)x(A(32-16))→B
(Smem)→T
2:MPYA dst (T)x(A(32-16))→dst
Operands:
Smem: Single data-memory operand
dst: A (accumulator A)
B (accumulator B)
Status Bits:
Affected by FRCT and OVM
dst: A (accumulator A)
B (accumulator B)
Status Bits:
Affected by FRCT and OVM
Affects OVdst
MAC[R]: Multiply Accumulate With/Without Rounding
Syntax Operation
1:MAC[R]Smem, src (Smem)x(T)+(src)→src
dst: A (accumulator A)
B (accumulator B)
–32 768 ≤ lk ≤32 767
Status Bits:
Affected by FRCT and OVM
dst: A (accumulator A)
B (accumulator B)
Status Bits:
Affected by FRCT and OVM
Affects OVdst (or OVsrc, if dst is not specified) and OVB in syntax 1
MACD: Multiply by Program Memory and Accumulate With
Delay
Syntax:
MACD Smem, pmad, src
Operands:
Smem: Single data-memory operand
src: A (accumulator A)
B (accumulator B)
0≤pmad≤65 535
Execution
pmad→PAR
if(RC)≠0
Then
(Smem)→T
(Smem)→Smem+1
(PAR)+1→PAR
Else
(Smem)→T
(Smem)→Smem+1
Status Bits:
Affected by FRCT and OVM
Affects Ovsrc
src: A (accumulator A)
B (accumulator B)
0≤pmad≤65 535
Execution:
pmad→PAR
if(RC)≠0
Then
(Smem)→T
(PAR)+1→PAR
Else
(Smem)→T
Status Bits:
Affects OVsrc
MACSU: Multiply Signed by Unsigned and Accumulate
Syntax Execution
MACSU Xmem, Ymem, src
unsigned(Xmem)xsigned(Ymem)+(src)→src
(Xmem)→T
Operands
Xmem,Ymem: Dual data-memory operands
Src :A(accumulator A)
B(accumulator B)
Status Bits:
Affected by FRCT and OVM
Affects OVsrc
MAS[R] :Multiply and Subtract With/Without Rounding
Syntax Execution
1: MAS[R] Smem, src (src)-(Smem)x(T)→src
2: MAS[R] Xmem,Ymem, src[dst] (src)-(Xmem)x(Ymem)→dst
(Xmem)→T
Operands
Smem: Single data-memory operands
Xmem,Ymem: Dual data-memory operands
Solution:
AR1as pointer to the numbers
This program computes the signed sum of data memory locations from
A=dmad(410h)+dmad(411h)+………..+ dmad(41fh)
mmregs
.global _c_int000
.text
._c_int00:
STM #10h, AR2 :initialize counter AR2=10h
STM #410h, AR1 :Initialize Pointer AR1=410h
LD #0h, A :Initialize sum A=0
SSBX SXM :Select sign extension mode
START:
ADD *AR1+, A :Add the next data value
BANZ START, *AR2- :Repeat if not done
NOP :No operation
.end
instruction
(T)*(dmad)→Acc A or B
.global _c_int00
h .int 10, 20, 30
.text
_c_int00:
SSBX SXM ; Select sign extension mode
STM #310H, AR2 ; Initialize pointer AR2 for x(n) stored
at 310H
STM @h, AR3 ; Initialize pointer AR3 for
coefficients
MPY *AR2+,*AR3+, A ; A = x(n) * h(0)
MPY *AR2+,*AR3+, B ; B = x(n-1) * h(1)
ADD A, B ; B = x(n) * h(0) + x(n-1) * h(1)
MPY *AR2+,*AR3+, A ; A = x(n-2) * h(2)
ADD A, B ; B = x(n) * h(0) + x(n-1) * h(1) + x(n-2) * h(2)
STL B, *AR2+ ; Save low part of result
STH B, * AR2+ ; Save high part of result
NOP ; No operation
.end
.global _c_int00
.data
.bss x, 3
.bss y, 2
h .int 10, 20, 30
.text
_c_int00:
SSBX SXM ; Select sign extension mode
STM #x, AR2 ; Initialize AR2 to point to x(n)
STM #h, AR3 ; Initialize AR3 to point to h(0)
LD #0H, A ; Initialize result in A = 0
RPT #2 ; Repeat the next operation 3 times
MAC *AR2+,*AR3+, A ; y(n) computed
STM #y, AR2 ; Select the page for y(n)
STL A, *AR2+ ; Save the low part of y(n)
STL A, *AR2+ ; Save the high part of y(n)
NOP ; No operation
.end
On chip peripherals
It facilitates interfacing with external devices
Hardware timer
Clock generator
Serial port
3. Hardware Timer
An on chip down counter
TIN &TOUT
The timer register (TIM) is a 16-bit memory-mapped register that
whose contents are loaded onto the TIM whenever the TIM
decrements to zero or the device is reset (SRESET)
The timer can also be independently reset using the TRB signal
the prescaler block after each time the prescaler bits count down to 0
That is to say that the 4-bit value of TDDR determines the divide-by
decrements to 0
TOUT can trigger the start of the conversion signal in an ADC
status bits
Logical block diagram of timer circuit
4. Host port interface (HPI):
Allows to interface to an 8bit or 16bit host devices or a host
processor
Signals in HPI are:
HRDY
HCNTL0 &HCNTL1
HBIL
HR/W
The host interrupt, Hint, for the DSP to signal the host when it
attention is required
HRDY, a DSP output indicating that the DSP is ready for transfer
HBIL. If this is low it indicates that the current byte is the first byte;
operation
5. Clock Generator:
The clock generator on TMS320C54xx devices has two options-an
programmed
Not all devices of the TMS320C54xx family have all these clock
i. Synchronous ports
device
It may also be generated by software
However, the types and the number under each type vary from
device to device
Some of these interrupts are reserved for use by the CPU