CA Chapter02

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Computer Architecture

Er. Hari K.C.


Asst. Professor
Soch College of IT
Tribhuvan University
[email protected]

Soch college of IT - Hari K.C. 1


Chapter 02: Micro operations
Micro-operations
• Micro-operations are the operations which are used to create assembly language instruction.
• The operations performed on the data stored in registers are called micro-operations.

Some common example of micro-operation are:


1) Register Transfer Micro-operation: The main purpose of Register Transfer Micro operation is to
transfer binary information from register to another register.
2) Arithmetic Micro-operation: The main purpose of Arithmetic Micro-operation is to perform
arithmetic operation on numeric data.
3) Logical Operation: The main purpose of Logical Operation is to perform bit manipulation on
numeric data.
4) Shift Micro-operation: The main purpose of Shift Micro-operation is to shift the temporary data
which are present in register.

Soch college of IT - Hari K.C.


Register Transfer Micro-operation
• Register transfer language is a symbolic language and a convenient
tool for describing the internal organization of digital computers.
• It can also be used to facilitate the design process of digital systems.
• Copying the contents of one register to another is a register transfer.
• Registers are designated by capital letters, sometimes followed by
numbers (E.g. R1, IR, MAR, etc.).
• A register transfer is indicated as: R2 ← R1
• The statement “R2 ← R1” denotes a transfer of the content of the R1
into resister R2.

Soch college of IT - Hari K.C.


Example: P: R3 ← R5, MAR ← IR
• Here, if the control function P = 1, load the contents of R5 into R3,
and at the same time (clock), load the contents of register IR into
register MAR

Soch college of IT - Hari K.C.


Arithmetic Microoperations
The arithmetic micro-operations are
• Addition
• Subtraction
• Increment
• Decrement
• Add with carry
• Subtract with borrow
• Transfer/Load

Soch college of IT - Hari K.C.


Soch college of IT - Hari K.C.
Binary adder - subtractor
• An n bit full adder requires n full adders.
• The subtraction (A-B) can takes place by : Taking twos complement of
one (B) and addding with the another number (A)
a) When M=0, A+B

b) When M=1, A-B

Soch college of IT - Hari K.C.


Binary Incrementer

Soch college of IT - Hari K.C.


Arithmetic Circuit
• A arithmetic circuit can be implemented by:
- 4 full adders
- 4 MUX
- Inputs and outputs
- Input carry and output carry

Soch college of IT - Hari K.C.


Soch college of IT - Hari K.C.
• When S1S0 = 00, the value of B is applied to the Y inputs of the adder.
If Cin = 0, the output D = A + B. If Cin = 1, output D = A + B + 1. Both
cases perform the add micro-operation with or without adding the
input carry.

• When S1S0 = 01, the complement of B is applied to the Y inputs of


the adder. If Cin = 1, then D =A+B’+ 1. This produces A plus the 2’s
complement of B, which is equivalent to a subtract with borrow, that
is, A – B – 1.

Soch college of IT - Hari K.C.


Soch college of IT - Hari K.C.
Logical Microoperation
• Logic operations specify binary operations for strings of bits stored in
registers and treat each bit separately.
• Logic micro-operations are bit-wise operations, i.e., they work on the
individual bits of data.
• They are useful for bit manipulations on binary data and for making
logical decisions based on the bit value.

Soch college of IT - Hari K.C.


Example: The XOR of R1 and R2 is symbolized by P: R1 ← R1 ⊕ R2
• Example: R1 = 1010 and R2 = 1100
• 1010 Content of R1
• 1100 Content of R2
• 0110 Content of R1 after P = 1

The Symbols used for logical micro-operations:


1. OR: ∨
2. AND: ∧
3. XOR: ⊕

Soch college of IT - Hari K.C.


Soch college of IT - Hari K.C.
1) OR operation
1010 A before
1100 B (logic operand)
1110 A Result
(A ← A ∨ B)
2) X-OR operation
1010 A before
1100 B (logic operand)
0110 A Result
(A ← A ⊕ B)

Soch college of IT - Hari K.C.


AND operation
1010 A before
1100 B (logic operand)
1000 A Result
A<-- A ^ B

Complement operation
1010 A
0101
A ← A’

Soch college of IT - Hari K.C.


Soch college of IT - Hari K.C.
Shift Micro-operation
• Shift micro-operations are used for serial transfer of data.
• They are also used in conjunction with arithmetic, logic, and other
data-processing operations.
• There are three types of shifts
1. Logical shift
2. Circular shift
3. Arithmetic shift

Soch college of IT - Hari K.C.


Soch college of IT - Hari K.C.
Right and left shift

Soch college of IT - Hari K.C.


Logical Shift
• A logical shift is one that transfers 0 through the serial input. The
symbols shl and shr are for logical shift-left and shift-right by one
position respectively.
Example:
• R1 ← shl R1
• R2 ← shr R2

Soch college of IT - Hari K.C.


Circular Shift
• The circular shift (aka rotate) circulates the bits of the register around
the two ends without loss of information.
• The symbols cil and cir are for circular shift left and right respectively.
Examples:
• R2 ← cir R2
• R3 ← cil R3

Soch college of IT - Hari K.C.


Arithmetic Shift
• The arithmetic shift shifts a signed binary number to the left or right.
To the left is multiplying by 2,to the right is dividing by 2 (i.e. an
arithmetic left shift multiplies a signed number by 2 and an arithmetic
right shift divides a signed number by 2).
• Arithmetic shifts must leave the sign bit unchanged because the sign
of the number remains the same when it is multiplied or divided by 2.
The left most bit in a resister holds a sign bit and remaining hold the
number.
• Negative numbers are in 2's complement form.
• The figure below shows the arithmetic shift right and left respectively.
Soch college of IT - Hari K.C.
Soch college of IT - Hari K.C.
Arithmetic Shift-right
• Arithmetic shift-right leaves the sign bit unchanged and shifts the
number (including a sign bit) to the right. Thus Rn-1 remains same;
Rn-2 receives input from Rn-1 and so on.
Arithmetic Shift-left
• Arithmetic shift-left inserts a 0 into R0 and shifts all other bits to left.
Initial bit of Rn-1 is lost and replaced by the bit from Rn-2.
Overflow case during arithmetic shift-left
• A sign reversal occurs if the bit in Rn-1 changes in value after the shift.
• This happens if the multiplication causes an overflow.
• Thus, left arithmetic shift operation must be checked for the
overflow.

Soch college of IT - Hari K.C.


Hardware implementation of shift micro-
operations
• A bi-directional shift unit with parallel load could be used to
implement this.
• Two clock pulses are necessary with this configuration: one to load
the value and another to shift.
• In a processor unit with many registers it is more efficient to
implement the shift operation with a combinational circuit.
• The content of a register to be shifted is first placed onto a common
bus and the output is connected to the combinational shifter, the
shifted number is then loaded back into the register.

Soch college of IT - Hari K.C.


Soch college of IT - Hari K.C.
Arithmetic Logic Shift Unit

Soch college of IT - Hari K.C.


End of chapter 02

You might also like