⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amf_biquadcascadesmoothed_ds_render.asm

📁 ADI SHARC DSP 音频算法标准模块库
💻 ASM
字号:
// Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
// This software is proprietary and confidential to Analog Devices, Inc. and its licensors.

// File    : $Id: //depot/development/visualaudio/modules/2.5.0/SHARC/Source/AMF_BiquadCascadeSmoothed_DS_Render.asm#3 $ 
// Part of : VisualAudio V2.5.0 
// Updated : $Date: 2006/10/12 $ by $Author: Fernando $




//    Module Name     : AMF_BiquadCascadeSmoothed_DS_Render.asm 
//    DSP Processor   : ADSP21161
//    Original Author : GJO  Ported to VA by Tim Stilson    
//    Date               : 6/23/03
//====================================================================================
// Processor resources used:
//  106+25 words pmem INTERNAL, (+25 for _AMF_BiquadSmoothedCoefUpdateEven)
//  969 cycles for tickSize=128 (1 stage)
//  cycles = 181 + TickSize*2 + numSections*(25 + TickSize*4)
//  (SIMD used)
//====================================================================================

#if 1

        /**************************************************************

        File Name:    CASCADE_BC.asm
                
        Date Modified:    6/23/03    Tim Stilson: created from AMF_BiquadCascade2b_Render.asm
        Date Modified:    8/15/03    Tim Stilson: some code-size optimizations
                        11/04/03        Tim Stilson, reworked state handling while fixing a bug with numSections>=3

        ****************************************************************************/

#include "processor.h"
#include "AMF_BiquadCascadeSmoothed_DS.h"
#include <asm_sprt.h>

// global routines
.global    _AMF_BiquadCascadeSmoothed_DS_Render;            
.extern _AMF_BiquadSmoothedCoefUpdateEven;

.segment /pm SEG_MOD_FAST_CODE;

_AMF_BiquadCascadeSmoothed_DS_Render:

    puts = mode1;
    puts = r10;
    puts = r7;
    puts = r6;
    puts = r5;
    puts = r3;
    r0 = i1;    puts = r0;
    r0 = i3;    puts = r0;
    puts = i9;

    ////////////////////// do the coef smoothing    

    // remember my inputs
    puts = r4;
    puts = r8;
    puts = r12;
    
    // set up arguments for the update fn
    i4=r4;                    //i4->testModuleInstance[0]
    
    r0=dm(AMF_BiquadCascadeSmoothed_DS_CoefsSmoothing,i4);
    puts = r0;
    s0=r0;

    // not doing these loads as SIMD because these may be off-chip
    r1=dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp1Target,i4);
    s1=dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp2Target,i4);
    r2=dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp1,i4);
    s2=dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp2,i4);
    bit set MODE1 PEYEN;     // to TotalAmp1 and TotalAmp2 at the same time    
    nop;

    f1=f1-f2;
    f1=f1*f0;
    f2=f2+f1; // current = current + CoefsSmoothing*(target-current)

    bit clr MODE1 PEYEN;         
    r12 = 8; // # of coefs per section (can be either SIMD or SISD,as s12 won't be used)

    dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp1,i4)=r2; // writeback
    dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp2,i4)=s2; // writeback
        
    r8=dm(AMF_BiquadCascadeSmoothed_DS_Coefs,i4);                    
    r4=dm(AMF_BiquadCascadeSmoothed_DS_CoefsTarget,i4);                    
    r0=dm(AMF_BiquadCascadeSmoothed_DS_NumSections,i4);

    r12 = r12*r0 (UUI);     // total number of coefs to smooth
    
    cjump _AMF_BiquadSmoothedCoefUpdateEven(db);
    dm(i7,m7)=r2;
    dm(i7,m7)=pc;
    alter(1); // eat up the stack location used by the 4th argument to that call

    // restore my inputs
    r12 = gets(1);
    r8 = gets(2);
    r4 = gets(3);
    alter(3);
    
    //////////////////////////// now on to the rest of the thing


    i4 = r4;                /* Read structure pointer */
    
    r1 = r12;              /* Read number of points */
    r1 = r1 - 1;


    r0 = dm(AMF_BiquadCascadeSmoothed_DS_Coefs,i4);
    i9 = r0;

    f4 = dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp1,i4);
    s4 = dm(AMF_BiquadCascadeSmoothed_DS_TotalAmp2,i4);
    
    r0 = dm(AMF_BiquadCascadeSmoothed_DS_State,i4);    
    b12 = r0;

    r0 = dm(AMF_BiquadCascadeSmoothed_DS_NumSections,i4);
    
    i4=r8;                    // i4->*buffers
    
 // initialize input and output samples pointers
    i3=dm(0,i4);            // i3->buffers[0], input
    i1=dm(1,i4);            // i1->buffers[1], output

    
// do initial scaling loop, into output buffer
    bit set MODE1 RND32 | PEYEN;         /* alu, multiplier precision -> 1 cycle of latency before PEYEN */
    m4 = 2;                                        /* stride = 2 for SIMD            */
    f3 = dm(i3,m4);
    lcntr = r12, do scaleLoop until lce;
        f2 = f3*f4, f3 = dm(i3,m4);
scaleLoop:            dm(i1,m4) = f2;

    // reset i/o pointers for filter
    i1=dm(1,i4);            // scale loop scaled into output buffer, so that is now the input too

    bit set mode1 CBUFEN;                /* Enable circular buffering */

    m12 = 2;
    l12 = 4;
    b13 = b12;
    l13 = l12;
        

    lcntr=r0, do quads until lce;
        // reset i/o pointers
        i3=i1;
        i4=i1;
        f4 = pm(i9,m12); // a2
        f5 = pm(i9,m12); // a1
        f6 = pm(i9,m12); // b2
        f7 = pm(i9,m12); // b1

                            f8=dm(i3,m4),                f2=pm(i12,m12);    /* get w(n-2) *//* load input sample */
            f12=f2*f4,                                      f3=pm(i12,m12); /* w(n-2)xa2, get w(n-1) */
            f12=f3*f5,         f8=f8+f12;                                    /* w(n-1)xa1, x(n)+(w(n-2)xa2) */ 
            f12=f2*f6,         f8=f8+f12,                     f2=f3;            /* w(n-2)xb2, w(n) = x(n)+w(n-1)xa1+w(n-2)xa2, f2 = next w(n-2) */
            f12=f3*f7,        f8=f8+f12,                    f3=f8;           /* w(n-1)xb1, w(n)+(w(n-2)xb2), f3 = next w(n-1) */
        
        lcntr=r1, do filtering until lce;
            f12=f2*f4,         f8=f8+f12,   f10=dm(i3,m4);                 /* w(n-2)xa2, out=w(n)+(w(n-2)xb2)+w(n-1)*b1, get input */
            f12=f3*f5,         f10=f10+f12, dm(i4,m4)=f8;                    /* w(n-1)xa1, x(n)+(w(n-2)xa2), write out */ 
            f12=f2*f6,         f8=f10+f12,                 f2=f3;            /* w(n-2)xb2, w(n) = x(n)+w(n-1)xa1+w(n-2)xa2, f2 = next w(n-2)*/
filtering:    f12=f3*f7,        f8=f8+f12,                     f3=f8;           /* w(n-1)xb1, w(n)+(w(n-2)xb2), f3 = next w(n-1) */

                            f8=f8+f12,                    pm(i12,m12)=f2; /* calc last y after dropping out of loop, write out state w(n-2) */
                                         dm(i4,m4)=f8,    pm(i12,m12)=f3; /* write last output, write out state w(n-1) */

        // point to next set of states
        r2 = b12;
        r3 = 4;
        r2 = r2 + r3;
        b12 = r2;
quads:    b13 = r2;

    bit clr mode1 PEYEN;                /* disable SIMD mode */

    l12 = 0;
    l13 = 0;
    
    i9  = gets(1);
    i3  = gets(2);
    i1  = gets(3);
    r3  = gets(4);
    r5  = gets(5);
    r6  = gets(6);
    r7  = gets(7);
    r10 = gets(8);
    mode1=gets(9);
    alter(9);

//------------------------------------------------------------------------------------
_AMF_BiquadCascadeSmoothed_DS_Render.END:
    leaf_exit; // C-rth requires this instead of rts
//------------------------------------------------------------------------------------
    
.endseg;
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -