0% found this document useful (0 votes)
6 views

4 Arithmetic Operations

The document discusses various arithmetic and logical operations, focusing on register transfer language, micro-operations, and their hardware implementations. It covers logic micro-operations, their applications, and different types of shift operations including logical, circular, and arithmetic shifts. Additionally, it details the hardware implementation of arithmetic logic and shift units, including operation tables and examples.

Uploaded by

vijayarj.p
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

4 Arithmetic Operations

The document discusses various arithmetic and logical operations, focusing on register transfer language, micro-operations, and their hardware implementations. It covers logic micro-operations, their applications, and different types of shift operations including logical, circular, and arithmetic shifts. Additionally, it details the hardware implementation of arithmetic logic and shift units, including operation tables and examples.

Uploaded by

vijayarj.p
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Arithmetic and Logical

Operations
Topics discussed :

• Register Transfer Language


• Register Transfer
• Bus and Memory Transfers

Topics to be discussed :

 Arithmetic Micro-operations
 Logic Micro-operations
 Shift Micro-operations
 Arithmetic Logic Shift Unit
1
2
Logic Micro-operations

2
Hardware Implementation
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 Micro-operations

Logic micro-operations 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/Compare AAB
 Insert A  (A • B) + C
Applications of Logic Micro-operations
Selective Set, the bit pattern in B is Selective complement, the bit pattern
used to set certain bits in A in B is used to complement certain
bits in A
1 1 0 0 At 1 1 0 0 At
1010 B 1010 B
1 1 1 0 At+1 (A  A + B)
0 1 1 0 At+1 (A  A  B)

If a bit in B is set to 1, that If a bit in B is set to 1, that


same position in A same position in A gets
complemented from its
gets set to 1,
original value, otherwise it is
otherwise that bit in A keeps unchanged
its previous value
Applications of Logic Microoperations

Selective Clear operation, the bit Mask operation, the bit pattern in B is
pattern in B is used to clear used to clear certain bits in A
certain bits in A
1 1 0 0 At 1 1 0 0 At
1010 B 1010 B
0 1 0 0 At+1 (A  A  B’) 1 0 0 0 At+1 (A  A  B)

If a bit in B is set to 1,
that same position in A If a bit in B is set to 0, that
gets set to 0, otherwise same position in A gets set
it is unchanged to 0, otherwise it is
unchanged
Applications of Logic Microoperations

Clear: 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

1 1 0 0 At
1010 B

0 1 1 0 At+1 (A  A  B)
Applications of Logic Micro-operations
Insert operation is used to introduce a specific bit pattern into A register,
leaving the other bit positions unchanged.
Steps :
 A mask operation to clear the desired bit positions, followed by
 An OR operation to introduce the new bits into the desired positions
Example
• 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)
Shift Micro-operations
3 types of shifts
• Logical shift
• Circular shift
• Arithmetic shift

Information that goes into the serial input differentiates them

Serial
input

Right Shift Operation

Serial
input

Left Shift Operation


Logical Shift
In a logical shift the serial input to the shift is a 0.

Right Logical Shift Operation: R2  shr R2

Left Logical Shift Operation: R3  shl R3


Circular Shift
Circular Shift the serial input is the bit that is shifted out of the
other end of the register.

A right circular shift operation R2  cir R2

A left circular shift operation : R3  cil R3


Arithmetic Shift
For Signed Binary Numbers (Integer) 0 for + ve ; 1 for - ve

Arithmetic Left Shift Multiplies a signed number by 2


Arithmetic Right Shift Divides a signed number by 2
Sign of the number the same as during multiplication /division

sign
bit
Arithmetic Right Shift

sign
bit
Arithmetic Left Shift
Arithmetic Shift

Arithmetic Left 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 notation is used

ashl for an arithmetic shift left R3  ashl R3

ashr for an arithmetic shift right R2  ashr R2


Hardware Implementation of Shift Micro-operation
Arithmetic Logic and Shift Unit S3 S2 S1 S0 Cin Operation
0 0 0 0 0 F=A
0 0 0 0 1 F=A+1
0 0 0 1 0 F=A+B
S3 0 0 0 1 1 F=A+B+1
S2 C
0 0 1 0 0 F = A + B’
i 0 0 1 0 1 F = A + B’+ 1
S1 0 0 1 1 0 F=A-1
S0 0 0 1 1 1 F=A
0 1 0 0 X F=AB
0 1 0 1 X F = A B
Arithmetic
D
i 0 1 1 0 X F=AB
0 1 1 1 X F = A’
Circuit 1 0 X X X F = shr A
1 1 X X X F = shl A
Select

0 4x1
C F
i+1 1 i
MUX
2
3

E
Logic i
B
i Circuit
A
i
shr
A
i-1
shl
A
i+1

You might also like