FPGA数字信号处理四Quartus FIR IP核实现


调用Quartus的FIR Compiler IP核完成FIR滤波,含testbench与仿真,仿真结果优秀;具体说明可参考本人博客。CSDN博客搜索:FPGADesigner
资源截图
代码片段和文件信息
%                                                                                                                                       
%THIS IS A WIZARD GENERATED FILE. DO NOT EDIT THIS FILE!                                                                                
%                                                                                                                                       
%---------------------------------------------------------------------------------------------------------                              
%This is a filter withfixed coefficients 
%This Model Only Support Single Channel Input Data. 
%Please input:                                                                                                                          
%data vector:  stimulation(1:n)                                                                                                 
%                                                                                                                                       
%    This Model Only Support FIR_WIDTH to 51 Bits
%                                                                                                                                       
%FILTER PARAMETER                                                                                                                       
%Input Data Type: Signed
%Input Data Width: 12
%FIR Width (Full Calculation Width Before Output Width Adjust) :   28
%-----------------------------------------------------------------------------------------------------------

%MegaWizard Scaled Coefficient Values
function  output = fir_mlab_mat (stimulation output)
coef_matrix=[-2 14 46 -117 -262 589 2047 2047 589 -262 -117 46 14 -2 ];
INTER_FACTOR  = 1;
DECI_FACTOR  = 1; 
MSB_RM  = 0;
MSB_TYPE  = 0;
LSB_RM  = 0;
LSB_TYPE  = 0;
FIR_WIDTH  = 28;
OUT_WIDTH  = FIR_WIDTH - MSB_RM - LSB_RM ;
DATA_WIDTH = 12;
            
data_type= 1;

        % check size of inputs.
        [DXDY] = size(stimulation);
        [CXCY] = size(coef_matrix);
        if (CX ~= DY * INTER_FACTOR)
        fprintf(‘WARNING : coef_matrix size and input data size is not match
‘);
        end
        
        %fill coef_matrix to length of data with the latest coef set
        if (CX < DY * INTER_FACTOR)
            for i= CX +1:DY * INTER_FACTOR
                coef_matrix(i:) = coef_matrix(CX:);
            end
        end

        %check if input is integer
        int_sti=round(stimulation);
    T = (int_sti ~= stimulation);
    if (max(T)~=0)
        fprintf(‘WARNING : Integer Input Expected: Rounding Fractional Input to Nearest Integer...
‘);
    end
    
    %Input overflow check
    switch  data_type
    case 1
        %set max/min for signed
        maxdat = 2^(DATA_WIDTH-1)-1;
        mindat = -maxdat-1;
    case 2
        %set max/min for unsigned
        maxdat = 2^DATA_WIDTH-1

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)