icaniwill said:i need to make a 4 bit full adder using verilog can anybody please help me?
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
malikmuhammadali said: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