ECE 645 – Computer Arithmetic Lecture 2: Number Representations (2) ECE 645—Computer Arithmetic 1/29/08.

Slides:



Advertisements
Similar presentations
Mathematics of Cryptography Part II: Algebraic Structures
Advertisements

Number Representation Part 2 Little-Endian vs. Big-Endian Representations Floating Point Representations ECE 645: Lecture 5.
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Cryptography and Network Security
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
Fabián E. Bustamante, Spring 2007 Floating point Today IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Floating Point Numbers
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Cryptography and Network Security Chapter 4
Cryptography and Network Security Chapter 4 Fourth Edition by William Stallings.
CSE 321 Discrete Structures Winter 2008 Lecture 8 Number Theory: Modular Arithmetic.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
MATH 224 – Discrete Mathematics
FINITE FIELDS 7/30 陳柏誠.
CPSC 3730 Cryptography and Network Security
Information Security and Management 4. Finite Fields 8
Computer Arithmetic Nizamettin AYDIN
Cryptography and Network Security Introduction to Finite Fields.
Fixed-Point Arithmetics: Part II
Computing Systems Basic arithmetic for computers.
ECE232: Hardware Organization and Design
Data Representation in Computer Systems
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /14/2013 Lecture 16: Floating Point Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
Number Representation Part 2 Little-Endian vs. Big-Endian Representations Floating Point Representations Rounding Representation of the Galois Field elements.
Monoids, Groups, Rings, Fields
Number Representation Part 2 Floating Point Representations Little-Endian vs. Big-Endian Representations Galois Field Representations ECE 645: Lecture.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
CSC 221 Computer Organization and Assembly Language
Chapter 4 – Finite Fields
Data Security and Encryption (CSE348) 1. Lecture # 12 2.
Chinese Remainder Theorem Dec 29 Picture from ………………………
Number Representation Part 2 Fixed-Radix Signed Representations Floating Point Representations Little-Endian vs. Big-Endian Representations Galois Field.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Computer Architecture Lecture 22 Fasih ur Rehman.
Information Security Lab. Dept. of Computer Engineering 87/121 PART I Symmetric Ciphers CHAPTER 4 Finite Fields 4.1 Groups, Rings, and Fields 4.2 Modular.
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
Cryptography and Network Security Chapter 4. Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic.
FAMU-FSU College of Engineering 1 Part III The Arithmetic/Logic Unit.
Modular Arithmetic and the RSA Cryptosystem Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 9Sept 27, 2005Carnegie.
FAMU-FSU College of Engineering 1 Computer Architecture EEL 4713/5764, Spring 2006 Dr. Michael Frank Module #9 – Number Representations.
Pertemuan #5 Pengantar ke Number Theory Kuliah Pengaman Jaringan.
15-499Page :Algorithms and Applications Cryptography II – Number theory (groups and fields)
Number Representation Part 2 Floating Point Representations Rounding Representation of the Galois Field elements ECE 645: Lecture 5.
Number Representation Fixed and Floating Point
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Page : 1 bfolieq.drw Technical University of Braunschweig IDA: Institute of Computer and Network Engineering  W. Adi 2011 Lecture-5 Mathematical Background:
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Number-Theoretic Algorithms
Mathematical Background: Extension Fields
Part III The Arithmetic/Logic Unit
2.4. Floating Point Numbers
Lecture 9: Floating Point
Topics IEEE Floating Point Standard Rounding Floating Point Operations
Floating Point Number system corresponding to the decimal notation
CS/COE0447 Computer Organization & Assembly Language
Number Representation
Cryptography and Network Security
Morgan Kaufmann Publishers Arithmetic for Computers
Cryptography Lecture 19.
Mathematical Background: Extension Finite Fields
Presentation transcript:

ECE 645 – Computer Arithmetic Lecture 2: Number Representations (2) ECE 645—Computer Arithmetic 1/29/08

2 Lecture Roadmap Number systems (cont'd) Floating point number system representations Residue number number systems Galois Field number systems Endian-ness Big endian Little endian

3 Required Reading B. Parhami, Computer Arithmetic: Algorithms and Hardware Design Chapter 17, Floating-Point Representations (17.1 – 17.4, 17.6) Chapter 4, Residue Number Systems (4.1, 4.3) Note errata at:

Floating Point Number Systems ECE 645 – Computer Arithmetic

5 Number Systems Modern number systems used in digital arithmetic can be broadly classified as: Fixed-point number representation systems Integers I = {-N, …., N} Rational numbers of the form x = a/2 f, a is an integer, f is a positive integer Floating-point number representation systems x * b E, where x is a rational number, b the integer base, and E the exponent There are also special number representation systems: Residue number systems Galois Field number systems

6 Real Numbers

7 Fixed Point Numbers

8 Floating Point Numbers Floating point range of values is [-max,-min] and [min,max] max = largest significand x b largest exponent min = smallest significand x b smallest exponent

9 Floating Point Format

10 Spacing of Floating Point Numbers

11 ANSI/IEEE Short and Double Precision

12 IEEE 754 Standard (now being revised to yield IEEE 754R) Fig The ANSI/IEEE Standard Floating-Point Number Representation Formats

13 Table 17.1 ANSI/IEEE Standard Floating Point Number Representation Formats

14 Exponent Encoding 00017FFEFF7E – –1+1 Decimal code Hex code Exponent value f = 0: Representation of  0 f  0: Representation of denormals, 0.f  2 –126 f = 0: Representation of  f  0: Representation of NaNs Exponent encoding in 8 bits for the single/short (32-bit) ANSI/IEEE format Exponent encoding in 11 bits for the double/long (64-bit) format is similar 1.f  2 e

15 Exceptions

16 Special Operands

17 Denormals in the IEEE Single-Precision Format Denormals defined as numbers without a hidden 1 and with the smallest possible exponent Provided to make the effect of underflow less abrupt Requires extra hardware overhead

18 Other Features of IEEE standard

19 Floating-Point Rounding Modes

20 Fixed-Point and Logarithmic Number Systems Fixed-point can be roughly viewed as case of floating-point with exponent equal to 0 (making exponent field unecessary) Logarithmic number systems is the other extreme (assuming the significant field is always 1)

21 Logarithmic Number System Sign-and-logarithm number system: Limiting case of FLP representation x = ± b e  1 e = log b |x| We usually call b the logarithm base, not exponent base Using an integer-valued e wouldn’t be very useful, so we consider e to be a fixed-point number Fig Logarithmic number representation with sign and fixed-point exponent.

Residue Number Systems ECE 645 – Computer Arithmetic

23 Divisibility Rules and Operations Modulo

24 a | b iff  c  Z such that b = c  a a | b a divides b a is a divisor of b a | b a does not divide b a is not a divisor of b Divisibility

25 -3 | | 7 7 | | | | 14 0 | 63 7 | 0 -5 | 0 0 | 0 True or False?

26 Given integers a and n, n>0  ! q, r  Z such that a = q  n + r and 0  r < n q – quotient r – remainder (of a divided by n) q = a n = a div n r = a - q  n = a – a n  n = = a mod n Quotient and Remainder

27 32 mod 5 = -32 mod 5 = Examples

28 Two integers a and b are congruent modulo n (equivalent modulo n) written a  b iff a mod n = b mod n or a = b + kn, k  Z or n | a - b Integers Congruent modulo n

29 a + b mod n = ((a mod n) + (b mod n)) mod n a - b mod n = ((a mod n) - (b mod n)) mod n a  b mod n = ((a mod n)  (b mod n)) mod n Addition, Subtraction, Multiplication modulo n

30 9 · 13 mod 5 = 25 · 25 mod 26 = Examples

31 Chinese Remainder Theorem: Intro

32 Let N = n 1  n 2  n 3...  n M and for any i, j gcd(n i, n j ) = 1 Then, any number 0  A  N-1  RANGE OF NUMBER can be represented uniquely by A  (a 1 = A mod n 1, a 2 = A mod n 2, …, a M = A mod n M ) A can be reconstructed from (a 1, a 2, …, a M ) using equation A =  i=1 M (a i  N i  N i -1 mod n i ) mod N where N i = N nini = n 1  n 2 ...  n i-1  n i+1 ...  n M = Chinese Remainder Theorem

33 The multiplicative inverse of a modulo n is an integer [!!!] x such that a  x  1 (mod n) The multiplicative inverse of a modulo n is denoted by a -1 mod n (in some books a or a * ). According to this notation: a  a -1  1 (mod n) Multiplicative Inverse Modulo n

mod 11 = 9 -1 mod 26 = 5 -1 mod 26 = mod 13 = Examples

35 Residue Number System Arithmetic Range of number in RNS(8|7|5|3) is 0 to 8*7*5*3 = 840 or (-420 to +419) or any other interval of 840 consecutive integers (7|6|4|2) represents -1 or 839 or …

36 RNS Hardware Arithmetic

37 M C = f(M) = M e mod N C M = f -1 (C) = C d mod N PUBLIC KEY PRIVATE KEY N = P  Q P, Q - large prime numbers e  d  1 mod ((P-1)(Q-1)) RSA as a trapdoor one way function

38 N = P  Q gcd(P, Q) = 1 M  (M p = M mod P, M Q = M mod Q) M = M P  N P  N P mod P + N Q  N Q mod Q M Q  mod N = M P  Q  ((Q -1 ) mod P) + M Q  P  ((P -1 ) mod Q) mod N = = M P  R Q + M Q  R P mod N Chinese Remainder Theorem for N=P∙Q greatest common divisor

39 = MPMP CPCP P dPdP mod = MQMQ CQCQ Q dQdQ C P = C mod P d P = d mod (P-1) C Q = C mod Q d Q = d mod (Q-1) = mod C M d N M = M P ·R Q + M Q ·R P mod N where R P = (P -1 mod Q) ·P = P Q-1 mod N R Q = (Q -1 mod P) ·Q= Q P-1 mod N Fast Modular Exponentiation Using Chinese Remainder Theorem

40 SOFTWARE HARDWARE Without CRT With CRT t EXP (k) = c s  k 3 t EXP-CRT (k)  2  c s  ( ) 3 = t EXP (k) 1 4 Without CRT With CRT t EXP (k) = c h  k 2 t EXP-CRT (k)  c h  ( ) 2 = t EXP (k) 1 4 k 2 k 2 Time of Exponentiation without and with Chinese Remainder Theorem

Galois Field Number Systems ECE 645 – Computer Arithmetic

42 Polynomial Representation of the Galois Field Elements

43 Evariste Galois ( )

44 Studied the problem of finding algebraic solutions for the general equations of the degree  5, e.g., f(x) = a 5 x 5 + a 4 x 4 + a 3 x 3 + a 2 x 2 + a 1 x+ a 0 = 0 Answered definitely the question which specific equations of a given degree have algebraic solutions On the way, he developed group theory, one of the most important branches of modern mathematics. Evariste Galois ( )

Galois submits his results for the first time to the French Academy of Sciences Reviewer 1 Augustin-Luis Cauchy forgot or lost the communication 1830Galois submits the revised version of his manuscript, hoping to enter the competition for the Grand Prize in mathematics Reviewer 2 Joseph Fourier – died shortly after receiving the manuscript 1831Third submission to the French Academy of Sciences Reviewer 3 Simeon-Denis Poisson – did not understand the manuscript and rejected it. Evariste Galois ( )

46 May 1832 Galois provoked into a duel The night before the duel he writes a letter to his friend containing the summary of his discoveries. The letter ends with a plea: “Eventually there will be, I hope, some people who will find it profitable to decipher this mess.” May 30, 1832 Galois is grievously wounded in the duel and dies in the hospital the following day. 1843Galois manuscript rediscovered by Joseph Liouville 1846 Galois manuscript published for the first time in a mathematical journal Evariste Galois ( )

47

48 Set F, and two operations typically denoted by (but not necessarily equivalent to) + and * Set F, and definitions of these two operations must fulfill special conditions. Definition of Field

49 { set Zp={0, 1, 2, …, p-1}, + (mod p): addition modulo p, * (mod p): multiplication modulo p } Infinite fields Finite fields { R= set of real numbers, + addition of real numbers * multiplication of real numbers } Examples of Fields

50 GF(p) GF(2 m ) Polynomial basis representation Normal basis representation Fast in hardware Arithmetic operations present in many libraries Fast squaring GF(p m ) p – prime p m – number of elements in the field Most significant special cases Finite Fields = Galois Fields

51 Binary representation (used for storing and processing in computer systems): Polynomial representation (used for the definition of basic arithmetic operations): A = (a m-1, a m-2, …, a 2, a 1, a 0 ) a i  {0, 1} A(x) =  a i  x i = a m-1  x m-1 + a m-2  x m-2 + …+ a 2  x 2 + a 1  x+a 0  multiplication + addition modulo 2 (XOR) i=0 m-1 Elements of the Galois Field GF(2 m )

52 Inputs A = (a m-1, a m-2, …, a 2, a 1, a 0 ) B = (b m-1, b m-2, …, b 2, b 1, b 0 ) a i, b i  {0, 1} Output C = (c m-1, c m-2, …, c 2, c 1, c 0 ) c i  {0, 1} Addition and Multiplication in the Galois Field GF(2 m )

53 Addition A  A(x) B  B(x) C  C(x) = A(x) + B(x) = = (a m-1 +b m-1 )  x m-1 + (a m-2 +b m-2 )  x m-2 + …+ + (a 2 +b 2 )  x 2 + (a 1 +b 1 )  x + (a 0 +b 0 ) = = c m-1  x m-1 + c m-2  x m-2 + …+ c 2  x 2 + c 1  x+c 0  multiplication + addition modulo 2 (XOR) c i = a i + b i = a i XOR b i C = A XOR B Addition in the Galois Field GF(2 m )

54 Multiplication A  A(x) B  B(x) C  C(x) = A(x)  B(x) mod P(X) = c m-1  x m-1 + c m-2  x m-2 + …+ c 2  x 2 + c 1  x+c 0 P(x) - irreducible polynomial of the degree m P(x) = p m  x m + p m-1  x m-1 + …+ p 2  x 2 + p 1  x+p 0 Multiplication in the Galois Field GF(2 m )

55 Applications Galois fields/finite fields used in cryptography and coding theory

Little-Endian and Big-Endian Representation of Integers ECE 645 – Computer Arithmetic

57 A0 B1 C2 D3 E4 F LSB MSB MSB = A0 B1 C2 D3 E4 F5 67 LSB = 89 Big-Endian Little-Endian LSB = 89 0 MAX 67 F5 E4 D3 C2 B1 MSB = A0 address Little-Endian vs Big-Endian Representation

58 Big-Endian Little-Endian 0 MAX address MSB LSB... LSB MSB... Motorola 68xx, 680x0 Intel IBM Hewlett-Packard DEC VAX Internet TCP/IP Sun SuperSPARC Bi-Endian Motorola Power PC Silicon Graphics MIPS RS 232 AMD Little-Endian vs Big-Endian Camps

59 Jonathan Swift, Gulliver’s Travels A law requiring all citizens of Lilliput to break their soft-eggs at the little ends only A civil war breaking between the Little Endians and the Big-Endians, resulting in the Big Endians taking refuge on a nearby island, the kingdom of Blefuscu Satire over holy wars between Protestant Church of England and the Catholic Church of France Little Endian versus Big Endian: Origin

60

61 Big-EndianLittle-Endian easier to determine a sign of the number easier to compare two numbers easier to divide two numbers easier to print easier addition and multiplication of multiprecision numbers Comparing Little-Endian and Big-Endian

F5 E4 D3 C2 B1 A0 Big-Endian Little-Endian 0 MAX address int * iptr; (* iptr) = 8967;(* iptr) = 6789; iptr+1 Pointers (1)

F5 E4 D3 C2 B1 A0 Big-Endian Little-Endian 0 MAX address long int * lptr; (* lptr) = 8967F5E4;(* lptr) = E4F56789; lptr + 1 Pointers (2)