9 Program Sequencer
9 Program Sequencer
Architecture 1
Introduction
The ADSP-2100 Family processors are single-chip microcomputers
– optimized for digital signal processing (DSP)
– and other high speed numeric processing applications.
They are all built upon a common core.
Each processor combines the core DSP architecture:
– Computation units,
– data address generators
– program sequencer
With differentiating features-
– on-chip program and data memory RAM
– a programmable timer
– one or two serial ports,
ADSP-2111 with a host interface port.
ADSP-2100 Family Core Features
16-Bit Fixed-Point DSP Microprocessors with
On-Chip Memory
Enhanced Harvard Architecture for Three-Bus
Performance: Instruction Bus & Dual Data Buses
Independent Computation Units: ALU,
Multiplier/Accumulator, and Shifter
Single-Cycle Instruction Execution & Multifunction
Instructions
On-Chip Program Memory RAM or ROM & Data
Memory RAM
Integrated I/O Peripherals: Serial Ports, Timer,
Host Interface Port (ADSP-2111 Only)
Dual Data Address Generators with Modulo and
Bit-Reverse Addressing
Efficient Program Sequencing with Zero-Overhead
Looping: Single-Cycle Loop Setup
ADSP-21xx
Fabricated in a high speed, submicron, double-layer metal CMOS process.
the highest-performance ADSP-21xx processors operate at 25 MHz with a 40 ns
instruction cycle time.
Every instruction can execute in a single cycle.
Fabrication in CMOS results in low power dissipation.
support a high degree of parallelism.
In one cycle the ADSP-21xx can perform all of the following operations:
Generate the next program address
MRO, MR1 and MR2 are multiplier / accumulator result registers; SRO
and SRI are shifter result registers.
Standard Functions
ALU Status
The ALU status bits in the ASTAT register are
defined below.
a 4 - 17
ALU Instructions
[IF condition] dest = xop + yop ; /* Add */
[IF condition] dest = xop + C ; /* Add with carry*/
[IF condition] dest = xop + yop + C ; /* Add with carry*/
[IF condition] dest = xop - yop ; /* Subtract */
[IF condition] dest = xop - yop + C - 1 ; /* Subtract with borrow*/
[IF condition] dest = yop - xop ; /* Subtract */
[IF condition] dest = yop - xop + C - 1; /* Subtract with borrow*/
[IF condition] dest = PASS xop ; /*Pass XOP through ALU, set flags*/
[IF condition] dest = PASS yop ; /*Pass XOP through ALU, set flags*/
[IF condition] dest = PASS 0; /*Pass 0 through ALU, set zeros */
[IF condition] dest = PASS 1; /*Pass 1 through ALU, clear all flags*/
a 4 - 18
ALU Instructions
[IF condition] dest = - xop ;
[IF condition] dest = - yop ;
[IF condition] dest = NOT xop ;
[IF condition] dest = NOT yop ;
[IF condition] dest = ABS xop ;
[IF condition] dest = yop +/- 1 ;
a 4 - 20
ALU Status Flags
Flag Name Definition
a 4 - 21
Arithmetic conditions
Syntax Status condition
EQ: ALU result = 0
NE: ALU Result 0
LT: ALU Result < 0
GE: ALU Result 0
LE: ALU Result 0
GT: ALU Result > 0
AC: ALU Carry Bit Set
NOT AC: ALU Carry Bit Not Set
AV: ALU Overflow Bit Set
NOT AV: ALU Overflow Bit Not Set
MV: MAC Overflow Bit Set
NOT MV: MAC Overflow Bit Not Set
NEG: XOP Input Negative (absolute value instruction only)
POS: XOP Input Positive (absolute value instruction only)
NOT CE: Not Counter Expired
a 4 - 22
ALU Saturation
• Sets ALU result to full scale positive or full scale
negative if overflow or underflow occurs
• Feature enabled by executing ‘ena ar_sat’ (bit 3 of
MSTAT)
• Once enabled, affects every ALU operation
• Only affects results sent to AR (AF - flags still get set)
• Overflow or underflow determined by the following
conditions
Overflow (AV) Carry (AC) AR Contents
0 0 ALU Output
0 1 ALU Output
1 0 0x7FFF full-scale positive
1 1 0x8000 full-scale negative
a 4 - 23
ALU Overflow Latch Mode
• Causes AV status flag to become “sticky”. Need to
explicitly clear.
a 4 - 24
ALU Mini-Quiz
Write the ADSP-2100 Family code to perform the
following operations:
Hint:
= 0x0070 ;
= 0x0030 ;
AF = + ;
14
PMA Bus
14
DMA Bus
24
PMD Bus
Bus Exchange
16
DMD Bus
16
R Bus
a 4 - 28
MAC Block Diagram
The multiplier has
– two 16-bit input ports X and Y,
– a 32-bit product output port P.
The 32-bit product is
– passed to a 40-bit adder / subtracter which adds or
subtracts the new product from the content of the
multiplier result (MR) register, or
passes the new product directly to MR.
The MR register is 40 bits wide.
MR consists of three smaller registers:
I. MRO (16 bits wide)
II. MR1 (16 bits wide)
III. MR2 (8 bits wide)
The adder/subtracter is greater than 32 bits to
allow for intermediate overflow in a series of
multiply/accumulate operations.
The multiply overflow (MV) status bit is set when
the accumulator has overflowed beyond the 32-bit
boundary.
i. e. when there are significant (non-sign) bits in
the top nine bits of the MR register (based on
twos-complement arithmetic).
The input/ output registers of the MAC are similar
to the ALD.
Source for X input port Source for Y input port Destination for R
output port
MXO,MXl MYO,MYI MR (MR2, MRl, MRO)
MRO, MRl, MR2 MF MF
SRO, SRI
The output of the adder / subtracter goes to either
the MF register or the MR register.
The MF register is a feedback register which
allows bits 16-31 of the result to be used directly
as the multiplier Y input on a subsequent cycle.
MAC Operations
Standard Functions:
The functions performed by the MAC are:
a 4 - 35
MAC Instructions
[IF condition] dest = xop * yop (format);
[IF condition] dest = MR + xop * yop (format);
-
[IF condition] dest = 0;
[IF condition] dest = MR [ (RND)];
*[IF condition] dest = xop * xop (format);
*[IF condition] dest = MR +- xop * xop (format);
a 4 - 36
Placement of Binary Point in
Multiplication
• Binary Integer Multiplication
M Bits
M+P Bits
• Mixed/Fractional Multiplication
M.N Bits
Example: 1.15 x 1.15 => 2.30**
x P.Q Bits
4.12 x 1.15 => 5.27
(M+P).(N+Q) Bits
** In fractional mode the result of a multiplication will be automatically left shifted by 1 bit resulting in a 1.31 format
a 4 - 37
Placement of Binary Point in MR
Sign Bit
MR2 MR1 MR0
S . Fractional
Mode
a 4 - 38
Multiplication Modes --Fractional Mode
MX0 MY1
a 4 - 40
Multiplication Modes --Integer Mode
In the integer mode, the 32-bit P register is not
shifted before being added to MR.
Multiplication Modes -- Integer Mode
Mode 2: Integer Mode
• Multiplier assumes all numbers in a 16.0 format
• No automatic left-shift necessary
• Example: MR = MX0 * MY1 (SS);
MX0 MY1
14 14
0x4000 =2 0x4000 =2
a 4 - 42
Input Formats
The multiplier accepts X and Y inputs represented in any
combination of signed twos-complement format and unsigned
format.
Multiplication on ADSP-2100 Family
Devices
To Switch Modes: ENA M_MODE; {Select Integer Mode} *
DIS M_MODE; {Select Fractional Mode}
a 4 - 44
Rounding in the MAC
• Rounding can be specified as part of multiply instruction (RND)
• Rounding only applies to fixed-point signed fractional results
• 40-bit results "rounded to nearest" 16 bit value.
• Rounded result can be placed in MR1 or MF register
Input: MX0 = 0x7FF9, MY0 = 0xEEEE
Command MR2 MR1 MR0
MR = MX0 * MY0 (SS); FF EEEE EEFC
MR = MX0 * MY0 (RND); FF EEEF 6EFC
• ADSP-217x / 218x / msp5x Support a “Biased” Rounding
– When MR0 = 0x8000, will always round up
– Enabled by setting BIASRND bit (bit12 of dm(0x3FF3))
– Useful for GSM speech coding where biased rounding is specified
a 4 - 45
Rounding in the MAC (contd…)
a 4 - 46
MAC Overflow And Saturation
a 4 - 47
MV MSB of MR contents after saturation
MR2
0 0 or 1 No change
1 0 00000000 0111111111111111 1111111111111111 (full-scale
positive)
1 1 11111111 1000000000000000 0000000000000000 (full-scale
negative)
a 4 - 48
Saturation and Overflow
• Overflow occurs when sign bit is corrupted during accumulation
• Overflow Status (MV) is updated everytime a MAC operation is
executed
• MV is set when any bits of significance cross into MR2
– This occurs when the bits in MR2 do not equal the MSB of MR1
• Saturation is performed by following instruction:
– IF MV SAT MR
Input: MX0 = 0x7FFF, MY0 = 0x7FFF, MR = 00 7FFE 0002
Command MR2 MR1 MR0
MR = MR + MX0 * MY0 (SS); 00 FFFC 0004
IF MV SAT MR; 00 7FFF FFFF
a 4 - 49
MAC Mini-Quiz
Write the ADSP-2100 Family program to add the values in
AX0 and AY0 and then multiply the result by 0x0020.
AX0 = 0x0020;
AY0 = 0x0010;
AR = _______________
___ = _______________
____=_______ * _________
a 4 - 50
Binary Multiply Mini-Quiz
0x4000 * 0x4000
0x4000 * 0x0002
a 4 - 51
Shifter
ADSP-2100 Family Shifter
Instruction
Register
14
PMA Bus
14
DMA Bus
24
PMD Bus
Bus Exchange
16
DMD Bus
16
R Bus
a 4 - 53
Shifter Block Diagram
DMD BUS 16
SI
REGISTER
BLOCK
EXPONENT MUX
LOGIC
EXPONENT
DETECTOR 16
I
SHIFTER
ARRAY
C
8 32 O
MUX MUX
32
OR / PASS
SE
REGISTER 16
NEGATE 16
8 MUX MUX
From
Instruction
SR1 SR0
REGISTER REGISTER
16 MUX
16
R - BUS 16
a 4 - 54
The shifter can be divided into the following
components:
– the shifter array
– the OR/PASS logic
– The exponent detector, and
– the exponent compare logic.
The shifter array is a 16x32 barrel shifter.
It accepts a 16-bit input and can place it anywhere
in the 32-bit output field, from off-scale right to off-
scale left, in a single cycle.
The placement of the 16 input bits is determined
by a control code (C) and a HI/LO reference signal.
The shifter array and its associated logic are
surrounded by a set of registers.
The shifter input (SI) register provides input to the
shifter array and the exponent detector.
The SI register is 16 bits wide and is readable and
writable from the DMD bus.
Also take as inputs AR, SR or MR via the R bus
The shifter result (SR) register is 32 bits wide and
is divided into two 16-bit sections, SRO and SRI
The SR register is also fed back to the OR/PASS
logic to allow double-precision shift operations.
The SE register (shifter exponent") is 8 bits wide
and holds the exponent
during the normalize and denormalize operations.
Shifter Features
• 16 Bit Input Value gets shifted and stored anywhere in
a 32 Bit output field
a 4 - 58
Shifter Instruction Examples
SR = ASHIFT SI BY -3 (LO); /* Perform an ARITHMETIC */
/* shift of the value in SI by */
/* three places to the right. */
SE=5;
SR = LSHIFT SI (HI); /* Perform a logical shift of the value */
/* in SI by the value specified in the */
/* SE register. */
a 4 - 59
a 4 - 60
Shift Immediate Instructions
a 4 - 61
Shift By Value in SE Register
Instructions
a 4 - 62
Shifter Instructions
• Arithmetic Shift Sign Extends Right Shifts
• Logical Shift Zero fills Right Shifts
• Left Shifts Are Always Zero Filled
• Positive SE or <data> Values Shift Left
• Negative SE or <data> Values Shift Right
• NO "+" for Positive Shifts
• Placement of Output Depends on HI/LO Modifier,
SE Register and <data> Value
a 4 - 63
Immediate Shift Instructions
• Example 1: SR = LSHIFT SI BY -1210 (LO);
SE xxxx xxxx
SR1 SR0
SE xxxx xxxx
After:
0000 0000 0000 0000 0000 0000 0000 1110
SR1 SR0
a 4 - 64
Immediate Shift Instructions
• Example 2: SR = LSHIFT SI BY -1210 (HI);
SE xxxx xxxx
SR1 SR0
SE xxxx xxxx
After:
0000 0000 0000 1110 1010 0011 0101 0000
SR1 SR0
a 4 - 65
Shift Instructions with SE Register
• Example 3: SE = -12;
SR = LSHIFT SI (HI);
a 4 - 66
Shift Instructions with OR Functionality
• Example 4: SE = -12;
SR = SR OR LSHIFT SI (HI);
SI 1110 1010 0011 0101
a 4 - 67
Shifter Mini-Quiz
Write the ADSP-2100 Family Assembly program to:
a 4 - 68