0% found this document useful (0 votes)
39 views32 pages

W13 Arithmetic Logic Unit Binary Integer Representation Binary Integer Arithmetic - PPT PDF

The document discusses arithmetic logic units, binary integer representation, binary integer arithmetic, and binary floating-point representation. Specifically, it defines the arithmetic logic unit and describes its arithmetic, bitwise, and bit shift operations. It also covers binary integer variables, representation of positive integers in binary, and methods for binary integer addition and multiplication, including unsigned, signed, and fractional numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views32 pages

W13 Arithmetic Logic Unit Binary Integer Representation Binary Integer Arithmetic - PPT PDF

The document discusses arithmetic logic units, binary integer representation, binary integer arithmetic, and binary floating-point representation. Specifically, it defines the arithmetic logic unit and describes its arithmetic, bitwise, and bit shift operations. It also covers binary integer variables, representation of positive integers in binary, and methods for binary integer addition and multiplication, including unsigned, signed, and fractional numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Week 13

ARITHMETIC LOGIC UNIT, BINARY


INTEGER REPRESENTATION, BINARY
INTEGER ARITHMETIC, BINARY
FLOATING-POINT REPRESENTATION

Design and deliver beautiful presentations with


ease and confidence.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

OBJECTIVES

At the end of the lesson the learner will be able to:


Define ALU
Identify the different types of arithmetic
operations used in ALU
Apply the binary integer representation
Describe the floating-point representation
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

ARITHMETIC LOGIC UNIT

An arithmetic logic unit (ALU) is


a combinational digital electronic
circuit that performs arithmetic and bitwise
operations on integer binary numbers.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

ARITHMETIC LOGIC UNIT

ARITHMETIC OPERATIONS
• ADD
• ADD WITH CARRY
• SUBTRACT
• SUBTRACT WITH BORROW
• TWO’S COMPLEMENT
• INCREMENT
• DECREMENT
• PASS THROUGH
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

ARITHMETIC LOGIC UNIT

BITWISE LOGICAL OPERATIONS


• AND
• OR
• EXCLUSIVE-OR
• ONE’S COMPLEMENT
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

ARITHMETIC LOGIC UNIT

BIT SHIFT OPERATIONS


• ARITHMETIC SHIFT
• LOGICAL SHIFT
• ROTATE
• ROTATE THROUGH CARRY
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

ARITHMETIC LOGIC UNIT

MULTIPLE-PRECISION ARITHMETIC
• In integer arithmetic computations, multiple-precision
arithmetic is an algorithm that operates on integers which are
larger than the ALU word size. To do this, the algorithm treats
each operand as an ordered collection of ALU-size fragments,
arranged from most-significant (MS) to least-significant (LS) or
vice versa.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

ARITHMETIC LOGIC UNIT

COMPLEX OPERATIONS
• CALCULATION IN A SINGLE CLOCK
• CALCULATION PIPELINE
• ITERATIVE CALCULATION
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER VARIABLE

A binary integer variable—also called a 0/1


variable—is a special case of an integer variable
that is required to be either zero or one. It's
often used as a switch to model Yes/No
decisions.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER DECIMAL

The IEEE 754-2008 standard includes an encoding


format for decimal floating point numbers in which
the significand and the exponent (and the payloads
of NaNs) can be encoded in two ways, referred to in
the draft as binary encoding and decimal encoding.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

BINARY REPRESENTATION OF POSITIVE INTEGERS

Binary representations of positive can be understood in the same way as


their decimal counterparts. For example
8610 = 1*64 + 0*32 + 1*16 + 0*8 + 1*4 + 1*2 + 0*1
or
8610 = 1* 26 + 0* 25 + 1* 24 + 0* 23 + 1* 22 + 1* 21 + 0* 20
or
8610 = 1010110 2
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

BINARY REPRESENTATION OF POSITIVE INTEGERS

The subscript 2 denotes a binary number. Each digit in a binary


number is called a bit. The number 1010110 is represented by 7
bits. Any number can be broken down this way, by finding all of
the powers of 2 that add up to the number in question (in this
case 26, 24, 22 and 21). You can see this is exactly analagous to
the decimal deconstruction of the number 125 that was done
earlier. Likewise we can make a similar set of observations:
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER ARITHMETIC,
BINARY FLOATING-POINT REPRESENTATION

BINARY REPRESENTATION OF POSITIVE INTEGERS

To multiply a number by 2 you can simply shift it to the left by one digit,
and fill in the rightmost digit with a 0. To divide a number by 2, simply shift
the number to the right by one digit.
To see how many digits a number needs, you can simply take the
logarithm (base 2) of the number, and add 1 to it. The integer part of the
result is the number of digits. For instance,
log2(86) + 1 = 7.426.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY REPRESENTATION OF POSITIVE INTEGERS

The integer part of that is 7, so 7 digits are needed.


With n digits, 2n unique numbers (from 0 to 2n-1)
can be represented. If n=8, 256 (=28) numbers can
be represented 0-255.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC


This presentation will introduce you to the methods for adding
and multiplying binary numbers. In each section, the topic is
developed by first considering the binary representation of
unsigned numbers (which are the easiest to understand),
followed by signed numbers and finishing with fractions (the
hardest to understand). For the most part we will deal with:
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

ADDITION
• ADDING UNSIGNED NUMBERS
• ADDING SIGNED NUMBERS
• ADDING FRACTIONS
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

MULTIPLICATION
• MULTIPLYING UNSIGNED NUMBERS
• MULTIPLYING SIGNED NUMBERS
• MULTIPLYING FRACTIONS
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

ADDING UNSIGNED NUMBERS

Decimal Unsigned Binary Decimal Unsigned Binary

0
1 110 1101 (carry)
(carry) (carry) (carry)
1101
06 0110 13
+07 +0111 +0101
+05
13 1101 10010
18
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

ADDING SIGNED NUMBERS

Decimal Signed Binary Decimal Signed Binary

1110 (carry) 011 (carry)


-2 5
1110 1011
+3 +3
+0011 +0011
1 -2
0001 1110
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

ADDING FRACTIONS

Decimal Fractional Binary Decimal Fractional Binary

1110 (carry) 011(carry)


-0.25 -0.625
1110 1011
+0.375 +0.375
+0011 +0011
0.125 -0.25
0001 1110
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

MULTIPLYING UNSIGNED NUMBERS

Decimal Binary Decimal Binary

1010 1101
x0110 x1110
10 0000 13 0000
x6 1010 x14 1101
60 1010 182 1101
+0000 +1101
0111100 10110110
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

MULTIPLYING SIGNED NUMBERS

There are many methods to multiply 2's complement numbers. The easiest is to simply
find the magnitude of the two multiplicands, multiply these together, and then use the
original sign bits to determine the sign of the result. If the multiplicands had the same
sign, the result must be positive, if the they had different signs, the result is negative.
Multiplication by zero is a special case (the result is always zero, with no sign bit).
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY INTEGER ARITHMETIC

MULTIPLYING FRACTIONS

Fractional
Decimal
Binary

1100
x0100
-0.5
0000
x0.5
0000
-0.25
+111100
11110000
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


The two most common floating-point binary storage formats used by Intel
processors were created for Intel and later standardized by the IEEE
organization:

1 bit for the sign, 8 bits for the exponent, and 23 bits for the mantissa. Also
IEEE Short Real: 32 bits
called single precision.

1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa. Also called double
IEEE Long Real: 64 bits
precision.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


The Sign
The sign of a binary floating-point number is represented by a single bit. A
1 bit indicates a negative number, and a 0 bit indicates a positive number.
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


THE MANTISSA

It is useful to consider the way decimal floating-point numbers represent


their mantissa. Using -3.154 x 105 as an example, the sign is negative,
the mantissa is 3.154, and the exponent is 5. The fractional portion of the
mantissa is the sum of each digit multiplied by a power of 10:
.154 = 1/10 + 5/100 + 4/1000
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


THE MANTISSA

A binary floating-point number is similar. For example, in the number


+11.1011 x 23, the sign is positive, the mantissa is 11.1011, and the
exponent is 3. The fractional portion of the mantissa is the sum of
successive powers of 2. In our example, it is expressed as:
.1011 = 1/2 + 0/4 + 1/8 + 1/16
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


THE MANTISSA
Or, you can calculate this value as 1011 divided by 24. In decimal terms,
this is eleven divided by sixteen, or 0.6875. Combined with the left-hand
side of 11.1011, the decimal value of the number is 3.6875. Here are
additional examples:

Binary Floating-Point Base 10 Fraction Base 10 Decimal

11.11 3 3/4 3.75

0.000000119209289550
0.00000000000000000000001 1/8388608
78125
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


THE EXPONENT
IEEE Short Real exponents are stored as 8-bit unsigned integers with a bias of 127. Let's use the number
1.101 x 25 as an example. The exponent (5) is added to 127 and the sum (162) is stored in binary as
10100010. Here are some examples of exponents, first shown as decimal values, then as biased decimal,
and finally as 8-bit unsigned binary:

Adjusted
Exponent (E) Binary Representation
(E + 127)

5 +162 10100010
0 +127 01111111
-10 +117 01110101
128 +255 11111111
-1 +126 01111110
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


Normalizing the Mantissa

Binary Value Normalized As Exponent

1101.101 1.101101 3

.00101 1.01 -3

1.0001 1.0001 0

10000011.0 1.0000011 7
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

BINARY FLOATING-POINT REPRESENTATION


Putting it All Together
Binary Value Biased Exponent Sign, Exponent, Mantissa
1 01111111 110000000000000000000
-1.11 127
00
0 10000010 101101000000000000000
+1101.101 130
00
1 01111100 010000000000000000000
-.00101 124
00
0 10000100 001110000000000000000
+100111.0 132
00
0 01111000 101011000000000000000
+.0000001101011 120
00
Week 13: ARITHMETIC LOGIC UNIT, BINARY INTEGER REPRESENTATION, BINARY INTEGER
ARITHMETIC, BINARY FLOATING-POINT REPRESENTATION

REFERENCES
https://en.wikipedia.org/wiki/Arithmetic_logic_unit
https://www.webopedia.com/TERM/A/ALU.html
https://www.lindo.com/doc/online_help/lingo15_0/binary_integer_variables.htm
https://en.wikipedia.org/wiki/Binary_integer_decimal
https://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html#posint
https://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/BinaryMath.html
http://cstl-
csm.semo.edu/xzhang/Class%20Folder/CS280/Workbook_HTML/FLOATING_tut.htm

You might also like