4 bit full adder in verilog

Status
Not open for further replies.

icaniwill

Junior Member level 3
Joined
Nov 9, 2007
Messages
26
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,283
Activity points
1,429
full adder verilog

i need to make a 4 bit full adder using verilog can anybody please help me?
 

verilog full adder

icaniwill said:
i need to make a 4 bit full adder using verilog can anybody please help me?
Code:
module   full_adder_4bit(
    cin,
    cout,
    in_a,
    in_b,
    sum
    );
    
    parameter   reg_size = 4;
    
    input   cin;
    input   [reg_size-1:0] in_a;
    input   [reg_size-1:0] in_b;
    output  [reg_size-1:0] sum;
    output  cout;
    
    assign   {cout,sum} = in_a + in_b + cin;
    
endmodule
 
Reactions: sntsh

    icaniwill

    Points: 2
    Helpful Answer Positive Rating

    sntsh

    Points: 2
    Helpful Answer Positive Rating
This is code is for an simple asynchronous
wrapping n-bit adder. By changing the value
of n you can make it a 2, 4, … bit adder
where n = <number of bits> - 1. f is the output register that will have the current value of the counter, cOut is the carry output. a & b are the number inputs and cIn is the carry input. Both the number outputs and inputs are set by the value of n so you can add two n-bit numbers and a carry bit then get an n-bit number plus carry bit ou




module nBitAdder(f, cOut, a, b, cIn);
parameter n = 7;

output reg [n:0] f;
output reg cOut;
input [n:0] a;
input [n:0] b;
input cIn;

always @(a, b, cIn)
{cOut, f} = a + b + cIn;
endmodule
 
Reactions: sntsh

    icaniwill

    Points: 2
    Helpful Answer Positive Rating

    sntsh

    Points: 2
    Helpful Answer Positive Rating

thanx alot
 
Reactions: sntsh

    sntsh

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…