6 bit Full adder using 3 bit Full adder

 

Full Adder 







Full Adder :

module full_add(output s,c,input a,b,cin);

    assign s=a^b^cin;

  assign c= (a&b)|cin &(a^b);

 endmodule 



3bit Full Adder

module bit3_full (s,c,a,b,cin);

  output [2:0]s;output c;input [2:0] a,b;input cin;

   reg w1,w2;

full_add  full_adder_Inst1  ( s[0],w1,a[0],b[0],cin); 

 full_add full_adder_Inst2  ( s[1],w2,a[1],b[1],w1);

 full_add full_adder_Inst3  ( s[2],c,a[2],b[2],w2);

endmodule


6bit Full Adder

module sbit_full(s,c,a,b,cin);

 output [5:0]s;output c;input [5:0] a,b;input cin;

  reg w1;

  bit3_full bit3_full_insta1 (s[2:0],w1,a[2:0],b[2:0],cin);

  bit3_full bit3_full_insta2  (s[5:3],c,a[5:3],b[5:3],w1);

  endmodule 


TESTBENCH :


module test ;

  wire [5:0] s;

  wire c;

  reg [5:0] a,b;

  reg  cin;

  sbit_full  insta (.s(s),.c(c),.a(a),.b(b),.cin(cin));

   initial begin 

  a=6'd1;cin=0;b=6'd2;

    #1 $display("s=%0d,c=%0d,a=%0d,b=%0d,cin=%0d",s,c,a,b,cin);

  a=6'd5;cin=0;b=6'd2;

    #1 $display("s=%0d,c=%0d,a=%0d,b=%0d,cin=%0d",s,c,a,b,cin);

 a=6'd10;cin=0;b=6'd2;

    #1 $display("s=%0d,c=%0d,a=%0d,b=%0d,cin=%0d",s,c,a,b,cin);

    end

endmodule

Comments

Popular posts from this blog

Weekend VLSI HOME

Digital Electronics Questions For VLSI Interview

VLSI COMPANIES