Aim: - Tool Used: Theory:: Experiment-5
Aim: - Tool Used: Theory:: Experiment-5
Aim:
To write a hardware description of 4 X 1 multiplexer using data flow and behavioural
modelling.
Theory:
The multiplexer, shortened to “MUX” or “MPX”, is a combinational logic circuit designed to
switch one of several input lines through to a single common output line by the application of
a control signal. Multiplexers operate like very fast acting multiple position rotary switches
connecting or controlling multiple input lines called “channels” one at a time to the output.
S1 S0 Output
0 0 I0
0 1 I1
1 0 I2
1 1 I3
module mux4(
input s0,
input s1,
input i0,
input i1,
input i2,
input i3,
output y
);
assign y = ((~s0)&(~s1)& i0)|((s0)&(~s1)& i1)|((~s0)&(s1)& i2)|((s0)&(s1)& i3);
endmodule
2.Behavioral Modelling
module mux4(
input s0,
input s1,
input i0,
input i1,
input i2,
input i3,
output reg y
);
always @(s1,s0,y)
begin
case({s1,s0})
2'b00:y=i0;
2'b01:y=i1;
2'b10:y=i2;
2'b11:y=i3;
endcase
end
endmodule
3.Test Bench
module muxtest;
reg s0;
reg s1;
reg i0;
reg i1;
reg i2;
reg i3;
wire y;
mux4 uut (
.s0(s0),
.s1(s1),
.i0(i0),
.i1(i1),
.i2(i2),
.i3(i3),
.y(y)
);
initial begin
i0 = 0;
i1 = 1;
i2 = 0;
i3 = 1;
s1=0; s0=0; #100;
s1=0; s0=1; #100;
s1=1; s0=0; #100;
s1=1; s0=1; #100;
end
endmodule
RTLs:
Waveforms:
Result: