You are on page 1of 25

Logic Microoperations

• Logic microoperations specify binary operations for strings of bits


stored in registers.

• These operations consider each bit of the register separately and treat
them as binary variables.

• Symbols used for logical microoperations:


OR: 
AND: 
XOR:

Ramesh Masuna-Associate professor - ACE engineering


college
Logic Microoperations

List Of Logical Microoperations


• There are 16 different logic operations that can be performed with two binary variables.

• They can be determined from all possible truth tables obtained with two binary variables.

TABLE : Truth Tables for 16 Functions of Two Variables

Ramesh Masuna-Associate professor - ACE engineering


college
Logic Microoperations

TABLE: Sixteen Logic Microoperations

Ramesh Masuna-Associate professor - ACE engineering


college
Logic Microoperations

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

Ramesh Masuna-Associate professor - ACE engineering


college
Applications of Logic Microoperations

Logic microoperations can be used to change bit values, delete a


group of bits, or insert new bit values into a register .

 Selective-set
 Selective-complement
 Selective-clear
 Mask (Delete)
 Clear
 Insert

Ramesh Masuna-Associate professor - ACE engineering


college
Applications of Logic Microoperations

Selective-set:

 The selective-set operation sets to 1, the bits in register A where there are
corresponding 1's in register B.

 It does not affect bit positions that have 0's in B.

1010 A before
1100 B (logic operand)
1110 A after

AAB
The OR microoperation can be used to selectively set bits of a register.

Ramesh Masuna-Associate professor - ACE engineering


college
Applications of Logic Microoperations

Selective-complement:

 The selective-complement operation complements bits in A where there are


corresponding l's in B .

It does not affect bit positions that have 0's in B .

1010 A before
1100 B (logic operand)
0110 A after

AA B
The exclusive-OR microoperation can be used to selectively set bits of a register.

Ramesh Masuna-Associate professor - ACE engineering


college
Applications of Logic Microoperations

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

AA B

Ramesh Masuna-Associate professor - ACE engineering


college
Applications of Logic Microoperations

mask:

 The mask operation is similar to the selective-clear operation except that


the bits of A are cleared only where there are corresponding 0' s in B.
1010 A before
1100 B (logic operand)
1000 A after

AAB
The mask operation is an AND microoperation.

Ramesh Masuna-Associate professor - ACE engineering


college
Applications of Logic Microoperations

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

0000 1010 A before


1001 0000 B (insert)
1001 1010 A after insertion

Ramesh Masuna-Associate professor - ACE engineering


college
Applications of Logic Microoperations

clear:

 The clear operation compares the words in A and B and produces an all
0' s result if the two numbers are equal.

This operation is achieved by an exclusive-OR microoperation

1010 A
1010 B
0000 AA B

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

 Used for serial transfer of data.

 Also used in conjunction with arithmetic, logic, and other data-processing


operations.

 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.

Three types of shift:


1. Logical shift
2. Circular shift
3. Arithmetic shift

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

MSB / LMB LSB / RMB

Serial Input rn-1 r3 r2 r1 r0 Serial Output

Determines Shift Right


the “shift”
type

Serial Output r1 Serial Input


rn-1 r3 r2 r0

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

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

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

 A left logical shift operation:


0

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

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.

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

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

 A left circular shift operation:

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

Circular shift

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

Arithmetic shift

 An arithmetic shift is a microoperation that shifts a signed binary


number to the left or right.

 The symbols ashl and ashr are for arithmetic shift left and right ,
respectively.

For example :
R1  ashl R1
R2  ashr R2

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

Arithmetic shift

rn-1 r3 r2 r1 r0 ?

Sign Arithmetic Shift Right


Bit

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.

An arithmetic shift-right divides the 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.

 left arithmetic shift operation must be checked for the overflow.

Before the shift, if the leftmost two bits differ, the shift will result in an overflow.

An overflow flip-flop Vs can be used to detect an arithmetic shift-left overflow.


Vs = Rn-1 ⊕ Rn-2
If Vs = 0, there is no overflow, but if Vs = 1, there is an overflow and a sign reversal after the shift.
 Vs must be transferred into the overflow flip-flop with the same clock pulse that shifts the register.

Ramesh Masuna-Associate professor - ACE engineering


college
Shift Microoperations

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

Serial input (IL)

Ramesh Masuna-Associate professor - ACE engineering


college
Examples of Shift Micro Operations

Example: Assume R1=11001110, then:


Arithmetic shift right once : R1 = 11100111
Arithmetic shift right twice : R1 = 11110011
Arithmetic shift left once : R1 = 10011100
Arithmetic shift left twice : R1 = 00111000
Logical shift right once : R1 = 01100111
Logical shift left once : R1 = 10011100
Circular shift right once : R1 = 01100111
Circular shift left once : R1 = 10011101

Ramesh Masuna-Associate professor - ACE engineering


college
Arithmetic Logic Shift Unit

 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.

Ramesh Masuna-Associate professor - ACE engineering


college
Arithmetic Logic Shift Unit

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

Ramesh Masuna-Associate professor - ACE engineering


college
Arithmetic Logic Shift Unit

TABLE : Function Table for Arithmetic Logic Shift Unit

Ramesh Masuna-Associate professor - ACE engineering


college

You might also like