0% found this document useful (0 votes)
322 views

2x4 and 3x8 Decoder Using MatLab

The document contains Matlab scripts to implement a 2x4 decoder and a 3x8 decoder using basic logic gates. For the 2x4 decoder, it takes the two input bits a1 and a0, defines the output bits d0 through d3 using logic operations on a1 and a0, and displays the decoder output. For the 3x8 decoder, it takes the three input bits a2, a1 and a0, defines the output bits d0 through d7 using logic operations on a2, a1 and a0, displays the decoder inputs and outputs.

Uploaded by

Manu Prakash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
322 views

2x4 and 3x8 Decoder Using MatLab

The document contains Matlab scripts to implement a 2x4 decoder and a 3x8 decoder using basic logic gates. For the 2x4 decoder, it takes the two input bits a1 and a0, defines the output bits d0 through d3 using logic operations on a1 and a0, and displays the decoder output. For the 3x8 decoder, it takes the three input bits a2, a1 and a0, defines the output bits d0 through d7 using logic operations on a2, a1 and a0, displays the decoder inputs and outputs.

Uploaded by

Manu Prakash
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

%% 2x4 Decoder using Logic Gates

%-----------------------------------------------%
% Following MatLab script implements
%JIIT %
% a 2x4 decoder with help of basic Logic Gates %
%-----------------------------------------------%
clc
close all
clear all;
a1=input('input MSB input of 2x4 decoder a1=');
a0=input('input LSB input of 2x4 decoder a0=');
d0=(~a0)&(~a1);
d1=(a0)&(~a1);
d2=(~a0)&(a1);
d3=(a0)&(a1);
result=[d3 d2 d1 d0];
sprintf('decoder output is \n%d \n%d \n%d \n%d',result)
%-----------------End of Script------------------%
3x8 Decoder
%% 3x8 Decoder using Logic Gates
%-----------------------------------------------%
% Following MatLab script implements
%JIIT%
% a 3x8 decoder with help of basic Logic Gates %
%-----------------------------------------------%
clc
close all
clear all;
a2=input('Enter MSB of 2x4 decoder a2=');
a1=input('Enter 2nd bit of 2x4 decoder a1=');
a0=input('Enter LSB of 2x4 decoder a0=');
d0=(~a0)&(~a1)&(~a2);
d1=(a0)&(~a1)&(~a2);
d2=(~a0)&(a1)&(~a2);
d3=(a0)&(a1)&(~a2);
d4=(~a0)&(~a1)&(a2);
d5=(a0)&(~a1)&(a2);
d6=(~a0)&(a1)&(a2);
d7=(a0)&(a1)&(a2);
clc
display('decoder input is');
[a2 a1 a0]'
display('decoder output is');
[d7 d6 d5 d4 d3 d2 d1 d0]'
%-----------------End of Script------------------%

You might also like