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

Chapter4 (Lect 41-44 Micro Operations)

The document discusses various microoperations including register transfer, arithmetic, and logic microoperations. It describes common arithmetic microoperations like addition, subtraction, increment, decrement, and shift. It also discusses logic microoperations including OR, AND, complement, XOR, and other operations like selective-set, selective-complement, and insert. Binary adders and arithmetic circuits are presented as implementations of arithmetic microoperations.

Uploaded by

nancy_01
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views

Chapter4 (Lect 41-44 Micro Operations)

The document discusses various microoperations including register transfer, arithmetic, and logic microoperations. It describes common arithmetic microoperations like addition, subtraction, increment, decrement, and shift. It also discusses logic microoperations including OR, AND, complement, XOR, and other operations like selective-set, selective-complement, and insert. Binary adders and arithmetic circuits are presented as implementations of arithmetic microoperations.

Uploaded by

nancy_01
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 37

Chapter 4:

Register Transfer and Microoperations

cpe 252: Computer Organization 1


4-4 Arithmetic Microoperations
• The microoperations most often
encountered in digital computers are
classified into four categories:
– Register transfer microoperations
– Arithmetic microoperations (on numeric data
stored in the registers)
– Logic microoperations (bit manipulations on
non-numeric data)
– Shift microoperations
cpe 252: Computer Organization 2
4-4 Arithmetic Microoperations cont.
• The basic arithmetic microoperations are:
addition, subtraction, increment,
decrement, and shift
• Addition Microoperation:
R3 ←R1+R2
• Subtraction Microoperation:
R3 ←R1-R2 or : 1’s complement

R3 ←R1+R2+1
cpe 252: Computer Organization 3
4-4 Arithmetic Microoperations cont.
• One’s Complement Microoperation:
R2 ←R2
• Two’s Complement Microoperation:
R2 ←R2+1
• Increment Microoperation:
R2 ←R2+1
• Decrement Microoperation:
R2 ←R2-1
cpe 252: Computer Organization 4
Half Adder/Full Adder
Half Adder x y c s x
0 0 0 0 c = xy s = xy’ + x’y c
=x  y y
0 1 0 1
1 0 0 1 s
1 1 1 0
Full Adder
y y
x y cn-1 cn s
0 0 0 0 0 0 0 0 1
0 0 1 0 1 0 1 c 1 0 cn-1
n-1
0 1 0 0 1 x 1 1 x 0 1
0 1 1 1 0 0 1 1 0
1 0 0 0 1 cn s
1 0 1 1 0
1 1 0 1 0 cn = xy + xcn-1+ ycn-1
1 1 1 1 1 = xy + (x  y)cn-1

x s = x’y’cn-1+x’yc’n-1+xy’c’n-1+xycn-1
y S = x  y  cn-1 = (x  y)  cn-1

cn-1
cn
cpe 252: Computer Organization 5
4-4 Arithmetic Microoperations
Binary Adder

B3 A3 B2 A2 B1 A1 B0 A0

C3 C2 C1
FA FA FA FA C0

C4 S3 S2 S1 S0

4-bit binary adder


(connection of FAs)

cpe 252: Computer Organization 6


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

C3 C2 C1 C0
FA FA FA FA

C4 S3 S2 S1 S0

4-bit adder-subtractor

cpe 252: Computer Organization 7


4-4 Arithmetic Microoperations
Binary Adder-Subtractor
• For unsigned numbers, this gives A – B if A≥B or the 2’s complement of (B – A) if A <
B
(example: 3 – 5 = -2= 1110)
• For signed numbers, the result is A – B provided that there is no overflow. (example :
-3 – 5= -8) 1101
1011 +
‫ـــــــــــــــــــــــــــ‬

1000

C3 1, if overflow
=V
C4 0, if no overflow

Overflow detector for signed numbers

cpe 252: Computer Organization 8


4-4 Arithmetic Microoperations
Binary Adder-Subtractor cont.
• What is the range of unsigned numbers
that can be represented in 4 bits?
• What is the range of signed numbers that
can be represented in 4 bits?
• Repeat for n-bit?!

cpe 252: Computer Organization 9


4-4 Arithmetic Microoperations
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

4-bit Binary Incrementer

cpe 252: Computer Organization 10


4-4 Arithmetic Microoperations
Binary Incrementer
• Binary Incrementer can also be
implemented using a counter
• A binary decrementer can be implemented
by adding 1111 to the desired register
each time!

cpe 252: Computer Organization 11


4-4 Arithmetic Microoperations
Arithmetic Circuit
• This circuit performs seven distinct
arithmetic operations and the basic
component of it is the parallel adder
• The output of the binary adder is
calculated from the following arithmetic
sum:
• D = A + Y + Cin

cpe 252: Computer Organization 12


4-4 Arithmetic Microoperations
Arithmetic Circuit cont.
A3 A2 A1 A0
1 0 B 3 B3 S 1 S 0 1 0 B2 B 2 S 1 S0 1 0 B1 B 1 S 1 S0 1 0 B 0 B0 S 1 S 0

3 2 1 0 S 1 S0 3 2 1 0 S 1 S0 3 2 1 0 S 1 S0 3 2 1 0 S 1 S0

4×1 MUX 4×1 MUX 4×1 MUX 4×1 MUX Figure A

Y3 X3 Y2 X2 Y1 X1 Y0 X0
C3 C2 C1
FA FA FA FA Cin

Cout D3 D2 D1 D0

4-bit Arithmetic Circuit

cpe 252: Computer Organization 13


4-5 Logic Microoperations
The four basic microoperations
OR Microoperation
• Symbol: , +

• Gate:

• Example: 1001102  10101102 = 11101102


OR OR

P+Q: R1←R2+R3, R4←R5 R6


cpe 252: Computer Organization
ADD 14
4-5 Logic Microoperations
The four basic microoperations
cont.
AND Microoperation
• Symbol: 

• Gate:

• Example: 1001102  10101102 = 00001102

cpe 252: Computer Organization 15


4-5 Logic Microoperations
The four basic microoperations
cont.
Complement (NOT) Microoperation
• Symbol: 

• Gate:

• Example: 10101102 = 01010012

cpe 252: Computer Organization 16


4-5 Logic Microoperations
The four basic microoperations
cont.
XOR (Exclusive-OR) Microoperation
• Symbol: 

• Gate:

• Example: 1001102  10101102 =


11100002

cpe 252: Computer Organization 17


4-5 Logic Microoperations
Other Logic Microoperations
Selective-set Operation
• Used to force selected bits of a register
into logic-1 by using the OR operation

• Example: 01002  10002 = 11002


Loaded into a register from
In a processor register
memory to perform the
selective-set operation

cpe 252: Computer Organization 18


4-5 Logic Microoperations
Other Logic Microoperations cont.
Selective-complement (toggling) Operation
• Used to force selected bits of a register to be
complemented by using the XOR operation

• Example: 00012  10002 = 10012

Loaded into a register from


In a processor register
memory to perform the
selective-complement operation

cpe 252: Computer Organization 19


4-5 Logic Microoperations
Other Logic Microoperations cont.
Insert Operation
• Step1: mask the desired bits
• Step2: OR them with the desired value

• Example: suppose R1 = 0110 1010, and we


desire to replace the leftmost 4 bits (0110) with
1001 then:
– Step1: 0110 1010  0000 1111
– Step2: 0000 1010  1001 0000
 R1 = 1001 1010
cpe 252: Computer Organization 20
4-5 Logic Microoperations
Other Logic Microoperations cont.
NAND Microoperation
• Symbols:  and 

• Gate:

• Example: 1001102  10101102 = 11110012

cpe 252: Computer Organization 21


4-5 Logic Microoperations
Other Logic Microoperations cont.
NOR Microoperation
• Symbols:  and 

• Gate:

• Example: 1001102  10101102 = 00010012

cpe 252: Computer Organization 22


4-5 Logic Microoperations
Other Logic Microoperations cont.
Set (Preset) Microoperation
• Force all bits into 1’s by ORing them with a value
in which all its bits are being assigned to logic-1
• Example: 1001102  1111112 = 1111112
Clear (Reset) Microoperation
• Force all bits into 0’s by ANDing them with a
value in which all its bits are being assigned to
logic-0
• Example: 1001102  0000002 = 0000002

cpe 252: Computer Organization 23


4-5 Logic Microoperations
Hardware Implementation
• The hardware implementation of logic
microoperations requires that logic gates
be inserted for each bit or pair of bits in the
registers to perform the required logic
function
• Most computers use only four (AND, OR,
XOR, and NOT) from which all others can
be derived.

cpe 252: Computer Organization 24


4-5 Logic Microoperations
Hardware Implementation cont.
S1
4×1 Operatio
S0
MUX S1 S0 Output n
Ai
0 0 E=AB XOR
Bi
0
0 1 E=AB OR

1 0 E=AB AND
1 Ei
1 1 E=A Complem
ent

3 This is for one bit i

Figure B cpe 252: Computer Organization 25


4-6 Shift Microoperations
• Used for serial transfer of data
• Also used in conjunction with arithmetic, logic,
and other data-processing operations
• The contents of the register can be shifted to the
left or to the right
• As being shifted, the first flip-flop receives its
binary information from the serial input
• Three types of shift: Logical, Circular, and
Arithmetic

cpe 252: Computer Organization 26


4-6 Shift Microoperations cont.

Serial Input r2 Serial Output


rn-1 r3 r1 r0

Determines Shift Right


the “shift”
type

Serial Output Serial Input


rn-1 r3 r2 r1 r0

Shift Left

**Note that the bit ri is the bit at position (i) of the register

cpe 252: Computer Organization 27


4-6 Shift Microoperations:
Logical Shifts
• Transfers 0 through the serial input
• Logical Shift Right: R1←shr R1
The same

• Logical Shift Left: R2←shl R2


The same

? rn-1 r3 r2 r1 r0 0

Logical Shift Left

cpe 252: Computer Organization 28


4-6 Shift Microoperations:
Circular Shifts (Rotate Operation)
• Circulates the bits of the register around
the two ends without loss of information
• Circular Shift Right: R1←cir R1
The same

• Circular Shift Left: R2←cil R2


The same

rn-1 r3 r2 r1 r0

Circular Shift Left


cpe 252: Computer Organization 29
4-6 Shift Microoperations
Arithmetic Shifts
• Shifts a signed binary number to the left or right
• An arithmetic shift-left multiplies a signed binary
number by 2: ashl (00100): 01000
• An arithmetic shift-right divides the number by 2
ashr (00100) : 00010
• An overflow may occur in arithmetic shift-left,
and occurs when the sign bit is changed (sign
reversal)

cpe 252: Computer Organization 30


4-6 Shift Microoperations
Arithmetic Shifts cont.

rn-1 r3 r2 r1 r0
?

Sign Arithmetic Shift Right


Bit

? rn-1 r3 r2 r1 r0 0
Sign
Arithmetic Shift Left
Bit

cpe 252: Computer Organization 31


4-6 Shift Microoperations
Arithmetic Shifts cont.
• An overflow flip-flop Vs can be used to detect
an arithmetic shift-left overflow

Vs = Rn-1  Rn-2

Rn-1 1  overflow
Vs =
Rn-2 0  no overflow

cpe 252: Computer Organization 32


4-6 Shift Microoperations cont.

• Example: Assume R1=11001110, then:


– Arithmetic shift right once : R1 = 11100111
– Arithmetic shift right twice : R1 = 11110011
– Arithmetic shift left once : R1 = 10011100
– Arithmetic shift left twice : R1 = 00111000
– Logical shift right once : R1 = 01100111
– Logical shift left once : R1 = 10011100
– Circular shift right once : R1 = 01100111
– Circular shift left once : R1 = 10011101
cpe 252: Computer Organization 33
4-6 Shift Microoperations
Hardware Implementation cont.
• A possible choice for a shift unit would be
a bidirectional shift register with parallel
load (refer to Fig 2-9). Has drawbacks:
– Needs two pulses (the clock and the shift
signal pulse)
– Not efficient in a processor unit where multiple
number of registers share a common bus
• It is more efficient to implement the shift
operation with a combinational circuit
cpe 252: Computer Organization 34
4-6 Shift Microoperations
Hardware Implementation cont.
Serial Input IR Serial Input IL
A3A2 A1 A0

Select

S 1 0 S 1 0 S 1 0 S 1 0 0 for shift right


1 for shift left
MUX MUX MUX MUX

H3 H2 H1 H0

4-bit Combinational Circuit Shifter

cpe 252: Computer Organization 35


4-7 Arithmetic Logic Shift Unit
• Instead of having individual registers
performing the microoperations directly,
computer systems employ a number of
storage registers connected to a common
operational unit called an Arithmetic Logic
Unit (ALU)

cpe 252: Computer Organization 36


4-7 Arithmetic Logic Shift Unit cont.
S3
S2
S1 Ci
S0

One stage of Di
arithmetic
circuit (Fig.A)
Select
One stage of Fi
ALU Ci+1 0 4×1
1 MUX
One stage of Ei 2
logic circuit
Bi (Fig.B) 3
Ai
shr
Ai+1
shl
Ai-1

cpe 252: Computer Organization 37

You might also like