Computer Architecture and Organization: L4: Micro-operations By: A. H. Abdul Hafez Abdul.hafez@hku.edu.tr, ah.abdulhafez@gmail.com, hafez@research.iiit.ac.in 1
Outlines 1. Arithmetic microoperation 2. Full adder 3. Four bit parallel adder 4. Adder subtractor circuit 5. Four bits arithmetic circuit 6. One stage logic unite 7. Logic microoperation example 8. Shift microoperation 1. Logic shift 2. Circular shift 3. Arithmetic shift 9. Shift unit 1. ALU 11. End 2
Main Types of Microoperations in Digital Computers 1. Register Transfer Microoperations transfer binary information from one register to another. 2. Arithmetic Microoperations perform arithmetic operations on numeric data stored in registers. 3. Logic Microoperations perform bit manipulation operations on (non-numeric) data stored in registers. 4. Shift Microoperations perform shift operations on data stored in registers. 3
Arithmetic Microoperations Symbolic Designation R3 R1 + R2 R3 R1 R2 R2 R 2 R2 R 2 + 1 Description Contents of R1 plus R2 transferred to R3 Contents of R1 minus R2 transferred to R3 Complement of the contents of R2 (1 s complement) 2 s complement of the contents of R2 R3 R1 + R 2 + 1 R1 plus the 2 s complement of R2 (subtraction) R1 R1 + 1 R1 R1-1 Increment the contents of R1 by one Decrement the contents of R1 by one 4
The full Adder Half Adder x y c s 1 1 1 1 1 1 1 c = xy s = xy + x y = x y x y c s Full Adder x y c n-1 c n s 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 x y c n-1 S c n 5
The full Adder The full adder accepts two input bits and an input carry and generates a sum output and an output carry A B C in C out 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6
Four-bits parallel adder 7
2 s complement form A negative value is the 2 s complement of the corresponding positive value. 8
Binary adder-subtractor B 3 A 3 A 2 A 1 B B 2 B 1 A M= Add M=1 Subtract M C 4 FA C 3 C 2 C 1 FA FA FA C S 3 S 2 S 1 S 9
C in 4-bit Arithmetic Circuit A X S 1 S B 1 1 2 3 S 1 S 4x1 MUX Y C FA C 1 D A 1 X 1 The output of the circuit is represented by the expression: D= A + Y + C in The value of Y is depend on the value of the selector lines. B 1 1 1 2 3 1 2 3 S 1 S S 1 S 4x1 MUX A 2 X 2 B 2 1 4x1 MUX A 3 X 3 Y 1 Y 2 FA C 2 FA C 3 D 1 D 2 1 CAO, by Dr. A.H. Abdul Hafez, CE Dept. HKU 1 B 3 1 2 3 S 1 S 4x1 Y MUX 3 FA C 4 D 3 C out
Select Input Output Microoperation S 1 S C in Y D = A + Y + C in B D = A + B Add 1 B D = A + B + 1 Add with carry 1 B D = A + B Subtract with borrow 1 1 B D = A + B + 1 Subtract 1 D = A Transfer A 1 1 D = A + 1 Increment A 1 1 1 D = A - 1 Decrement A 1 1 1 1 D = A Transfer A Arithmetic Circuit Function Table 11
Logic Microoperations 12
One Stage Logic Circuit S 1 S A i B i 1 4x1 MUX E i S S Output Operation 2 1 E = A B AND 3 1 E = A B OR 1 E = A B XOR 1 1 E = A Complement
Logic microoperation Examples Selective set Selective clear Selective complement Mask Compare Insert 14
Selective Set Setting a bit is turning that bit on (making it 1) 1 1 1 11 Content of Register A before Microoperation 11 Content of Register B (Logic Operand) ------- 111 Content of Register A after Microoperation What is the logic function that performs the selective set micro-operation? A or B
Selective Clear Clearing a bit is turning that bit off (making it ) 1 11 A Before 11 B (Logic Operand) ------- 1 A after What is the logic function that performs the selective clear micro-operation? A and B
Selective Complement Complementing a bit is negating the bit 1 1 11 A Before 11 B (Logic Operand) ------- 11 A after What is the logic function that performs the selective complement micro-operation? A xor B
Mask (Select) Operation Masking a bit is selecting the bit if the mask bit is 1 Mask bit = 1, 1 1 Mask bit = 1, 11 A Before 11 B (Mask) ------- 1 A after What is the logic function that performs the mask micro-operation? A and B
Compare Microoperation A A B 11 A 11 B ------- A A B
Insert Microoperation Inserting a group of bits into one part of a register e.g. insert 11 into the most significant nibble of a register Microoperation 1 11 11 A Before 1111 B (mask) ------- 11 A after Step no.1 Masking (A And B) Microoperation 2 11 A Before 11 B (insert) ------- 11 11 A after Step No.2 (A OR B)
Shift microoperations 1. Logical shift : transfers through the serial input R2 shr R2 7 R1 shl R1 7 Logical Shift 2. Circular shift : circulates the bits around the two ends without loss the information. R1 cil R1 R2 cir R2 7 7 Circular Shift (Rotate) 21
Shift microoperations 3. Arithmetic shift: shifts a signed binary number to the left or to the right. The sign bit must not changed because the sign of the number remains the same. R ashr R 7 Arithmetic Shift Right (Divide by 2) -8 4 2 1-8 4 2 1 Before 1 1 Before 1 1 After 1 1 After 1 1 1 Positive Numbers Negative Numbers 22
Shift microoperations 3. Arithmetic shift: shifts a signed binary number to the left or to the right. The sign bit may be changed. R ashl R 7-8 4 2 1 Arithmetic Shift Left (Multiply by 2) -8 4 2 1 Before 1 Before 1 1 After 1 No Overflow After 1 1 Overflow! Overflow occurs if, before the shift, V s = R 3 R 2 23 V s = R n-1 R n-2
4-bits combinational circuit shifter 24
Arithmetic logic shift unit ALU 25
Function Table for Arithmetic Logic Shift Unit 26
The end of the Lecture Thanks for your time Questions are welcome 27