1 / 53

Advanced Computer Arithmetic Residue Number System Week 4

CENG536 Computer Engineering department Ç ankaya University . Advanced Computer Arithmetic Residue Number System Week 4.

milton
Download Presentation

Advanced Computer Arithmetic Residue Number System Week 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CENG536 Computer Engineering department Çankaya University Advanced Computer ArithmeticResidue Number SystemWeek 4

  2. Residue number systems (RNS) were invented by the third-century Chinese scholar Sun Tzu – a different Sun Tzu from the author of the famous Art of War. In Problem 26 of his Suan Ching (Calculation Classic), our Sun Tzu posed a mathematical riddle: We have things of which we do not know the number If we count them by threes, we have two left over If we count them by fives, we have three left over If we count them by sevens, we have two left over How many things are there? Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  3. In other words, “What number yields the remainders 2, 3, and 2 when divided by 3, 5, and 7, respectively?" In modern terminology, 2, 3, and 2 are residues, and 3, 5, and 7, are moduli. Sun Tzu gave a rule, the Tai-Yen (Great Generalization) for the solution of his puzzle. In 1247, another Chinese mathematician, Qin Jiushao, generalized the Great Generalization into what we now call the Chinese Remainder Theorem, a mathematical jewel. Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  4. In the 1950s, RNS were rediscovered by computer scientists, who sought to put them to use in the implementation of fast arithmetic and fault-tolerant computing. Three properties of RNS make them well suited for these. The first is absence of carry propagation in addition and multiplication, carry-propagation being the most significant speed-limiting factor in these operations. Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  5. The second is that because the residue representations carry no weight-information, an error in any digit-position in a given representation does not affect other digit-positions. And the third is that there is no significance-ordering of digits in an RNS representation, which means that faulty digit-positions may be discarded with no effect other than a reduction in dynamic range. Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  6. Papers printed by Czech scientists M. Valach and A. Svoboda were the impulse to start explorations in RNS mathematic (1955 – 1957). Soviet scientists I. Akushskiy, D. Yuditskiy, V. Amerbayev and B. Pak analyzing and developing this system have offered computer arithmetic (1955 – 1962). RNS was used in few military systems of USSR designed in period 1958 – 1970. Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  7. Anti-missile defense system A-35 Exoatmospheric missile А-350Ж (1958-1968) (distance of flight 400 km, height range of defeat 50-400 km, time of flight (max) 3 min, nuclear warhead) Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  8. Residue Number System Anti-missile defense system A-35 Exoatmospheric missile А-350Ж CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  9. Residue Number System Anti-missile defense system A-35 Radar "Дунай-3У" (1958-1968) CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  10. Residue Number System Anti-missile defense system A-35 Control center CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  11. Soviet military computer 5Э53 – designed for anti-missile defense system A-35 (1967-1972). Work in residue number system. Rate 40 MIPS. Clocking frequency 6 MHz. RAM 10 Mbit. ROM 2,9 Mbit. External memory 3 Gbit. Harvard architecture. Pipelined arithmetic. Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  12. Front bomber СУ24 (First flight – 1967). Equipped by control computer based on RNC. Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  13. Western definition of RNS : Residue number systems are based on the congruence relation, which is defined as follows. Two integers a and b are said to be congruent modulo m if m divides exactly the difference of a and b; it is common, especially in mathematics tests, to write ab (mod m) to denote this. Thus, for example, 10  7 (mod 3); 10  4 (mod 3); 10  1 (mod 3), and 10  – 2 (mod 3). The number m is a modulus or base, and we shall assume that its values exclude unity, which produces only trivial congruences. Residue Number System. Definition CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  14. Western definition of RNS : If q and r are the quotient and remainder, respectively, of the integer division of a by m – that is, a = q:m + r – then, by definition, we have a  r (mod m). The number r is said to be the residue of a with respect to m, and is usually denoted by r = |a|m. The set of m smallest values {0, 1, 2, …., m – 1}, that the residue may assume is called the set of least positive residues modulo m. Unless otherwise specified, we shall assume that these are the only residues in use. Residue Number System. Definition CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  15. Russian definition of RNC: Let is given set of positive integer relatively prime numbers that are the moduli (bases) of the system. The residue number system is that system in which integer positive number is presented by set of residui (remainders) on selected moduli where each i is determined according equation for each where operation [ . ] means separation of integer part. Residue Number System. Definition CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  16. Theory of numbers proves that, if numbers pi are relatively prime, the number described by digits has the unique representation. The range of numbers (dynamic range), represented in this system is Like in positional system range of numbers increases as product of moduli and number of digits to represent N increases as the sum of word lengths of the same bases. Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  17. Example: p1 = 3, p2 = 5, p3 = 7–the moduli of the RNS system P = 3 ∙ 5 ∙ 7 = 105– range of numbers presentation 0 ≡ ( 0, 0, 0 ) 8 ≡ ( 2, 3, 1 ) 1 ≡ ( 1, 1, 1 ) . 2 ≡ ( 2, 2, 2 ) . 3 ≡ ( 0, 3, 3 ) . 4 ≡ ( 1, 4, 4 ) 103 ≡ ( 1, 3, 5 ) 5 ≡ ( 2, 0, 5 ) 104 ≡ ( 2, 4, 6 ) 6 ≡ ( 0, 1, 6 ) 105 ≡ ( 0, 0, 0 ) 7 ≡ ( 1, 2, 0 ) 106 ≡ ( 1, 1, 1 ) Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  18. included not included Lets analyze the rules of execution of arithmetic operations for the case of both operands and result are in range [ 0, P). and the conditions Residue Number System Arithmetic are satisfied. CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  19. Residui for addition and multiplication will be determined as and the digit of results is taken from Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  20. For addition we can write Representation of A and B are where ki and liare non negative integers. Then From which Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  21. In case of multiplication Substituting representation of A an B gives From which Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  22. Example 1: Let the moduli of the system are We want add numbers A = 17 and B = 63. For the given moduli numbers are represented as Result of addition is Its easy check that (2, 0, 3) is 80 and is equal to the sum of operands. Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  23. Example 2: For the system with the same moduli we want multiply numbers In accordance with the multiplication rules result is Its easy to check, that this number is 102 and is equal to product of operands. Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  24. Advantages of the system: - Independence of creating (determining) of the digits, as each residue carry information about whole original number. - Independence of digits of each other and from this possibility of parallel processing of residui. - Small number of bits to represent each residue, that opens possibility to process data using tables, instead of units on the base of logical elements. Residue Number System Properties CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  25. Disadvantages of the system: - Impossibility to visual comparing of the numbers. - Absence of simple indication of overflow and underflow over the range [ 0, P). - Limitedness of the system by the area of integer positive numbers. - Obtaining in all cases accurate results and absence of possibilities of rounding and truncation. Residue Number System Properties CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  26. How to introduce negative numbers? Let be realized subtraction of two numbers for the same system. Result is presented by residui i for the same bases And let conditions are satisfied. Then for subtraction we have Sign in Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  27. Sign of result is not determined. Strongly say, sign of operands were not processed (in representation of numbers they are absent) and the sign of result is not created. Let for the system with the bases the range of numbers is Let the base We denote or In residue number system this number is presented as Sign in Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  28. Accepting this number as zero we can represent positive numbers in form and negative numbers as Realizing algebraic addition positive and negative numbers will be represented as This form is referred to as artificial form and we always will deal with positive numbers. But, the numbers in range will reflect negative numbers in this artificial form, and in range – positive. Sign in Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  29. Let we add two numbers N1 and N2. The artificial forms are and their sum is Artificial form of the sum is presented by then from this and because is half of the range, we can write 0 Sign in Residue Number System CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  30. Example 1: Given the system with the moduli and half of range Let We create artificial forms And determining sum of this numbers we get The number is artificial form of the sum, that may be checked by conversion to decimal Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  31. Example 2: For the same system with the moduli and half of range Let The artificial forms are positive Determining sum of this numbers we get negative Result is artificial form of the sum, that may be checked by conversion to decimal Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  32. Example 3: For the same system we add numbers We create artificial forms negative numbers Adding this numbers we get Result is artificial form of the sum, that may be checked by conversion to decimal Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  33. Transform of positive numbers to negativeand vice versa, i.e. creating of its complement is realized by subtracting of this number from number For analyzed examples this transform may be illustrated as Note: If subtrahend is in artificial form, to form the complement it should be subtracted not from but from Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  34. Example: Given numbers Their artificial forms are complement code of N2 is Sum of and is From one of preceding examples is known that Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  35. Example: Given numbers Lets create complement code of N2 and add these numbers Producing mathematical operations in decimal we get Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  36. Lets analyze multiplication. Artificial forms of the two numbers are then from which Taking in account that and because that numbers are in artificial form we get Because P is odd number, we have The rule for multiplication is defined in form: if N1 and N2 are of the same parity if N1 and N2 are of different parity Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  37. Because one of the basis of the system is 2, we can determine parity (odd, even) of the number analyzing residue by this modulo. Odd numbers have residue of 1 and even – 0. Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  38. Example 1: For the same system let Artificial form of numbers are Product of numbers is Because both numbers are of the same parity we get Applying decimal conversion gives Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  39. Example 2: For the same system let Artificial form of numbers are Product of numbers is Because both numbers are of the same parity we get Applying decimal conversion gives Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  40. Example 3: For the same system let Artificial form of numbers are and their product is From Example 1 we have and the same result gives Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  41. Example 4: Now let numbers for the same system are of different parity Artificial form of numbers are and their product is Applying rule for multiplicand and multiplier of different parity gives In decimal system we get Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  42. Example 5: Now let numbers for the same system are of different parity Artificial form of numbers are and their product is Applying rule for multiplicand and multiplier of different parity gives In decimal system we get Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  43. The general approach to the introduction of negative numbers. Let moduli of the system are and let The range of numbers is divided in two parts and . Let Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  44. Let the number will represent zero for the system. Positive numbers will be represented in form and negative one will be of form General description for all numbers is Such representation is referred to as general artificial form of the number. Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  45. If no overflow/underflow while arithmetic operation is processed, addition and subtraction may be realized in artificial form Artificial form of the sum is Lets denote as Here we have And sum of numbers in artificial code is Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  46. Complement code of N may be obtained by subtracting the number from If the number is represented in artificial form, complement code should be obtained by subtracting from Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  47. Example 1: Let system has moduli For this system Let The artificial forms are According to introduced rules And in decimal system and Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  48. Example 2: Let The artificial forms are And in decimal system Residue Number System Arithmetic CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  49. Residue Number System Arithmetic Now lets analyze multiplication representing numbers in general artificial form. Let numbers are and then Denoting we have from which We can denote 49 Integer part Fraction part CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

  50. Residue Number System Arithmetic Now new edition of this expression is of form If  is even, then and that gives in this case If  is odd, then and 50 CENG 536 - Spring 2012-2013 Dr. Yuriy ALYEKSYEYENKOV

More Related