📄 corrfunc.dsp
字号:
/*************************************************************************/
/* $$01/10/2000 checked correaltion module data variables and function */
/* $$01/16/2001 modified and printed,Author: Jason.wang (zhigang wang) */
/* $$01/16/2001 Email: wzg119@yeah.net, BP: 86+02195950-161452 */
/* $$01/16/2001 This modlue is not optimized! should be test on Emulator */
/*************************************************************************/
.MODULE/SEG=App_PM Corrfunc;
/*************************************************************************/
#include "ld8a.inc"
/**************************************************************************
* Find the correlations between the target xn[], the filtered adaptive *
* codebook excitation y1[], and the filtered 1st codebook innovation y2[].*
* $$01/10/2000 only used in encoder *
* Calling Parameters *
* I0 : Q0 Target vector. *
* I1 : Q0 Adaptive codebook. *
* I2 : Q12 Filtered innovative vector. *
* Return Values *
* I4 : Correlations between xn,y1,y2(+2) *
* I5 : Q-format of Enc_gcoeff[] (+2) *
* Altered Registers: MR,SR,SE,AR,AX0,MY0,I0,I1,I2,I3,I4,I5 *
* Computation Time : 18 cycles *
***************************************************************************/
.ENTRY Corr_xy2;
.VAR/DM/RAM/SEG=App_DMbuf scaled_y2[L_SUBFR];
Corr_xy2: MR =0;
MR0=1;
AY0=3;
/*------------------------------------------------------------*
* Scale down y2[] from Q12 to Q9 to avoid overflow *
*------------------------------------------------------------*/
// CNTR=L_SUBFR;
I3=^scaled_y2;
CNTR=L_SUBFR;
DO scaled_down UNTIL CE;
SR0=DM(I2,M1);
SR=ASHIFT SR0 BY -3(LO);
scaled_down: DM(I3,M1)=SR0;
/*-------Compute scalar product <y2[],y2[]>---------*/
I3=^scaled_y2;
CNTR=L_SUBFR;
DO compu_scalar UNTIL CE;
AR=DM(I3,M1);
compu_scalar: IF NOT MV MR=MR+AR*AR(SS);
IF MV SAT MR;
SE=EXP MR1(HI);
SE=EXP MR0(LO);
SR=NORM MR0(LO),AX0=SE;
SR=SR OR NORM MR1(HI);
AR=SR0+H#8000;
AR=SR1+C;
AR=AY0-AX0,DM(I4,M4)=AR;
/*-------Compute scalar product <xn[],y2[]>--------*/
MR =0;
MR0=1;
AY0=-6;
// CNTR=L_SUBFR;
I3=^scaled_y2;
CNTR=L_SUBFR;
DO mac_xnscal UNTIL CE;
SR0=DM(I0,M1);
MY0=DM(I3,M1);
mac_xnscal: IF NOT MV MR=MR+SR0*MY0(SS);
IF MV SAT MR;
SE=EXP MR1(HI),DM(I5,M4)=AR;
SE=EXP MR0(LO);
SR=NORM MR0(LO),AX0=SE;
SR=SR OR NORM MR1(HI);
AR=SR0+H#8000;
AR=SR1+C;
AR=-AR;
AR=AY0-AX0,DM(I4,M4)=AR;
AR=AR-1;
/*---------Compute scalar product <y1[],y2[]>---------*/
MR =0;
MR0=1;
// CNTR=L_SUBFR;
I3=^scaled_y2;
CNTR=L_SUBFR;
DO mac_y1scal UNTIL CE;
MX0=DM(I1,M1);
MY0=DM(I3,M1);
mac_y1scal: IF NOT MV MR=MR+MX0*MY0(SS);
IF MV SAT MR;
SE=EXP MR1(HI),DM(I5,M4)=AR;
SE=EXP MR0(LO);
SR=NORM MR0(LO),AX0=SE;
SR=SR OR NORM MR1(HI);
AR=AY0-AX0,DM(I4,M4)=SR1;
AR=AR-1;
DM(I5,M4)=AR;
RTS;
/**************************************************************************
* Function Cor_h_X() *
* Compute correlations of input response h[] with the target vector X[] *
* $$01/10/2000 only used in encoder *
* Calling Parameters *
* I1 : Target vector *
* I2 : Impulse response of filters *
* Return Values *
* I0 : Correlations between h[] and D[] Normalized to 13 bits *
* Altered Registers: MR,SR,SE,AR,AY0,AY1,MY0,I0,I1,I2,I3,I4,I5 *
* Computation Time : 18 cycles *
***************************************************************************/
.ENTRY Cor_h_X;
.VAR/DM/RAM/SEG=App_DMbuf y32[2*L_SUBFR];
Cor_h_X: I5=^y32;
/*----------first keep the result on 32 bits and ----------*/
/*----------find absolute maximum--------------------------*/
AY0=H#0000;
AY1=H#0000;
AR=L_SUBFR;
CNTR=L_SUBFR;
DO find_absmax UNTIL CE;
I3=I1;
I4=I2;
// CNTR=AR;
MR=0,MY0=DM(I1,M1);
CNTR=AR;
DO mac_absmax UNTIL CE;
AF=PASS AR,MY0=DM(I3,M1);
SR0 =DM(I4,M4);
mac_absmax: IF NOT MV MR=MR+SR0*MY0(SS);
IF MV SAT MR;
AF=AF-1,DM(I5,M4)=MR0;
AR=PASS MR1,DM(I5,M4)=MR1;
IF GE JUMP pos_maxy32;
DIS AR_SAT;
AR=-MR0;
ENA AR_SAT;
MR0=AR,AR=-MR1+C-1;
MR1=AR;
pos_maxy32: DIS AR_SAT;
AR=MR0-AY0,SR0=AY0;
ENA AR_SAT;
AY0=AR,AR=MR1-AY1+C-1;
NONE=PASS AR;
IF LT JUMP find_absmax;
NONE=AR OR AY0;
IF EQ JUMP find_absmax;
SR0=MR0;
AY1=MR1;
find_absmax: AR=PASS AF,AY0=SR0;
/*----------Find the number of right shifts to do on y32[]----------*/
/*----------so that maximum is on 13 bits---------------------------*/
SR0=AY1;
NONE=SR0 OR AY0;
IF EQ JUMP zero_se;
SE=EXP SR0(HI),AR=AY0;
SE=EXP AR(LO);
AR=SE;
AR=-AR;
zero_se: AF=AR-16;
IF GT AR=PASS 16;
AY0=18;
I5=^y32;
// CNTR=L_SUBFR;
AR=AR-AY0,MR0=DM(I5,M4);
SE=AR;
CNTR=L_SUBFR;
DO shr_maxy32 UNTIL CE;
SR=LSHIFT MR0 (LO),AR=DM(I5,M4);
SR=SR OR ASHIFT AR(HI),MR0=DM(I5,M4);
shr_maxy32: DM(I0,M1)=SR0;
RTS;
/*************************************************************************/
.ENDMOD;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -