5 2017 12 26!10 57 40 Am
5 2017 12 26!10 57 40 Am
5 2017 12 26!10 57 40 Am
Binary Adder-Subtractor
Figure 5.7 shows a 4-bit Adder-Subtractor logical circuit. The circuit
combines both addition and subtraction operations. The circuit differs
from the 4-bit binary adder shown in figure 5.6 by including an
exclusive-OR gate which receives input M and one of the inputs (B)
with each full-adder. The mode input M controls the operation of the
circuit as follows:
1. For M = 0
The circuit is an adder, since we have B 0 B . The full-adders
receive the value of B, the input carry C0 is 0, and the circuit
performs the addition of A to B (i.e. A+B).
2. For M = 1
The circuit becomes a Subtractor, since we have B 1 B . The
full-adders receive the value of B , the input carry C0 is 1. The B
inputs are all complemented and a 1 is added through the input
carry. The circuit performs the addition of A to 2's complement of
B.
Note.
1. For signed numbers, the result is A – B provided that there
is no overflow.
2. For unsigned numbers, the result is A – B for A ≥ B, and
the 2's complement of ( B – A ) for A < B.
Figure 5.7
11-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
Binary Incremental
Figure 5.8 shows a 4-bit Combinational Circuit Incrementer. Simply
this logic circuit is implemented by means of half-adders connected
in cascade. One of the inputs to the least significant half-adder is
connected to logic 1 and the other input connected to the least
significant bit of the number to be incremented. The circuit receives
the four bits A0 to A3, adds 1 to it, and generates the incremented
output in S0 to S3. The output carry C4 will be 1 only after
incrementing binary number 1111. This also causes output S0 to S3
to go to 0 (i.e. 0000).
The circuit shown in figure 5.8 can be extended to an n-bit binary
Incrementer by extending the diagram to include n half-adders. Keep
in mind that the least significant bit must have one input connected
to logic 1.
Figure 5.8
Arithmetic Circuit
Figure 5.9 shows a 4-bit arithmetic circuit. The circuit has four full-
adders and four multiplexers for choosing different operations. There
are two 4-bit inputs A and B and a 4-bit output D. the 4 inputs from A
connected directly to the X inputs of the binary adder, while the other
4 inputs from B and their complements are connected to two of the
data inputs of the multiplexers. The remaining two inputs of the
multiplexers are connected to logic 0 and logic 1.
The two selection inputs, S1 & S0 controls the operation of the four
multiplexers. The input carry Cin is connected to the input of the full-
adder FA0, while the other carries are connected from one stage to
the next.
The output of the binary adder s is calculated from the following
arithmetic sum:
D = A + Y + Cin … (5.1)
12-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
Figure 5.9
13-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
(1) P : R1 R1 R 2
1001 Content of R1
1101 Content of R2
0100 Content of R1 after P = 1
(2) P Q : R1 R 2 R3, R 4 R5 R 6
14-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
15-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
1. Logical Shift.
A logical shift transfers 0 through the serial input. The symbol shl
stands for logical shift-left, while shr stands for logical shift-right.
Examples
(1) R ← shl R
This microoperation, shift to the left one bit the contents of
register R. The bit transferred to the end position through the
serial input is assumed to be 0.
(2) R ← shr R
This microoperation, shift to the right one bit the contents of
register R. The bit transferred to the end position through the
serial input is assumed to be 0.
2. Circular Shift.
The circular shift circulates the bits of the register around the two
ends without loss of information. This is accomplished by
connecting the serial output of the shift register to its serial input.
The symbol cil stands for circular shift-left, while cir stands for
circular shift-right.
Examples
(1) R ← cil R
This microoperation circulates to the left one bit the contents
of register R. No bit transferred to any end positions of the
specified register.
(2) R ← cir R
This microoperation circulates to the right one bit the
contents of register R. No bit transferred to any end positions
of the specified register.
16-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
3. Arithmetic Shift.
Arithmetic Shift Microoperations shift a signed binary number to the
left (multiplies the signed binary number by 2) or to the right
(divides the signed binary number by 2).
Arithmetic shifts must leave the sign bit unchanged because the
sign of the number remains the same when the number is
multiplied or divide by 2.
For signed binary numbers, the left bit in a register holds the sign
bit (0 for positive and 1 for negative), and the remaining bits hold
the number magnitude. Negative numbers are in 2's
complement form.
Figure 5.11 shows a typical register of n bits, where bit Rn-1 in the
leftmost position holds the sign bit, and Rn-2 is the most significant
bit of the number with R0 the least significant bit.
Figure 5.11
17-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
Figure 5.12
Table 5.7
18-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
For an n-bit ALU, the circuit of figure 5.13 must be repeated n times.
The output carry Ci+1 of a given arithmetic stage must be connected to
the input carry Ci of the next stage in sequence.
The input carry to the first stage is the input carry Cin, which provides a
selection variable for the arithmetic operations.
The circuit shown in the figure provides eight arithmetic operation, four
logic operations, and two shift operations. The operations are selected
according to the variables S3, S2, S1, S0, and Cin. The input carry Cin
used for selecting arithmetic operations only.
19-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
Table 5.8 lists the fourteen operations of the ALU. When S3S2 = 00, the
first eight arithmetic operations are selected. For S3S2 = 01, the next
four logic operations are selected. The input carry has no effect during
the logic operations and is marked with don't-care x's. The last two
operations are shift operations and are selected with S3S2 = 10 and 11.
The other three selection inputs have no effect on the shift.
Figure 5.13
20-23 Yacoup K.
Hanna
Computer Architecture
Chapter Five Register Transfer and Microoperations
Table 5.8
Operation
Select Operation Function
S3 S2 S1 S0 Cin
0 0 0 0 0 F A Transfer A
0 0 0 0 1 F A 1 Increment A
0 0 0 1 0 F A B Addition
0 0 0 1 1 F A B 1 Add with carry
0 0 1 0 0 F A B Subtract with borrow
0 0 1 0 1 F A B 1 Subtraction
0 0 1 1 0 F A 1 Decrement A
0 0 1 1 1 F A Transfer A
0 1 0 0 x F A B AND
0 1 0 1 x F A B OR
0 1 1 0 x F A B XOR
0 1 1 1 x FA Complement A
1 0 x x x F shr A Shift right A into F
1 1 x x x F shl A Shift left A into F
21-23 Yacoup K.
Hanna