5EC3-01: Computer Architecture: UNIT-2
5EC3-01: Computer Architecture: UNIT-2
5EC3-01: Computer Architecture: UNIT-2
To understand the organization of the processor, let us consider the requirements placed on the
processor, the things that it must do:
Fetch instruction: The processor reads an instruction from memory (register, cache, main
memory).
Interpret instruction: The instruction is decoded to determine what action is required.
Fetch data: The execution of an instruction may require reading data from memory or an I/O
module.
Process data: The execution of an instruction may require performing some arithmetic or
logical operation on data.
Write data: The results of an execution may require writing data to memory or an I/O module.
Figure shown below is the simplified view of a processor, indicating its connection to the rest
of the system via the system bus.
The major components of the processor are an arithmetic and logic unit (ALU) and a control
unit (CU). The ALU does the actual computation or processing of data. The control unit controls the
movement of data and instructions into and out of the processor and controls the operation of the ALU.
In addition, the figure shows a minimal internal memory, consisting of a set of storage locations, called
registers.
Figure shown below is a detailed view of the processor. The data transfer and logic control
paths are indicated, including an element labeled internal processor bus. This element is needed to
transfer data between the various registers and the ALU because the ALU in fact operates only on data
Unit-2: Page | 1 Dr S K Singh
in the internal processor memory. The figure also shows typical basic elements of the ALU. Note the
similarity between the internal structure of the computer as a whole and the internal structure of the
processor. In both cases, there is a small collection of major elements (computer: processor, I/O,
memory; processor: control unit, ALU, registers) connected by data paths.
Representation of Information:
Digital Computers use Binary number system to represent all types of information inside the
computers. Alphanumeric characters are represented using binary bits (i.e., 0 and 1). Digital
representations are easier to design, storage is easy, accuracy and precision are greater.
There are various types of number representation techniques for digital number representation,
for example: Binary number system, octal number system, decimal number system, and hexadecimal
number system etc. But Binary number system is most relevant and popular for representing numbers
in digital computer system.
This procedure will not work for twos complement negative integers. Using the same example,
Instead, the rule for twos complement integers is to move the sign bit to the new leftmost
position and fill in with copies of the sign bit. For positive numbers, fill in with zeros, and for
negative numbers, fill in with ones. This is called sign extension.
INTEGER ARITHMETIC:
Unit-2: Page | 3 Dr S K Singh
# Hardware for Addition and Subtraction
Figure shown below the data paths and hardware elements needed to realize addition and subtraction.
The central element is a binary adder, which is accessible two numbers for addition and produces a
sum and an overflow indication. The binary adder treats the two numbers as unsigned integers.
For addition, the two numbers are presented to the adder from two registers, designated in this case as
A and B registers. The result may be stored in one of these registers or in a third. The overflow
indication is stored in a 1-bit overflow flag (0 = no overflow; 1 = overflow). For subtraction, the
subtrahend (B register) is passed through a twos complementer so that its twos complement is
presented to the adder. Note that Figure only shows the data paths. Control signals are needed to
control whether or not the complementer is used, depending on whether the operation is addition or
subtraction.
#Multiplication
1. Multiplication involves the generation of partial products, one for each digit in the multiplier.
These partial products are then summed to produce the final product.
2. The partial products are easily defined. When the multiplier bit is 0, the partial product is
0.When the multiplier is 1, the partial product is the multiplicand.
3. The total product is produced by summing the partial products. For this operation, each
successive partial product is shifted one position to the left relative to the preceding partial
product.
4. The multiplication of two n-bit binary integers results in a product of up to bits in length.
(e.g., 11 X 11 = 1001)
Compared with the pencil-and-paper approach, there are several things has do to make computerized
multiplication. First, it can perform a running addition on the partial products rather than waiting until
the end. This eliminates the need for storage of all the partial products; fewer registers are needed.
Second, we can save some time on the generation of partial products. For each 1 on the multiplier, an
add and a shift operation are required; but for each 0, only a shift is required.
Figure shown below the multiplier and multiplicand are loaded into two registers (Q and M). A third
register, the A register, is also needed and is initially set to 0. There is also a 1-bit C register, initialized
to 0, which holds a potential carry bit resulting from addition. The operation of the multiplier is as
follows. Control logic reads the bits of the multiplier one at a time. If Q 0 is 1, then the multiplicand is
added to the A register and the result is stored in the A register, with the C bit used for overflow. Then
all of the bits of the C, A, and Q registers are shifted to the right one bit, so that the C bit goes into A n-
1, A0 goes into Qn- 1, and Q0 is lost.
A flowchart of the operation is shown below. Note that on the second cycle, when the
multiplier bit is 0, there is no add operation.
If these numbers are considered to be unsigned integers, then we are adding 9 (1001) plus 3 (0011) to
get 12 (1100). As twos complement integers, we are adding -7 (1001) to 3 (0011) to get -4 (1100).
Unfortunately, this simple scheme will not work for multiplication.
Now it can demonstrate that straightforward multiplication will not work if the multiplicand is
negative. The problem is that each contribution of the negative multiplicand as a partial product must
be a negative number on a 2n-bit field; the sign bits of the partial products must line up.
Example shows that multiplication of 1001 by 0011. If these are treated as unsigned integers, the
multiplication of 9 x 3 = 27 proceeds simply. However, if 1001 is interpreted as the twos complement
-7 value then each partial product must be a negative twos complement number of 2n (8) bits, as
Booth’s algorithm can be described as follows. The multiplier and multiplicand are placed in the Q and
M registers respectively. There is also a 1-bit register placed logically to the right of the least
significant bit (Q0) of the Q register and designated Q-1. The results of the multiplication will appear in
the A and Q registers. A and Q-1 are initialized to 0. As before, control logic scans the bits of the
multiplier one at a time. Now, as each bit is examined, the bit to its right is also examined. If the two
bits are the same (1–1 or 0–0), then all of the bits of the A, Q, and Q-1 registers are shifted to the right 1
bit. If the two bits differ, then the multiplicand is added to or subtracted from the A register, depending
on whether the two bits are 0–1 or 1–0. Following the addition or subtraction, the right shift occurs. In
either case, the right shift is such that the leftmost bit of A, namely An- 1, not only is shifted into An- 2,
but also re-mains in An- 1. This is required to preserve the sign of the number in A and Q. It is known
as an arithmetic shift, because it preserves the sign bit. The sequence of events in Booth’s algorithm
for the multipli-cation of 7 by 3 is shown below.
At each cycle, additional bits from the dividend are appended to the partial remainder until the result is
greater than or equal to the divisor. As before, the divisor is subtracted from this number to produce a
new partial remainder. The process continues until all the bits of the dividend are exhausted.
Flowchart shows a machine algorithm that corresponds to the long division process. The
divisor is placed in the M register, the dividend in the Q register. At each step, the A and Q registers
together are shifted to the left 1 bit. M is subtracted from A to determine whether A divides the partial
remainder. If it does, then Q0 gets a 1 bit. Otherwise, Q0 gets a 0 bit and M must be added back to A to
restore the previ-ous value. The count is then decremented, and the process continues for n steps. At
the end, the quotient is in the Q register and the remainder is in the A register.
These are:
In fixed point notation, there are a fixed number of digits after the decimal point, whereas floating
point number allows for a varying number of digits after the decimal point.
Fixed-Point Representation:
This representation has fixed number of bits for integer part and for fractional part. For example, if
given fixed-point representation is IIII.FFFF, then you can store minimum value is 0000.0001 and
maximum value is 9999.9999. There are three parts of a fixed-point number representation: the sign
field, integer field, and fractional field.
Example: Assume number is using 32-bit format which reserve 1 bit for the sign, 15 bits for the
integer part and 16 bits for the fractional part.
These are above smallest positive number and largest positive number which can be store in 32-bit
representation as given above format. Therefore, the smallest positive number is 2-16 ≈ 0.000015
approximate and the largest positive number is (215-1)=32768, and gap between these numbers is 2-16.
Floating-Point Representation:
This representation does not reserve a specific number of bits for the integer part or the fractional part.
Instead it reserves a certain number of bits for the number (called the mantissa or significand) and a
certain number of bits to say where within that number the decimal place sits (called the exponent).
The floating number representation of a number has two part: the first part represents a signed fixed
point number called mantissa. The second part of designates the position of the decimal (or
binary) point and is called the exponent. The fixed point mantissa may be fraction or an integer.
e
Floating -point is always interpreted to represent a number in the following form: m x r .
Only the mantissa m and the exponent e are physically represented in the register (including
their sign). A floating-point binary number is represented in a similar manner except that is uses base 2
for the exponent. A floating-point number is said to be normalized if the most significant digit of the
mantissa is 1.
Note that signed integers and exponent are represented by either sign representation, or one’s
complement representation, or two’s complement representation.
The floating point representation is more flexible. Any non-zero number can be represented in the
normalized form of ±(1.b1b2b3 ...)2x2n This is normalized form of a number x.
Example: Suppose number is using 32-bit format: the 1 bit sign bit, 8 bits for signed exponent, and
23 bits for the fractional part. The leading bit 1 is not stored (as it is always 1 for a normalized
number) and is referred to as a “hidden bit”.
Where 10000100 is the 8-bit binary value of exponent value +5 in form of baised representation.
Note that with bias of 127, 8-bit exponent field is used to store true integer exponents values are
-127 ≤ n ≤ 128.
IEEE (Institute of Electrical and Electronics Engineers) has standardized Floating-Point Representation
as following diagram.
So, actual number is (-1)s(1+m)x2(e-Bias), where s is the sign bit, m is the mantissa, e is the exponent
value, and Bias is the bias number. The sign bit is 0 for positive number and 1 for negative number.
Exponents are represented by or two’s complement representation.
According to IEEE 754 standard, the floating-point number is represented in following ways:
Half Precision (16 bit): 1 sign bit, 5 bit exponent, and 10 bit mantissa
Single Precision (32 bit): 1 sign bit, 8 bit exponent, and 23 bit mantissa
Double Precision (64 bit): 1 sign bit, 11 bit exponent, and 52 bit mantissa
Quadruple Precision (128 bit): 1 sign bit, 15 bit exponent, and 112 bit mantissa
All the exponent bits 0 with all mantissa bits 0 represents 0. If sign bit is 0, then +0, else -0.
All the exponent bits 1 with all mantissa bits 0 represents infinity. If sign bit is 0, then +∞, else -∞.
All the exponent bits 0 and mantissa bits non-zero represents denormalized number.
All the exponent bits 1 and mantissa bits non-zero represents error.
Arithmetic operations on floating point numbers consist of addition, subtraction, multiplication and
division.
The operations are done with algorithms similar to those used on sign magnitude integers
(because of the similarity of representation) -- example, only add numbers of the same sign. If the
numbers are of opposite sign, must do subtraction.
# ADDITION
3.25 x 103
+ 2.63 x 10-1
-----------------
3.25 x 103
+ 0.000263 x 103
--------------------
3.250263 x 103
(presumes use of infinite precision, without regard for accuracy)
Example on floating point value given in binary: i.e. 100 + 0.25 = 100.25 = 1.0025 X 102
Step 3: Normalize the result (get the "hidden bit" to be a 1), it already is for this example.
# SUBTRACTION
Like addition as far as alignment of radix points then the algorithm for subtraction of sign mag.
numbers takes over.
#MULTIPLICATION
Example on decimal values given in scientific notation:
3.0 x 101
0.5 x 102
-------------
1.50 x 103
Add exponents: Always add true exponents (otherwise the bias gets added in twice)
Biased:
10000011 - 01111111= 00000100 (true exp is 4) and
10000100 -01111111 = 00000101 (true exp is 5)
Now put the result back together (and add sign bit).
0 10001000 10.1110111
This is the value stored (not the hidden bit!): 0 10001001 01110111
https://www.rapidtables.com/calc/math/binary-calculator.html
#DIVISION
Similar to multiplication.
True division: do unsigned division on the mantissas (don't forget the hidden bit)
subtract TRUE exponents
--------------------------------------------End of Unit-2--------------------------------------------------------