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

📄 firdecim_001.m

📁 This lab exercise will introduce you to the AccelWare IP generators. AccelWare is a library of over
💻 M
字号:
%       AccelDSP 8.1.1 build 690 Production, compiled Apr 26 2006 
% 
%    THIS IS UNPUBLISHED, LICENSED SOFTWARE THAT IS THE CONFIDENTIAL 
%        AND PROPRIETARY PROPERTY OF XILINX OR ITS LICENSORS 
% 
%     Copyright(c) Xilinx, Inc., 2000-2006, All Rights Reserved. 
%     Reproduction or reuse, in any form, without the explicit written 
%     consent of Xilinx, Inc., is strictly prohibited. 

function [SigOut, DataValid] = firdecim_002( SigIn )

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  AccelWare Function: FIRDecim                                                
%  AccelChip Version: 2005.4.2 build 594 Production                            
%  AccelWare Version: 2005.4.2 build 594 Production                            
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  branches: Number of sub-filter structures used to implement polyphase filter.
%		value used "auto"
%  cbits: Wordlength of the filter coefficients
%		value used "16"
%  coefficient_file: 
%		value used "C:\hill\training\new_training_rev2\lab_data\05_UsingAccelWare\part_a\solution\b.txt"
%  form: Type of structure for filter implementation.
%		value used "Direct - Resource Shared"
%  ibits: Wordlength of the input signal
%		value used "16"
%  ifbits: Fractional wordlength of the input signal
%		value used "13"
%  input_structure: Input structure with 1(serial) or m(Parallel) samples presented per invocation of filter.
%		value used "Serial"
%  m_val: Decimation factor. Must be integer sub-multiple of the number of filter coefficients.
%		value used "2"
%  number_of_channels: Number of channels to support with implementation
%		value used "1"
%  obits: Output and filter stages wordlength.
%		value used "auto"
%  pipelining: Pipelined adder tree for higher throughput.
%		value used "no"
%  programmable_coefficients: Include structure for progammable coefficients
%		value used "no"
%  storage_mapping: Storage type for filter coefficients
%		value used "Register Mapped"
%  trunc: Number of LSB bits to drop after multiplies
%		value used "8"
%

% mechanization quantizers
qin = quantizer( 'fixed', 'floor', 'wrap', [ 16 13 ] );
qinfract = quantizer( 'fixed', 'floor', 'wrap', [ 16 15 ] );
qcoef = quantizer( 'fixed', 'floor', 'wrap', [ 16 15 ] );
qmult = quantizer( 'fixed', 'floor', 'wrap', [ 24 22 ] );
qaccum = quantizer( 'fixed', 'floor', 'wrap', [ 27 22 ] );
qout = quantizer( 'fixed', 'floor', 'wrap', [ 27 22 ] );

SigInFract = quantize(qinfract, SigIn/2^(2));

% define delay line
persistent DelayLine;
if (isempty(DelayLine));DelayLine = zeros(2,16);end

DelayIdxTbl = [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 ];

% define filter coefficients
FIRCoefsB1 = quantize(qcoef, [-0.00726318359375 -0.00634765625 0.0333251953125 0.02703857421875 -0.118927001953125 -0.089202880859375 0.444580078125 0.97491455078125 0.76983642578125 0.124114990234375 -0.159271240234375 -0.036712646484375 0.047210693359375 0.009490966796875 -0.01025390625 -0.002532958984375 ]);
FIRCoefsB2 = quantize(qcoef, [-0.002532958984375 -0.01025390625 0.009490966796875 0.047210693359375 -0.036712646484375 -0.159271240234375 0.124114990234375 0.76983642578125 0.97491455078125 0.444580078125 -0.089202880859375 -0.118927001953125 0.02703857421875 0.0333251953125 -0.00634765625 -0.00726318359375 ]);


% initializing variables
qoneb = quantizer( 'ufixed', 'floor', 'wrap', [ 1 0 ] );
qcount = quantizer( 'ufixed', 'floor', 'wrap', [ 2 0 ] );
qchancount = quantizer( 'ufixed', 'floor', 'wrap', [ 1 0 ] );
persistent DecimCounter SigInVecFract ChanCounter DataReady_t
if (isempty(DecimCounter));DecimCounter = 1;end
if (isempty(ChanCounter));ChanCounter = 0;end
if (isempty(DataReady_t));DataReady_t = 0;end
if (isempty(SigInVecFract));SigInVecFract = zeros(1,1);end

if (ChanCounter == 0)
   ChanCounter=quantize(qchancount,0);
   if (DecimCounter == 1)
      DataReady_t = quantize(qoneb,1);
      DecimCounter=quantize(qcount,0);
   else
      DataReady_t =quantize(qoneb,0);
      DecimCounter=quantize(qcount,DecimCounter+1);
   end
else
   ChanCounter = quantize(qchancount,ChanCounter+1);
end

if DataReady_t == 1  
   
   % valid data indication
   DataValid = 1;
   chan = 1;
   
   % convolution loop
   chan_idx = 1;
   TempReg = zeros(2,1);
   for (ii = 1:16)
      TempReg(1) = quantize(qaccum,TempReg(1) + ((DelayLine(1,chan_idx)*FIRCoefsB1(ii))));
      TempReg(2) = quantize(qaccum,TempReg(2) + ((DelayLine(2,chan_idx)*FIRCoefsB2(ii))));
      chan_idx = DelayIdxTbl(ii);
   end
   
   % adder tree
   TempReg1_1 = quantize(qaccum, TempReg(1) + TempReg(2));
   
   % output
   SigOut(chan) = quantize(qout,TempReg1_1*2^(0) );
   
   % delay line update
   DelayLine=quantize(qinfract,[ [[ SigInVecFract(1) ]; [ SigInFract ] ] DelayLine(:,1:15) ]);
   
else
   SigOut = 0;
   DataValid = 0;
end
SigInVecFract = quantize(qinfract, [SigInFract]);

⌨️ 快捷键说明

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