You are on page 1of 51

Computer Organization

(CE-313)

Lecture – 5

Instructors:
Ms.Raazia Saher
Mr. Marwan El-Haj
Ms. Madeeha Anjam

1
 Logic Microoperations
 Selective Set
 Selective Complement
 Selective Clear
 Mask Operation
 Insert Operation
 Clear Operation
 Shift Microoperations
 Logical
 Circular
 Arithmetic
 ALU
 The composite circuit for all operations

2
Categories of Microoperations
 Register Transfer Microoperations:
 Transfer binary information from one register to another
 Arithmetic Microoperations:
 Performs arithmetic operations on numeric data stored in registers.
 Logic Microoperations:
 Perform bit manipulation operations on non-numeric data stored in
registers
 Shift Microoperations:
 Perform shift operations on data stored in registers.

3
Logic Microoperations

4
Logic Microoperations
The “+” Sign has two different meanings in
logical operations:

Example:

+ between P + Q is OR operation
+ between R2 + R3 is ADD operation

5
Logic Microoperations
There are 16 different logic micro-operations that can
be performed on two different binary variables

6
Logic Microoperations

F0 is set to 0 and F15 is set to 1 operations

7
Logic Microoperations

F1 is AND and F7 is OR operations

8
Logic Microoperations

F6 is EX-OR and F9 is EX-NOR operations

9
Logic Microoperations

F8 is NOR and F14 is NAND operations

10
Logic Microoperations

F10 is B’ and F12 is A’ operations

11
Logic Microoperations

F3 is Transfer A and F5 is Transfer B operations

12
Logic Microoperations
Similarly you can see the following
operations

F2 = xy’, F4 = x’y, F11 = x+y’ , F13 = x’+y

13
Logic Microoperations

14
Logic Microoperations
The hardware implementation
The hadwere implementation requires that logic gates be inserted for
each bit or pair of bits in the registers to perform the required logic
function

Although there are 16 logic microoperations, most computers use


only four AND, OR, XOR and compliment gates from which others
can be derived easily.

F2 = xy’, F4 = x’y, F11 = x+y’ and F13 = x’+y


15
Logic Microoperations

16
Logic Microoperations
Some applications
 Logic microoperations are very useful for manipulating individual bits or portion
of word stored in register

 These can be used for:


 Change bit values
 Delete group of values
 Insert new bit values

F2 = xy’, F4 = x’y, F11 = x+y’ and F13 = x’+y


17
Logic Microoperations
The Selective-Set microoperation
The selective-set operation set to 1 the bits in
Register A where, there are corresponding 1’s in
Register B. It does not affect the bit position
that have 0’s in the B.
Example:

Thus we can conclude that OR operation can


be used to selectively set the bits of a register.
18
Logic Microoperations
The Selective-Complement microoperation
 The selective-complement operation complement
to 1 the bits in Register A where, there are
corresponding 1’s in Register B. It does not affect
the bit position that have 0’s in the B.
 Example:

 Thus we can conclude that EXOR operation can be used to


selectively complement the bits of a register. 19
Logic Microoperations
The Selective-Clear microoperation
The selective-clear microoperation clears the 0
bits in A only where, there are corresponding
1’s in Register B.
Example:

A  A B

Thus we can conclude that Boolean operation


performed on the individual bits is AB’.
20
Logic Microoperations
The MASK microoperation
The mask microoperation is simillar to seletive-
clear except that the bits of A are cleared only
when there are corresponding 0’s in B

Example:

Thus we can conclude that mask


microoperation is actually like a AND operation

21
Logic Microoperations
The INSERT microoperation
The insert microoperation inserts a new value into
the group of bits. This is done as follows:
 First mask the bits
 ORing them with the required value
 Example:

Thus we can conclude that the mask is AND


microoperation and insert is OR microoperation.
22
Logic Microoperations
The CLEAR microoperation
The CLEAR compares the word in A and B and
produce an all 0’s result if the two numbers are
equal.
Example:

Thus we can conclude that the clear


microoperation can be achieved by XOR
operation
23
Computer Organization
(CE-313)

Lecture – 6

Instructors:
Ms.Raazia Saher
Mr. Marwan El-Haj
Ms. Madeeha Anjam

24
 Shift Microoperations
 Logical
 Circular
 Arithmetic
 ALU
 The composite circuit for all operations

25
Categories of Microoperations
 Register Transfer Microoperations:
 Transfer binary information from one register to another
 Arithmetic Microoperations:
 Performs arithmetic operations on numeric data stored in registers.
 Logic Microoperations:
 Perform bit manipulation operations on non-numeric data stored in
registers
 Shift Microoperations:
 Perform shift operations on data stored in registers.

26
Shift Microoperations
 Logical
 Shift Left (shl)
 Shift Right (shr)

 Circular (Rotate)
 Circular Left (cil)
 Circular Right (cir)

 Arithmetic
 Arithmetic-Shift Left (ashl)
 Arithmetic-Shift Right (ashr)
27
Shift Microoperations
Logical Shift
 shr (Logical shift right)
 Shl (Logical shift left)
 These are used for logical shift left and
logical shift right the bits of register by
one position.
 The symbolic representation of operation
is:

28
Shift Microoperations
Logical Shift Right

Example :
1 0 1 0 1 1 0 1 (original)
0 1 0 1 0 1 1 0 (after shr)

29
Shift Microoperations
Logical Shift left

Example :
1 0 1 0 1 1 0 1 (original)
0 1 0 1 1 0 1 0 (after shl)

30
Shift Microoperations
Few Important Points

 There is always loss of one bit

 Zero is provided to fill the blank space


produced

31
Shift Microoperations
Circular Shift

 Circular shift is also known as rotate operation


 This operation circulates the bits of the register
around the two ends without the loss of
information
 There are two types:
cil (Circular shift left)
cir (Circular shift right)

32
Circular Shift Right

Example :
1 0 1 0 1 1 0 1 (original)
1 1 0 1 0 1 1 0 (after cir)
33
Circular Shift Left

Example :
1 0 1 0 1 1 0 1 (original)
0 1 0 1 1 0 1 1 (after cil)
34
Shift Microoperations
Arithmetic Shift

Shift the signed binary number to the left or


right and are referred as:

 Arithmetic Shift Right (ashr)


 Arithmetic Shift left (ashl)

35
Arithmetic Shift Right
Arithmetic shift right divides the signed
number by 2
Example 1:
0100 (+4) 4/2=2
0010 (+2)
Example 2:
1010 (-6) -6/2 = -3
1101 (-3)
36
Arithmetic Shift Right
Arithmetic shift right leaves the sign bit
unchanged and shift the number
(including sign bit) to the right
 Example
1100 (-4)
0110 ( sign bit has been
changed ) put 1 on left side to maintain
the –ve sign of number
1110 (-2)
37
Arithmetic Shift Left
Arithmetic shift left multiplies the signed
number by 2
 Example 1
0010 (2) 2*2=4
0100 (4)
 Example 2
1110 (-2) -2 * 2 = -4
1100 (-4)
38
Shift Microoperations

39
Shift Microoperations
Arithmetic Shift
(Few important points)
 Arithmetic shifts must leave the sign bit
unchanged because sign of the number
remain same when it is multiplied or
divided by 2

40
Shift Microoperations
Arithmetic Shift
(Few important points)
 A sign reversal occurs if the bit in Rn-1
changes in value after the shift
 This happens if the multiplication causes
an overflow

41
Arithmetic Shift Left
 Arithmetic Shift Left (Overflow)
 Example
1010 (-6)
0100 (overflow)

42
Shift Microoperations
 An overflow flip-flop can be used to
predict the overflow

43
Arithmetic Shift Left
 The operation is same with Logic shift-left
 The only difference is you need to check
overflow problem
Carry out
Sign bit
R 2  ashl R 2

LSB

Rn-1 Rn-2
0 insert
Vs=1 : Overflow
44
Vs=0 : use sign bit
Shift Microoperations
Hardware implementation
 A possible choice for a shift unit would be
a bidirectional shift register with parallel
load
 Two clock-pulses will be required
One for loading the data into the register
One for the initiating the shift

 But if we require the generation with one


clock pulse the combinational circuit can
be used 45
Shift Microoperations

46
Arithmetic Logic Shift Unit (ALU)

 Instead of having individual registers


performing the microoperations directly,
computer system employ a number of
storage registers connected to a common
operational unit called arithmetic logic unit
(ALU)
 To perform the microoperation, the
contents of special register are placed in
the inputs of ALU
47
Arithmetic Logic Shift Unit (ALU)

 The arithmetic, logic and shift circuits can


be combined into one ALU with common
selection variables
 One stage of ALU is shown in Figure 4-13.

48
49
Arithmetic Logic Shift Unit (ALU)
 The diagram shown in Figure 4-13
provides eight arithmetic operations, four
logic operations and two shift operations
 Each operator is selected with five
variables S3, S2, S1 S0 and Cin
 The Cin is used for selecting an arithmetic
operation only

50
Arithmetic Logic Shift Unit (ALU)

51

You might also like