Professional Documents
Culture Documents
i0 = 0;
i1 = 1;
i2 = 0;
i3 = 0;
s0 = 1;
s1 = 0;
#100;
i0 = 0;
i1 = 0;
i2 = 1;
i3 = 0;
s0 = 0;
s1 = 1;
#100;
i0 = 0;
i1 = 0;
i2 = 0;
i3 = 1;
s0 = 1;
s1 = 1;
#100;
end
endmodule
Waveform:
Waveform:
endmodule
module bit(sum,cout,a,b,cin);
input a,b,cin;
output sum,cout;
wire w1,w2,w3;
xor(w1,a,b);
and(w2,a,b);
xor(sum,w1,cin);
and(w3,w1,cin);
xor(cout,w3,w2);
endmodule
RTL SCHEMATIC:
TESTBENCH:
initial begin
// Initialize Inputs
a = 4'b0000;
b =4'b0000;
cin =1'b0;
#100;
a = 4'b0011;
b =4'b0100;
cin =1'b0;
#100;
a = 4'b1010;
b =4'b0101;
cin =1'b1;
#100;
end
endmodule
Waveform:
output out;
input in1,in2,sel;
assign out=sel ? in1:in2;
endmodule
RTL SCHEMATIC:
TEST BENCH:
initial begin
sel = 0;// Initialize Inputs
in1 = 0;// Initialize Inputs
in2 = 1;// Initialize Inputs
#100;
sel = 1;// Initialize Inputs
in1 = 1;// Initialize Inputs
in2 = 0;// Initialize Inputs
#100;
end
endmodule
WAVEFORM:
TEST BENCH:
initial begin
a =4'b0000;
// Initialize Inputs
b = 4'b0000;
// Initialize Inputs
cin = 0;
// Initialize Inputs
#100;
end
endmodule
WAVEFORM:
TEST BENCH:
initial begin
a =4'b0000; // Initialize Inputs
b =4'b0000; // Initialize Inputs
#100; // Wait 100 ns for global reset to finish
a =4'b0001;
b =4'b0010;
#100;
a = 0;
b = 0;
#100;
a =4'b0100;
b =4'b0011;
#100;
end
endmodule
Waveform: