Sie sind auf Seite 1von 39

ECE603 UNIFIED ELECTRONICS LABORATORY LAB MANUAL

CONTENTS ECE603 Experiment no 1. 2. Name of the Experiments


To develop a program for computing DFT and IDFT in MATLAB. To develop a program for computing circular convolution. Using MATLAB

Tool Used MATLAB MATLAB

MATLAB 3.
To develop program for spectrum estimation using Welch method using MATLAB. To develop a program for computing CWT and DWT using MATLAB To develop a program for designing FIR filter in MATLAB

4. 5.

MATLAB MATLAB

To develop a program for designing

MATLAB

6. 7.

IIR filter in MATLAB


Static CMOS NAND, Static CMOS NOR and implement 4 to 1 Mux by NAND and NOR.

NC Sim

8.

Static CMOS EXNOR, static CMOS EXOR and implement Adders by universal gates.. More Layout Techniques on SDC Constraints applying on Half adder 4-bit serial adder Test bench for adders(NC SIM) Static CMOS NAND, Static CMOS NOR and implement 4 to 1 Mux by NAND and NOR

NC Sim

NC Sim

9. 10. 11 12

NC Sim RTL compiler RTL compiler

Static CMOS EXNOR, static CMOS EXOR and implement Adders by universal gates

EXPERIMENT -1 AIM: To develop a program for Computing DFT and IDFT in MATLAB REQUIREMENTS: MATLAB 7.5

Learning Objectives: To make the students familiar with concept of DFT and IDFT using
MATLAB. THEORY: The discrete Fourier transform (DFT) X[k] of a finite-length sequence x[n] can be easily computed in MATLAB using the function fft. There are two versions of this function. fft(x) computes the DFT X[k] of the sequence x[n] where the length of X[k] is the same as that of x[n]. fft(x,L) computes the L-point DFT of a sequence x[n] of lengthN where L N. IfL > N, x[n] is zero-padded with LN trailing zero-valued samples before the DFT is computed. The inverse discrete Fourier transform (IDFT) x[n] of a DFT sequence X[k] can likewise be computed using the function ifft, which also has two versions. PROGRAM CODE:
% Program to perform Discrete Fourier Transform clc;clear all; close all hidden; x=input('The given sequence is x(n): '); N=length(x); for k=1:N X(k)=0; for n=1:N X(k)=X(k)+x(n).*exp(-j.*2.*pi.*(n-1).*(k-1)./N); end end display('The DFT of the given sequence is:') X p=0:(N-1); stem(p,abs(X)),grid

Input Sequence:-

ALGORITHM: 1 Enter the input Sequence ,x having length=4 2 Set the range of k according to the length of x. 3 Computing DFT, store the value in X(k). 4 Plotting the DFT of given Sequence,store in X(k). RESULT:

20 18 16 14 12 10 8 6 4 2 0

0.5

1.5

2.5

Fig shows DFT of input sequence


% Program to perform Inverse Discrete Fourier Transform clc;clear all; close all hidden; x=input('The given sequence is x(n): '); N=length(x); for k=1:N X(k)=0; for n=1:N X(k)=X(k)+x(n).*exp(j.*2.*pi.*(n-1).*(k-1)./N); end end display('The DFT of the given sequence is:') X p=0:(N-1); stem(p,abs(X)),grid

Input Sequence:

ALGORITHM: 1 Enter the input Sequence, x having length=4 2 Set the range of k according to the length of x. 3 Computing IDFT, store the value in X(k). 4 Plotting the IDFT of given Sequence, store in X(k). RESULT:

10 9 8 7 6 5 4 3 2 1 0

0.5

1.5

2.5

Fig shows IDFT of input sequence Scope of Results: NA

EXPERIMENT -2 AIM: To develop a program for computing circular convolution. Using MATLAB. EQUIPMENTS: Software - MATLAB 7.5 Learning Objectives: To make the students familiar with concept of Circular convolution using MATLAB. THEORY: Circular convolution is another way of finding the convolution sum of two input signals. It resembles the linear convolution, except that the sample values of one of the input signals is folded and right shifted before the convolution sum is found. Also note that circular convolution could also be found by taking the DFT of the two input signals and finding the product of the two frequency domain signals. The Inverse DFT of the product would give the output of the signal in the time domain which is the circular convolution output. The two input signals could have been of varying sample lengths. But we take the DFT of higher point, which ever signals levels to. For eg. If one of the signal is of length 256 and the other spans 51 samples, then we could only take 256 point DFT. So the output of IDFT would be containing 256 samples instead of 306 samples, which follows N1+N2 1 where N1 & N2 are the lengths 256 and 51 respectively of the two inputs. Thus the output which should have been 306 samples long is fitted into 256 samples. The 256 points end up being a distorted version of the correct signal. This process is called circular convolution. PROGRAM:
%circular convolution program clc;clear all;close all; disp('circular convolution program'); x=input('enter i/p x(n):'); m=length(x); h=input('enter i/p sequence h(n)'); n=length(h); subplot(2,2,1), stem(x); title('i/p sequencce x(n)is:'); xlabel('---->n'); ylabel('---->x(n)');grid; subplot(2,2,2), stem(h); title('i/p sequencce h(n)is:'); xlabel('---->n'); ylabel('---->h(n)');grid; disp('circular convolution of x(n) & h(n) is y(n):'); if(m-n~=0) if(m>n) h=[h,zeros(1,m-n)]; n=m; end x=[x,zeros(1,n-m)]; m=n; end y=zeros(1,n); y(1)=0; a(1)=h(1);

for j=2:n a(j)=h(n-j+2); end %ciruclar conv for i=1:n y(1)=y(1)+x(i)*a(i); end for k=2:n y(k)=0; % circular shift for j=2:n x2(j)=a(j-1); end x2(1)=a(n); for i=1:n if(i<n+1) a(i)=x2(i); y(k)=y(k)+x(i)*a(i); end end end y subplot(2,2,[3,4]),stem(y); title('convolution of x(n) & h(n) is:'); xlabel('---->n'); ylabel('---->y(n)');grid;

RESULT:

Scope of Results: NA

EXPERIMENT -3 Aim: To develop program for spectrum estimation using Welch method using MATLAB EQUIPMENTS: MATLAB 7.5 Learning Objectives: To make the students familiar with concept of spectrum estimation using Welch method using MATLAB Theory: .
Program for Welch Method randn; fs = 1000; % Sampling frequency t = (0:0.3*fs)./fs; % 301 samples A = [2 8]; % Sinusoid amplitudes (row vector) f = [150;140]; % Sinusoid frequencies (column vector) xn = A*sin(2*pi*f*t) + 5*randn(size(t)); Hs = spectrum.periodogram('rectangular'); psd(Hs,xn,'Fs',fs,'NFFT',1024); >> Hs = spectrum.welch('rectangular',150,50); psd(Hs,xn,'Fs',fs,'NFFT',512);
Periodogram Power Spectral Density Estimate 10

Power/frequency (dB/Hz)

-10

-20

-30

-40

-50

-60

50

100

150

200 250 300 Frequency (Hz)

350

400

450

500

Welch Power Spectral Density Estimate 10 5 0


Power/frequency (dB/Hz)

-5 -10 -15 -20 -25 -30

50

100

150

200 250 300 Frequency (Hz)

350

400

450

500

EXPERIMENT -4 Aim: To develop a program for computing CWT and DWT using MATLAB EQUIPMENTS: MATLAB 7.5 Learning Objectives: To make the students familiar with concept computing CWT and DWT using MATLAB Theory: Program for CWT t=0:0.001:0.2; x=sin(2*pi*40*t); y=sin(2*pi*100*t); z=[x,y]; x(120:121)=0; subplot(2,1,1) plot(t,x) subplot(2,1,2) cw1 = cwt(x,1:5,'haar','3dplot'); colormap gray

Results:

DWT:

Program:
t=0:0.001:10; x=sin(5*pi*t); [Lo_D,Hi_D,] = wfilters('db2'); [cA,cD] = dwt(x,Lo_D,Hi_D); [cA1,cD1] = dwt(cA,Lo_D,Hi_D); [cA2,cD2] = dwt(cA1,Lo_D,Hi_D); [cA3,cD3] = dwt(cA2,Lo_D,Hi_D); subplot(4,1,1),plot(x),title 'Original signal'

subplot(4,1,2),plot(abs(cD),'r'),title 'Detailed coefficient 1' subplot(4,1,3),plot(abs(cD1),'g'),title 'Detailed coefficient 2' subplot(4,1,4),plot(abs(cD2)),title 'Detailed coefficient 3'

2-Dimentional DWT

Scope of Results: NA

EXPERIMENT -5 AIM: To To develop a program for designing FIR filter in MATLAB EQUIPMENTS: MATLAB Software Learning Objectives: To make the students familiar with concept of designing FIR filter in MATLAB

THEORY: A Finite Impulse Response (FIR) filter is a discrete linear time-invariant system whose output is based on the weighted summation of a finite number of past inputs. An FIR transversal filter structure can be obtained directly from the equation for discrete-time convolution.

In this equation, x(k) and y(n) represent the input to and output from the filter at time n. h(n-k) is the transversal filter coefficients at time n. These coefficients are generated by using FDS (Filter Design Software or Digital filter design package). FIR filter is a finite impulse response filter. Order of the filter should be specified. Infinite response is truncated to get finite impulse response. placing a window of finite length does this. Types of windows available are Rectangular, Barlett, Hamming, Hanning, Blackmann window etc. This FIR filter is an all zero filter.

PROGRAM: %fir filt design window techniques clc; clear all; close all; rp=input('enter passband ripple'); rs=input('enter the stopband ripple'); fp=input('enter passband freq'); fs=input('enter stopband freq'); f=input('enter sampling freq '); wp=2*fp/f; ws=2*fs/f; num=-20*log10(sqrt(rp*rs))-13; dem=14.6*(fs-fp)/f; n=ceil(num/dem); n1=n+1; if(rem(n,2)~=0)

n1=n; n=n-1; end c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n '); if(c==1) y=rectwin(n1); disp('Rectangular window filter response'); end if (c==2) y=triang(n1); disp('Triangular window filter response'); end if(c==3) y=kaiser(n1); disp('kaiser window filter response'); end %LPF b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,1);plot(o/pi,m); title('LPF'); ylabel('Gain in dB-->'); xlabel('(a) Normalized frequency-->'); %HPF b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,2);plot(o/pi,m); title('HPF'); ylabel('Gain in dB-->'); xlabel('(b) Normalized frequency-->'); %BPF wn=[wp ws]; b=fir1(n,wn,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,3);plot(o/pi,m); title('BPF'); ylabel('Gain in dB-->'); xlabel('(c) Normalized frequency-->'); %BSF b=fir1(n,wn,'stop',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(2,2,4);plot(o/pi,m); title('BSF'); ylabel('Gain in dB-->'); xlabel('(d) Normalized frequency-->')

RESULTS:

Scope of Results: NA

EXPERIMENT -6

AIM: To develop a program for designing IIR filter in MATLAB EQUIPMENTS: MATLAB Learning Objectives: To make the students familiar with concept of IIR filter using MATLAB THEORY: The IIR filter can realize both the poles and zeroes of a system because it has a rational transfer function, described by polynomials in z in both the numerator and the denominator:

The difference equation for such a system is described by the following:

M and N are order of the two polynomials. bk and ak are the filter coefficients. These filter coefficients are generated using FDS (Filter Design software or Digital Filter design package). IIR filters can be expanded as infinite impulse response filters. In designing IIR filters, cutoff frequencies of the filters should be mentioned. The order of the filter can be estimated using butter worth polynomial. Thats why the filters are named as butter worth filters. Filter coefficients can be found and the response can be plotted. PROGRAM: % IIR filters LPF & HPF clc;clear all;close all; disp('enter the IIR filter design specifications'); rp=input('enter the passband ripple'); rs=input('enter the stopband ripple'); wp=input('enter the passband freq'); ws=input('enter the stopband freq'); fs=input('enter the sampling freq'); w1=2*wp/fs;w2=2*ws/fs; [n,wn]=buttord(w1,w2,rp,rs,'s'); c=input('enter choice of filter 1. LPF 2. HPF \n '); if(c==1) disp('Frequency response of IIR LPF is:'); [b,a]=butter(n,wn,'low','s'); end if(c==2) disp('Frequency response of IIR HPF is:');

[b,a]=butter(n,wn,'high','s'); end w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); an=angle(h); figure,subplot(2,1,1);plot(om/pi,m); title('magnitude response of IIR filter is:'); xlabel('(a) Normalized freq. -->'); ylabel('Gain in dB-->'); subplot(2,1,2);plot(om/pi,an); title('phase response of IIR filter is:'); xlabel('(b) Normalized freq. -->'); ylabel('Phase in radians-->'); RESULTS:

Scope of Results: NA

EXPERIMENT -7 Aim: To design a CMOS Nand Gate using verilog HDL and Simulate using NC-SIM Equipment: CADENCE Software Learning Objectives: To make the students familiar with concept of Nand Gate using verilog HDL and Simulate using NC-SIM Program: module nandg(a,b,c); input a,b; output c; nand A(c,a,b); endmodule //u can even design using assign c= !(a&b);

Testbench module nandtb(); reg a,b; wire c; nandg N(a,b,c); initial begin a=0;b=0; #2 a=1;b=0; #2 a=0;b=1; #2 a=1;b=1; #2 $stop; end endmodule

ii) CMOS NOR module norg(a,b,c); input a,b; output c; nor A(c,a,b); endmodule //u can even design using assign c= !(a|b);

Testbench module nortb(); reg a,b; wire c; norg N(a,b,c); initial begin a=0;b=0; #2 a=1;b=0; #2 a=0;b=1; #2 a=1;b=1; #2 $stop; end endmodule
Scope of Results: NA

Experiment- 8 Aim: Static CMOS EXNOR, static CMOS EXOR and implement Adders by
universal gates.(NC SIM)
Equipment: CADENCE Software Learning Objectives: To make the students familiar with concept of Static CMOS EXNOR,

static CMOS EXOR and implement Adders by universal gates.(NC SIM) Theory:
module xorg(a,b,c); input a,b; output c; xor A(c,a,b); endmodule Testbench module xortb(); reg a,b; wire c; xorg N(a,b,c); initial begin a=0;b=0; #2 a=1;b=0; #2 a=0;b=1; #2 a=1;b=1; #2 $stop; end //u can even design using assign c= (a^b);

endmodule 2) CMOS XNOR module xnorg(a,b,c); input a,b; output c; xnor A(c,a,b); endmodule Testbench module xnortb(); reg a,b; wire c; xnorg N(a,b,c); initial begin a=0;b=0; #2 a=1;b=0; #2 a=0;b=1; #2 a=1;b=1; #2 $stop; end endmodule 3) Implement xor and xnor using NAND and nor i) xor gate using nand gate //u can even design using assign c= !(a~^b);

module xoruniv(A,B,out);

input A,B; wire i1,i2,i3; nand n1(i1,A,B); nand n2(i2,A,i1); nand n3(i3,B,i); nand n4(out,i2,i3); endmodule

xnor gate using nand gate

Xnor using Nor gate:

Scope of Results: NA

Experiment- 10
AIM: Design 4-bit serial adder Test bench for adders(NC SIM)
Equipment: CADENCE Software Learning Objectives: To make the students familiar with concept of 4-bit serial adder Test bench for adders(NC SIM)

Theory:

Halfadder :
module halfadd(a,b,sum,out); input a,b; output sum,carry; assign sum=a^b; assign carry=ab; endmodule

Fulladder :
module fulladd(a,b,c,sum,out); input a,b,c; output sum,carry; assign sum=a^b^c; assign carry=ab + bc + ca; endmodule

SDC constraints: Add some timing constraints, delay constraints in sequential design and analyse the Waveforms.
Scope of Results: NA

Experiment- 11
RTL COMPILER

Aim: To synthesize CMOS NAND and CMOS NOR using Cadence-RTLcompiler Equipment: CADENCE Software, RC compiler Learning Objectives: To make the students familiar with concept of 4-bit serial adder Test bench for adders (NC SIM) Procedure: 1.Type the commands as shown in figure to enter into RC prompt

2.

step 3: Enter the commands as shown in figures to synthesize the design 1. Set library path

2.Set the target library

3.Set the RTL path

4.Read HDL Files

5.Elaborate

6.Synthesize

Analyze the report using following commands 1. Area reports

Gate reports:

power report :

Timing Report

Net report:

Power report:

summary report:

same to be followed all the Experiments only the command read_hdl module name will be vary for all the experiments

Scope of Results: NA

APPENDIX-1 STEPS TO DO NCSIM: 1.Type the following commands in openterminalWindow

2. Open NCLAUNCH window.

3. SET design directory. File--Set design directory

4.

5. create cds.lib

6.Create design file ------- Fileedit new file

7.vi editor will open

8.Design the main module in VI editor

9. Main module has designed

10. create another vi editor for Testbench

10.New VI editor will open

12) Testbench has created.

13.Compilation for design and test bench module toolss-verilog compiler

15.elaboration(toolselaborator)

16.write design unit name.

17.Go to snapshot.

toolssimulator 18.simvision will open

19.

20.output waveform obtained

APPENDIX-2 Basic Linux commands used in synthesis 1.cd folder name to enter into folder 2.cd .. comeout of current folders 3.ls to list the file

4.cd to come out of current path to openterminal 5.source cshrc1 to source cadence tools 6.csh to enter into c shell 7.vi filename to create a text file 8. :wq to save and quit text file

9.:q to quit text file APPENDIX-3 Creating Testbench:

1. 2. 3.

input should be declared in reg output should be declared in wire module instantiation of design module to be done in test bench and parameter list and order of that should match with design module.

RTL COMPILER COMMANDS

set_attribute lib_search_path path ../ library set_attribute library {slow_highvt.lib slow_normal.lib} set_attribute hdl_search_path path read_hdl filename elaborate modulename synthesize to_mapped ../rtl

Das könnte Ihnen auch gefallen