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

2024 Lecture5 Come321

ch3

Uploaded by

ghada
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 views30 pages

2024 Lecture5 Come321

ch3

Uploaded by

ghada
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/ 30

Electrical Engineering Dept.

COME321: Computer Organization


(Fall 2024)
Dr. Eng. Ghada Abozaid
[email protected]
Outlines
• Register Transfer Microoperations

• Arithmetic Microoperations

• Hardware Implementation of Arithmetic Microoperations

• Logic Microoperations

• Hardware Implementation of Logic Microoperations

• Applications of Logic Microoperations

• Shift Microoperations

• Hardware Implementation of Shift Microoperations

• Arithmetic Logic Shift Unit


MICROOPERATIONS

• Computer system microoperations are of four types:

1. - Register transfer microoperations


2. - Arithmetic microoperations 
3. - Logic microoperations
4. - Shift microoperations
ARITHMETIC MICROOPERATIONS
• The basic arithmetic microoperations are
• Addition
• Subtraction
• Increment
• Decrement

• The additional arithmetic microoperations are


• Add with carry
• Subtract with borrow
• Transfer/Load
• etc. …

Summary of Typical Arithmetic Microoperations


R3  R1 + R2 Contents of R1 plus R2 transferred to R3
R3  R1 - R2 Contents of R1 minus R2 transferred to R3
R2  R2’ Complement the contents of R2
R2  R2’+ 1 2's complement the contents of R2 (negate)
R3  R1 + R2’+ 1 subtraction
R1  R1 + 1 Increment
R1  R1 - 1 Decrement
BINARY ADDER / SUBTRACTOR / INCREMENTER
B3 A3 B2 A2 B1 A1 B0 A0

Binary Adder C3 C2 C1 C0
FA FA FA FA

C4 S3 S2 S1 S0

Binary Adder-Subtractor
B3 A3 B2 A2 B1 A1 B0 A0

FA C3 FA C2 FA C1 FA C0

C4 S3 S2 S1 S0

Binary Incrementer A3 A2 A1 A0 1

x y x y x y x y
HA HA HA HA
C S C S C S C S

C4 S3 S2 S1 S0
ARITHMETIC CIRCUIT

S1 S0 Cin Y Output Microoperation


0 0 0 B D=A+B Add
0 0 1 B D=A+B+1 Add with carry
0 1 0 B’ D = A + B’ Subtract with borrow
0 1 1 B’ D = A + B’+ 1 Subtract
1 0 0 0 D=A Transfer A
1 0 1 0 D=A+1 Increment A
1 1 0 1 D=A-1 Decrement A
1 1 1 1 D=A Transfer A
ARITHMETIC CIRCUIT
Cin
Control S1
signals S0
A0 X0 C0
S1 D0
S0 Y0
FA
B0 0 4x1 Y0 C1
1 MUX
2
3
A1 X1 C1
S1 D1
S0 Y1 FA
B1 0 4x1 Y1 C2
1 MUX
2
Data 3
signals A2 X2 C2
S1 D2
S0 Y2 FA
B2 0 4x1 Y2 C3
1 MUX
2
3
A3 X3 C3
S1 D3
S0 Y3 FA
B3 0 4x1 Y3 C4
1 MUX
2
3 Cout
0 1
MICROOPERATIONS

• Computer system microoperations are of four types:

1. - Register transfer microoperations


2. - Arithmetic microoperations
3. - Logic microoperations
4. - Shift microoperations
LOGIC MICROOPERATIONS

• Specify binary operations on the strings of bits in registers


• Logic microoperations are bit-wise operations, i.e., they work on the individual bits
of data
• useful for bit manipulations on binary data
• useful for making logical decisions based on the bit value

• There are, in principle, 16 different logic functions that can be defined


over two binary input variables
A B F0 F1 F2 … F13 F14 F15
0 0 0 0 0 … 1 1 1
0 1 0 0 0 … 1 1 1
1 0 0 0 1 … 0 1 1
1 1 0 1 0 … 1 0 1

• However, most systems only implement four of these


• AND (), OR (), XOR (), Complement/NOT

• The others can be created from combination of these


LIST OF LOGIC MICROOPERATIONS

x 0011 Boolean Micro-


Name
y 0101 Function Operations
0000 F0 = 0 F0 Clear
0001 F1 = xy FAB AND
• Truth tables for 16 0010 F2 = xy' F  A  B’
functions of 2 variables 0011 F3 = x FA Transfer A
0100 F4 = x'y F  A’ B
and the corresponding 0101 F5 = y FB Transfer B
16 logic microoperations 0110 F6 = x  y FAB Exclusive-OR
0111 F7 = x + y FAB OR
1000 F8 = (x + y)' F  A  B)’ NOR
1001 F9 = (x  y)' F  (A  B)’ Exclusive-NOR
1010 F10 = y' F  B’ Complement B
1011 F11 = x + y' FAB
1100 F12 = x' F  A’ Complement A
1101 F13 = x' + y F  A’ B
1110 F14 = (xy)' F  (A  B)’ NAND
1111 F15 = 1 F  all 1's Set to all 1's
HARDWARE IMPLEMENTATION OF
LOGIC MICROOPERATIONS

Ai
0
Bi

1
4X1 Fi
MUX
2

3 Select

S1
S0

Function table
S1 S0 Output -operation
0 0 F=AB AND
0 1 F = AB OR
1 0 F=AB XOR
1 1 F = A’ Complement
APPLICATIONS OF LOGIC MICROOPERATIONS

• Logic microoperations can be used to manipulate individual bits or a


portions of a word in a register

• Consider the data in a register A. In another register, B, is bit data that


will be used to modify the contents of A

• Selective-set AA+B
• Selective-complement AAB
• Selective-clear A  A • B’
• Mask (Delete) AA•B
• Clear AAB
• Insert A  (A • B) + C
• Compare AAB
• ...
SELECTIVE SET

• In a selective set operation, the bit pattern in B is used to set certain


bits in A

1100 At
1010 B
1110 At+1 (A  A + B)

• If a bit in B is set to 1, that same position in A gets set to 1, otherwise


that bit in A keeps its previous value
SELECTIVE COMPLEMENT

• In a selective complement operation, the bit pattern in B is used to


complement certain bits in A

1100 At
1010 B
0110 At+1 (A  A  B)

• If a bit in B is set to 1, that same position in A gets complemented


from its original value, otherwise it is unchanged
SELECTIVE CLEAR

• In a selective clear operation, the bit pattern in B is used to clear certain


bits in A

1100 At
1010 B
0100 At+1 (A  A  B’)

• If a bit in B is set to 1, that same position in A gets set to 0, otherwise


it is unchanged
MASK OPERATION

• In a mask operation, the bit pattern in B is used to clear certain bits in A

1100 At
1010 B
1000 At+1 (A  A  B)

• If a bit in B is set to 0, that same position in A gets set to 0, otherwise


it is unchanged
CLEAR OPERATION

• In a clear operation, if the bits in the same position in A and B are the
same, they are cleared in A, otherwise they are set in A

1100 At
1010 B
0110 At+1 (A  A  B)
INSERT OPERATION
• An insert operation is used to introduce a specific bit pattern into A register,
leaving the other bit positions unchanged
• This is done as
1. A mask operation to clear the desired bit positions, followed by
2. An OR operation to introduce the new bits into the desired positions
• Example
• Suppose you wanted to introduce 1010 into the low order four bits of A:
1101 1000 1011 0001 A (Original) 1101 1000
1011 1010 A (Desired)

1101 1000 1011 0001 A (Original)


1111 1111 1111 0000 Mask
1101 1000 1011 0000 A (Intermediate)
0000 0000 0000 1010 Added bits
1101 1000 1011 1010 A (Desired)
MICROOPERATIONS

• Computer system microoperations are of four types:

1. - Register transfer microoperations


2. - Arithmetic microoperations
3. - Logic microoperations
4. - Shift microoperations
SHIFT MICROOPERATIONS
• There are three types of shifts
• Logical shift
• Circular shift
• Arithmetic shift

• What differentiates them is the information that goes into the


serial input
• A right shift operation

Serial
input

• A left shift operation Seri


inpu
LOGICAL SHIFT
• In a logical shift the serial input to the shift is a 0.

• A right logical shift operation:


0

• A left logical shift operation:


0

• In a Register Transfer Language, the following notation is used


• shl for a logical shift left

• shr for a logical shift right

• Examples:
• R2  shr R2
• R3  shl R3
CIRCULAR SHIFT
• In a circular shift the serial input is the bit that is shifted out of the other
end of the register.

• A right circular shift operation:

• A left circular shift operation:

• In a RTL, the following notation is used


• cil for a circular shift left
• cir for a circular shift right
• Examples:
• R2  cir R2
• R3  cil R3
ARITHMETIC SHIFT
• An arithmetic shift is meant for signed binary numbers (integer)
• An arithmetic left shift multiplies a signed number by two
• An arithmetic right shift divides a signed number by two
• The main distinction of an arithmetic shift is that it must keep the sign
of the number the same as it performs the multiplication or division

• A right arithmetic shift operation:

sign
bit

• A left arithmetic shift operation: 0


sign
bit
ARITHMETIC SHIFT

• An left arithmetic shift operation must be checked for the overflow


0
sign
bit

Before the shift, if the leftmost two


V bits differ, the shift will result in an
overflow

• In a RTL, the following notations are used:


– ashl for an arithmetic shift left
– ashr for an arithmetic shift right

 Examples:
» R2  ashr R2
» R3  ashl R3
HARDWARE IMPLEMENTATION OF
SHIFT MICROOPERATIONS

0 for shift left (down)


Serial Select 1 for shift right (up)
input (IL)

S
MUX H0
0
1
A0

A1 S
MUX H1
0
A2 1

A3
S
MUX H2
0
1

S
MUX H3
0
1

Serial
input (IR)
ARITHMETIC LOGIC SHIFT
UNIT
Implementation
ARITHMETIC LOGIC SHIFT
UNIT Implementation

S3 S2 S1 S0 Cin Operation Function

0 0 0 0 0 F=A Transfer A
0 0 0 0 1 F=A+1 Increment A
0 0 0 1 0 F=A+B Addition
0 0 0 1 1 F=A+B+1 Add with carry
0 0 1 0 0 F = A + B’ Subtract with borrow
0 0 1 0 1 F = A + B’+ 1 Subtraction
0 0 1 1 0 F=A-1 Decrement A
0 0 1 1 1 F=A Transfer A

0 1 0 0 X F=AB AND
0 1 0 1 X F = A B OR
0 1 1 0 X F=AB XOR
0 1 1 1 X F = A’ Complement A

1 0 X X X F = shr A Shift right A into F


1 1 X X X F = shl A Shift left A into F
ARITHMETIC LOGIC SHIFT UNIT

S3
S2 C i
S1
S0

Di
 ONE bit circuit
Arithmetic
Circuit
Select

0 4x1 F
C i+1 i
1 MUX
2
3
E i
Logic
Bi S3 S2 S1 S0 Cin Operation
Circuit
A 0 0 0 0 0 F=A
i 0 0 0 0 1 F=A+1
shr
A i-1 0 0 0 1 0 F=A+B
shl 0 0 0 1 1 F=A+B+1
A
i+1 0 0 1 0 0 F = A + B’
0 0 1 0 1 F = A + B’+ 1
0 0 1 1 0 F=A-1
0 0 1 1 1 F=A
0 1 0 0 X F=AB
0 1 0 1 X F = A B
0 1 1 0 X F=AB
0 1 1 1 X F = A’
1 0 X X X F = shr A
1 1 X X X F = shl A
References

• M. Mano, “Computer System Architecture,” Pearson


Publisher, 3rd Edition, 1992.
10/16/2024

You might also like