c2sa.sa
上传用户:csczyc
上传日期:2021-02-19
资源大小:1051k
文件大小:4k
- .def _envelope
- _envelope:.cproc input,prev_in,output,npts
- .reg i,curr_abs,prev_abs,sign,CONST
- .reg x,input1,output1,output2
- .reg C1_Q14,C2_Q14
- MVK -15415,C2_Q14
- MVK 31565,C1_Q14
- ABS prev_in,prev_abs
- ZERO i
- LOOP1: LDH *input++,input1
- LDH *--output,output1
- LDH *--output,output2
- ADD output,4,output
- ABS input1,curr_abs
- SUB curr_abs,prev_abs,x
- SSHL x,16,x
- SHR x,5,x
- SMPY output1,C1_Q14,output1
- SMPY output2,C2_Q14,output2
- SADD x,output1,x
- SADD x,output2,x
- SSHL x,1,x
- MVK -32768,CONST
- MVKH 0x00008000,CONST
- SADD x,CONST,x
- SHR x,16,x
- STH x,*output++
- MV curr_abs,prev_abs
- ADD i,1,i
- CMPLT i,npts,sign
- [sign]B LOOP1
-
- .return
- .endproc
- ;/* */
- ;/* Subroutine iir_2nd_s: Second order IIR filter */
- ;/* (Single precision) */
- ;/* Note: the output array can overlay the input. */
- ;/* */
- ;/* Input scaled down by a factor of 2 to prevent overflow */
- .def _iir_2nd_s
- _iir_2nd_s: .cproc input,den,num,output,delin,delout,npts
- .reg i,temp,x,inputi,outputi,CONST,sign
- .reg delin0,delin1,num0,num1,num2,delout0,delout1,den1,den2
- zero i
- LDH *delin++,delin0
- LDH *delin,delin1
- LDH *delout++,delout0
- LDH *delout,delout1
- LDH *num++,num0
- LDH *num++,num1
- LDH *num,num2
- LDH *++den,den1 ;load den[1]
- LDH *++den,den2 ;load den[2]
- LOOP2: LDH *input++,inputi
- SMPY inputi,num0,temp ;temp=input[i]*num[0]
- SMPY delin0,num1,outputi ;delin[0]*num[1]
- SADD temp,outputi,x
- SMPY delin1,num2,outputi ;delin[1]*num[2]
- SADD x,outputi,x
- SMPY delout0,den1,outputi ;delout[0]*den[1]
- SADD x,outputi,x
-
- ; SUB den,4,den
- SMPY delout1,den2,outputi ;delout[1]*den[2]
- SADD x,outputi,x
- SSHL x,2,x
- MV delin0,delin1 ;updata delin
- MV inputi,delin0
- MVK -32768,CONST ;round(x)
- MVKH 0x00008000,CONST
- SADD x,CONST,x
- SHR x,16,x
- STH x,*output++
-
- MV delout0,delout1 ;updata delout
- MV x,delout0
- ADD i,1,i
- CMPLT i,npts,sign
- [sign]B LOOP2
-
- STH delout1,*delout--
- STH delout0,*delout
- STH delin1,*delin--
- STH delin0,*delin
- .return
- .endproc
- ;/***************************************************************************
- ; *
- ; * FUNCTION NAME: L_v_magsq
- ; *
- ; * PURPOSE:
- ; *
- ; * Compute the sum of square magnitude of a 16 bit input vector
- ; * with saturation and truncation. Output is a 32 bit number.
- ; *
- ; * INPUTS:
- ; *
- ; * vec1 16 bit short signed integer (Shortword) whose value
- ; * falls in the range 0xffff 8000 <= vec1 <= 0x0000 7fff.
- ; *
- ; * n size of input vectors
- ; *
- ; * qvec1 Q value of vec1
- ; *
- ; * qout Q value of output
- ; * OUTPUTS:
- ; *
- ; * none
- ; *
- ; * RETURN VALUE:
- ; *
- ; * L_magsq 32 bit long signed integer (Longword) whose value
- ; * falls in the range
- ; * 0x8000 0000 <= L_magsq <= 0x7fff ffff.
- ; *
- ; * IMPLEMENTATION:
- ; *
- ; * Compute the sum of square magnitude of a 16 bit input vector.
- ; * The output is a 32 bit number.
- ; *
- ; * KEYWORDS: square magnitude
- ; *
- ; *************************************************************************/
-
-