4 Substractor
4 Substractor
Experiment-4
Aim: To write VHDL code for Adder circuits: 4-bit Half Adder, 4-bit Full Adder and observe the
waveform and synthesize the code with technological library with given Constraints.
Apparatus: Modelsim PE Student Edition 10.1 Software.
Theory:
Binary Subtractor is a decision making circuit that subtracts two binary numbers from each other,
for example, X – Y to find the resulting difference between the two numbers.
Binary Subtraction can take many forms but the rules for subtraction are the same whichever
process you use. As binary notation only has two digits, subtracting a “0” from a “0” or a “1” leaves
the result unchanged as 0-0 = 0 and 1-0 = 1. Subtracting a “1” from a “1” results in a “0”, but sub-
tracting a “1” from a “0” requires a borrow. In other words 0 – 1 requires a borrow.
Half Subtractor
A half subtractor is a logical circuit that performs a subtraction operation on two binary digits. The
half subtractor produces a sum and a borrow bit for the next stage.
1
Adama Science & Technology University
School of Electrical Engineering &Computing
Department of Electronic &Communication Engineering
From the truth table of the half subtractor we can see that the DIFFERENCE (D) output is the result
of the Exclusive-OR gate and the Borrow-out (Bout) is the result of the NOT-AND combination.
Then the Boolean expression for a half subtractor is as follows.
For the DIFFERENCE bit:
D=X⊕Y
For the BORROW bit
B =(NOT X) .Y
ENTITY Half_Subtractor IS
PORT(X,Y: IN STD_LOGIC_vector(3 downto 0); DIFF, BARROW: OUT STD_LOGIC_vector(3
downto 0));
END Half_Subtractor;
2
Adama Science & Technology University
School of Electrical Engineering &Computing
Department of Electronic &Communication Engineering
Full Subtractor
The main difference between the Full Subtractor and the previous Half Subtractor circuit is that a
full subtractor has three inputs. The two single bit data inputs X (minuend) and Y (subtrahend) the
same as before plus an additional Borrow-in (B-in) input to receive the borrow generated by the
subtraction process from a previous stage
Table 3.2. The Truth table of the Full Adder Circuit.
3
Adama Science & Technology University
School of Electrical Engineering &Computing
Department of Electronic &Communication Engineering
Results: VHDL code for the adder circuits is written, the waveform is observed and the code is
synthesized with the technological library and is verified.