www.gusucode.com > hdlverifier 案例代码 matlab源码程序 > hdlfilter/GenerateTestBenchStimulusForFIRFilterExample.m

    %% Generate Test Bench Stimulus for FIR Filter
% Design a lowpass filter and construct a direct-form FIR filter System object(TM),
% Hd.
filtdes = fdesign.lowpass('N,Fc,Ap,Ast',30,0.4,0.05,0.03,'linear');
fir_lp = design(filtdes,'filterstructure','dffir','Systemobject',true);
%%
% Generate test bench input data. The call to |generatetbstimulus| generates
% ramp and chirp stimuli and returns the results. Specify the fixed-point 
% input data type as a |numerictype| object.
rc_stim = generatetbstimulus(fir_lp,'InputDataType',numerictype(1,12,10),'TestBenchStimulus',{'ramp','chirp'}); 
%%
% Apply the quantized filter to the data and plot the results. The call to
% the |step| function computes the filtered response to the input stimulus.
% The input data for the step function must be a column-vector to indicate 
% samples over time. A row-vector would represent independent data channels. 
plot(step(fir_lp,rc_stim'))