---
# System prepended metadata

title: LAB-8

---

# LAB-8
#### Name: Aseem Anand
#### Roll No:CS22B008
## Question-1
module Fulladder_using_halfadder(a,b,cin,cout,s);

    input a,b,cin;
    output cout,s;
    wire w1,w2,w3;
    half_adder p(a,b,w1,w2);
    half_adder q(cin,w1,s,w3);
    or r(cout,w3,w2);

endmodule

module half_adder (a,b,sum,carry);

    input a, b;
    output sum, carry;
    assign sum = a ^ b; 
    assign carry = a & b; 
     
endmodule
#### TestBench
module Fulladder_using_halfadder_TB();
reg a,b,cin;
wire cout,s;
Fulladder_using_halfadder f(.a(a),.b(b),.cin(cin),.cout(cout),.s(s));
initial
begin
      a=0;b=0;cin=0;
#100  a=0;b=0;cin=1;
#100  a=0;b=1;cin=0;
#100  a=0;b=1;cin=1;
#100  a=1;b=0;cin=0;
#100  a=1;b=0;cin=1;
#100  a=1;b=1;cin=0;
#100  a=1;b=1;cin=1;
end
endmodule
## Question-2
module Four_bit_ripple_adder(A,B,Cin,SUM,Cout);

    input [3:0]A; 
    input [3:0]B;
    wire [2:0]Carry;
    output [3:0]SUM;
    output Cout;
    input Cin;
    Full_adder a(A[0],B[0],Cin,Carry[0],SUM[0]);
    Full_adder b(A[1],B[1],Carry[0],Carry[1],SUM[1]);
    Full_adder c(A[2],B[2],Carry[1],Carry[2],SUM[2]);
    Full_adder d(A[3],B[3],Carry[2],Cout,SUM[3]);
endmodule

module Full_adder(a,b,cin,cout,s);

    input a,b,cin;
    output cout,s;
    wire w1,w2,w3;
    half_adder p(a,b,w1,w2);
    half_adder q(cin,w1,s,w3);
    or r(cout,w3,w2);

endmodule

module half_adder (a,b,sum,carry);

    input a, b;
    output sum, carry;
    assign sum = a ^ b; 
    assign carry = a & b; 
     
endmodule
#### TestBench
module Ripple_Carry_adder_tb();

    reg [3:0] A;
    reg [3:0] B;
    wire [3:0]SUM;
    wire Cout;
    Ripple_Carry_adder rca(.A(A),.B(B),.Cin(Cin),.SUM(SUM),.Cout(Cout));
    initial begin
		A = 4'b0000; B = 4'b0000;Cin=0; #10
		A = 4'b0000; B = 4'b0001;Cin=0; #10
		A = 4'b0000; B = 4'b0010;Cin=0; #10
		A = 4'b0000; B = 4'b0011;Cin=0; #10
		A = 4'b0000; B = 4'b0100;Cin=0; #10
		A = 4'b0000; B = 4'b0101;Cin=0; #10
		A = 4'b0000; B = 4'b0110;Cin=0; #10
		A = 4'b0000; B = 4'b0111;Cin=0; #10
		A = 4'b0000; B = 4'b1000;Cin=0; #10
		A = 4'b0000; B = 4'b1001;Cin=0; #10
		A = 4'b0000; B = 4'b1010;Cin=0; #10
		A = 4'b0000; B = 4'b1011;Cin=0; #10
		A = 4'b0000; B = 4'b1100;Cin=0; #10
		A = 4'b0000; B = 4'b1101;Cin=0; #10
		A = 4'b0000; B = 4'b1110;Cin=0; #10
		A = 4'b0000; B = 4'b1111;Cin=0; #10
		A = 4'b0001; B = 4'b0000;Cin=0; #10
		A = 4'b0001; B = 4'b0001;Cin=0; #10
		A = 4'b0001; B = 4'b0010;Cin=0; #10
		A = 4'b0001; B = 4'b0011;Cin=0; #10
		A = 4'b0001; B = 4'b0100;Cin=0; #10
		A = 4'b0001; B = 4'b0101;Cin=0; #10
		A = 4'b0001; B = 4'b0110;Cin=0; #10
		A = 4'b0001; B = 4'b0111;Cin=0; #10
		A = 4'b0001; B = 4'b1000;Cin=0; #10
		A = 4'b0001; B = 4'b1001;Cin=0; #10
		A = 4'b0001; B = 4'b1010;Cin=0; #10
		A = 4'b0001; B = 4'b1011;Cin=0; #10
		A = 4'b0001; B = 4'b1100;Cin=0; #10
		A = 4'b0001; B = 4'b1101;Cin=0; #10
		A = 4'b0001; B = 4'b1110;Cin=0; #10
		A = 4'b0001; B = 4'b1111;Cin=0; #10
		A = 4'b0010; B = 4'b0000;Cin=0; #10
		A = 4'b0010; B = 4'b0001;Cin=0; #10
		A = 4'b0010; B = 4'b0010;Cin=0; #10
		A = 4'b0010; B = 4'b0011;Cin=0; #10
		A = 4'b0010; B = 4'b0100;Cin=0; #10
		A = 4'b0010; B = 4'b0101;Cin=0; #10
		A = 4'b0010; B = 4'b0110;Cin=0; #10
		A = 4'b0010; B = 4'b0111;Cin=0; #10
		A = 4'b0010; B = 4'b1000;Cin=0; #10
		A = 4'b0010; B = 4'b1001;Cin=0; #10
		A = 4'b0010; B = 4'b1010;Cin=0; #10
		A = 4'b0010; B = 4'b1011;Cin=0; #10
		A = 4'b0010; B = 4'b1100;Cin=0; #10
		A = 4'b0010; B = 4'b1101;Cin=0; #10
		A = 4'b0010; B = 4'b1110;Cin=0; #10
		A = 4'b0010; B = 4'b1111;Cin=0; #10
		A = 4'b0011; B = 4'b0000;Cin=0; #10
		A = 4'b0011; B = 4'b0001;Cin=0; #10
		A = 4'b0011; B = 4'b0010;Cin=0; #10
		A = 4'b0011; B = 4'b0011;Cin=0; #10
		A = 4'b0011; B = 4'b0100;Cin=0; #10
		A = 4'b0011; B = 4'b0101;Cin=0; #10
		A = 4'b0011; B = 4'b0110;Cin=0; #10
		A = 4'b0011; B = 4'b0111;Cin=0; #10
		A = 4'b0011; B = 4'b1000;Cin=0; #10
		A = 4'b0011; B = 4'b1001;Cin=0; #10
		A = 4'b0011; B = 4'b1010;Cin=0; #10
		A = 4'b0011; B = 4'b1011;Cin=0; #10
		A = 4'b0011; B = 4'b1100;Cin=0; #10
		A = 4'b0011; B = 4'b1101;Cin=0; #10
		A = 4'b0011; B = 4'b1110;Cin=0; #10
		A = 4'b0011; B = 4'b1111;Cin=0; #10
		A = 4'b0100; B = 4'b0000;Cin=0; #10
		A = 4'b0100; B = 4'b0001;Cin=0; #10
		A = 4'b0100; B = 4'b0010;Cin=0; #10
		A = 4'b0100; B = 4'b0011;Cin=0; #10
		A = 4'b0100; B = 4'b0100;Cin=0; #10
		A = 4'b0100; B = 4'b0101;Cin=0; #10
		A = 4'b0100; B = 4'b0110;Cin=0; #10
		A = 4'b0100; B = 4'b0111;Cin=0; #10
		A = 4'b0100; B = 4'b1000;Cin=0; #10
		A = 4'b0100; B = 4'b1001;Cin=0; #10
		A = 4'b0100; B = 4'b1010;Cin=0; #10
		A = 4'b0100; B = 4'b1011;Cin=0; #10
		A = 4'b0100; B = 4'b1100;Cin=0; #10
		A = 4'b0100; B = 4'b1101;Cin=0; #10
		A = 4'b0100; B = 4'b1110;Cin=0; #10
		A = 4'b0100; B = 4'b1111;Cin=0; #10
		A = 4'b0101; B = 4'b0000;Cin=0; #10
		A = 4'b0101; B = 4'b0001;Cin=0; #10
		A = 4'b0101; B = 4'b0010;Cin=0; #10
		A = 4'b0101; B = 4'b0011;Cin=0; #10
		A = 4'b0101; B = 4'b0100;Cin=0; #10
		A = 4'b0101; B = 4'b0101;Cin=0; #10
		A = 4'b0101; B = 4'b0110;Cin=0; #10
		A = 4'b0101; B = 4'b0111;Cin=0; #10
		A = 4'b0101; B = 4'b1000;Cin=0; #10
		A = 4'b0101; B = 4'b1001;Cin=0; #10
		A = 4'b0101; B = 4'b1010;Cin=0; #10
		A = 4'b0101; B = 4'b1011;Cin=0; #10
		A = 4'b0101; B = 4'b1100;Cin=0; #10
		A = 4'b0101; B = 4'b1101;Cin=0; #10
		A = 4'b0101; B = 4'b1110;Cin=0; #10
		A = 4'b0101; B = 4'b1111;Cin=0; #10
		A = 4'b0110; B = 4'b0000;Cin=0; #10
		A = 4'b0110; B = 4'b0001;Cin=0; #10
		A = 4'b0110; B = 4'b0010;Cin=0; #10
		A = 4'b0110; B = 4'b0011;Cin=0; #10
		A = 4'b0110; B = 4'b0100;Cin=0; #10
		A = 4'b0110; B = 4'b0101;Cin=0; #10
		A = 4'b0110; B = 4'b0110;Cin=0; #10
		A = 4'b0110; B = 4'b0111;Cin=0; #10
		A = 4'b0110; B = 4'b1000;Cin=0; #10
		A = 4'b0110; B = 4'b1001;Cin=0; #10
		A = 4'b0110; B = 4'b1010;Cin=0; #10
		A = 4'b0110; B = 4'b1011;Cin=0; #10
		A = 4'b0110; B = 4'b1100; Cin=0;#10
		A = 4'b0110; B = 4'b1101;Cin=0; #10
		A = 4'b0110; B = 4'b1110;Cin=0; #10
		A = 4'b0110; B = 4'b1111;Cin=0; #10
		A = 4'b0111; B = 4'b0000;Cin=0; #10
		A = 4'b0111; B = 4'b0001;Cin=0; #10
		A = 4'b0111; B = 4'b0010;Cin=0; #10
		A = 4'b0111; B = 4'b0011;Cin=0; #10
		A = 4'b0111; B = 4'b0100;Cin=0; #10
		A = 4'b0111; B = 4'b0101;Cin=0; #10
		A = 4'b0111; B = 4'b0110;Cin=0; #10
		A = 4'b0111; B = 4'b0111;Cin=0; #10
		A = 4'b0111; B = 4'b1000;Cin=0; #10
		A = 4'b0111; B = 4'b1001;Cin=0; #10
		A = 4'b0111; B = 4'b1010;Cin=0; #10
		A = 4'b0111; B = 4'b1011;Cin=0; #10
		A = 4'b0111; B = 4'b1100;Cin=0; #10
		A = 4'b0111; B = 4'b1101;Cin=0; #10
		A = 4'b0111; B = 4'b1110;Cin=0; #10
		A = 4'b0111; B = 4'b1111;Cin=0; #10
		A = 4'b1000; B = 4'b0000;Cin=0; #10
		A = 4'b1000; B = 4'b0001;Cin=0; #10
		A = 4'b1000; B = 4'b0010;Cin=0; #10
		A = 4'b1000; B = 4'b0011;Cin=0; #10
		A = 4'b1000; B = 4'b0100;Cin=0; #10
		A = 4'b1000; B = 4'b0101;Cin=0; #10
		A = 4'b1000; B = 4'b0110;Cin=0; #10
		A = 4'b1000; B = 4'b0111;Cin=0; #10
		A = 4'b1000; B = 4'b1000;Cin=0; #10
		A = 4'b1000; B = 4'b1001;Cin=0; #10
		A = 4'b1000; B = 4'b1010;Cin=0; #10
		A = 4'b1000; B = 4'b1011;Cin=0; #10
		A = 4'b1000; B = 4'b1100;Cin=0; #10
		A = 4'b1000; B = 4'b1101;Cin=0; #10
		A = 4'b1000; B = 4'b1110;Cin=0; #10
		A = 4'b1000; B = 4'b1111;Cin=0; #10
		A = 4'b1001; B = 4'b0000;Cin=0; #10
		A = 4'b1001; B = 4'b0001;Cin=0; #10
		A = 4'b1001; B = 4'b0010;Cin=0; #10
		A = 4'b1001; B = 4'b0011;Cin=0; #10
		A = 4'b1001; B = 4'b0100;Cin=0; #10
		A = 4'b1001; B = 4'b0101;Cin=0; #10
		A = 4'b1001; B = 4'b0110;Cin=0; #10
		A = 4'b1001; B = 4'b0111;Cin=0; #10
		A = 4'b1001; B = 4'b1000;Cin=0; #10
		A = 4'b1001; B = 4'b1001;Cin=0; #10
		A = 4'b1001; B = 4'b1010;Cin=0; #10
		A = 4'b1001; B = 4'b1011;Cin=0; #10
		A = 4'b1001; B = 4'b1100;Cin=0; #10
		A = 4'b1001; B = 4'b1101;Cin=0; #10
		A = 4'b1001; B = 4'b1110;Cin=0; #10
		A = 4'b1001; B = 4'b1111;Cin=0; #10
		A = 4'b1010; B = 4'b0000;Cin=0; #10
		A = 4'b1010; B = 4'b0001;Cin=0; #10
		A = 4'b1010; B = 4'b0010;Cin=0; #10
		A = 4'b1010; B = 4'b0011;Cin=0; #10
		A = 4'b1010; B = 4'b0100;Cin=0; #10
		A = 4'b1010; B = 4'b0101;Cin=0; #10
		A = 4'b1010; B = 4'b0110;Cin=0; #10
		A = 4'b1010; B = 4'b0111;Cin=0; #10
		A = 4'b1010; B = 4'b1000;Cin=0; #10
		A = 4'b1010; B = 4'b1001;Cin=0; #10
		A = 4'b1010; B = 4'b1010;Cin=0; #10
		A = 4'b1010; B = 4'b1011;Cin=0; #10
		A = 4'b1010; B = 4'b1100;Cin=0; #10
		A = 4'b1010; B = 4'b1101; Cin=0;#10
		A = 4'b1010; B = 4'b1110;Cin=0; #10
		A = 4'b1010; B = 4'b1111;Cin=0; #10
		A = 4'b1011; B = 4'b0000;Cin=0; #10
		A = 4'b1011; B = 4'b0001;Cin=0; #10
		A = 4'b1011; B = 4'b0010;Cin=0; #10
		A = 4'b1011; B = 4'b0011;Cin=0; #10
		A = 4'b1011; B = 4'b0100;Cin=0; #10
		A = 4'b1011; B = 4'b0101;Cin=0; #10
		A = 4'b1011; B = 4'b0110;Cin=0; #10
		A = 4'b1011; B = 4'b0111;Cin=0; #10
		A = 4'b1011; B = 4'b1000;Cin=0; #10
		A = 4'b1011; B = 4'b1001;Cin=0; #10
		A = 4'b1011; B = 4'b1010;Cin=0; #10
		A = 4'b1011; B = 4'b1011;Cin=0; #10
		A = 4'b1011; B = 4'b1100;Cin=0; #10
		A = 4'b1011; B = 4'b1101;Cin=0; #10
		A = 4'b1011; B = 4'b1110;Cin=0; #10
		A = 4'b1011; B = 4'b1111;Cin=0; #10
		A = 4'b1100; B = 4'b0000;Cin=0; #10
		A = 4'b1100; B = 4'b0001;Cin=0; #10
		A = 4'b1100; B = 4'b0010;Cin=0; #10
		A = 4'b1100; B = 4'b0011;Cin=0; #10
		A = 4'b1100; B = 4'b0100;Cin=0; #10
		A = 4'b1100; B = 4'b0101;Cin=0; #10
		A = 4'b1100; B = 4'b0110;Cin=0; #10
		A = 4'b1100; B = 4'b0111;Cin=0; #10
		A = 4'b1100; B = 4'b1000;Cin=0; #10
		A = 4'b1100; B = 4'b1001;Cin=0; #10
		A = 4'b1100; B = 4'b1010;Cin=0; #10
		A = 4'b1100; B = 4'b1011;Cin=0; #10
		A = 4'b1100; B = 4'b1100;Cin=0; #10
		A = 4'b1100; B = 4'b1101;Cin=0; #10
		A = 4'b1100; B = 4'b1110;Cin=0; #10
		A = 4'b1100; B = 4'b1111;Cin=0; #10
		A = 4'b1101; B = 4'b0000;Cin=0; #10
		A = 4'b1101; B = 4'b0001;Cin=0; #10
		A = 4'b1101; B = 4'b0010;Cin=0; #10
		A = 4'b1101; B = 4'b0011;Cin=0; #10
		A = 4'b1101; B = 4'b0100;Cin=0; #10
		A = 4'b1101; B = 4'b0101;Cin=0; #10
		A = 4'b1101; B = 4'b0110;Cin=0; #10
		A = 4'b1101; B = 4'b0111;Cin=0; #10
		A = 4'b1101; B = 4'b1000;Cin=0; #10
		A = 4'b1101; B = 4'b1001;Cin=0; #10
		A = 4'b1101; B = 4'b1010;Cin=0; #10
		A = 4'b1101; B = 4'b1011;Cin=0; #10
		A = 4'b1101; B = 4'b1100;Cin=0; #10
		A = 4'b1101; B = 4'b1101;Cin=0; #10
		A = 4'b1101; B = 4'b1110;Cin=0; #10
		A = 4'b1101; B = 4'b1111;Cin=0; #10
		A = 4'b1110; B = 4'b0000;Cin=0; #10
		A = 4'b1110; B = 4'b0001;Cin=0; #10
		A = 4'b1110; B = 4'b0010;Cin=0; #10
		A = 4'b1110; B = 4'b0011;Cin=0; #10
		A = 4'b1110; B = 4'b0100;Cin=0; #10
		A = 4'b1110; B = 4'b0101;Cin=0; #10
		A = 4'b1110; B = 4'b0110;Cin=0; #10
		A = 4'b1110; B = 4'b0111;Cin=0; #10
		A = 4'b1110; B = 4'b1000;Cin=0; #10
		A = 4'b1110; B = 4'b1001;Cin=0; #10
		A = 4'b1110; B = 4'b1010;Cin=0; #10
		A = 4'b1110; B = 4'b1011;Cin=0; #10
		A = 4'b1110; B = 4'b1100;Cin=0; #10
		A = 4'b1110; B = 4'b1101;Cin=0; #10
		A = 4'b1110; B = 4'b1110;Cin=0; #10
		A = 4'b1110; B = 4'b1111;Cin=0; #10
		A = 4'b1111; B = 4'b0000;Cin=0; #10
		A = 4'b1111; B = 4'b0001;Cin=0; #10
		A = 4'b1111; B = 4'b0010;Cin=0; #10
		A = 4'b1111; B = 4'b0011;Cin=0; #10
		A = 4'b1111; B = 4'b0100;Cin=0; #10
		A = 4'b1111; B = 4'b0101;Cin=0; #10
		A = 4'b1111; B = 4'b0110;Cin=0; #10
		A = 4'b1111; B = 4'b0111;Cin=0; #10
		A = 4'b1111; B = 4'b1000;Cin=0; #10
		A = 4'b1111; B = 4'b1001;Cin=0; #10
		A = 4'b1111; B = 4'b1010;Cin=0; #10
		A = 4'b1111; B = 4'b1011;Cin=0; #10
		A = 4'b1111; B = 4'b1100;Cin=0; #10
		A = 4'b1111; B = 4'b1101;Cin=0; #10
		A = 4'b1111; B = 4'b1110;Cin=0; #10
		A = 4'b1111; B = 4'b1111;Cin=0; #10
        A = 4'b0000; B = 4'b0000;Cin=1; #10
		A = 4'b0000; B = 4'b0001;Cin=1; #10
		A = 4'b0000; B = 4'b0010;Cin=1; #10
		A = 4'b0000; B = 4'b0011;Cin=1; #10
		A = 4'b0000; B = 4'b0100;Cin=1; #10
		A = 4'b0000; B = 4'b0101;Cin=1; #10
		A = 4'b0000; B = 4'b0110;Cin=1; #10
		A = 4'b0000; B = 4'b0111;Cin=1; #10
		A = 4'b0000; B = 4'b1000;Cin=1; #10
		A = 4'b0000; B = 4'b1001;Cin=1; #10
		A = 4'b0000; B = 4'b1010;Cin=1; #10
		A = 4'b0000; B = 4'b1011;Cin=1; #10
		A = 4'b0000; B = 4'b1100;Cin=1; #10
		A = 4'b0000; B = 4'b1101;Cin=1; #10
		A = 4'b0000; B = 4'b1110;Cin=1; #10
		A = 4'b0000; B = 4'b1111;Cin=1; #10
		A = 4'b0001; B = 4'b0000;Cin=1; #10
		A = 4'b0001; B = 4'b0001;Cin=1; #10
		A = 4'b0001; B = 4'b0010;Cin=1; #10
		A = 4'b0001; B = 4'b0011;Cin=1; #10
		A = 4'b0001; B = 4'b0100;Cin=1; #10
		A = 4'b0001; B = 4'b0101;Cin=1; #10
		A = 4'b0001; B = 4'b0110;Cin=1; #10
		A = 4'b0001; B = 4'b0111;Cin=1; #10
		A = 4'b0001; B = 4'b1000;Cin=1; #10
		A = 4'b0001; B = 4'b1001;Cin=1; #10
		A = 4'b0001; B = 4'b1010;Cin=1; #10
		A = 4'b0001; B = 4'b1011;Cin=1; #10
		A = 4'b0001; B = 4'b1100;Cin=1; #10
		A = 4'b0001; B = 4'b1101;Cin=1; #10
		A = 4'b0001; B = 4'b1110;Cin=1; #10
		A = 4'b0001; B = 4'b1111;Cin=1; #10
		A = 4'b0010; B = 4'b0000;Cin=1; #10
		A = 4'b0010; B = 4'b0001;Cin=1; #10
		A = 4'b0010; B = 4'b0010;Cin=1; #10
		A = 4'b0010; B = 4'b0011;Cin=1; #10
		A = 4'b0010; B = 4'b0100;Cin=1; #10
		A = 4'b0010; B = 4'b0101;Cin=1; #10
		A = 4'b0010; B = 4'b0110;Cin=1; #10
		A = 4'b0010; B = 4'b0111;Cin=1; #10
		A = 4'b0010; B = 4'b1000;Cin=1; #10
		A = 4'b0010; B = 4'b1001;Cin=1; #10
		A = 4'b0010; B = 4'b1010;Cin=1; #10
		A = 4'b0010; B = 4'b1011;Cin=1; #10
		A = 4'b0010; B = 4'b1100;Cin=1; #10
		A = 4'b0010; B = 4'b1101;Cin=1; #10
		A = 4'b0010; B = 4'b1110;Cin=1; #10
		A = 4'b0010; B = 4'b1111;Cin=1; #10
		A = 4'b0011; B = 4'b0000;Cin=1; #10
		A = 4'b0011; B = 4'b0001;Cin=1; #10
		A = 4'b0011; B = 4'b0010;Cin=1; #10
		A = 4'b0011; B = 4'b0011;Cin=1; #10
		A = 4'b0011; B = 4'b0100;Cin=1; #10
		A = 4'b0011; B = 4'b0101;Cin=1; #10
		A = 4'b0011; B = 4'b0110;Cin=1; #10
		A = 4'b0011; B = 4'b0111;Cin=1; #10
		A = 4'b0011; B = 4'b1000;Cin=1; #10
		A = 4'b0011; B = 4'b1001;Cin=1; #10
		A = 4'b0011; B = 4'b1010;Cin=1; #10
		A = 4'b0011; B = 4'b1011;Cin=1; #10
		A = 4'b0011; B = 4'b1100;Cin=1; #10
		A = 4'b0011; B = 4'b1101;Cin=1; #10
		A = 4'b0011; B = 4'b1110;Cin=1; #10
		A = 4'b0011; B = 4'b1111;Cin=1; #10
		A = 4'b0100; B = 4'b0000;Cin=1; #10
		A = 4'b0100; B = 4'b0001;Cin=1; #10
		A = 4'b0100; B = 4'b0010;Cin=1; #10
		A = 4'b0100; B = 4'b0011;Cin=1; #10
		A = 4'b0100; B = 4'b0100;Cin=1; #10
		A = 4'b0100; B = 4'b0101;Cin=1; #10
		A = 4'b0100; B = 4'b0110;Cin=1; #10
		A = 4'b0100; B = 4'b0111;Cin=1; #10
		A = 4'b0100; B = 4'b1000;Cin=1; #10
		A = 4'b0100; B = 4'b1001;Cin=1; #10
		A = 4'b0100; B = 4'b1010;Cin=1; #10
		A = 4'b0100; B = 4'b1011;Cin=1; #10
		A = 4'b0100; B = 4'b1100;Cin=1; #10
		A = 4'b0100; B = 4'b1101;Cin=1; #10
		A = 4'b0100; B = 4'b1110;Cin=1; #10
		A = 4'b0100; B = 4'b1111;Cin=1; #10
		A = 4'b0101; B = 4'b0000;Cin=1; #10
		A = 4'b0101; B = 4'b0001;Cin=1; #10
		A = 4'b0101; B = 4'b0010;Cin=1; #10
		A = 4'b0101; B = 4'b0011;Cin=1; #10
		A = 4'b0101; B = 4'b0100;Cin=1; #10
		A = 4'b0101; B = 4'b0101;Cin=1; #10
		A = 4'b0101; B = 4'b0110;Cin=1; #10
		A = 4'b0101; B = 4'b0111;Cin=1; #10
		A = 4'b0101; B = 4'b1000;Cin=1; #10
		A = 4'b0101; B = 4'b1001;Cin=1; #10
		A = 4'b0101; B = 4'b1010;Cin=1; #10
		A = 4'b0101; B = 4'b1011;Cin=1; #10
		A = 4'b0101; B = 4'b1100;Cin=1; #10
		A = 4'b0101; B = 4'b1101;Cin=1; #10
		A = 4'b0101; B = 4'b1110;Cin=1; #10
		A = 4'b0101; B = 4'b1111;Cin=1; #10
		A = 4'b0110; B = 4'b0000;Cin=1; #10
		A = 4'b0110; B = 4'b0001;Cin=1; #10
		A = 4'b0110; B = 4'b0010;Cin=1; #10
		A = 4'b0110; B = 4'b0011;Cin=1; #10
		A = 4'b0110; B = 4'b0100;Cin=1; #10
		A = 4'b0110; B = 4'b0101;Cin=1; #10
		A = 4'b0110; B = 4'b0110;Cin=1; #10
		A = 4'b0110; B = 4'b0111;Cin=1; #10
		A = 4'b0110; B = 4'b1000;Cin=1; #10
		A = 4'b0110; B = 4'b1001;Cin=1; #10
		A = 4'b0110; B = 4'b1010;Cin=1; #10
		A = 4'b0110; B = 4'b1011;Cin=1; #10
		A = 4'b0110; B = 4'b1100; Cin=1;#10
		A = 4'b0110; B = 4'b1101;Cin=1; #10
		A = 4'b0110; B = 4'b1110;Cin=1; #10
		A = 4'b0110; B = 4'b1111;Cin=1; #10
		A = 4'b0111; B = 4'b0000;Cin=1; #10
		A = 4'b0111; B = 4'b0001;Cin=1; #10
		A = 4'b0111; B = 4'b0010;Cin=1; #10
		A = 4'b0111; B = 4'b0011;Cin=1; #10
		A = 4'b0111; B = 4'b0100;Cin=1; #10
		A = 4'b0111; B = 4'b0101;Cin=1; #10
		A = 4'b0111; B = 4'b0110;Cin=1; #10
		A = 4'b0111; B = 4'b0111;Cin=1; #10
		A = 4'b0111; B = 4'b1000;Cin=1; #10
		A = 4'b0111; B = 4'b1001;Cin=1; #10
		A = 4'b0111; B = 4'b1010;Cin=1; #10
		A = 4'b0111; B = 4'b1011;Cin=1; #10
		A = 4'b0111; B = 4'b1100;Cin=1; #10
		A = 4'b0111; B = 4'b1101;Cin=1; #10
		A = 4'b0111; B = 4'b1110;Cin=1; #10
		A = 4'b0111; B = 4'b1111;Cin=1; #10
		A = 4'b1000; B = 4'b0000;Cin=1; #10
		A = 4'b1000; B = 4'b0001;Cin=1; #10
		A = 4'b1000; B = 4'b0010;Cin=1; #10
		A = 4'b1000; B = 4'b0011;Cin=1; #10
		A = 4'b1000; B = 4'b0100;Cin=1; #10
		A = 4'b1000; B = 4'b0101;Cin=1; #10
		A = 4'b1000; B = 4'b0110;Cin=1; #10
		A = 4'b1000; B = 4'b0111;Cin=1; #10
		A = 4'b1000; B = 4'b1000;Cin=1; #10
		A = 4'b1000; B = 4'b1001;Cin=1; #10
		A = 4'b1000; B = 4'b1010;Cin=1; #10
		A = 4'b1000; B = 4'b1011;Cin=1; #10
		A = 4'b1000; B = 4'b1100;Cin=1; #10
		A = 4'b1000; B = 4'b1101;Cin=1; #10
		A = 4'b1000; B = 4'b1110;Cin=1; #10
		A = 4'b1000; B = 4'b1111;Cin=1; #10
		A = 4'b1001; B = 4'b0000;Cin=1; #10
		A = 4'b1001; B = 4'b0001;Cin=1; #10
		A = 4'b1001; B = 4'b0010;Cin=1; #10
		A = 4'b1001; B = 4'b0011;Cin=1; #10
		A = 4'b1001; B = 4'b0100;Cin=1; #10
		A = 4'b1001; B = 4'b0101;Cin=1; #10
		A = 4'b1001; B = 4'b0110;Cin=1; #10
		A = 4'b1001; B = 4'b0111;Cin=1; #10
		A = 4'b1001; B = 4'b1000;Cin=1; #10
		A = 4'b1001; B = 4'b1001;Cin=1; #10
		A = 4'b1001; B = 4'b1010;Cin=1; #10
		A = 4'b1001; B = 4'b1011;Cin=1; #10
		A = 4'b1001; B = 4'b1100;Cin=1; #10
		A = 4'b1001; B = 4'b1101;Cin=1; #10
		A = 4'b1001; B = 4'b1110;Cin=1; #10
		A = 4'b1001; B = 4'b1111;Cin=1; #10
		A = 4'b1010; B = 4'b0000;Cin=1; #10
		A = 4'b1010; B = 4'b0001;Cin=1; #10
		A = 4'b1010; B = 4'b0010;Cin=1; #10
		A = 4'b1010; B = 4'b0011;Cin=1; #10
		A = 4'b1010; B = 4'b0100;Cin=1; #10
		A = 4'b1010; B = 4'b0101;Cin=1; #10
		A = 4'b1010; B = 4'b0110;Cin=1; #10
		A = 4'b1010; B = 4'b0111;Cin=1; #10
		A = 4'b1010; B = 4'b1000;Cin=1; #10
		A = 4'b1010; B = 4'b1001;Cin=1; #10
		A = 4'b1010; B = 4'b1010;Cin=1; #10
		A = 4'b1010; B = 4'b1011;Cin=1; #10
		A = 4'b1010; B = 4'b1100;Cin=1; #10
		A = 4'b1010; B = 4'b1101; Cin=1;#10
		A = 4'b1010; B = 4'b1110;Cin=1; #10
		A = 4'b1010; B = 4'b1111;Cin=1; #10
		A = 4'b1011; B = 4'b0000;Cin=1; #10
		A = 4'b1011; B = 4'b0001;Cin=1; #10
		A = 4'b1011; B = 4'b0010;Cin=1; #10
		A = 4'b1011; B = 4'b0011;Cin=1; #10
		A = 4'b1011; B = 4'b0100;Cin=1; #10
		A = 4'b1011; B = 4'b0101;Cin=1; #10
		A = 4'b1011; B = 4'b0110;Cin=1; #10
		A = 4'b1011; B = 4'b0111;Cin=1; #10
		A = 4'b1011; B = 4'b1000;Cin=1; #10
		A = 4'b1011; B = 4'b1001;Cin=1; #10
		A = 4'b1011; B = 4'b1010;Cin=1; #10
		A = 4'b1011; B = 4'b1011;Cin=1; #10
		A = 4'b1011; B = 4'b1100;Cin=1; #10
		A = 4'b1011; B = 4'b1101;Cin=1; #10
		A = 4'b1011; B = 4'b1110;Cin=1; #10
		A = 4'b1011; B = 4'b1111;Cin=1; #10
		A = 4'b1100; B = 4'b0000;Cin=1; #10
		A = 4'b1100; B = 4'b0001;Cin=1; #10
		A = 4'b1100; B = 4'b0010;Cin=1; #10
		A = 4'b1100; B = 4'b0011;Cin=1; #10
		A = 4'b1100; B = 4'b0100;Cin=1; #10
		A = 4'b1100; B = 4'b0101;Cin=1; #10
		A = 4'b1100; B = 4'b0110;Cin=1; #10
		A = 4'b1100; B = 4'b0111;Cin=1; #10
		A = 4'b1100; B = 4'b1000;Cin=1; #10
		A = 4'b1100; B = 4'b1001;Cin=1; #10
		A = 4'b1100; B = 4'b1010;Cin=1; #10
		A = 4'b1100; B = 4'b1011;Cin=1; #10
		A = 4'b1100; B = 4'b1100;Cin=1; #10
		A = 4'b1100; B = 4'b1101;Cin=1; #10
		A = 4'b1100; B = 4'b1110;Cin=1; #10
		A = 4'b1100; B = 4'b1111;Cin=1; #10
		A = 4'b1101; B = 4'b0000;Cin=1; #10
		A = 4'b1101; B = 4'b0001;Cin=1; #10
		A = 4'b1101; B = 4'b0010;Cin=1; #10
		A = 4'b1101; B = 4'b0011;Cin=1; #10
		A = 4'b1101; B = 4'b0100;Cin=1; #10
		A = 4'b1101; B = 4'b0101;Cin=1; #10
		A = 4'b1101; B = 4'b0110;Cin=1; #10
		A = 4'b1101; B = 4'b0111;Cin=1; #10
		A = 4'b1101; B = 4'b1000;Cin=1; #10
		A = 4'b1101; B = 4'b1001;Cin=1; #10
		A = 4'b1101; B = 4'b1010;Cin=1; #10
		A = 4'b1101; B = 4'b1011;Cin=1; #10
		A = 4'b1101; B = 4'b1100;Cin=1; #10
		A = 4'b1101; B = 4'b1101;Cin=1; #10
		A = 4'b1101; B = 4'b1110;Cin=1; #10
		A = 4'b1101; B = 4'b1111;Cin=1; #10
		A = 4'b1110; B = 4'b0000;Cin=1; #10
		A = 4'b1110; B = 4'b0001;Cin=1; #10
		A = 4'b1110; B = 4'b0010;Cin=1; #10
		A = 4'b1110; B = 4'b0011;Cin=1; #10
		A = 4'b1110; B = 4'b0100;Cin=1; #10
		A = 4'b1110; B = 4'b0101;Cin=1; #10
		A = 4'b1110; B = 4'b0110;Cin=1; #10
		A = 4'b1110; B = 4'b0111;Cin=1; #10
		A = 4'b1110; B = 4'b1000;Cin=1; #10
		A = 4'b1110; B = 4'b1001;Cin=1; #10
		A = 4'b1110; B = 4'b1010;Cin=1; #10
		A = 4'b1110; B = 4'b1011;Cin=1; #10
		A = 4'b1110; B = 4'b1100;Cin=1; #10
		A = 4'b1110; B = 4'b1101;Cin=1; #10
		A = 4'b1110; B = 4'b1110;Cin=1; #10
		A = 4'b1110; B = 4'b1111;Cin=1; #10
		A = 4'b1111; B = 4'b0000;Cin=1; #10
		A = 4'b1111; B = 4'b0001;Cin=1; #10
		A = 4'b1111; B = 4'b0010;Cin=1; #10
		A = 4'b1111; B = 4'b0011;Cin=1; #10
		A = 4'b1111; B = 4'b0100;Cin=1; #10
		A = 4'b1111; B = 4'b0101;Cin=1; #10
		A = 4'b1111; B = 4'b0110;Cin=1; #10
		A = 4'b1111; B = 4'b0111;Cin=1; #10
		A = 4'b1111; B = 4'b1000;Cin=1; #10
		A = 4'b1111; B = 4'b1001;Cin=1; #10
		A = 4'b1111; B = 4'b1010;Cin=1; #10
		A = 4'b1111; B = 4'b1011;Cin=1; #10
		A = 4'b1111; B = 4'b1100;Cin=1; #10
		A = 4'b1111; B = 4'b1101;Cin=1; #10
		A = 4'b1111; B = 4'b1110;Cin=1; #10
		A = 4'b1111; B = 4'b1111;Cin=1; 
	end
    endmodule
    
## Question-3
module multiplexer(i1,i2,s,o);

    input i1;
    input i2;
    input s;
    output o;
    wire x,y,not_s;
    not(not_s,s);
    and(x,i1,s);
    and(y,i2,not_s);
    or(o,x,y);
endmodule

#### TestBench
module multiplexer_TB();

    reg i1,i2,s;
    wire o;
    multiplexer(.i1(i1),.i2(i2),.s(s),.o(o));
    initial
    begin
    i1=0;i2=0;s=0;
    i1=0;i2=0;s=1;
    i1=0;i2=1;s=0;
    i1=0;i2=1;s=1;
    i1=1;i2=0;s=0;
    i1=1;i2=0;s=1;
    i1=1;i2=1;s=0;
    i1=1;i2=1;s=1;
    end
endmodule