In digital electronics and VLSI design, adders are fundamental building blocks used to perform arithmetic operations. Among various types of adders, the 4-bit Ripple Carry Adder (RCA) is one of the simplest and most commonly studied designs. It is widely used to add two 4-bit binary numbers and produce a 4-bit sum along with a carry-out.
This article will explain the working principle of the 4-bit Ripple Carry Adder, provide a clean Verilog implementation, and guide you through writing a testbench to verify its functionality. Whether you are a student preparing for interviews or a beginner learning Verilog, this article will help you grasp the concept clearly.
What is a Ripple Carry Adder?
A Ripple Carry Adder is a digital circuit that adds two binary numbers bit by bit, starting from the least significant bit (LSB) to the most significant bit (MSB). It uses multiple 1-bit full adders connected in series, where the carry output of one full adder “ripples” to the next full adder as its carry input.
How it works:
- Each 1-bit full adder adds two input bits and a carry-in.
- It produces a sum bit and a carry-out.
- The carry-out from the current bit addition becomes the carry-in for the next higher bit.
- This process continues through all bits, hence the name “Ripple Carry.”
Advantages and Limitations
- Advantages:
- Simple and easy to implement.
- Requires minimal hardware.
- Limitations:
- The carry propagation delay increases linearly with the number of bits.
- Not suitable for very high-speed applications.
Verilog Design of 4-bit Ripple Carry Adder
The design consists of two parts:
- 1-bit Full Adder Module
- 4-bit Ripple Carry Adder Module that instantiates four 1-bit full adders.

1-bit Full Adder Verilog Code
module full_adder (
input wire a,
input wire b,
input wire cin,
output wire sum,
output wire cout
);
assign sum = a ^ b ^ cin; // Sum = A XOR B XOR Cin
assign cout = (a & b) | (b & cin) | (a & cin); // Carry-out logic
endmodule
4-bit Ripple Carry Adder Verilog Code
module ripple_carry_adder_4bit (
input wire [3:0] a,
input wire [3:0] b,
input wire cin,
output wire [3:0] sum,
output wire cout
);
wire c1, c2, c3; // Internal carry wires
// Instantiate 4 full adders
full_adder fa0 (a[0], b[0], cin, sum[0], c1);
full_adder fa1 (a[1], b[1], c1, sum[1], c2);
full_adder fa2 (a[2], b[2], c2, sum[2], c3);
full_adder fa3 (a[3], b[3], c3, sum[3], cout);
endmodule
Testbench for 4-bit Ripple Carry Adder
A testbench is essential to verify that the design works correctly under various input conditions. Below is a simple testbench for the 4-bit RCA.
module tb_ripple_carry_adder_4bit;
reg [3:0] a, b;
reg cin;
wire [3:0] sum;
wire cout;
// Instantiate the 4-bit RCA
ripple_carry_adder_4bit uut (
.a(a),
.b(b),
.cin(cin),
.sum(sum),
.cout(cout)
);
initial begin
// Initialize inputs
a = 4'b0000; b = 4'b0000; cin = 1'b0;
// Test vector 1
#10 a = 4'b0011; b = 4'b0101; cin = 1'b0; // 3 + 5 = 8
// Test vector 2
#10 a = 4'b1111; b = 4'b0001; cin = 1'b0; // 15 + 1 = 16
// Test vector 3
#10 a = 4'b1010; b = 4'b0101; cin = 1'b1; // 10 + 5 + 1 = 16
// Test vector 4
#10 a = 4'b1111; b = 4'b1111; cin = 1'b1; // 15 + 15 + 1 = 31
// Finish simulation
#10 $finish;
end
initial begin
$monitor("Time=%0t | a=%b b=%b cin=%b | sum=%b cout=%b", $time, a, b, cin, sum, cout);
end
endmodule
Explanation of the Testbench:
- The testbench applies different sets of inputs to the 4-bit adder.
$monitorprints the inputs and outputs every time they change.- The
#10delays simulate time between input changes. - The test vectors cover normal addition, carry generation, and carry-in scenarios.
- The simulation ends after all test vectors are applied.
Understanding the 4-bit Ripple Carry Adder is a stepping stone to mastering more advanced adders like Carry Lookahead or Carry Select adders. This foundational knowledge is vital for VLSI design interviews and practical digital system design.