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

📄 block_fir.asm

📁 2005 Center for Biological & Computational Learning at MIT and MIT All rights reserved. Permissio
💻 ASM
字号:
/***********************************************************************

This is an example of a C callable floating point block FIR.
The example is for 64 taps with 128 samples and is provided to show
how the techniques detailed in the accompanying application note can be
applied to this example to convert it for operation on the TigerSHARC
family of processors.

Some of the macros for saving and restoring to and from the stack
have been added simply to show how the TigerSHARC macros provided with
the accompanying application note can be implemented without much
alteration of the code.

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

#include  "def21160.h"				/* Symbol Definition File */
#include "asm_sprt.h"

.global _block_fir;

/* program memory code */
.section/pm seg_pmco;

_block_fir:
	leaf_entry;
 
/****************************************************
*	Save various registers to stack
*	This is simply added to show the use of the macros
*****************************************************/	
	/* save all register block to stack */
	save_reg;
	
	/* save some other registers to stack */
	r0 = i0;
	puts = r0;
	
	r0 = i1;
	puts = r0;
	
	r0 = i8;
	puts = r0;
	
	r0 = i9;
	puts = r0;
	
/****************************************************
* 	Retrieve passed arguments
*	The 3 pointers are passed through r4, r8 and r12
*	The output pointer is saved on stack
*	The number of samples and number of taps
*	are integer values passed on the stack
*	r4 = input
*	r8 = dline
*	r12 = coeffs
*	reads(1) = output
*	reads(2) = samples
*	reads(3) = TAPS
*****************************************************/	
	/* reads Output pointer N and TAPS from the stack */
	r3 = reads(1);	// Output pointer
	r2 = reads(2);	// N number of samples
	r1 = reads(3);	// Number of TAPS 
	
	/* dline pointer CB setup */
	/* second parameter passed stired in r8 */
	i0 = r8; b0 = r8; l0 = r1;
	
	/* input samples buffer setup */
	/* first parameter passed stored in r4 */
	i1 = r4; b1 = r4; l1 = 0x0;
	
	/* coeffs pointer CB setup */
	/* third parameter passed stored in r12 */
	i8 = r12; b8 = r12;	l8 = r1;
	
	/* output buffer setup */
	i9 = r3; b9 = r3; l9 = 0x0;
	
	/* Setup modify registers for arrays */ 
	m0 = 0;
	m1 = 1;
	m2 = -1;
	m3 = 2;
  	m9 = 2;
	m10= 1;
	
	/* Zero the first output result */
	f8 = 0.0;
	
	/* Circular Buffer Enable */
	bit set MODE1 CBUFEN;
	
	/* Circular Buffering not in effect until next cycle */				
	nop;								
	
	/* move pointer to delay[1] */
	s0 = dm(i0, m1);
	
	/* load s0 with the value of delay[1] for SIMD store, move pointer to delay[0] */					
	s0 = dm(i0, m2);					

	/* r1 = taps/2 due to SIMD mode */
	r1 = lshift r1 by -1;
	
	/* 3 macs outside of fir mac loop */				
	r3 = 3;	
	
	/* r3 = taps/2 - 3 for fir mac loop counter */ 							
	r3 = r1 - r3;						

	/* SIMD Mode Enable */
    bit set MODE1 PEYEN;				
    
    /* SIMD not in effect until next cycle */
    /* read one sample from INPUT[i] */
    r0 = dm(i1,m1);						
    
    /* read 2 coeffs */										
   	f4 = pm(i8,m9);	
   	
   	/* outer loop - sample loop */					
	lcntr = r2, do main_fir until lce;	

  		/* transfer new sample and last new sample to delayline */
		dm(i0,m3)=f0;
		
		/* samples * coeffs, read 2 samples, read 2 coeffs */			
		f8=f0*f4, f0=dm(i0,m3), f4=pm(i8,m9);
		
		/* samples * coeffs, read 2 samples, read 2 coeffs */	
		f12=f0*f4, f0=dm(i0,m3), f4=pm(i8,m9);	
  
		/* FIR loop */
		lcntr=r3, do macs until lce;

		/* samples * coeffs, accum, read 2 samples, read 2 coeffs */			
macs:   f12=f0*f4, f8=f8+f12, f0=dm(i0,m3), f4=pm(i8,m9);	
        
		/* samples * coeffs, accum, load s0 with the value of delay[1] for SIMD store, move pointer to delay[0] */
		f12=f0*f4, f8=f8+f12, s0=dm(i0,m2);		
        
		/* final SIMD accum, read new sample into s10 */
		f8=f8+f12, s10=dm(i1,m1);			
        
		/* move PEy total into PEx register file */
		r12=s8;								
		
		/* last accum, read sample into s0 for first MAC of next sample, read 2 coeffs */
		f8=f8+f12, f4=pm(i8,m9);

		/* place new sample from s10 into f0 without corrupting s0, swaps f0 and s10 only */
		f0 <-> s10;
		
		/* write result to OUTPUT[i] */
main_fir:	pm(i9,m10)=f8;							

	/* Circular Buffer Disable, SIMD Mode Disable */
	bit clr MODE1 CBUFEN | PEYEN;
	
	/* restore registers from stack */
	r0 = gets(1);
	i9 = r0;
	
	r0 = gets(2);
	i8 = r0;
	
	r0 = gets(3);
	i1 = r0;
	
	r0 = gets(4);
	i0 = r0;
	
	/* modify stack pointer */
	alter(4);
	
	/* restore register block from stack */
	restore_reg;
		
_block_fir.END:	leaf_exit;

⌨️ 快捷键说明

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