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

COA Module 3

Uploaded by

praptigandhi14
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

COA Module 3

Uploaded by

praptigandhi14
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 99

Module 03

Data Representation: and Arithmetic


Algorithms
By
Mrs Sudeshna Baliarsingh
Dept. of IT
Data Representation: and Arithmetic Algorithms:
1. Number Systems: Introduction to Number Systems
2. Binary Number Systems
3. Signed Binary Numbers
4. Binary, Octal, Decimal and Hexadecimal Number and their Conversions
5. 1’s and 2’s Complement
6. Basics of Digital Circuits: NOT, AND, OR, NAND, NOR, EX-OR, EX-NOR
Gates
7. Introduction to K-Mal Booth’s Algorithm
8. Division of Integers: Restoring and Non-Restoring Division
9. Signed Division Floating-Point Representation: IEEE 754 Floating Point
(Single & Double Precision) Number Representation.
Books to Refer: Modern Digital
Electronics by R P Jain
Number Systems: Introduction to Number Systems
A number system is a method to represent numbers mathematically. It can use arithmetic
operations to represent every number uniquely. To represent a number, it requires a base or
radix.
Types of Number Systems
Based on the base value and the number of allowed digits, number systems are
of many types.

Table 2.1
Binary Number System
Number System with base value 2 is termed as Binary number system. It
uses 2 digits i.e. 0 and 1 for the creation of numbers. The numbers
formed using these two digits are termed Binary Numbers. The binary
number system is very useful in electronic devices and computer systems
because it can be easily performed using just two states ON and OFF i.e.
0 and 1.
The leftmost bit is called as the most significant bit (MSB) and the right
most bit is called as least significant bit (LSB). Any number of 0s can be
added to the left of the number without changing the value of the number.
In binary system , a group of 4 bits is called as the Nibble and a group of
eight bits is called a byte.
Example of 19 in the binary system Remember
Exp 1
Here 19 Or (19)10 can be written as (10011)2
Exp 2

Exp
3
● Bit is the smallest unit of data
● 1 Nibble = 4 bits (Nibble is used in BCD and
Hexadecimal number)
● 1 Byte= 8bits
● 1 Word= 16 bit
● 1 Double word= 32 bit
Decimal Number System
Number system with a base value of 10 is termed a Decimal number system.
It uses 10 digits i.e. 0-9 for the creation of numbers.
Here, each digit in the number is at a specific place with a place value of a
product of different powers of 10.
Here, the place value is termed from
right to left as first place value called units,
second to the left as Tens, so on Hundreds,
Thousands, etc.
Test Yourself:
Test Yourself :
Signed Binary Numbers
In the decimal number system a plus (+) sign is used to denote a positive number and
a minus (-) sign for denoting a negative number.

The plus sign is usually dropped, and the absence of any sign means that the number
has positive value.

This representation of numbers is known as signed number.

As is well known, digital circuits can understand only two symbols, 0 and 1; therefore,
we must use the same symbols to indicate the sign of the number also.

Normally, an additional bit is used as the sign bit and it is placed as the most
significant bit.

A 0 is used to represent a positive number and a 1 to represent a negative


number.
Signed Binary Numbers
For example, an 8-bit signed number 01000100 represents a positive number and its value
(magnitude) is (1000100)2 = (68)10.

The left most 0 (MSB) indicates that the number is positive.

On the other hand, in the signed binary form, 11000100 represents a negative number with
magnitude (1000100)2 = (68)10

The 1 in the left most position (MSB) indicates that the number is negative and the other
seven bits give its magnitude.

This kind of representation for signed numbers is known as sign-magnitude


representation.

The user must take care to see the representation used while dealing with the binary
numbers.
One’s Complement Representation
In a binary number, if each 1 is replaced by 0 and each 0 by 1, the resulting
number is known as the one's complement of the first number.

In fact, both the numbers are complement of each other.

If one of these numbers is positive, then the other number will be negative with the
same magnitude and vice-versa.

For example, (0101), represents (+5) 10, whereas (1010), represents (-5) 10 in this
representation.

This method is widely used for representing signed numbers.

In this representation also, MSB is 0 for positive numbers and 1 for negative
numbers.
Two’s Complement Representation
If 1 is added to 1's complement of a binary number, the resulting number is known as
the two's complement of the binary number.

For example, 2's complement of 0101 is 1011.

Since 0101 represents (+5) 10, therefore,


1011 represents (-5)10 in 2's complement
representation.

In this representation also,


if the MSB is 0 the number is positive,
whereas if the MSB is 1
the number is negative.
Test Yourself
Binary Addition
Test Yourself
Binary Subtraction
Binary Multiplication
Binary Division
Octal Number System
The number system with base (or radix) eight is known as the octal number system.
In this system, eight symbols, 0, 1, 2, 3, 4, 5, 6, and 7 are used to represent numbers.

Similar to decimal and binary number systems, it is also a positional system and has, in general, two parts:
integer and fractional, set apart by a radix (octal) point (.).

The weights assigned to the various positions are given in Table 2.1. For example, (6327.4051), is an octal
number.
Decimal to Octal Number System
The conversion from decimal to octal (base-10 to base-8) is similar to the conversion procedure for base-10 to
base-2 conversion.

The only difference is that number 8 is used in place of 2 for division in the case of integers and for
multiplication in the case of fractional numbers.
Decimal to Octal Number System
Octal Number System
The number system with base (or radix) eight is known as the octal number
system.
In this system, eight symbols, 0, 1, 2, 3, 4, 5, 6, and 7 are used to represent
numbers.
Similar to decimal and binary number systems, it is also a positional system and
has, in general, two parts: integer and fractional, set apart by a radix (octal)
point (.).

For example, (6327.4051), is an octal number.


Octal To Decimal Conversion
Decimal to Octal conversion
Test Yourself:
Test Yourself
HexaDecimal Number system
We have already learnt that :
Test Yourself:
Signed Division Floating-Point Representation: IEEE
754 Floating Point (Single & Double Precision) Number
Representation.
Introduction Floating
Point Numbers
Impractical!!!!!

Here in 0.623
when
converting to
binary we
dont really
know when
will entire
sequence of
0’s will come
This information will be
saved in a fixed bit
memory representation
like the below fig.

But before we save we


need to know about the
Need of
Normalisation

This information will be


saved in a fixed bit memory
representation 10 bit of
memory space
Shifted Radix towards left to 3bits

Shifted radix towards left to 2 bits

Shifted radix towards left but 4 bits

Shifted radix towards right but 3 bits so it's

We can represent the mantissa


and exponent in various
ways…….This process leads to
confusion
Explicit Representations:
Implicit Representations:
The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point
computation which was established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE).
The standard addressed many problems found in the diverse floating point implementations that made them
difficult to use reliably and reduced their portability. IEEE Standard 754 floating point is the most common
representation today for real numbers on computers, including Intel-based PC’s, Macs, and most Unix platforms.

IEEE 754 Revisions


Accumulati
on of
signed and
mantissa 2^5
Pattern -14 to +15
portion
85.125 Represent the number in single and Double precision
85 = 1010101
0.125 = 001
85.125 = 1010101.001
=1.010101001 x 2^6
sign = 0

1. Single precision:
biased exponent 127+6=133
133 = 10000101
Normalised mantissa = 010101001
we will add 0's to complete the 23 bits

The IEEE 754 Single precision is:


= 0 10000101 01010100100000000000000
This can be written in hexadecimal form 42AA4000

2. Double precision:
biased exponent 1023+6=1029
1029 = 10000000101
Normalised mantissa = 010101001
we will add 0's to complete the 52 bits

The IEEE 754 Double precision is:


= 0 10000000101 0101010010000000000000000000000000000000000000000000
This can be written in hexadecimal form 4055480000000000
K-Mal’s Booth Algorithm
Application of Booth’s Algorithm:
1. Processors: Speeds up arithmetic operations in ALUs, enhancing performance in tasks like
graphics and cryptography.
2. DSP: Improves efficiency in real-time processing of audio, video, and signals by optimizing
large binary multiplications.
3. Hardware Accelerators: Accelerates multiplication in specialized hardware for image
processing, AI, and machine learning.
4. Cryptography: Enhances the efficiency of modular multiplication in encryption and digital
signature algorithms.
5. HPC: Optimizes large-scale multiplications in scientific simulations, boosting overall system
performance.
6. Embedded Systems: Reduces energy consumption and improves multiplication efficiency in
resource-limited devices.
7. Network Processing: Decreases processing time and power usage in network devices handling
packet headers and payloads.
Advantages:
Faster than traditional multiplication: Booth’s algorithm is faster than traditional multiplication methods, requiring
fewer steps to produce the same result.
Efficient for signed numbers: The algorithm is designed specifically for multiplying signed binary numbers, making
it a more efficient method for multiplication of signed numbers than traditional methods.
Lower hardware requirement: The algorithm requires fewer hardware resources than traditional multiplication
methods, making it more suitable for applications with limited hardware resources.
Widely used in hardware: Booth’s algorithm is widely used in hardware implementations of multiplication
operations, including digital signal processors, microprocessors, and FPGAs.

Disadvantages:
Complex to understand: The algorithm is more complex to understand and implement than traditional
multiplication methods.
Limited applicability: The algorithm is only applicable for multiplication of signed binary numbers, and cannot be
used for multiplication of unsigned numbers or numbers in other formats without additional modifications.
Step-by-Step Explanation of Booth's Algorithm

1. Initialization:
- Acc (Accumulator)** is initialized to `0`.
- Q (Multiplier)** is set to the binary value of the multiplier.
- M (Multiplicand)** is set to the binary value of the multiplicand.
- Q-1 (Previous Bit)** is initialized to `0`.
- Count is initialized to the number of bits in the multiplier (`n`).

2. Evaluate the Current Pair of Bits (Q0 and Q-1):


- Q0 (Least Significant Bit of Q)** and **Q-1** are the bits that determine the
operation:
- If Q0 and Q-1 = 01:** Perform `Acc = Acc + M` (Add the multiplicand to the
accumulator).
- If Q0 and Q-1 = 10:** Perform `Acc = Acc - M` (Subtract the multiplicand from
the accumulator).
- If Q0 and Q-1 = 00 or 11:** No addition or subtraction is done.
3. Arithmetic Right Shift:
- After the addition or subtraction operation (if any), perform an **Arithmetic Right
Shift** on the concatenated value of `Acc`, `Q`, and `Q-1`.
- This operation shifts all bits to the right, preserving the sign bit of `Acc`.
- The count is decremented by 1 after the shift.

4. Check the Count:


- f Count = 0: The algorithm stops. The final result of the multiplication is stored in
the combined register `[Acc Q]`.
- If Count ≠ 0: The algorithm goes back to step 2, continuing the process until the
count reaches 0.

5. End of the Algorithm:


- The loop continues until all the bits of the multiplier have been processed (i.e.,
`Count` becomes 0).
- The final product is found in the combined content of the `Acc` and `Q` registers.
Operations
Multiply 01011 with 01110 using Booth’s Algorithm.
Given

Initialisation

Accumulator will perform operation and store the result .


Accumulator and Q-1 will be initialised to 0 ( no. of bits will be equal to the Q i.e 5
and for Q-1 1 bit) . Q-1 is a flip flop which is the previous bit of Q0 in Q. Also find
I.e2’s complement of M = 10101.
3. Operations will be performed in Accumulator Q and Q-1
4. Operations will be performed based on the bits present in the Q0 & Q-1 Memory cells
i.e LSB of Q and Q-1 .
5. Write the initial condition and values of A , Q ,Q-1.
6. Now check the value of Q0 Q-1 =00, which is 00 here.
7.Now check the combinations and find out which operation to be done. Here we have to
perform ARS as

8.In booth's algorithm we are performing negative inverse of a value so whenever we


perform the shifts we should remember the shifts are to be performed keeping sign bit
extension of 2’s complement in mind.
9. So we will shift all the bit to right by 1 cell however, whatever present in the MSB place
we have to copy in the vacant place.
10.The no. of steps should be equal to no. of bits on Multiplier (Q).
11. If in question both no. given in decimal form and are negative then need to find 2’s
complement of both the numbers.
C

0 0
n=5=
101

1 0

1 1 100

011
1 1 010

011

0 1
000
Division of Integers: Restoring and Non-Restoring Division
Signed Division.
Basics of Digital Circuits: NOT, AND, OR,
NAND, NOR, EX-OR, EX-NOR Gates

You might also like