Chapter Three RTL
Chapter Three RTL
R1 7 6 5 4 3 2 1 0
15 0
PC
Numbering of bits
15 87 0
Upper byte PC(H) PC(L) Lower byte
AR
x0C 19
x12 x0E 34
R1 x10 45
100 x12 66
x14 0
x16 13
R1←M[AR] x18 22
RAM
R1 R1
100 66
3-4 Arithmetic Microoperations
• The microoperations most often encountered in digital
computers are classified into four categories:
– Register transfer microoperations
– Arithmetic microoperations (on numeric data stored in
the registers)
– Logic microoperations (bit manipulations on non-
numeric data)
– Shift microoperations
3-4 Arithmetic Microoperations cont.
• The basic arithmetic microoperations are: addition,
subtraction, increment, decrement, and shift
• The following table shows the arithmetic microoperation
3-4 Arithmetic Microoperations Binary
Adder
B3 A3 B2 A2 B1 A1 B0 A0
C3 C2 C1
FA FA FA FA C0
C4 S3 S2 S1 S0
C3 C2 C1 C0
FA FA FA FA
C4 S3 S2 S1 S0
4-bit adder-subtractor
3-4 Arithmetic Microoperations Binary
Adder-Subtractor
• The mode input M controls the operation
• When M=0, the circuit is an adder and
B 0=B and the input carry is 0, then A+B
• When M=1, the circuit becomes subtractor
B 1=B’ and the input carry is 1, then A plus
2’complement of B
The subtraction A-B can be carried out by the following steps
• Take the 1 ’ complement of B
• Get the 2 ’ complement by adding 1
• Add the result to A
3-4 Arithmetic Microoperations Binary
Incrementer
A3 A2 A1 A0 1
x y x y x y x y
HA HA HA HA
C S C S C S C S
C4 S3 S2 S1 S0
• Gate:
• Gate:
• Gate:
• Gate:
1 0 E=AB AND
1 Ei
1 1 E=A Complement
Shift Left
**Note that the bit ri is the bit at position (i) of the register
3-6 Shift Microoperations:
Logical Shifts
• A logical Shift transfers 0 through the serial
input (Zero inserted)
• Logical Shift Right: R1←shr R1
The same
• Logical Shift Left: R2←shl R2
The same
? rn-1 r3 r2 r1 r0 0
Logical Shift Left
• Example: use a logical shift left on the bit pattern 10011000.
• Solution: The leftmost bit is lost and a 0 is inserted as the rightmost bit.
3-6 Shift Microoperations:
Circular Shifts (Rotate Operation)
• Circulates the bits of the register around the
two ends without loss of information
• Circular Shift Right: R1←cir R1
The same
• Circular Shift Left: R2←cil R2 The same
rn-1 r3 r2 r1 r0
Circular Shift Left
• Use a Circular Left Shift Operation on the bit pattern 10011000.
• Solution: The leftmost bit is circulated and becomes the rightmost bit.
3-6 Shift Microoperations
Arithmetic Shifts
• Shifts a signed binary number to the left or right
• An arithmetic shift-left multiplies a signed binary
number by 2: ashl (00100): 01000
• An arithmetic shift-right divides the number by 2
ashr (00100) : 00010
• The sign bit is 0 for positive and 1 for negative.
Sign
Bit
3-6 Shift Microoperations
Arithmetic Shifts cont.
• An overflow may occur in arithmetic shift-left, and
occurs when the sign bit is changed (sign reversal)
• An overflow flip-flop Vs can be used to detect an
arithmetic shift-left overflow
Vs = Rn-1 Rn-2
Rn-1 1 overflow
Vs=
Rn-2 0 no overflow
3-6 Shift Microoperations
Arithmetic Shifts
Arithmetic shift right:
Rn-1 remains unchanged;
Rn-2 receives Rn-1, Rn-3 receives Rn-2, so on.
For a negative number, 1 is shifted from the sign bit to
the right.
A negative number is represented by the 2’s
complement form. The sign bit remained unchanged.
3-6 Shift Microoperations
Arithmetic Shifts
Arithmetic Shift Right :
Example 1
0100 (4) 0010 (2)
Example 2
1010 (-6) 1101 (-3)
3-6 Shift Microoperations
Arithmetic Shifts
Arithmetic Shift Left :
• The operation is same with Logic shift-left
• transfers 0 through the serial input (Zero inserted)
• The only difference is you need to check overflow
problem
Carry out
Sign bit
R2←ashl R2
LSB