Computer Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Advertisements

Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Major Numeric Data Types Unsigned Integers Signed Integer Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
Fixed-Point Arithmetics: Part I
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Operations on data CHAPTER 4.
School of Computer Science G51CSA 1 Computer Arithmetic.
Lecture 12: Computer Arithmetic Today’s topic –Numerical representations –Addition / Subtraction –Multiplication / Division 1.
Data Representation – Binary Numbers
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Conversion Between Lengths Positive number pack with leading zeros +18 = = Negative numbers pack with leading ones -18 =
Computer Arithmetic.
ECE232: Hardware Organization and Design
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
L/O/G/O CPU Arithmetic Chapter 7 CS.216 Computer Architecture and Organization.
ECE 456 Computer Architecture
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Computer Architecture Lecture 22 Fasih ur Rehman.
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
IT253: Computer Organization
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
Chapter 8 Computer Arithmetic. 8.1 Unsigned Notation Non-negative notation  It treats every number as either zero or a positive value  Range: 0 to 2.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
More Binary Arithmetic - Multiplication
Integer Division.
NxN Crossbar design for Barrel Shifter
Floating Point Number system corresponding to the decimal notation
William Stallings Computer Organization and Architecture 7th Edition
Computer Organization and ASSEMBLY LANGUAGE
Data Representation Data Types Complements Fixed Point Representation
ECEG-3202 Computer Architecture and Organization
Computer Architecture
Chapter 8 Computer Arithmetic
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Computer Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski

Arithmetic-Logical Unit (ALU) Performs arithmetic-logical operations Calculations are performed on the binary system numbers (Boole’s algebra) ALU CU registers state pointers (flags) registers

Number representations Integer numbers: Real numbers: = , = 1, LSB MSB

Integer numbers (fixed point representation) Representation of the unsigned number A: Sign-magnitude representation: Two’s complement (U2):

Examples (sign-magnitude) = = = = double zero representation addition and subtraction requires analysis of signs and magnitudes

Integer systems characteristics Adding the opposite number Additional algorithm Subtraction When signs of the operands are equal and result's opposite Sign and magnitude analysis Overflow Additional bits filled with a sign Additional bits = 0 MSB  sign Increase bits number Two’s complementChange MSBNegation OneTwoZero representations -2 n-1 to 2 n n-1 +1 to 2 n-1 -1Range Two’s complementSign-magnitudeCharacteristics

Arithmetic operations on integers (1) Negation: Sign-magnitude (21) (-21) Two’s complement (21) NEG(21) (-21)

Arithmetic operations on integers (2) Conversion between lengths: Sign-magnitude (21) 8b (21) 16b (-21) (-21) 16b Two’s complements (21) 8b (21) 16b (-21) 8b (-21) 16b

Arithmetic operations on integers (3) Addition: Sign-magnitude (25) (13) (38) (-25) (-13) (-38) (-25) x (13) x NEG(13) (-12) (-12) (-13) x (25) x NEG(25) (12) R NEG(R)

Arithmetic operations on integers (4) Addition: Two’s complements (25) (13) (38) (-25) (-13) (-38) (-25) (13) (-12) (-13) (25)

Arithmetic operations on integers (5) Multiplication Unsigned integers: 0111 (7) 4b 0101 (5) 4b (35) 8b !!

Increasing effectiveness of the multiplication Every partial result can be summed at once (fewer registers!) Multiplying by zero is only bit shifting!

Hardware realization of the unsigned integers multiplication Carry (C) Accumulator (A)

Example of the hardware algorithm’s work C A Q M starting values add shift right move add shift move result

Multiplication in Two’s complement representation Signed integers: 1001 (-7)  multiplier 0011 (3)  multiplicand (-21) Different interpretation of the binary shifting Negative number must be represented in the two’s complement code

Realization of the multiplication in the Two’s complement code –Booth’s algorithm A  0, Q -1  0, LOAD(M, Q) Bit counter = n Right shifting A, Q, Q -1 Bit counter = bit counter - 1 A  A - M A  A + M START Q 0, Q -1 STOP Bit count.=0 YES =01 =10 =11 =00 NO

Example of the Two’s complement code multiplication (7 x 3 operation) A Q Q -1 M starting values subtract shift arithmetically shift arithmetically add shift arithmetically shift arithmetically result

Division of unsigned integers A  0, LOAD(M, Q) Bit counter = n Bit counter = bit counter - 1 Q 0  1 Q 0  0 A  A + M START A < 0? STOP Bit count.=0 YES NO Move A,Q left A  A - M

Division of integers in Two’s complement representation LOAD(A, M, Q) Bit counter = n Bit counter = bit counter - 1 Q 0  0 Q 0  1 START Oper. successful? STOP Bit count.=0 YES NO Move A,Q left A  A - M signs A, M identical? A  A + M NO YES restore A

Example of the Two’s complement representation division (–7/3 operation) A Q M starting values shift left 0010 add restore shift left 0001 add restore shift left 1111 add set Q 0 = shift left 0010 add restore result

Floating point representation Used to represent very small and very large numbers Form the following number: where: m – mantissa c – exponent b - base

Examples 1.24 x 10 7 (1.24e7) 5.82 x x x Format of the 32-bit floating point number: 8 bits 23 bits sign exponent mantissa

Representation of the floating point binary number 1, x 2 20 = x , x 21, , , x 20, ,53125 x 21,0625 0, ,0625 x 20, ,125 x 20,25 0 0,25 x 20,5 1 0,5 x 21,0 0

Representation of the binary floating-point number 1, x 2 20 = x Exponent is a displaced number at 127, so 20 = = 147 (as above)

Normalization of the floating- point number Exponent is changed, so the first mantissa’s digit before the comma was non-zero Because the non-zero number is 1, it does not have to be stored

Range and accuracy of the floating-point numbers For the 32-bit number: Exponent is 8-bit, so range is Mantissa is 23-bit, so accuracy is = 1.2 x We make a compromise between the accuracy and range

Density of the floating point numbers -n 0 n 2n 4n negative overflow positive overflow zero negative underflow positive underflow

Standard IEEE 754 Apllied standard of storing floating point numbers Refers to the 32- i 64-bit numbers Exponent of length, respectively, 8 i 11 bits Default base is 2 Predefined formats for the indirect calculations

Special values in IEEE 754 c = 0, m = 0 – positive or negative zero c = , m = 0 – positive or negative infinity c = 0, m  0 - denormalized number (bit on the left from the comma is zero!) c = , m  0 - NaN

Floating point arithmetics Basic operations:

Addition and subtraction 1.Checking for zeros 2.Equalization of mantissas 3.Adding or subtracting of mantissas 4.Result normalization Example: (123 x 10 0 )+(456 x )=(123 x 10 0 )+(4,56 x 10 0 ) = = 127,56 x 10 0

Multiplying and dividing 1.Checking zeros 2.Adding exponents and subtracting shifted values from the sum 3.Checking for exponent overflow and underflow 4.Multiplication of the mantissas considering signs (sign-magnitude representation!) 5.Rounding and normalization of the multiplication result

Logical structures (1) Basic gates: ABAB Y Y = A AND B ABAB Y A Y Y = A OR B A = NOT Y ABY ABY ABY ABY AY1001AY1001

Logical structures (2) Additional gates: ABAB Y Y = A NAND B ABAB Y Y = A NOR B ABY ABY ABY ABY ABAB Y = A XOR B Y ABY ABY

Logical structures (3) Half-adder ABAB SCSC ABSC ABSC A S B C

Logical structures (4) Adder A S B C A S B C CiABCiAB SCoSCo A B C i S C o

Logical structures (5) 4-bit adder A 0 B 0 A 1 B 1 A 2 B 2 A 3 B 3 0 S 0 S 1 S 2 S 3 C1C1 C2C2 C3C3 C4C4