Академический Документы
Профессиональный Документы
Культура Документы
EXPERIMENT: 4(a)
AIM: Implement 4:1 & 8:1 Mux using data and Behavioral modeling.
SOFTWARE: Xilinx
4x1 mux
Using data flow modeling:
`timescale 1ns / 1ps
module mux4(
input A0,
input A1,
input A2,
input A3,
input S0,
input S1,
output OUT
);
assign OUT= (~S1&~S0&A0)| (~S1&S0&A1)|(S1&~S0&A2)|(S1&S0&A3);
endmodule
RTL:
4:1 mux Using Behavioral modeling.
`timescale 1ns / 1ps module
mux4x1(s,inp,out);
input[0:1] s;
input[0:3] inp;
output íeg out;
always@(*)
begin
case({s[1],s[0]})
2'b00: begin
out=inp[0];
end
2'b01: begin
out=inp[1];
end
2'b10: begin
out=inp[2];
end
2'b11: begin
out=inp[3];
end
default: begin
out=1'b0;
end
endcase end
endmodule
RľL:
4:1mux Simulation :
`timescale 1ns / 1ps
module muxg4tb( );
reg s1,s2,A0,A1,A2,A3;
wire out;
mux4 uut(s1,s2,A0,A1,A2,A3,out);
initial
begin
A0=1'b0;
A1=1'b0;
A2=1'b0;
A3=1'b0;
s1=1'b0;
s2=1'b0;
#100 $finish ;
end
always #1 s1=~s1;
always #2 s2=~s2;
always #3 A0=~A0;
always #4 A1=~A1;
always #5 A2=~A2;
always #6 A3=~A3;
always @ (A0 or A1 or A2 or A3 or s1 or s2)
$monitor ("At time=%t, Output=%d",$time,out);
endmodule
WAVEFORM:
8:1mux
Using data flow
`timescale 1ns / 1ps
module mux8(
input A0,
input A1,
input A2,
input A3,
input A4,
input A5,
input A6,
input A7,
input S0,
input S1,
input S2,
output OUT
);
assign OUT=(~S2 &~S1 &~S0 &A0)|
(~S2 &~S1 &~S0 &A0)|
(~S2 &~S1 &S0 &A1)|
(~S2 &S1 &~S0 &A2)|
(~S2 &S1 &S0 &A3)|
(S2 &~S1 &~S0 &A4)|
(S2 &~S1 &S0 &A5)|
(S2 &S1 &~S0 &A6)|
(S2 &S1 &S0 &A7);
Endmodule
RTL:
module mux8(
input D0,
input D1,
input D2,
input D3,
input D4,
input D5,
input D6,
input D7,
input S1,
input S2,
input S3,
);
always@(*)
begin
case({S1,S2,S3})
3'b000: OUT=D0;
3'b001: OUT=D1;
3'b010: OUT=D2;
3'b011: OUT=D3;
3'b100: OUT=D4;
3'b101: OUT=D5;
3'b110: OUT=D6;
3'b111: OUT=D7;
default: OUT=1'b0;
endcase
end
endmodule
RTL:
);
reg D0,D1,D2,D3,D4,D5,D6,D7,S1,S2,S3;
wire OUT;
mux8 uut(D0,D1,D2,D3,D4,D5,D6,D7,S1,S2,S3,OUT);
initial
begin
D0=1'b0;
D1=1'b0;
D2=1'b0;
D3=1'b0;
D4=1'b0;
D5=1'b0;
D6=1'b0;
D7=1'b0;
S1=1'b0;
S2=1'b0;
S3=1'b0;
end
always #1 D0=~D0;
always #2 D1=~D1;
always #3 D2=~D2;
always #4 D3=~D3;
always #5 D4=~D4;
always #6 D5=~D5;
always #7 D6=~D6;
always #8 D7=~D7;
always #9 S1=~S1;
always@(D0 or D1 or D2 or D3 or D4 or D5 or D6 or D7 or S1 or S2 or S3)
endmodule
Waveform:
EXPERIMENT: 4(b)
AIM: Implement 16:1 Mux using 4:1 mux
SOFTWARE: Xilinx
16:1 mux using 4:1 mux
module mux_4to1 (
);
always @(*)
begin
case(sel)
endcase
end
endmodule
module mux_16to1 (
);
endmodule
RTL:
module tb_mux_16x1;
wire out;
mux_16to1 UUT (
.data_in(data_in),
.sel(sel),
.out(out)
);
initial begin
data_in = 16'b0000_0000_0000_0001;
sel = 4'b0000;
#10;
data_in = 16'b0000_0000_0000_0010;
sel = 4'b0001;
#10;
data_in = 16'b0000_0000_0000_0100;
sel = 4'b0010;
#10;
data_in = 16'b0000_0000_0000_1000;
sel = 4'b0011;
#10;
end
endmodule
waveform: