Simple Arithmetic Operations Addition (Subtraction) of Numbers in The Sign Magnitude Representation
Simple Arithmetic Operations Addition (Subtraction) of Numbers in The Sign Magnitude Representation
Simple Arithmetic Operations Addition (Subtraction) of Numbers in The Sign Magnitude Representation
At consecutive binary positions, bits of arguments and a carry (borrow) bit from a previous position are added
(or subtracted) with carry (borrow) bit generation to the next position. The operation result is obtained after
the operation has been performed on all argument positions.
When big magnitude numbers are added the overflow can occur which is the carry over-passing the size of
the argument magnitudes (to the sign position). We have here the arithmetic overflow which results from the
fact that the result value does not fit the scope of number which can be written in a word of a given length.
The result is not correct and an execution error is signaled. The arguments of the operation should be then
decreased (shifted in the binary way to the right) and the operation should be performed again.
When we add numbers 010100010 (+162) and 011010001 (+209), we add magnitudes of the numbers and
we obtain
10100010
+11010001
(1)01110011 (-115 instead of +371)
A carry appeared to the sign position, the result has changed the sign and it is incorrect.
After we shift arguments one position to the right, the result will be correct.
Example
When adding positive or negative numbers that have very large magnitudes, the result obtained can be
incorrect due to the appearance of the overflow, as in the example below.
00111101 (+61)
+01010001 (+81)
10001110 (-114 instead of +142, the result has changed its sign)
10100010 (-94)
+11010001 (-47)
(1)01110011 (+115 instead of -141, the result has changed its sign)
Subtraction in the 2's complement representation is performed by adding to the minuend the 2's complement
of the subtrahend, i.e, by adding the complemented subtrahend with a binary number that has zeros on all
positions except the least significant position on which 1 appears.
01101101 (+109)
- 01010001 (+81)
01101101
+ 00000001
00011100 (+28)
Adders (subtractors) are built as a sequence of circuits, which perform operations on bit positions being
supported in some cases by circuits that speed-up carry generation.
We distinguish:
Parallel adders (subtractors) perform addition (subtraction) of consecutive pairs of digits in parallel in
consecutive executive cycles.
Ripple carry (parallel) adders are constructed as a ripple structure of elementary adders (i.e. a structure in
which a carry output from the preceding position is transferred to the input at the next position). In ripple
carry adders an important execution slowdown is observed due to the propagation of carries through all adder
positions (stages). The addition result can be read only after a period of time (delay), which corresponds to
the propagation of the carry in the worst case i.e. assuming it equal to 1 and propagated through all adder
positions. For long addition arguments the delay is many times bigger than the delay coming from a single
adder stage.
A ripple carry adder for 2's complement representation
To subtract numbers in 2's complement representation the same circuits are used as for addition (it is a big
advantage of the 2's complement representation) but the arguments are slightly transformed, which is
implemented in a very simple way. On one adder input, the minuend is supplied. On the other input, the
complemented subtrahend is supplied with the value one supplied to the carry input of the lest significant
position. The result appears on the adder output only when the carry propagation process has been
completed.
To eliminate the delay due to carry propagation in adders different solutions are applied.
the first solution is to built circuits, which generate carries for all positions in the same time, in parallel with
additions executed on all bit positions. It is useful, since the carry generation circuits incure smaller delays
than the carry propagation in ripple carry adder.
The adders of this type are called carry look-ahead adders. The carry generation circuits are 3-level logical
combinational circuits , which work according to the logic equations shown below.
C1 = g0 + C0p0
C2 = g1 + p1g0 + p1p0C0
Signal propagation concerned with carry generation for any position of the adder incurs a delay equal to the
signal transition time through three logical gates, instead of, in the worst case, the propagation of a signal
through all the adder circuitry.
An exemplary carry look-ahead adder scheme (for 4-bit arguments) is shown below.
Another solution for the adder which speeds-up addition is carry select adder (CSA). In this adder the
arguments bit sequences are divided into two halves. For each pair of half-sequences of argument bits
separate adders are built. For low-order bits it is one ripple carry adder. For high-order bits - two ripple carry
adders are used, working in parallel: one acting with the initial carry equal to 0 and another with the carry
equal to 0. When the carry from the low-order bits - adder is ready, the generated carry select one of the
results produced by the high-order bits - adder to be read as the addition result. Such an adder speeds-up
addition about 2 times, however at the cost of important build-up of the adder hardware. The constituent
adders in this solutions can be divided into smaller ones which work using the described idea of speculative
additions for conditional carries, thus further speeding-up the addition.
Serial adders
In the first figure a serial adder is shown which includes an elementary adder and 3 registers. The added
components are stored in two shift registers. The initial carry and the carry generated for each pair of
argument bits is stored in the D flip-flop. The sum bit - the addition result of each pair of bits and the carry
from the previous position (taken from the D) is written into the shift register for the sum. The writes take
place with the rising edge of the clock signal supplied on the input C. The same signal shifts the contents of in
all the 3 registers on position to the right. After a shift has been completed, the elementary adder "sees" two
new argument bits and implements their addition with the carry from the D flip-flop.
The second schematic shows more economic serial adder design, which is based on only two shift registers.
Initially both registers store the arguments X and Y of the addition. After completion of each two bits addition
the result is written into the accumulator register, on the input position which is liberated as a result of
shifting the contents of this register by clock signals. At the same time, the carry generated on the basis of
addition of two argument bits and the old carry is written into the flip-flop. When all bits of arguments have
been shifted out, the accumulator register contains the result of addition and the D flip-flop contains the last
generated carry.
An important type of arithmetic units is the binary comparator. It is a combinational circuit composed of many
stages which compare pairs of bits on consecutive positions of compared numbers. It transfers 2 elementary
comparison result bits between positions (in a similar way as an adder does). After propagation of elementary
comparison results through all comparator stages, the final logical circuit composed of 3 gates, generates the
final comparison result on its 3 outputs: equal, smaller, greater.
Logical-arithmetical units are frequently produced as multi-functional integrated arithmetic modules, which
perform different arithmetical and logical operations as well as their combinations on arguments of given
length, for example 4-bit. By connecting many such units in ripple structure we can build arithmetical-logical
units for long (multi-bit) arguments.
Below we can see the specification of an exemplary multi-functional arithmetic unit. The selection of a
function to be performed is done by setting the control inputs M, F 0, ..., F3.
For M=1 the circuit performs logical operations, for M=0 the circuit executes arithmetical operations or
combinations of logical and arithmetical operations. Inputs F i determine the selected operation for agiven M.
The arguments A, B are supplied on inputs Ai, Bi. The result appears on output Si. The pins Cn, Cn+1 are used
for input and output of a carry, which is useful when connecting modules in a ripple structure. The pins G, P
can be used to built more complicated adders. The pin A=B is used for comparison of numbers A, B.
The table shown below describes functions and control principles for the multi-functional arithmetical module.
For M=0 and F1 F2 F3 F4 = 1001 the module performs arithmetic addition. For M=0 and F 1 F2 F3 F4 = 0110,
the circuit performs arithmetic subtraction. The comparison of A and B is done for M=0 and F 1 F2 F3 F4 =
1001 and Cn = 1, with egzamining outputs G, P: when equal to 00 then A<B, when 10 then A=B, when 11
then A>B. For M=1 and F1 F2 F3 F4 = 1001 the circuit furnishes the complement of A on the output S. For
M=1 and F1 F2 F3 F4 = 1011 the circuit furnishes on the logical product of A and B. For M=0 and different
combinations on inputs F, the circuit performs different mixed logical-arithmetical operations.