You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

261 lines
15 KiB

;* ======================================================================== *;
;* TEXAS INSTRUMENTS, INC. *;
;* *;
;* DSPLIB DSP Signal Processing Library *;
;* *;
;* Release: Revision 1.04b *;
;* CVS Revision: 1.8 Sun Sep 29 03:32:17 2002 (UTC) *;
;* Snapshot date: 23-Oct-2003 *;
;* *;
;* This library contains proprietary intellectual property of Texas *;
;* Instruments, Inc. The library and its source code are protected by *;
;* various copyrights, and portions may also be protected by patents or *;
;* other legal protections. *;
;* *;
;* This software is licensed for use with Texas Instruments TMS320 *;
;* family DSPs. This license was provided to you prior to installing *;
;* the software. You may review this license by consulting the file *;
;* TI_license.PDF which accompanies the files in this library. *;
;* ------------------------------------------------------------------------ *;
;* Copyright (C) 2003 Texas Instruments, Incorporated. *;
;* All Rights Reserved. *;
;* ======================================================================== *;
;* ======================================================================== *;
;* Assembler compatibility shim for assembling 4.30 and later code on *;
;* tools prior to 4.30. *;
;* ======================================================================== *;
.if $isdefed(".ASSEMBLER_VERSION")
.asg .ASSEMBLER_VERSION, $asmver
.else
.asg 0, $asmver
.endif
.if ($asmver < 430)
.asg B, CALL ; Function Call
.asg B, RET ; Return from a Function
.asg B, CALLRET ; Function call with Call / Ret chaining.
.if .TMS320C6400
.asg BNOP, CALLNOP ; C64x BNOP as a Fn. Call
.asg BNOP, RETNOP ; C64x BNOP as a Fn. Return
.asg BNOP, CRNOP ; C64x Fn call w/, Call/Ret chaining via BNOP.
.endif
.asg , .asmfunc ; .func equivalent for hand-assembly code
.asg , .endasmfunc ; .endfunc equivalent for hand-assembly code
.endif
;* ======================================================================== *;
;* End of assembler compatibility shim. *;
;* ======================================================================== *;
* ========================================================================= *
* NAME *
* DSP_bexp -- Block exponent of a vector *
* *
* REVISION DATE *
* 12-Jul-2001 *
* *
* USAGE *
* This routine has the following C prototype: *
* *
* int DSP_bexp *
* ( *
* const int *x, /* Input Data */ *
* unsigned nx /* Number of elements */ *
* ); *
* *
* The DSP_bexp routine accepts a list of 'num' input points and *
* performs the determination of the block exponent. It returns *
* the minimum number of "redundant sign bits" observed on the *
* block of data. *
* *
* DESCRIPTION *
* The DSP_bexp function, performs a determination of the block *
* exponent of the vector of elements and returns the maximum *
* exponent. This information can then be used to re-normalize *
* the vector. This operation is useful when auto-scaling is *
* required as in a FFT. The DSP_bexp operation returns the minimum *
* norm of the vector. The minimum norm corresponds to the *
* maximum exponent. *
* *
* C CODE *
* The following is a general C code description of the algorithm *
* without restrictions. This implementation may have restrictions *
* as noted under 'ASSUMPTIONS' below. *
* *
* int DSP_bexp(const int *x, short nx) *
* { *
* int i; *
* int mask, mag; *
* *
* mask = 0; *
* *
* /* ---------------------------------------------------- */ *
* /* Merge the absolute values of all the elements */ *
* /* together. The leftmost bit-change on this mask */ *
* /* gives us the magnitude we desire. */ *
* /* ---------------------------------------------------- */ *
* for (i = 0; i < nx; i++) *
* mask |= x[i] ^ (x[i] >> 31); *
* *
* /* ---------------------------------------------------- */ *
* /* Find the magnitude of the mask. */ *
* /* ---------------------------------------------------- */ *
* for (mag = 0; (1 << mag) < mask; mag++) *
* ; *
* *
* return 31 - mag; *
* } *
* *
* ASSUMPTIONS *
* nx >= 8. *
* nx % 8 == 0. *
* *
* The array 'x' is double-word aligned. *
* *
* NOTES *
* This code is interrupt tolerant, but not interruptible. It masks *
* interrupts for its entire duration with branch delay slots. *
* *
* This code is ENDIAN NEUTRAL. *
* *
* SOURCE *
* DSPLIB. *
* *
* CYCLES *
* cycles = nx/2 + 21, including 6 cycle function call overhead. *
* For nx = 32, cycles = 37. *
* *
* CODESIZE *
* 236 bytes. *
* *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *
.sect ".text:_bexp"
.global _DSP_bexp
_DSP_bexp:
* ===================== SYMBOLIC REGISTER ASSIGNMENTS ===================== *
.asg A4, A_x
.asg B4, B_nx
.asg B3, B_ret_addr
.asg A4, A_ret_val
.asg B0, B_i
.asg A0, A_p
.asg B17, B_x
.asg A9, A_x7
.asg A8, A_x6
.asg B9, B_x5
.asg B8, B_x4
.asg A7, A_x3
.asg A6, A_x2
.asg B7, B_x1
.asg B6, B_x0
.asg A16, A_k31
.asg A18, A_a7
.asg A17, A_a6
.asg B16, B_k31
.asg B19, B_a5
.asg B18, B_a4
.asg A18, A_a3
.asg A17, A_a2
.asg B19, B_a1
.asg B18, B_a0
.asg A9, A_b7
.asg A17, A_b6
.asg B9, B_b5
.asg B18, B_b4
.asg A7, A_b3
.asg A17, A_b2
.asg B7, B_b1
.asg B18, B_b0
.asg A5, A_m
.asg B5, B_m
* ========================================================================= *
* =========================== PIPE LOOP PROLOG ============================ *
B .S1 loop
|| MVK .L1 2, A_p
|| ADD .L2X A_x, 8, B_x
|| SHR .S2 B_nx, 3, B_i
|| ZERO .D1 A_m
|| ZERO .D2 B_m
LDDW .D1T2 *A_x[2], B_x5:B_x4 ;[ 1,1]
|| LDDW .D2T1 *B_x[2], A_x7:A_x6 ;[ 1,1]
|| MVK .S1 31, A_k31
|| MVK .S2 31, B_k31
|| SUB .L2 B_i, 1, B_i
; ===== 2 stages of prolog collapsed
* =========================== PIPE LOOP KERNEL ============================ *
loop:
[!A_p]OR .S2 B_b4, B_m, B_m ;[10,1]
||[!A_p]OR .S1 A_b6, A_m, A_m ;[10,1]
|| XOR .D2 B_x1, B_a1, B_b1 ;[10,1]
|| XOR .D1 A_x3, A_a3, A_b3 ;[10,1]
|| SSHVR .M2 B_x5, B_k31, B_a5 ;[ 6,2]
|| SSHVR .M1 A_x7, A_k31, A_a7 ;[ 6,2]
[!A_p]OR .L2 B_b1, B_m, B_m ;[11,1]
||[!A_p]OR .S1 A_b3, A_m, A_m ;[11,1]
|| XOR .S2 B_x0, B_a0, B_b0 ;[11,1]
|| XOR .L1 A_x2, A_a2, A_b2 ;[11,1]
|| SSHVR .M2 B_x4, B_k31, B_a4 ;[ 7,2]
|| SSHVR .M1 A_x6, A_k31, A_a6 ;[ 7,2]
|| LDDW .D1T2 *A_x++[4], B_x1:B_x0 ;[ 3,3]
|| LDDW .D2T1 *B_x++[4], A_x3:A_x2 ;[ 3,3]
[!A_p]OR .L2 B_b0, B_m, B_m ;[12,1]
||[!A_p]OR .D1 A_b2, A_m, A_m ;[12,1]
||[ B_i]BDEC .S2 loop, B_i ;[ 8,2]
||[ A_p]SUB .L1 A_p, 1, A_p ;[ 8,2]
|| XOR .D2 B_x5, B_a5, B_b5 ;[ 8,2]
|| XOR .S1 A_x7, A_a7, A_b7 ;[ 8,2]
|| SSHVR .M2 B_x1, B_k31, B_a1 ;[ 8,2]
|| SSHVR .M1 A_x3, A_k31, A_a3 ;[ 8,2]
[!A_p]OR .S2 B_b5, B_m, B_m ;[ 9,2]
||[!A_p]OR .L1 A_b7, A_m, A_m ;[ 9,2]
|| XOR .L2 B_x4, B_a4, B_b4 ;[ 9,2]
|| XOR .S1 A_x6, A_a6, A_b6 ;[ 9,2]
|| SSHVR .M2 B_x0, B_k31, B_a0 ;[ 9,2]
|| SSHVR .M1 A_x2, A_k31, A_a2 ;[ 9,2]
|| LDDW .D1T2 *A_x[2], B_x5:B_x4 ;[ 1,4]
|| LDDW .D2T1 *B_x[2], A_x7:A_x6 ;[ 1,4]
* =========================== PIPE LOOP EPILOG ============================ *
; ===== 2 stages of epilog collasped
OR .L2 B_b4, B_m, B_m ;[10,4]
|| OR .S1 A_b6, A_m, A_m ;[10,4]
|| XOR .D2 B_x1, B_a1, B_b1 ;[10,4]
|| XOR .D1 A_x3, A_a3, A_b3 ;[10,4]
|| RET .S2 B_ret_addr
OR .L2 B_b1, B_m, B_m ;[11,4]
|| OR .S1 A_b3, A_m, A_m ;[11,4]
|| XOR .S2 B_x0, B_a0, B_b0 ;[11,4]
|| XOR .L1 A_x2, A_a2, A_b2 ;[11,4]
OR .L2 B_b0, B_m, B_m ;[12,4]
OR .D1 A_b2, A_m, A_m ;[12,4]
OR .L1X A_m, B_m, A_m
NORM .L1 A_m, A_ret_val
* ========================================================================= *
* End of file: dsp_bexp.asm *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *