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

📄 mri_filter_model.m

📁 This is GMS down upper converter and down converter in simulink. you may understand the structure in
💻 M
字号:
% %  $Id: mri_filter_model.m,v 1.1.2.3 2008/06/12 16:12:55 igork Exp $% %  DISCLAIMER OF LIABILITY%  %  This text/file contains proprietary, confidential%  information of Xilinx, Inc., is distributed under license%  from Xilinx, Inc., and may be used, copied and/or%  disclosed only pursuant to the terms of a valid license%  agreement with Xilinx, Inc. Xilinx hereby grants you a %  license to use this text/file solely for design, simulation, %  implementation and creation of design files limited %  to Xilinx devices or technologies. Use with non-Xilinx %  devices or technologies is expressly prohibited and %  immediately terminates your license unless covered by%  a separate agreement.% %  Xilinx is providing this design, code, or information %  "as-is" solely for use in developing programs and %  solutions for Xilinx devices, with no obligation on the %  part of Xilinx to provide support. By providing this design, %  code, or information as one possible implementation of %  this feature, application or standard, Xilinx is making no %  representation that this implementation is free from any %  claims of infringement. You are responsible for %  obtaining any rights you may require for your implementation. %  Xilinx expressly disclaims any warranty whatsoever with %  respect to the adequacy of the implementation, including %  but not limited to any warranties or representations that this%  implementation is free from claims of infringement, implied %  warranties of merchantability or fitness for a particular %  purpose.% %  Xilinx products are not intended for use in life support%  appliances, devices, or systems. Use in such applications is%  expressly prohibited.% %  Any modifications that are made to the Source Code are %  done at the user抯 sole risk and will be unsupported.% % %  Copyright (c) 2008 Xilinx, Inc. All rights reserved.% %  This copyright and support notice must be retained as part %  of this text at all times. %%  Purpose: This file function generate CIC and CFIR filters %  using MATLAB built-in filter generator%-------------------------------------------------------------%%function [ hcic, hcfir] = mri_filter_model(...    flarmor, fwidth, ...    fclk, fs_cic,m_cic,...    use_cfir,fs_cfir,m_cfir,...    channel, ast, ShowPlots)%% Filter design parametersfpass = 1.2*fwidth;         % Upper frequency limit of MRI bandapass = 0.01;               % Passband ripple (dB)%% Create CICast_cic  = ast;             % Stopband attenuation of CIC first lobedd = 1;                     % Differential delay of CIC - 1 or 2hcic = design(fdesign.decimator(m_cic,'cic',dd,fpass,ast_cic,fs_cic));set(hcic, 'Arithmetic','fixed');info(hcic)if ShowPlots>=3    fvtool(cascade(hcic,dfilt.scalar(1/(gain(hcic)))),'Fs',[fs_cic]);    title(sprintf('CIC Magnitude Response (dB), R=%d',m_cic));end%% Create CIC compensator (CFIR)% Determine the available taps using the selected number of MAC unitscfir_os = (fclk/fs_cfir)/channel;% make sure that at least 32 taps are available, even if it means more than% one DSP48 to be usedtaps_cfir = max((cfir_os*2),64); % There is no need in more than 128 taps, even if there are available% cycles.taps_cfir = min(taps_cfir, 128);n_cfir = taps_cfir-1;macs = max(1,cfir_os/(2*taps_cfir));display(sprintf('CFIR tap count is %d, using %d MACs',taps_cfir,macs));% Set stop-band attenuation of Compensation FIR; ast_cfir = ast;  for i=1:4    % Allow built-in Matlab function to generate the CIC compensation response    % Specification formats    % fpass,fstop,apass,ast_cfir, ...              % Too loose, not tied to max order    % 'n,fp,ap,ast',ord,fpass,apass,ast_cfir, ...  % Better for fixed order    if m_cfir>1        hcfir(i) = design( ...            fdesign.decimator(m_cfir,'ciccomp', ...            hcic.differentialdelay, ...            hcic.numberofsections, ...            'n,fp,ap,ast',floor(n_cfir),fpass,apass,ast_cfir, ...            fs_cfir ));    else        hcfir(i) = design( ...            fdesign.ciccomp( ...            hcic.differentialdelay, ...            hcic.numberofsections, ...            'n,fp,ap,ast',n_cfir,fpass,apass,ast_cfir, ...            fs_cfir ));    end    % Quantize filter coefficients    set(hcfir(i),...        'Arithmetic','fixed',...        'CoeffWordLength',18,...        'FilterInternals','SpecifyPrecision','RoundMode','floor');    if ShowPlots>=3        fvtool(hcfir(i),'Fs',[ fs_cfir ])        title(sprintf('CFIR Magnitude Response (dB) with N=%d, Ast=%d',n_cfir,ast_cfir));    end    % Next loop adjustments    ast_cfir=ast_cfir+10;end% Display the loop results in an overlayif ShowPlots>=4    fvtool(hcfir,'Fs',[ fs_cfir ],'ShowReference','off');    title('Overlay of CFIR Magnitude Responses (dB)');end% Choose an option from the loop, cascade and analyze response (including% passband zoom)hcfir = hcfir(3);if ShowPlots>=3    fvtool(cascade(hcic,dfilt.scalar(1/(gain(hcic))),hcfir),'Fs',[ fs_cic ]);    axis([0 1.5 -200 +10]);    title('CFIR-CIC Cascaded Magnitude Response (dB)');    fvtool(cascade(hcic,dfilt.scalar(1/(gain(hcic)))),...           hcfir,...           cascade(hcic,dfilt.scalar(1/(gain(hcic))),hcfir),...           'Fs',[ fs_cic fs_cfir fs_cic ],...           'Legend','off',...           'ShowReference','off');    axis([0 0.12 -0.8 +0.8]);   % Focus in on passband    legend('CIC','CFIR','CIC-CFIR Cascade');    title('Passband Zoom Overlay of CIC, CFIR and cascaded CIC-CFIR Magnitude Responses (dB)');end%% Filter cascade and overlay visualizationfull_chain = cascade(hcic,dfilt.scalar(1/(gain(hcic))),hcfir);if ShowPlots>=2    fvtool(full_chain,'Fs',[fs_cic]); axis([0 2 -200 10]);    title('Final Cascaded Magnitude Response (dB)')    fvtool(cascade(hcic,dfilt.scalar(1/(gain(hcic)))),...           hcfir,...           full_chain,...           'Fs',[fs_cic fs_cfir fs_cic],...           'Legend','off',...           'ShowReference','off');    axis([0 2 -200 10]);    legend off; legend('CIC','CFIR', 'Full Cascade');    title('Final Overlaid Magnitude Responses (dB)')end

⌨️ 快捷键说明

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