Experiment 2: Inputs Output
Experiment 2: Inputs Output
AIM: To write the expression for Multiplexer (MUX) & De-multiplexer (DEMUX) in gate level modeling
with NCSIM software.
THEORY:
MULTIPLEXER (MUX)
In electronics, a multiplexer (or mux) is a device that selects one of several analog or digital input signals
and forwards the selected input into a single line. A multiplexer of 2n inputs has n select lines, which
are used to select which input line to send to the output.
Truth table
INPUTS OUTPUT
S0 S1 Y
0 0 I0
0 1 I1
1 0 I2
1 1 I3
LOGIC DIAGRAM
DEMULTIPLEXER (DEMUX)
A demultiplexer (or demux) is a device that takes a single input line and routes it to one of
several digital output lines. Ademultiplexer of 2n outputs has n select lines, which are used to
select which output line to send the input. A demultiplexer is also called a data distributor.
Truth table
LOGIC DIAGRAM
RESULT:
module mux4(a,b,c,d,s0,s1,y);
input a,b,c,d,s0,s1;
output y;
wire w1,w2,w3,w4,w5,w6;
not x1(w1,s0);
not x2(w2,s1);
and x3(w3,w1,w2,a);
and x4(w4,w1,s1,b);
and x5(w5,s0,w2,c);
and x6(w6,s0,s1,d);
or x7(y,w3,w4,w5,w6);
endmodule
module muxtest();
reg a,b,c,d,s0,s1;
wire y;
mux4 test1(a,b,c,d,s0,s1,y);
initial
begin
#2 $stop;
end
endmodule
module demux4(a,b,c,d,s0,s1,e);
input e,s0,s1;
output a,b,c,d;
wire w1,w2;
not x1(w1,s0);
not x2(w2,s1);
and x3(a,w1,w2,e);
and x3(b,w1,s1,e);
and x4(c,s0,w2,e);
and x5(d,s0,s1,e);
endmodule
module demuxtest();
reg e,s0,s1;
wire a,b,c,d;
demuxtest test1(a,b,c,d,s0,s1,e);
initial
begin
e=1; s0=s1=0;
#2 e=1; s0=s1=1;
#2 $stop
end
endmodule
Waveform: