U-I. Logic and Shift Micro Operations
U-I. Logic and Shift Micro Operations
• These operations consider each bit of the register separately and treat
them as binary variables.
• They can be determined from all possible truth tables obtained with two binary variables.
Hardware Implementation
• The hardware implementation of logic microoperations requires that logic gates be inserted for each bit or
pair of bits in the registers to perform the required logic function.
S1
S0 4×1 S1 S0 Output Operation
Ai
MUX
Bi 0 0 E =A B XOR
0
0 1 E =A B OR
1 Ei 1 0 E =A B AND
1 1 E =A Complement
Selective-set
Selective-complement
Selective-clear
Mask (Delete)
Clear
Insert
Selective-set:
The selective-set operation sets to 1, the bits in register A where there are
corresponding 1's in register B.
1010 A before
1100 B (logic operand)
1110 A after
AAB
The OR microoperation can be used to selectively set bits of a register.
Selective-complement:
1010 A before
1100 B (logic operand)
0110 A after
AA B
The exclusive-OR microoperation can be used to selectively set bits of a register.
Selective-clear:
The selective-clear operation clears to 0, the bits in A, only where there are
corresponding 1's in B.
1010 A before
1100 B (logic operand)
0010 A after
AA B
mask:
AAB
The mask operation is an AND microoperation.
insert:
The insert operation inserts a new value into a group of bits.
This is done by first masking the bits to be replaced and then ORing them
with the bits to be inserted
0110 1010 A before
0000 1111 B (mask)
0000 1010 A after masking
And then insert the new value
clear:
The clear operation compares the words in A and B and produces an all
0' s result if the two numbers are equal.
1010 A
1010 B
0000 AA B
The contents of the register can be shifted to the left or to the right.
As being shifted, the first flip-flop receives its binary information from the serial
input.
Shift Left
**Note that the bit ri is the bit at position (i) of the register
LSB / RMB: Least Significant Bit (or) Right Most Bit
MSB / LMB : Most Significant Bit (or) Left Most Bit
Logical shift
A logical shift transfers 0 through the serial input.
The symbols shl and shr are for logical shift-left and shift-right microoperations.
For example :
R1 shl R1
R2 shr R2
A right logical shift operation
0
Logical shift
When a number is Logical shifted left by When a number is Logical shifted right
n times the number is multiplied by 2n. by n times the number is divided by 2n.
Circular shift
In a circular shift the serial input is the bit that is shifted out of the other end of the
register.
The symbols cil and cir are for circular shift left and right , respectively.
For example :
R1 cil R1
R1 cir R2
A right circular shift operation
Circular shift
Arithmetic shift
The symbols ashl and ashr are for arithmetic shift left and right ,
respectively.
For example :
R1 ashl R1
R2 ashr R2
Arithmetic shift
rn-1 r3 r2 r1 r0 ?
rn-1 r3 r2 r1 r0 0
Sign Arithmetic Shift Left
Bit
10101011 10101011
11010101 11010110
Ramesh Masuna-Associate professor - ACE engineering
college
Shift Microoperations
Arithmetic shift
An arithmetic shift-left multiplies a signed binary number by 2.
Arithmetic shifts must leave the sign bit unchanged because the sign of the number remains the same when
it is multiplied or divided by 2.
Before the shift, if the leftmost two bits differ, the shift will result in an overflow.
Hardware Implementation
Select 0 for shift left(down)
Serial input (IR) 1 for shift right(up)
S
MUX 0 H0
0
1
A0
A1 S
H1
0 MUX 1
A2 1
A3
S
H2
0 MUX 2
1
S
H3
0 MUX 3
1
Computer systems employ a number of storage registers connected to a common operational unit
called an arithmetic logic unit (ALU).
To perform a microoperation, the contents of specified registers are placed in the inputs of the
common ALU.
The ALU performs an operation and the result of the operation is then transferred to a destination
register.
The ALU is a combinational circuit so that the entire register transfer operation from the source
registers through the ALU and into the destination register can be performed during one clock pulse
period .
The shift microoperation is often performed in a separate unit, but sometimes the shift unit is
made part of the overall ALU.
S3
S2
S1 Ci
S0
Di
One stage of
arithmetic
circuit (Fig.A) Select
One stage of Fi
ALU Ci+1 0 4×1
1 MUX
One stage of Ei 2
logic circuit
Bi (Fig.B) 3
Ai
shr
Ai+1
shl
Ai-1