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

Computer Architecture and

Organization

• Course Code: BCSE205L


• Course Type: Theory (ETH)
• Slot: D2+TD2
• Timings:

Monday 16:00-16:50
Wednesday 17:00-17:50
Thursday 14:00-14:50
Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore
Syllabus- Module 2
Module:2 Data Representation and Computer Arithmetic 10 hours

Algorithms for fixed point arithmetic operations: Multiplication (Booths,


Modified Booths), Division (restoring and non-restoring) - Algorithms for
floating point arithmetic operations - Representation of nonnumeric data
(character codes).

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Arithmetic & Logic Unit:
• Does the calculations
• Everything else in the computer is there to service this unit
• Handles integers
• May handle floating point (real) numbers
• May be separate FPU (A floating-point unit: maths co-processor colloquially a
math coprocessor, is a part of a computer system specially designed to carry
out operations on floating-point numbers.maths co-processor)
• May be on chip separate FPU (486DX +)

Flag: For a number of reasons, it can be important to export a number of status codes from the ALU, for detecting errors, and for
making decisions. Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore
Data Representation

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Data Representation: Integer /Fixed point representations
• There are different binary representations for integers
• possible qualifications
1. positive numbers only 2. positive and negative numbers
3. ease of human readability 4. speed of computer operations
• There are 4 commonly known (1 not common) integer representations
1. unsigned
2. sign magnitude
3. one's complement
4. two's complement
All have been used at various times for various reasons

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :UNSIGNED
The standard binary encoding already given only positive values
range: 0 to 2n -1 for n bits
Example: 4 bits, values 0 to 15
n=4, 24 -1 is 15

Unsigned integer (or fixed-point)


representations are numerical formats that
represent non-negative whole numbers. In
the context of fixed-point representation,
the term "unsigned" indicates that the
numbers are always positive or zero; there
is no sign bit dedicated to representing
negative values.

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :UNSIGNED
Advantages of Unsigned Integer (or Fixed-Point) Representations:
• Simplicity: Unsigned representations are straightforward and simple to understand. There is no need to deal with sign bits and
the complexities associated with representing both positive and negative numbers.

• Efficiency: Unsigned integer operations are often more efficient in hardware because there is no need to perform additional
operations for sign extension or handling negative numbers.

• Memory Efficiency: Unsigned representations can be more memory-efficient when negative values are not needed. This is
crucial in applications with limited memory resources.

• Logical Operations: Logical operations (e.g., AND, OR, XOR) on unsigned integers are straightforward and align with
common bitwise operations.

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :UNSIGNED
Limitations of Unsigned Integer (or Fixed-Point) Representations:

• Limited Range: Unsigned integers have a limited range, representing only non-negative values. If
negative numbers need to be represented, an alternative signed representation is required.

• No Representation of Negative Values: Unsigned representations cannot represent negative values,


which can be a significant limitation in certain applications where negative numbers are meaningful.

• Arithmetic Overflow: Unsigned integers are susceptible to arithmetic overflow, where the result of an
operation exceeds the maximum representable value. This can lead to unexpected behavior and
requires careful handling.

• Complexities in Certain Operations: Certain mathematical operations, such as subtraction, become


more complex with unsigned integers. Borrowing in subtraction may require additional attention.

• Compatibility Issues: When interfacing with systems that use signed representations, conversion and
compatibility issues may arise. It's important to handle data types carefully in mixed-sign
environments. Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore
Integer /Fixed point representations :Sign-Magnitude
Sign-magnitude representation is a numerical format used to represent both
positive and negative numbers. In this representation, a specific bit is used to
indicate the sign of the number (positive or negative), and the remaining bits
represent the magnitude (absolute value) of the number.
• Use left most (most significant bit, MSB) bit of integer to represent the sign of
the integer
• 0 be positive,
• 1 be negative.
• The rest of the integer is a magnitude, using same encoding as unsigned integers

• Example: 4 bits • Example: 8 bits


• 0101 is 5 • +18 = 00010010
• 1101 is -5 Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore • -18 = 10010010
Integer /Fixed point representations :Sign-Magnitude
Advantages of Sign-Magnitude Representation:

• Ease of Interpretation: Sign-magnitude representation is easy to interpret, as


the sign bit directly indicates whether the number is positive or negative.

• Human Readability: The representation aligns well with human intuition,


making it more readable and understandable.

• Straightforward Sign Manipulation: Sign manipulation, such as changing


the sign of a number, is straightforward by toggling the sign bit.

• Clear Sign Information: Sign-magnitude representation explicitly separates


the sign from the magnitude, providing clear information about the nature of
the number. Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore
Integer /Fixed point representations :Sign-Magnitude (Problems)

• range: -2n-1 + 1 to 2n-1 -1


• where n is the number of bits 4 bits, -7 to +7
• n=4,
• - 23 + 1 to 23 – 1
• Means: -8 + 1 to 8–1
• Things to Notice: Because of the sign bit, there are 2 representations for 0.
This is a problem for hardware. . .
• 0000 is 0, 1000 is 0
• The computer must do all calculations such that they come out correctly and
the same whichever representation is used.

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :ONE's COMPLEMENT
• The complement is used for representing the negative decimal number in binary
form.
• Way: For finding 1's complement of the binary number, we can implement the logic
circuit also by using NOT gate. For finding 1's complement of the given number,
change all 0's to 1 and all 1's to 0.
• Historically important, and we use this representation to get 2's complement integers.
• Now, nobody builds machines that are based on 1's comp. integers.
• In the past, early computers built by Semour Cray (while at CDC: Control Data
Corporation (CDC) was a mainframe and supercomputer firm) were based on 1's
comp. integers.
• positive integers use the same representation as unsigned.
• 00000 is 0
• 00111 is 7, etc.
• negation (finding an additive inverse) is done by taking a bit wise complement of the
positive representation. Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore
Integer /Fixed point representations :ONE's COMPLEMENT
• COMPLEMENT. INVERT. NOT. FLIP. NEGATE.
• a logical operation done on a single bit
• the complement of 1 is 0.
• the complement of 0 is 1
• EXAMPLES: 11001
• This must be a negative number.
• To find out which, find the additive inverse!
• 00110 is +6 by sight,
• so 11001 must be -6

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :ONE's COMPLEMENT
Problem:

Things to notice:
• 1. any negative number will have a 1 in the MSB.
• 2. there are 2 representations for 0,
• 00000 and 11111.
+6: 0110
-6: 1001
-----------
0: 1111

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :TWO's COMPLEMENT
• Just like 1's complement, 2's complement is also used to represent the signed
binary numbers. positive values are the same as for sign/mag and 1's comp.
• They will have a 0 in the MSB (but it is NOT a sign bit!) positive:
• just write down the value as before negative:

• For finding 2's complement of the binary number, we will first find the 1's
complement of the binary number and then add 1 to the least significant bit
of it.
• To get the additive inverse of a 2's comp integer,
• 1. take the 1's comp.
• 2. add 1
Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore
Integer /Fixed point representations :TWO's COMPLEMENT

range: -2n-1 to 2n-1 -1

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :TWO's COMPLEMENT

• A variation on 1's complement that does NOT have 2 representations for 0.


• This makes the hardware that does arithmetic faster than for the other
representations.
• A 3-bit example:
• bit pattern: 100 101 110 111 000 001 010 011
• 1's comp: -3 -2 -1 0 0 1 2 3
• 2's comp.: -4 -3 -2 -1 0 1 2 3
• the negative values are all "slid" down by one, eliminating the extra zero
representation

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Integer /Fixed point representations :TWO's COMPLEMENT
A Number circle representation for 3-bit two s complement number

range: -2n-1 to 2n-1 -1

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


range: -2n-1 to 2n-1 -1

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Summary
• ALU
– Arithmetic & Logic Unit
• Data Representations
• Fixed point representations
• Unsinged
• Sign Magnitude
• 1’s Complement
• 2’s Complement
• 3-bit two s complement number

Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore


Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore
Dr. Venkata Phanikrishna B, SCOPE, VIT-Vellore

You might also like