Single-Precision Matrix Multiply - Analog Devices adsp-2100 Manual

Adsp-2100 family programmable single-chip microprocessors
Table of Contents

Advertisement

}
.VAR/DM
sin_coeff[5];
.INIT
sin_coeff : 0x3240, 0x0053, 0xAACC, 0x08B7, 0x1CCE;
.ENTRY
sin;
sin:
I3=^sin_coeff;
AY0=0x4000;
AR=AX0, AF=AX0 AND AY0;
IF NE AR=-AX0;
AY0=0x7FFF;
AR=AR AND AY0;
MY1=AR;
MF=AR*MY1 (RND), MX1=DM(I3,M3);
MR=MX1*MY1 (SS), MX1=DM(I3,M3);
CNTR=3;
DO approx UNTIL CE;
MR=MR+MX1*MF (SS);
approx:
MF=AR*MF (RND), MX1=DM(I3,M3);
MR=MR+MX1*MF (SS);
SR=ASHIFT MR1 BY 3 (HI);
SR=SR OR LSHIFT MR0 BY 3 (LO);
AR=PASS SR1;
IF LT AR=PASS AY0;
AF=PASS AX0;
IF LT AR=-AR;
RTS;
.ENDMOD;
Listing 14.3 Sine Approximation
14.6

SINGLE-PRECISION MATRIX MULTIPLY

The routine presented in this section multiplies two input matrices: X, an
RxS (R rows, S columns) matrix stored in data memory and Y, an SxT
(S rows, T columns) matrix stored in program memory. The output Z, an
RxT (R rows, T columns) matrix, is written to data memory.
The routine is shown in Listing 14.4. It requires a number of registers to be
initialized, as listed in the "Calling Parameters" section of the initial
comment. SE must contain the value necessary to shift the result of each
multiplication into the desired format. For example, SE would be set to
zero to obtain a matrix of 1.31 values from the multiplication of two
matrices of 1.15 values.
Software Examples
{Pointer to coeff. buffer}
{Check 2nd or 4th quad.}
{If yes, negate input}
{Remove sign bit}
{MF = x 2 }
{MR = C 1 x}
{Convert to 1.15 format}
{Saturate if needed}
{Negate output if needed}
14
14 – 9

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents