nasdec08

Upload: nehaaadi3236

Post on 10-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 NASDEC08

    1/4

    An overview of Residue Number SystemMrs. Neha Singh

    Lecturer, Birla Institute of Technology, Extension center, Jaipur.E-mail:[email protected]

    Abstract This paper provides an overview of Residue NumberSystem, which is finding vast application now-a-days in the field of embedded processing as in mobiles. The paper is focused onvarious general issues and concepts of the representation system.The choice of moduli and conversion of decimal to residue numberand inverse conversion with the help of Chinese RemainderTheorem is dealt with.

    Key-words Chinese remainder theorem, residue number system.

    I. INTRODUCTION

    The ancient study of the residue numbering system begins witha mathematical riddle from a third-century book, Suan-Ching ,by Sun Tzu . The riddle goes like:

    We have things of which we do not know the number, If we count them by three, the remainder is 2, If we count them by five, the remainder is 3,

    If we count them by seven, the remainder is 2, How many things are there?

    In simple words, it means, what number yields a remainder of 2, 3 and 2 when divided by 3, 5 and 7 respectively? Sun Tzugave the solution to this riddle with a rule called Tai Yen,

    which was later generalized in 1247 by another ChineseMathematician Qin Jiushao into what is now known as TheChinese Remainder Theorem [1-5] .

    In 1950, this system of number representation was revisited bythe computer scientists to implement fast arithmetic and faulttolerant computing. The three properties of RNS which make itsuitable are: first, it allows carry-free parallel addition andmultiplication to save the time required for carry propagation inany processing. Secondly, residue number system are non-positional i.e. the representation carries no weight informationand thus any error in a digit position does not affects any otherdigit position. Thirdly, there is no significance-ordering of

    digits, which means that the faulty digit-positions can bediscarded with no effect other than a reduction in dynamicrange.

    However, the interest in this representation system was onlyfor a short duration due to two main reasons: one, an arithmeticunit is required to be atleast capable of addition, multiplication,division, square root and comparison, but implementation of last three functions in RNS is not easy, two, conversion of RNS

    representation to conventional notation for human consumptionis difficult.

    Nevertheless, in recent years there has been renewed interest inRNS. There are several reasons for this new interest, includingthe following. A great deal of computing now takes place inembedded processors, such as those found in mobile devices,and for these high speed and low-power consumption arecritical; the absence of carry-propagation facilitates therealization of high-speed, low-power arithmetic. Also,computer chips are now getting to be so dense that full testing

    will no longer be possible; so fault-tolerance and the generalarea of computational integrity have again become moreimportant. Lastly, there has been progress in theimplementation of the difficult arithmetic operations. In anycase, RNS is extremely good for many applications such asdigital signal processing, communications engineering,computer security (cryptography), image processing, speechprocessing, and transformation in which the critical arithmeticoperations are addition and multiplication.

    This paper is organized as follows: In section II, we brieflyintroduce the basics of Residue Number System. Then insection III, the choice of moduli is dealt with. Section IV givesan understanding of decimal to residue conversion and inversein section V, which develops a system for converting residuenumber to binary. Section VI discusses the limitations andproblems of the residue number representation.

    II. RESIDUE NUMBER SYSTEM

    Residue number systems are based on the congruence relation,which is defined as follows. Two integers a and b are said to becongruent modulo m if m divides exactly the difference of aand 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 2). The numberm is a modulus or base , and we shall assume that its valuesexclude unity, which produces only trivial congruences. If qand r are the quotient and remainder, respectively, of theinteger division of a by m, that is, a = q.m+ r then, bydefinition, we have a r (mod m). The number r is said to bethe residue of a with respect to m, and we shall usually denote

    this 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 . Suppose we have a set, { m1,

  • 8/8/2019 NASDEC08

    2/4

    m2,....., m N }, of N positive and pairwise relatively prime moduli.Let M be the product of the moduli. Then every number X < M has a unique representation in the residue number system,

    which is the set of residues {im

    X : 1 i N}. A partial

    proof of this is as follows. Suppose X 1 and X 2 are two different

    numbers with the same residue-set . Then 1 mi X =

    2 mi X , and so 1 2 mi X X = 0. Therefore (X 1-X2) is the leastcommon multiple (lcm) of mi. But if the mi are relatively prime,then their lcm is M , and it must be that ( X 1- X 2) is a multiple of

    M . So it cannot be that X 1 < M and X 2 < M . Therefore, the set

    {im

    X : 1 i N} is unique and may be taken as the

    representation of X . We shall write such a representation in the

    form 1 2, ,..... N x x x where xi = 1 mi X , and we shall indicatethe relationship between X and its residues by writing

    X 1 2, , ..... N x x x . The number M is called the dynamicrange of the RNS, because the number of numbers that can berepresented is M . For unsigned numbers, that range is [0, M-1].The extension of sign-and-magnitude notation to RNS involvesthe use of a single sign-digit. For the complement notations, therange of representable numbers is usually partitioned into twoapproximately equal parts, such that approximately half of thenumbers are positive and the rest are negative. Thus, if themoduli used are { m1, m2,....., m N }, then there are M

    1

    N

    ii

    m representable numbers, and every representable

    number, X , satisfies one of two relations: 1 1

    2 2 M M

    X if M is odd

    2 2

    M M X 1 if M is even

    Then, for complement notation, if 1 2, ,..... N x x x is the

    representation of X , where xi = mi X , then the representation

    of X is 1 2, , ......, N x x x where i x is the mi's-complement,

    i.e. the radix complement or the diminished-radix complement,of xi. For example, with the moduli-set {2, 3, 5, 7}, therepresentation of 17 is {1, 2, 2, 3} and the radix-complementrepresentation of its negation is {1, 1, 3, 4}, from {2 1, 3 2;5 2, 7 3}. The justification for taking the complement(negation) of each residue digit is

    that i i imim x x . M M X X If we again take [0, M-1] as the nominal range of an RNS, thenit will be seen that in the last example {1, 1, 3, 4} is also therepresentation of 193. That is, in splitting the range [0 ,M- 1], we

    take for positive numbers the subrange [0, 12

    M ] if M is even,

    or [0,( 1)

    2

    M ] if M is odd, and correspondingly, for the

    negative numbers we take [2

    M , M 1] or [

    ( 1)

    2

    M , M 1]. This

    makes sense since M

    M X X (in the last example 210

    17 = 193). Representations, in a system, in which the moduliare not pair-wise relatively prime, will not be unique: two ormore numbers will have the same representation.

    III. CHOICE OF MODULI

    In residue number system representation, the moduli arerequired to have the ability of efficient representation andbalance [2] . To better understand the efficient representation, letus consider an example. Suppose we take the moduli as {13,17}. The dynamic range for this set is 221 and number of bitsrequired to represent the corresponding residues is 4 and 5respectively. The representational efficiency for this choice of

    moduli is low as it comes out to be 13/16 and 17/32 for the twomoduli respectively. If however, the set of moduli is chosen tobe {13, 16}, the representational efficiency is increased to16/16 for the latter but at the cost of dynamic range, which isreduced to 208. The best choice of moduli appears to be {15,16}, as the efficiency is now 15/16 and 16/16 respectively withthe dynamic range increased to 240.

    The second requirement for the moduli is to have balance or itcan be put as, the two moduli should have the difference assmall as possible. A common choice of prime modulus thatdoes not complicate arithmetic and which has goodrepresentational efficiency is mi = 2

    i - 1. Not all pairs of numbers of the form 2 i 1 are relatively prime, but it can beshown that that 2 j- 1 and 2 k -1 are relatively prime if and only if

    j and k are relatively prime. Many moduli sets are based onthese choices, but there are other possibilities; for example,moduli-sets of the form {2n-1, 2n, 2n +1} are among the mostpopular in use. If the moduli are small, then a large number of them may be required to ensure a sufficient dynamic range. Of course, ultimately the choices made, and indeed whether RNSis useful or not, depend on the particular applications andtechnologies at hand.

    IV. DECIMAL TO RESIDUE CONVERSION

    For a competitive system, the speed of data acquisition and

    conversion is required to be fast. Let X = 29 be the givennumber in decimal whose residue equivalent (x 1, x2)is to becalculated. The number X is represented in binary 2scomplement form as (b N, bN-1 , ., b 2, b1, b0) =(011101).assuming the moduli to be {5, 7}, the residues can befound as

    xi = X mod m i

    =1

    0

    ( (2 mod )) (2 mod ) mod N

    N j

    N i i j i i

    j

    b m m b m m

  • 8/8/2019 NASDEC08

    3/4

    Using the 2 look up tables to store the values for realization of system as:LUT#1 for (m i-2

    5 mod m i)

    i=1 3i=2 3

    LUT # 2 for (2 j

    mod m i) j=4 J=3 j=2 j=1 j=0

    i=1 1 3 4 2 1i=2 2 1 4 2 1

    x1 = (0.3+1.1+1.3+1.4+0.2+1.1) mod 5 = 4x2 = (0.3+1.2+1.1+1.4+0.2+1.1) mod 7 = 1So, X = 29 decimal = (4, 1) residue

    V. RESIDUE TO DECIMAL CONVERSION

    Residue to decimal conversion has some speed limitations. Thetwo novel methods for residue to decimal conversion are [5]:

    1.

    Chinese remainder theorem (CRT)2. Mixed radix conversion (MRC)

    Before moving to understand The Chinese RemainderTheorem, we need to have the multiplicative inverse. Themultiplicative inverse of X of modulus m i is denoted as X i

    -1 andshould satisfy (X i

    -1X) mod m i = 1. For example: for m i = 5 g 0 1 2 3 4g-1 X 1 3 2 4

    For m i = 7g 0 1 2 3 4 5 6g-1 X 1 4 5 2 3 6

    The following part of the paper studies one of the twoapproaches for residue to decimal conversion i.e. ChineseRemainder Theorem.

    CHINESE REMAINDER THEOREM

    Here, we try to solve the riddle as given in the beginning of thepaper. Using proper notations, the mathematical formulation of the riddle can be:Let, the number of things be X, then,X = 2 ( mod 3)X = 3 ( mod 5)X = 2 ( mod 7)

    The method for solving this set of three simultaneouscongruences is to reduce it to three separate problems whoseanswers may be added together to get a solution to the originalproblem.

    To start with, taking the last two of the three moduli, 3, 5 and 7,we compute their product, 5 7 =35. We now look for a

    multiple of this product, 35 which, satisfies the first congruencei.e. is congruent to 2 modulo 3. In fact, 35 2(mod 3) , so 35is the first summand. Next, taking the first and the last moduli,the product is 21. The lowest multiple of 21 satisfying thesecond congruence is 63. This is the second addend. Similarly,taking the first and second moduli, the third addend comes outto be 30. Adding the three addends obtained we get X = 35 +21 + 30 = 86.

    Thus, the answer to the riddle is 86 things. This shows Chineseremainder theorem in action. Stating the theorem in generalform [5]:

    11

    mod mod N

    i i i ii

    X s x s m M

    Where,

    1 2 1 1 / ....... .......i i i i N s M m m m m m m and s i-1 is

    the multiplicative inverse of s i mod m i so that (s i si -1)mod m i

    =1. Working according to the equation for Chinese Remainder

    Theorem, we take an example. Let the given residue number be{1, 0, 4} and the moduli are {3, 4, 5} so, M = 60.

    11 1 1

    12 2 2

    13 3 3

    3 | 20 2

    4 | 15 3

    5 | 12 3

    m s s

    m s s

    m s s

    Then,X comes out to be 4.

    The block diagram is as shown in figure 1.

    VI. LIMITATIONS OF RESIDUE NUMBER SYSTEM

    Although the basic arithmetic operations like addition andmultiplication are easily implemented using RNS. However,there are some operations that are not easily implemented.Some of these unimplementable [4] or difficult to implementfunctions are division, magnitude comparison, signdetermination, scaling and overflow detection. Although work is being done in this area to have these operations done withresidue number system, so that the system emerges as a betteroption for processing data in the growing technology.

  • 8/8/2019 NASDEC08

    4/4

    REFERENCES :1. Lie-Liang Yang and Lajos Hanzo, Redundant Residue Number

    System based Error CorrectionCodes, Dept. of ECS, University of Southampton, SO17 1BJ, UK.

    2. Shaoqiang Bi andWarren J. Gross, The mixed radix Chineseremainder theorem, 2008 IEEE, Transactions oncomputers,0532139.

    3. Mohammad Addallah and Alexander Skavantzos, Systematicapproach for selecting practical moduli sets for Residue numbersystem, 1995 IEEE proceedings of the 27 th South-easternSymposium on system theory, pages 445-449.

    4. http://larc.ee.nthu.edu/.tw/~tyc/arith/rnscns.pdf 5. access.ee.ntu.edu.tw/course/VSP/SLIDE/6%20Residue%system%2

    0(color)%2011-30-2.

    6. http://ce.et.tudelft.nl/cecoll/slides/08/0305_Kazeem.pdf

    Mrs. Neha Singh did her B.E. from Institute of Engineering and Technology, Alwar (Rajasthan), affiliatedto University of Rajasthan, in Electronics &

    Communication Engineering in the year 2004 and iscurrently pursuing M.Tech. in VLSI Design from MalviyaNational Institute of Technology, Jaipur. She has been intoteaching since 2004. Her area of interest includeselectronics devices, Image Processing, and VLSI.