Computer Organization and Architecture
Computer Organization and Architecture
Computer Organization and Architecture
– E.g. In order to carry out a task such as ADD, the control unit must generate a set of
processing section.
• Execution
– CU causes each micro-operation to be performed
• Control Signals
– External: inputs indicating the state of the system
4.Arithmetic/Logic Ops.
5.Execution of Complete Instruction
6.Branching Ops.
REGISTER TRANSFERS
• Instruction execution involves a sequence of steps in which data
are transferred from one register to another.
• For each register, two control-signals are used: Ri in & Riout. These
are called Gating Signals.
EX:
Transfer the contents of R1 to R4(MOV R1,R4)
1. Enable output of register R1 by setting R1out=1. This
places the contents of R1 on the processor bus.
2. Enable input of register R4 by setting R4in=1. This
loads the data from the processor bus into register R4.
Contd...
• All operations and data transfers within the processor take
place within time-periods defined by the processor-clock.
• Control-signals that govern a particular transfer are
asserted at the start of the clock cycle.
Register Transfers Internal processor
b us
Riin
Ri out
Y in
Constant 4
Select MUX
A B
ALU
Z in
Z out
Simple register transfer example
CONTROL-SIGNALS OF MDR
• The MDR register has 4 control-signals :
– MDRin & MDRout control the connection to the internal processor
data bus
– MDRinE & MDRoutE control the connection to the memory Data bus.
• When requested-data are received from memory, they are stored in MDR. From MDR,
they are transferred to other registers.
• The response time of each memory access varies (based on cache miss, memory-mapped
I/O).
• MFC informs the processor that the requested operation has been completed by
addressed-device.
Contd...
• Consider the instruction Move (R1),R2. The sequence of steps
– R1out, MARin, Read ;desired address is loaded into MAR & Read
command is issued.
– MDRinE, WMFC ;load MDR from memory-bus & Wait for MFC
response from memory.
– MDRout, R2in ;load R2 from MDR. where WMFC=control-signal
that causes processor's control. circuitry to wait for arrival of
MFC signal
Storing a Word in Memory
– Step2 --> Contents from Y and from register R2 are applied to the A
and B inputs of ALU; Addition is performed & Result is stored in the Z
register.
– Step 3 --> The contents of Z register is stored in the R3 register.
• The signals are activated for the duration of the clock cycle
corresponding to that step. All other signals are inactive.
Instruction Cycle
• The instruction execution may involve several operations and depends on
the nature of the instruction.
• Processing required for a single instruction is called an instruction cycle.
• At the beginning of each instruction cycle, processor fetches an instruction
from memory.
• Program counter (PC) holds address of the instruction to be fetched next.
• The processor increments the PC after each instruction fetch so that it will
fetch the next instruction in sequence
• The fetched instruction is loaded into instruction register (IR).
• Instruction contains bits that specify the action the processor is to take.
• The processor interprets the instruction and performs the required action.
ADD B,A
• ADD B,A, that stores the sum of the contents of memory locations B and A
– Read the contents of memory location B into the processor. In order that the contents
of A are not lost, the processor must have at least two registers for storing memory
values.
Control signals
Add (R3), R1
PC
Instruction
Step Action Address
decoder and
lines
MAR control logic
• The Select signal is set to Select4, which causes the Mux to select
constant 4.
• This value is added to operand at input B (PC‟s content), and the result
is stored in Z.
issued.
• Conditional branch
Execution of Branch Instructions
StepAction
• Step 5--> the result, which is the branch-address, is loaded into the PC.
• The branch instruction loads the branch target address in PC so that PC will
• The offset X is usually the difference between the branch target-address and
• Solution:
– To reduce the number of steps, most processors provide multiple
internal-paths.
– Multiple paths enable several transfers to take place in parallel.
Multiple-bus organization
• Multiple-bus organization.
– Most commercial processors provide multiple internal
paths to enable several transfers to take place in parallel.
Contd….
StepAction
Control signals
PC
MDR
Data
the instruction lines IR
Select MUX
Z
bus architecture)
• Assumptions:
4-bit machine word
16 different values can be represented
Roughly half are positive, half are negative
Sign and Magnitude Representation
-7 +0
-6 1111 0000 +1
1110 0001
-5 +2 +
1101 0010
-4 1100 0011 +3 0 100 = + 4
-0 +0
-1 1111 0000 +1
1110 0001
-2 +2 +
1101 0010
-3 1100 0011 +3 0 100 = + 4
B Values represented
Sign and
b3 b2 b1 b0 magnitude 1' s complement 2' s complement
0 1 1 1 +7 +7 + 7
0 1 1 0 +6 +6 + 6
0 1 0 1 +5 +5 + 5
0 1 0 0 +4 +4 + 4
0 0 1 1 +3 +3 + 3
0 0 1 0 +2 +2 + 2
0 0 0 1 +1 +1 + 1
0 0 0 0 +0 +0 + 0
1 0 0 0 - 0 -7 - 8
1 0 0 1 - 1 -6 - 7
1 0 1 0 - 2 -5 - 6
1 0 1 1 - 3 -4 - 5
1 1 0 0 - 4 -3 - 4
1 1 0 1 - 5 -2 - 3
1 1 1 0 - 6 - 1 - 2
1 1 1 1 - 7 -0 - 1
0 1 0 1
+ 0 + 0 + 1 + 1
0 1 1 10
Carry-out
4 0100 -4 1100
result sign bit is the
same as the operands' +3 0011 + (-3) 1011
sign
7 0111 -7 1111
4 0100 -4 1011
+3 0011 + (-3) 1100
7 0111 -7 10111
End around carry 1
1000
4 0100 -4 1011
-3 1100 +3 0011
1 10000 -1 1110
End around carry 1
0001
Addition and Subtraction – 2’s Complement
4 0100 -4 1100
+3 0011 + (-3) 1101
If carry-in to the high
order bit = 7 0111 -7 11001
carry-out then ignore
carry
-1 +0 -1 +0
-2 1111 0000 +1 -2 1111 0000 +1
1110 0001 1110 0001
-3 +2 -3
1101 1101 +2
0010 0010
-4 -4
1100 0011 +3 1100 0011 +3
-5 1011 -5 1011
0100 +4 0100 +4
1010 1010
-6 0101 -6 0101
1001
+5 +5
0110 1001
0110
-7 1000 0111 +6 -7 1000 +6
0111
-8 +7 -8 +7
5 + 3 = -8 -7 - 2 = +7
Overflow
Overflow can occur only when adding 2 numbers that have the
same sign.
The carry out signal from the sign bit position is not a sufficient
indicator of overflow when adding signed numbers.
To detect overflow, examine the signs of the 2 summands X & Y
and the sign of the result. When both operands X & Y have the
same sign, an overflow occurs when the sign of S is not the same
as the signs of X & Y.
Addition of Unsigned Numbers – Half Adder
x 0 0 1 1
+y +0 +1 +0 +1
c s 0 0 0 1 0 1 1 0
Carry Sum
Carry Sum
x y c s
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
x
s
y
x s
HA
y c
c
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
si = xi yi ci + xi yi ci + xi yi ci + xi yi ci = x y c
i i i
c i +1 = y i c i + x i ci + x i y i
E xample:
X 7 0 1 1 1 xi
Carry-out Carry-in
+ Y = +6 = + 0 0 1 1 1 1 0 0 0 yi
c i+1 ci
Z 13 1 1 0 1 si
yi
c
i
xi
xi
yi si c
c i +1
i
ci
x
xi yi i
yi
ci + 1 Full adder ci
(FA)
s
i
c c
n - 1 1
c c
n
FA FA FA
0
s s s
n - 1 1 0
x y x y x y x y x y
k n - 1 k n - 1 2n - 1 2n - 1 n n n - 1 n - 1 0 0
c
n - bit n- bit n n - bit
c c
kn adder adder adder 0
s s s s s s
k n - 1 k - 1 n 2n - 1 n n - 1 0
• The circuit network can be used to perform either addition or subtraction based on
the value applied to Add/Sub input control line.
• Add/Sub= 0 for addition.
• When the Add/Sub is set to 1, the Y is 1’s complemented by the XOR gates and
C0 is set to 1 to complete the 2’s complementation of Y.
• An XOR gate can be added to detect the overflow
•Overflow can only occur when the signs of the 2 operands are
the same.
•Overflow occurs when the carry bits Cn & Cn-1 are different.
•Therefore a simpler circuit for detecting overflow can be
obtained by implementing the logic expression Cn XOR Cn-1
with an XOR gate
Multiplication of positive numbers
•The product of two n-digit numbers can be
accommodated in 2n digits, so the product of the two
4-bit numbers fits into 8 bits.
1 1 0 1 (13) Multiplicand M
1 0 1 1 (11) Multiplier Q
1 1 0 1
1 1 0 1
0 0 0 0
1 1 0 1
1 0 0 0 1 1 1 1 (143) Product P
•At the end of each cycle, C, A & Q are shifted right one bit
position to allow for growth of the partial product as
multiplier is shifted out of Q.
• Because of this shifting, multiplier bit qi appears at the LSB of Q
to generate Add/Noadd signal at the correct time, starting with
q0 during first cycle, q1 during the second cycle, and so on.
• After they are used, the multiplier bits are discarded by the right
shift operation.
• The carry out from the adder is the leftmost bit of PP(i+1), and it
must be held in the C to be shifted right with the contents of A &
Q.
• After n cycles, the high order half of the product is in A and the
low order half is in Q
Iteration Step Multiplier Multiplicand Product
• For eg:, -13 (5 bit signed operand) * +11 to get the 10 bit product,
-143.
Signed Multiplication
1 0 0 1 1 - 13
0 1 0 1 1 ( + 11)
1 1 1 1 1 1 0 0 1 1
1 1 1 1 1 0 0 1 1
Sign extension is
shown in blue 0 0 0 0 0 0 0 0
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 0 1 1 1 0 0 0 1 - 143
• Features
• It handles both + ve & - ve numbers uniformly.
21 = 0001 0101
-21 = 1s complement of 21 + 1 = 1110 1010 + 1 = 1110 1011
Result =(1110 1011)2 = - 21
Booth Algorithm
Multiplier
version of multiplicand
selected by bit i
Bit i Bit i -1
0 0 0xM
0 1 +1x M
1 0 1 × M
1 1 0xM
0 +1 - 1 +1 0 - 1 0 +1 0 0 - 1 +1 - 1 +1 0 - 1 0 0
Booth recoding of a multiplier.
• Booth algorithm can be extended to any number of blocks
of 1s in a multiplier, including the situation in which a
single 1 is considered a block.
• The case when the LSB of the multiplier is 1 is handled by
assuming that an implied 0 lies to its right.
Booth Algorithm
0 1 0 1 1 0 1
0 0 +1 +1 + 1 +1 0
0 0 0 0 0 0 0
0 1 0 1 1 0 1
0 1 0 1 1 0 1
0 1 0 1 1 0 1
0 1 0 1 1 0 1
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 1 0 1 0 1 0 0 0 1 1 0
Booth Algorithm
0 1 0 1 1 0 1
0 +1 0 0 0 -1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 2's complement of
1 1 1 1 1 1 1 0 1 0 0 1 1 the multiplicand
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 1 1 0 1
0 0 0 0 0 0 0 0
0 0 0 1 0 1 0 1 0 0 0 1 1 0
Booth Algorithm
0 1 1 0 1 ( + 13 ) 0 1 1 0 1
1 1 0 1 0 - 6 0 - 1 +1 - 1 0
0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 1 1
0 0 0 0 1 1 0 1
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 1 0 1 1 0 0 1 0 - 78
+1 -1 +1 -1 +1 - 1 +1 - 1 +1 - 1 +1 - 1 +1 - 1 +1 - 1
Ordinary
1 1 0 0 0 1 0 1 1 0 1 1 1 1 0 0
multiplier
0 -1 0 0 +1 - 1 +1 0 - 1 +1 0 0 0 - 1 0 0
0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1
Good
multiplier
0 0 0 +1 0 0 0 0 - 1 0 0 0 +1 0 0 - 1
•The transformation 011….110 to 100….0-10 is called
skipping over 1s.
Computer Organization
Binary Division by Shift and Subtract
consider the pencil-and-paper method for dividing the byte 10010011
Computer Organization
BCD
SExp Coefficient
IEEE Standard 754
– 1 + 8 + 23 = 32 bits
– 1+ 11 + 52 = 64 bits (double precision)
The sign bit
• Represent 7:
– Convert to binary: 111
– Normalize: 1.11×22
– Sign bit is 0
– Biased exponent is 127 + 2 = 12910=10000001two
Coefficient is 1100…0
–
example
• Represent –2
– Convert to binary: 10
– Normalize: 1.0×21
– Sign bit is 1
– Biased exponent is 127 + 1 = 10000000two
– Coefficient is 00…0
–
Floating Point Addition
• 5.25×103 + 1.22×102 = ?
• Denormalize number with smaller
exponent:
• 5.25×103 + 0.122×103
• Add the numbers:
• 5.25×103 + 0.122×103 = 5.372×103
• Result is normalized
Decimal floating point addition
• 9.25×103 + 8.22×102 = ?
• Denormalize number with smaller
exponent:
• 9.25×103 + 0.822×103
• Add the numbers:
• 9.25×103 + 0.822×103 = 10.072×103
• Normalize the result:
• 10.072×103 = 1.0072×104
Binary floating point addition
• Say 1.01×22 + 1.1×21
• Denormalize number with smaller exponent:
• 1.01×22 + 0.11×22
• Add the numbers:
• 1.01×22 + 0.11×22 = 10.00×22
• Normalize the results
• 10.00×22 = 1.000×23
Binary floating point subtraction
• 1.01×22 – 1.1×21
• Denormalize number with smaller exponent:
• 1.01×22 – 0.11×22
• Perform the subtraction:
• 1.01×22 – 0.11×22 = 0.10×22
• Normalize the results
• 0.10×22 = 1.0×21
Add/Subtract Rule/Algorithm
1. Choose the number with the smaller exponent and shift its mantissa right a
number of steps equal to the diffrence in exponents.
3. perform addition /subtraction on the mantissa and determine the sign of the
result.
AC ←BR * QR
truncate low order bits
Computer Organization