# 4 bit full adder in verilog

Status
Not open for further replies.

sntsh

### sntsh

Points: 2

#### yanzixuan

##### Member level 3

icaniwill said:
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

sntsh

Points: 2

### sntsh

Points: 2

##### Newbie level 5
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

sntsh

Points: 2

### sntsh

Points: 2

#### icaniwill

##### Junior Member level 3
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

thanx alot

sntsh

### sntsh

Points: 2

#### nizamalphas

##### Newbie level 3
how can i interface the 5 output of 4bit full adder into 7 segment display, anyone can help me?

sntsh

### sntsh

Points: 2

#### atulaxc

##### Member level 1

Status
Not open for further replies.