Write a code in C / Verilog to implement a basic FIR filter.

Need an answer.



Write a code in C / Verilog to implement a basic FIR filter. Need an answer...

Answer / mk

%program for FIR filters

disp('choose the window from the list');
ch=menu('types of
windows','bartlett','blackman','hamming','hanning','kaiser',
'rectangular');
rp=input('enter the passband ripple in db');
rs=input('enter the stopband ripple in db');
wsample=input('enter sampling frequency in hertz');
wp=input('enter the passband frequency in hertz');
ws=input('enter the stopband frequency in hertz');
wp=2*wp/wsample; ws=2*ws/wsample;
p=20*log10(sqrt(rp*rs))-13;
q=14.6*(ws-wp)/wsample;
N=1+floor(p/q);
N1=N;
if(rem(N,2)==0)
N1=N+1;
else
N=N-1;
end
switch ch
case 1
y=bartlett(N1);
case 2
y=blackman(N1);
case 3
y=hamming(N1);
case 4
y=hanning(N1);
case 5
beta=input('enter beta for kaiser window');
y=kaiser(N1,beta);
case 6
y=boxcar(N1);
otherwise
disp('enter proper window number');
end
disp('select the type of filter from the list');
type=menu('types of
filters','lowpass','highpass','bandpass','bandstop');
switch type
case 1
b=fir1(N,wp,'low',y);
case 2
b=fir1(N,wp,'high',y);
case 3
b=fir1(N,[wp ws],'bandpass',y);
case 4
b=fir1(N,[wp ws],'stop',y);
otherwise
disp('enter type number properly');
end
[h,w]=freqz(b,1,512);
magn=20*log10(abs(h));
phase=(180/pi)*unwrap(angle(h));
w=(w*wsample)/(2*pi);
subplot(2,1,1); plot(w,magn),grid on;title('magnitude
plot'); subplot(2,1,2); plot(w,phase),grid on;title('phase
plot');

Is This Answer Correct ?    8 Yes 17 No

Post New Answer

More DSP Interview Questions

What is an anti aliasing filter? Why is it required?

6 Answers   Honeywell,


Explain the different types of AM, FM along with the Diagrams on the paper.

0 Answers   Huawei,


What are recursive and non recursive systems? give examples?

0 Answers  


What is the difference between ProtoPlus and ProtoPlus Lite ?

1 Answers  


What is sectioned convolution?

0 Answers  






Write a code in C / Verilog to implement a basic FIR filter. Need an answer.

1 Answers  


Why is digital communication better than analogue communication?

0 Answers   Aricent,


How will you classify the discrete time signals?

0 Answers  


Define discrete time

0 Answers  


What do you mean by ionospheric bending?

0 Answers   Ericsson,


State difference between analog and digital signals.

0 Answers   HPCL, Hughes Systique Corporation,


im using I2C communication, in that first im sending address of thesalve and then data then after i want to read the data which i was sent recently, in that case before im reading is there any need to send a stop bit before read.

1 Answers  


Categories