6 residue number system (color) 11-30-2002

Upload: hayumbe08

Post on 14-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    1/34

    Overview ofResidue Number System (RNS)

    forAdvanced VLSI Design and VLSI Signal

    Processing

    11-30-2002

    NTUEE

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    2/34

    Outline

    History

    Why RNS is needed ?

    Fundamental concepts in RNS.

    Conversion between Decimal and Residue.

    Conventional complex RNS Difficult arithmetic operations

    Applications

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    3/34

    History

    The ancient study of the residue numbering

    system begins with a verse from a third-

    centry book, Suan-Ching, by Sun Tzu.

    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?

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    4/34

    History

    We commemorate this contribution as the

    Chinese Remainder Theorem, orCRT.

    This theorem, as well as RNS, was set forth

    in the 19th by Carl Friedrich Gauss in his

    celebratedDisquisitiones Arithmetical.

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    5/34

    Why RNS?

    It is a carry-free system that performsaddition, substraction, and multiplication as

    parallel operations.

    FA FA FA HAFA

    00ba11ba22ba33ba44ba

    0s

    1s2s3s4soutc

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    6/34

    Definition

    The RNS is defined in terms ofa set of rela-

    tively prime moduli.

    IfP denotes the moduli set, then

    Lppp ,,, 21 P

    jiforpp ji ,1,GCD The dynamic rangeMis

    LpppM 21

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    7/34

    Any integer in the residue class ZM has a

    uniqueL-tuple representation given by

    LRNS

    XXXX ,,, 21

    whereXi=Xmodpi and is called the ith residue.

    Definition

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    8/34

    5,3, 21 ppP 1553 M

    X1

    0

    1

    2

    0

    1

    X2

    0

    1

    2

    3

    4

    X1

    2

    0

    1

    2

    0

    X2

    0

    1

    2

    3

    4

    X1

    1

    2

    0

    1

    2

    X2

    0

    1

    2

    3

    4

    X

    0

    1

    2

    3

    4

    5

    6

    7

    8

    9

    X

    10

    11

    12

    13

    14

    X

    Example

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    9/34

    4

    5

    6

    7

    8

    9

    10

    11

    0

    1

    2

    3

    X

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X3

    0

    1

    2

    3

    4

    0

    1

    2

    3

    4

    0

    1

    16

    17

    18

    19

    20

    21

    22

    23

    12

    13

    14

    15

    X

    X3

    2

    3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    3

    28

    29

    30

    31

    32

    33

    34

    35

    24

    25

    26

    27

    X

    X3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    3

    4

    0

    40

    41

    42

    43

    44

    45

    46

    47

    36

    37

    38

    39

    X

    X3

    1

    2

    3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    52

    53

    54

    55

    56

    57

    58

    59

    48

    49

    50

    51

    X

    X3

    3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    3

    4

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    5,4,3,, 321 pppP 60543 M

    Example

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    10/34

    Signed Representation

    Forsigned RNS, any integer in (-M/2,M/2],

    has a unique RNS L-tuple representation

    where xi=(X mod pi) ifX>0, and (M-|X|)modpi otherwise.

    4,3, 21 ppPX1

    0

    1

    2

    0

    X2

    2

    3

    0

    1

    X1

    1

    2

    0

    1

    X2

    2

    3

    0

    1

    X1

    2

    0

    1

    2

    X2

    2

    3

    0

    1

    X

    -6

    -5

    -4

    -3

    -2

    -1

    0

    1

    X

    2

    3

    4

    5

    X

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    11/34

    LRNS

    L

    RNS

    YYYY

    XXXX

    ,,,

    ,,,

    21

    21

    YXZ

    LRNS ZZZZ ,,, 21

    tionmultiplicaandnsubtractioaddition,present

    ,mod 111 pYX ,mod 222 pYX LLL pYX mod,

    Operation

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    12/34

    7(1, 3, 2 )

    +3(0, 3, 3 )

    10(1 mod 3, 6 mod 4, 5 mod 5) = (1,2,0)

    7(1, 3, 2 )

    - 3(0, 3, 3 )

    4(1 mod 3, 0 mod 4, -1 mod 5) = (1,0,4)

    7(1, 3, 2 )

    *3(0, 3, 3 )

    21(0 mod 3, 9 mod 4, 6 mod 5) = (0,1,1)

    Operation (Example)

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    13/34

    4

    5

    6

    7

    8

    9

    10

    11

    0

    1

    2

    3

    X

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X3

    0

    1

    2

    3

    4

    0

    1

    2

    3

    4

    0

    1

    16

    17

    18

    19

    20

    21

    22

    23

    12

    13

    14

    15

    X

    X3

    2

    3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    3

    28

    29

    30

    31

    32

    33

    34

    35

    24

    25

    26

    27

    X

    X3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    3

    4

    0

    40

    41

    42

    43

    44

    45

    46

    47

    36

    37

    38

    39

    X

    X3

    1

    2

    3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    52

    53

    54

    55

    56

    57

    58

    59

    48

    49

    50

    51

    X

    X3

    3

    4

    0

    1

    2

    3

    4

    0

    1

    2

    3

    4

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X1

    0

    1

    2

    0

    1

    2

    0

    1

    2

    0

    1

    2

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    X2

    0

    1

    2

    3

    0

    1

    2

    3

    0

    1

    2

    3

    5,4,3,, 321 pppP 60543 M

    (3,4,5) Modulo Set

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    14/34

    Efficient and rapid implementation of the

    operation (Xi o Yi) modpi must be found.

    Only for the case where pi=2^n can beeasily implemented in conventional system.

    RAM or ROMTable Lookup

    Zi = (Xi o Yi) modpi

    Xi (n bits)

    Yi (n bits)

    Zi (n bits)

    Conversion

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    15/34

    To be competitive system, the speed ofdata

    acquisition and the accompanying decimal-

    to-residue conversion must be equally fast.

    Decimal-to-residue Conversion

    1

    0

    0121'2 22N

    j

    j

    j

    N

    NNNcomps bbbbbbbX

    iN

    j

    i

    j

    ji

    N

    iN

    ii

    ppbppb

    pXX

    modmod2mod2

    mod

    1

    0

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    16/34

    Decimal-to-residue Conversion

    binarydecimalX 01110129 7,5, 21 ppP

    45mod1120413111301 X

    17mod1120411121302

    X

    2j modpi j=4

    i=1

    i=2

    j=3 j=2 j=1 j=0

    1 3 4 2 1

    2 1 4 2 1

    pi-(25modpi)

    i=1

    i=2

    3

    3

    1

    0mod2mod2

    N

    j

    i

    j

    ji

    N

    iN pbppb

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    17/34

    Generally speaking, the speed limitation of

    residue-to-decimal conversion is a problem

    in residue number system.

    The R/D problem can be solved in one of

    the following two ways:Mixed radix conversion (MRC)

    Chinese Remainder Theorem (CRT)

    Residue-to-decimal Conversion

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    18/34

    Multiplicative Inverse

    The multiplicative inverse ofgof modulopi

    is denoted asgi-1 and satisfies

    1mod1

    ii pgg

    Example:

    Pi=5g

    gi-1

    0

    1

    1

    2

    3

    3

    2

    4

    4

    g

    gi-1

    Pi=60

    1

    1

    2

    3

    4

    5

    5

    g

    gi-1

    Pi=70

    1

    1

    2

    4

    3

    5

    4

    2

    5

    3

    6

    6

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    19/34

    Mixed Radix Conversion

    X LXXX ,,, 21 RNS

    LXXX

    ,,

    ,

    21

    MRC

    The MRC representation is given by

    MXvXvXvX LL mod 2211 where v1=1, v2=p1, v3=p1p2, v4=p1p2p3,

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    20/34

    Mixed radix conversion

    LL

    LL

    XpppXppXpX

    XvXvXvXvX

    121321211

    332211

    111mod XXpX

    LLLL

    XppXpXXXp

    XpppXppXpXX

    123221

    1

    1

    121321211

    221

    1

    2,1mod XpXXp

    221212,1 mod XpXXp

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    21/34

    Mixed Radix Conversion

    33211

    3,1

    1

    3,2

    1343321

    1

    1

    1

    2

    124323221

    1

    1

    mod

    XpXXXpp

    XppXpXXXXpp

    XppXppXpXXXp

    LL

    LL

    33213

    1

    3,1

    1

    3,2mod XpXXXpp

    Use nesting subtractions and multiplicative

    inverse to makesequential conversion.

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    22/34

    Block Diagram of MRC

    p12-1

    p13-1 M

    M

    p1L-1 M

    p23-1 M

    p2L-1 M pL-1,L

    -1 M

    1X

    2X

    3X

    LX

    1X

    2X

    3X

    LX

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    23/34

    Chinese Remainder Theorem

    MpsXsXL

    i

    iiii modmod

    1

    1

    where

    andsi

    -1 is the multiplicative

    inverse ofsi modpi, so that

    1mod1 iii pss

    Liii

    i ppppppMs 1121

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    24/34

    Chinese Remainder Theorem

    MpsXsXL

    i

    iiii modmod1

    1

    X1s1-1 modp1

    X2s2-1 modp2

    XLsL-1 modpL

    modM

    1X

    2X

    LX

    X

    sL

    s2

    s1

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    25/34

    Chinese Remainder Theorem

    5,4,3,, 321 pppP 60543 M

    1mod..3125

    1mod..3154

    1mod..2203

    33

    1

    3

    1

    333

    221

    21

    222

    11

    1

    1

    1

    111

    psstsssp

    psstsssp

    psstsssp

    4,0,1X

    1*2 mod 3

    0*3 mod 4

    4*3 mod 5

    20

    15

    12

    mod 604X

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    26/34

    Conventional Complex RNS

    MMLRNS ZYZXZZZjYXZ ,;,,, 21

    A complex numberZis defined to be

    iii pYjpXZ modmod

    LZZZZZZ 33231213 ,,,

    iiiii YYjXXZ 21213

    LZZZZZZ 33231213 ,,, iiiiiiiii YXYXjYYXXZ 122121213

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    27/34

    Difficult Arithmetic Operations

    Magnitude comparison / Sign detection

    Division

    Base extension

    Scaling / Rounding / Truncation

    Overflow detection

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    28/34

    Magnitude Comparison

    Sign Detection

    Not a weighted number system.

    Every digits are equally important.

    3,3,30,1,13,3,2 ZYX

    ?6?0? ZYYX

    The problem makes the RNS-based signal

    processors inefficient.

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    29/34

    Division

    Blend of nested subtractions and magnitude

    comparisons, so it is more difficult in the

    RNS domain. RNS is not closed under division, since the

    RNS is an integer system.

    It is an slow, high-overhead operation, andshould be avoided in RNS.

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    30/34

    Base Extension

    Increase the dynamic range

    Increase the resolution.

    R/D and D/R conversions are needed.

    R/D conversion

    L - tuple RNS

    D/R conversion

    K- tuple RNS

    Moduli

    extension

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    31/34

    Scaling / Rounding / Truncation

    Prevent dynamic-range overflow.

    A special form of division.

    The scaling operation can be easily to

    implemented when scaling factor is:

    Power of two (2n) in 2complement.

    Product of one or more of the moduli in RNS.

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    32/34

    Overflow Detection

    A special form ofmagnitude comparison.

    Can be avoided by using scaling operation

    during run-time.

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    33/34

    Applications

    High-speed systems

    (**) FPGA-based solution

    Filtering (FIR, IIR) systems

    Linear transformations

    Adaptive systems

  • 7/30/2019 6 Residue Number System (Color) 11-30-2002

    34/34

    References

    [1] A good tutorial paper of RNS: Fred J. Taylor,

    "Residue Arithmetic: A Tutorial with Examples",

    IEEE Trans. on Computer, pp. 50~62, May 1984.[2] A good paper collections for RNS: M. A.

    Soderstrand, W. K. Jenkins, G. A. Jullien, F. J.

    Taylor (eds.),Residue Number System Arithmetic:

    Modern Applications in digital Signal Processing,IEEE Press, New York, 1986.