Skip to content
Digital circuitsCHIP Chair Logo

4-bit Arithmetic

We will now discuss some arithmetic circuits that perform operations with 4 bits. We will see examples of 4-bit adders and subtractors and a very simple ALU (Arithmetic Logic Unit).

Example: 4-bit number addition

In this example we will see how we can add two 4-bit binary numbers. Binary adders (ripple-carry adders) can be built from full adders (full adders) and a half adder (half adder). Since we are dealing with a 4-bit addition, we will need to cascade 3 full adders and a half adder, or else 4 full adders if we configure the first full adder as a half adder.

CircuitVerse has an object named adder that implements an adder.

Circuit elements
Input AInput BInput CinSum OutputCout Output

The inputs A and B are the operands being added and Cin is the input carry bit. The outputs are Sum with the result and Cout with the output carry. If you hover the mouse over the inputs and outputs of the object you can see its name.

The circuit that performs the addition cascades 3 full adders and a half adder:

4-bit adder

If convenient, we can implement the same circuit with 4 full adders. The function of the half adder can be performed by a full adder if we feed a constant 0 to its input Centrada.

4-bit adder (alternative)

Implement it in CircuitVerse:

4-bit adder in CircuitVerse

In this example the input values are:

  • Input A = 0010
  • Input B = 0001

And the outputs:

  • Output S = A + B
  • Output Cout = Carry-out

At Jutge.org, the 4-bit and n-bit algebra exercises use the bus notation A[3:0] (defined in Busos) and 4- or n-bit inputs/outputs. To allow Jutge to validate the circuit correctly, you must use the BitWidth property of the inputs, outputs and adders. This parameter can be seen in the Properties menu:

4-bit input AProperties

Once the BitWidth is set to 4 we can perform the addition with a single adder and simplify the circuit:

Addition with a single adder

In CircuitVerse, the 4-bit inputs and outputs have black wires, while Cin and Cout, being only 1 bit, are green.

Example: 4-bit subtraction

To subtract two binary numbers we use the formula:

S=AB=A+(B¯+1)

In this example we will perform a 4-bit subtraction. Consider:

  • Input A = 1100 (12 in decimal)
  • Input B = 0101 (5 in decimal)
  • Output S = A - B (4 bits)
  • Output Cout = Carry-out

First negate B:

B=0101B¯=1010

Then perform the addition:

S=A+B¯+1=1100+1010+1=1100+1011=0111

The following table specifies this operation bit by bit (it is not a truth table):

bitAiBi¯CiSiCsortida
0 (LSB)00110
101010
210010
3 (MSB)11001

The circuit that performs the subtraction cascades 4 adders, with B¯ and Centrada=1:

4-bit subtractor

In CircuitVerse it is represented like this:

4-bit subtractor in CircuitVerse

With BitWidth = 4 we can simplify the circuit:

Subtractor with a single adder

Example: Selecting operations

Beyond performing arithmetic operations, arithmetic circuits can also implement operation selection. ALUs (Arithmetic Logic Units) allow choosing between operations based on a variable. This example explores this capability.

We want to implement a circuit that selects between a sum and a subtraction based on the input variable op.

  • If op=0, a sum is performed.
  • If op=1, a subtraction is performed.

To perform the 4-bit addition A+B we will use a 4-bit Adder. The input carry (Cin) must be 0, so we will connect a ground.

Sum block

To perform the subtraction we will use:

S=AB=A+B¯+1

To negate B we will use a 4-bit NOT gate. The input carry (Cin) must be 1, so we will use a power source.

Adding the circuit piece that performs the subtraction we obtain:

Sum and subtraction

Both Power and Ground can be found in the CircuitVerse inputs menu. Both act as constants. Power always has the value 1 and Ground always has the value 0.

Now we need to add the part of the circuit capable of choosing between one operation and the other based on the input variable op. We will use a multiplexer, as shown in the Multiplexors section of the combinational circuits. Multiplexers pass one signal or another depending on a select input, and that is what we require here.

The complete circuit, after adding this final element, is the following:

Selected sumSelected subtraction

We can use a multiplexer with more than two inputs to handle more possible operations.
In the CircuitVerse properties menu you can modify the number of inputs with the control signal size property.

ALUs (ALU) typically select between 4 operations (4-input multiplexers) with a 2-bit selector op.

4-input multiplexer

Exercises on Jutge.org: Introduction to Digital Circuit Design

Remember that to access the exercises and for Jutge to evaluate your solutions you must be enrolled in the course. You will find all instructions here.



CHIP Chair Logos

Xavier Casas, Francesc Madrid
Lliçons.jutge.org
© Universitat Politècnica de Catalunya, 2026

lliçons.jutge.org