2x4 and 3x8 decoder using matlab

2
%% 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);

Upload: manu-prakash

Post on 17-Aug-2015

244 views

Category:

Documents


9 download

DESCRIPTION

Binary to Decimal Decoder

TRANSCRIPT

%% 2x4 Decoder using Logic Gates%-----------------------------------------------%%Following MatLab script implements %JIIT %%a 2x4 decoder with help of basic Logic Gates %%-----------------------------------------------%clcclose allclear alla!"inp#t$%inp#t M&' inp#t of 2x4 decoder a!"%(a)"inp#t$%inp#t L&' inp#t of 2x4 decoder a)"%(d)"$*a)(+$*a!(d!"$a)(+$*a!(d2"$*a)(+$a!(d,"$a)(+$a!(res#lt"-d, d2 d! d).sprintf$%decoder o#tp#t is /n%d /n%d /n%d /n%d%0res#lt(%-----------------1nd of &cript------------------%3x8 Decoder%% ,x2 3ecoder #sing Logic Gates%-----------------------------------------------%%Following MatLab script implements%JIIT%%a ,x2 decoder with help of basic Logic Gates %%-----------------------------------------------%clcclose allclear alla2"inp#t$%1nter M&' of 2x4 decoder a2"%(a!"inp#t$%1nter 2nd bit of 2x4 decoder a!"%(a)"inp#t$%1nter L&' of 2x4 decoder a)"%(d)"$*a)(+$*a!(+$*a2(d!"$a)(+$*a!(+$*a2(d2"$*a)(+$a!(+$*a2(d,"$a)(+$a!(+$*a2(d4"$*a)(+$*a!(+$a2(d4"$a)(+$*a!(+$a2(d5"$*a)(+$a!(+$a2(d6"$a)(+$a!(+$a2(clcdispla7$%decoder inp#t is%(-a2 a! a).%displa7$%decoder o#tp#t is%(-d6 d5 d4 d4 d, d2 d! d).%%-----------------1nd of &cript------------------%