0% found this document useful (0 votes)
28 views31 pages

Microoperations III

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views31 pages

Microoperations III

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

CSEN402: Computer Organization

Microoperations III

Nada Sharaf

Spring Semester 2021

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 1 / 31


Lecture Outline

Arithmetic Operations
Arithmetic Circuit
Logic Operations
Shift Operations

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 2 / 31


Arithmetic Circuit

One composite arithmetic circuit


The basic component is the parallel adder
Only by controlling inputs, different operations could be carried out

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 3 / 31


Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 4 / 31
Arithmetic Circuit

Two 4-bit inputs: A and B


Cin as the carry to the full-adder
in the lease significant location
One 4-bit output: D
A bits go directly to the adder
Multiplexers have as data
inputs:
I B bits
I Complement of the B bits
I Logic 0
I Logic 1

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 5 / 31


Arithmetic Circuit II

Simulate A + B: Sli.do Code


836692 S1 = 0, S0 = 0, Cin = 0
Simulate A - B:
I B’
I Cin = 1
S1 = 0, S0 = 1, Cin = 1

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 6 / 31


Arithmetic Circuit III

Output = A + Y + Cin
S1 S0 Cin Y D Micro operation
0 0 0 B A+B Addition
0 0 1 B A+B+1 Addition with carry
0 1 0 B’ A+B’ Subtract with Borrow
0 1 1 B’ A+B’+1 Subtraction
1 0 0 0 A Transfer A
1 0 1 0 A+1 Increment A
1 1 0 1(1111) A-1 Decrement A
1 1 1 1(1111) A(A-1+1) Transfer A

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 7 / 31


Logic Microoperations

Binary operations
For bits stored inside the registers
Bit-Wise: consider bits separately
Each bit is treated as a binary variable
Examples: ∧, ∨, ⊕
+ vs ∨
I ∨ represent the oring microoperation
I + is used as the arithmetic addition when used as a microoperation
I + is used as the or boolean function when used as part of the control
function

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 8 / 31


Examples

P : R1 ← R1 ⊕ R2
1010 Contents of R1
1100 Contents of R2
--------
0110 Contents of R1 after P=1
P + Q : R1 ← R2 + R3, R4 ← R5 ∨ R6

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 9 / 31


Possible Logic Microoperations

If we have two inputs, how many logic functions can we have


16
Why?
x y F0 F1 F2 F3 F4 ... F13 F14 F15
0 0 0 0 0 0 0 ... 1 1 1
0 1 0 0 0 0 1 ... 1 1 1
1 0 0 0 1 1 0 ... 0 1 1
1 1 0 1 0 1 0 ... 1 0 1

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 10 / 31


16 Logic Microoperations

Boolean Function Microoperation Name Boolean Function Microoperation Name

F0=0 F ←0 Clear F8=(x+y)’ F ←A∨B


F1=xy F ←A∧B AND F9=(x⊕y)’ F ←A⊕B

F2=xy’ F ←A∧B F10=y’ F ←B Complement B


F3=x F ←A Transfer A F11=x+y’ F ←A∨B
F4=x’y F ←A∧B F12=x’ F ←A Complement A
F5=y F ←B Trasfer B F13=x’+y F ← A0 ∨ B
F6=x⊕y F ←A⊕B XOR F14=(xy)’ F ←A∧B NAND
F7=x+y F ←A∨B OR F15=1 F ← all10 s Set all to 1’s

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 11 / 31


Implementation of Logic Microoperations

Logic function should be performed for every two pairs of bits


Mots computers usually implement only AND ∧, OR ∨, XOR ⊕,
Complement
Other operations could be derived from them

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 12 / 31


Hardware Implementation II

S1 S0 Output Operation
0 0 A∧B AND
0 1 A∨B OR
1 0 A⊕B XOR
1 1 A Complement

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 13 / 31


Applications

Manipulating part of a register


Manipulating individual bits
In the following examples we will try to manipulate parts of the bits
of register A

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 14 / 31


Selective Set

We want to set a group of bits in register A i.e. change then to 1


Use a B register with the same size
Whenever a bit in B has the value 1, the corresponding bit in A is set
The other bits of A are left unchanged
Example:
1010: A before
1100: B (logic operand)
------------
1110: A after
The operations is ∨
A←A∨B

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 15 / 31


Selective Complement

We want to complement a group of bits in register A


Use a B register with the same size
Whenever a bit in B has the value 1, the corresponding bit in A is
complemented
The other bits of A are left unchanged
Example:
1010: A before
1100: B (logic operand)
------------
0110: A after
The operations is ⊕
A←A⊕B

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 16 / 31


Selective Clear

We want to clear a group of bits in register A i.e. change to 0


Use a B register with the same size
Whenever a bit in B has the value 1, the corresponding bit in A is
cleared
The other bits of A are left unchanged
Example:
1010: A before
1100: B (logic operand)
------------
0010: A after
The operations is A ← A ∧ B 0

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 17 / 31


Mask Operation

We want to clear a group of bits in register A i.e. change to 0


Use a B register with the same size
Whenever a bit in B has the value 0, the corresponding bit in A is
cleared
The other bits of A are left unchanged
Example:
1010: A before
1100: B (logic operand)
------------
1000: A after
The operations is ∧
A←A∧B

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 18 / 31


Introducing a Pattern

If we need to insert a pattern into some bits of a register


Assume Register A having bits: 0110 1010
We want to have the pattern 1001 as the left-most 4 bits
How can we do it?
1 A mask operation (AND) to clear the desired bits
01101010 Original A
00001111 Mask
---------------
00001010 A after masking
2 A selective set (OR) operation to insert the pattern
00001010 A after masking
10010000 A Pattern
---------------
10011010 A after masking

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 19 / 31


Example

Given A: 11011001. What is the operand (B) and the microoperation that
converts A to
11000001 Use sli.do Code: 836692
I Selective Clear
I B: 00011000
I A ← A ∧ B0

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 20 / 31


Shift Microoperations

For serial transfer of data


There are different types according to the serial input
Left or right shift

Right Shift

Left Shift

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 21 / 31


Logical Shift

Transfers 0 through the serial input


shl and shr

R1 ← shl R1
R2 ← shr R2
The register must be the same on both sides

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 22 / 31


Circular Shift/ Rotate

Circulates the bits without losing information


cil and cir
The serial output is connected to the serial input

Right Circular Shift

Left Circular Shift

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 23 / 31


Arithmetic Shifts

For signed numbers


Multiplies (shift left) and divides (shift right)
It handles the sign
ashr and ashl

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 24 / 31


Right Arithmetic Shift

R ← ashr R
Example if R=1010 before shifting after shifting it is 1101

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 25 / 31


Left Arithmetic Shift

We have to check the overflow


V = BitLast ⊕ BitBeforelast
R ← ashl R
If the value of R was 0010 New value is 0100 and V=0
If the value of R was 0110 New value is 1100 and V=1

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 26 / 31


Hardware Implementation

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 27 / 31


Combined Circuit

The behaviour of the arithmetic unit


depends on its design and its input
lines.

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 28 / 31


References

Chapter 4

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 29 / 31


Basic Computer

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 30 / 31


Thank you :)

Nada Sharaf Lecture 3: Microoperations III Spring Semester 2021 31 / 31

You might also like