//code
module mux(out,i,s); ///mux 8:1
output out;
input [7:0]i;
input[2:0]s;
wire out;
assign out=i[s];
endmodule
//Testbench
`timescale 1ns / 1ps
module test1;
// Inputs
reg [7:0] i;
reg [2:0] s;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
mux uut (
.out(out),
.i(i),
.s(s)
);
initial begin
// Initialize Inputs
i = 0;
s = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
i=3'b00000010;
s=3'b001;
#100;
i=3'b00000100;
s=3'b010;
end
endmodule
//Output
module mux(out,i,s); ///mux 8:1
output out;
input [7:0]i;
input[2:0]s;
wire out;
assign out=i[s];
endmodule
//Testbench
`timescale 1ns / 1ps
module test1;
// Inputs
reg [7:0] i;
reg [2:0] s;
// Outputs
wire out;
// Instantiate the Unit Under Test (UUT)
mux uut (
.out(out),
.i(i),
.s(s)
);
initial begin
// Initialize Inputs
i = 0;
s = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
i=3'b00000010;
s=3'b001;
#100;
i=3'b00000100;
s=3'b010;
end
endmodule
//Output
No comments:
Post a Comment