overview of residue number system (rns) for advanced vlsi design and vlsi signal processing...

34
Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳吳吳

Upload: maude-miles

Post on 06-Jan-2018

215 views

Category:

Documents


0 download

DESCRIPTION

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?

TRANSCRIPT

Page 1: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Overview ofResidue Number System (RNS)

forAdvanced VLSI Design and VLSI Signal

Processing

11-30-2002

NTUEE 吳安宇

Page 2: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Outline

• History• Why RNS is needed ?• Fundamental concepts in RNS.• Conversion between Decimal and Residue.• Conventional complex RNS• Difficult arithmetic operations• Applications

Page 3: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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?

Page 4: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

History

• We commemorate this contribution as the Chinese Remainder Theorem, or CRT.

• This theorem, as well as RNS, was set forth in the 19th by Carl Friedrich Gauss in his celebrated Disquisitiones Arithmetical.

Page 5: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Why RNS?

• It is a “carry-free” system that performs addition, substraction, and multiplication as parallel operations.

FA FA FA HAFA

00 ba11 ba22 ba33 ba44 ba

0s1s2s3s4soutc

Page 6: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Definition

• The RNS is defined in terms of a set of rela-tively prime moduli.

• If P denotes the moduli set, then Lppp ,,, 21 P

jiforpp ji ,1,GCD• The dynamic range M is

LpppM 21

Page 7: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

• Any integer in the residue class ZM has a unique L-tuple representation given by

LRNS XXXX ,,, 21

where Xi=X mod pi and is called the ith residue.

Definition

Page 8: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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

Page 9: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

456789

1011

0123

X →

X1

012012012012

X2

012301230123

X3

012340123401

1617181920212223

12131415

X →

X3

234012340123

2829303132333435

24252627

X →

X3

401234012340

4041424344454647

36373839

X →

X3

123401234012

5253545556575859

48495051

X →

X3

340123401234

X1

012012012012

X1

012012012012

X1

012012012012

X1

012012012012

X2

012301230123

X2

012301230123

X2

012301230123

X2

012301230123

5,4,3,, 321 pppP 60543 M

Example

Page 10: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Signed Representation

• For signed RNS, any integer in (-M/2, M/2], has a unique RNS L-tuple representation where xi=(X mod pi) if X>0, and (M-|X|) mod pi otherwise.

4,3, 21 ppPX1

0120

X2

2301

→X1

1201

X2

2301

X1

2012

X2

2301

X-6-5-4-3

-2-101

X2345

X

Page 11: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

L

RNSL

RNS

YYYYXXXX

,,,,,,

21

21

YXZ

LRNS ZZZZ ,,, 21

tionmultiplica and nsubtractio addition,present

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

Operation

Page 12: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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)

Page 13: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

456789

1011

0123

X →

X1

012012012012

X2

012301230123

X3

012340123401

1617181920212223

12131415

X →

X3

234012340123

2829303132333435

24252627

X →

X3

401234012340

4041424344454647

36373839

X →

X3

123401234012

5253545556575859

48495051

X →

X3

340123401234

X1

012012012012

X1

012012012012

X1

012012012012

X1

012012012012

X2

012301230123

X2

012301230123

X2

012301230123

X2

012301230123

5,4,3,, 321 pppP 60543 M

(3,4,5) Modulo Set

Page 14: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

• Efficient and rapid implementation of the operation (Xi o Yi) mod pi must be found.

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

RAM or ROMTable Lookup

Zi = (Xi o Yi) mod pi

Xi (n bits)

Yi (n bits)Zi (n bits)

Conversion

Page 15: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

• To be competitive system, the speed of data acquisition and the accompanying decimal-to-residue conversion must be equally fast.

Decimal-to-residue Conversion

1

00121'2 22

N

j

jj

NNNNcomps bbbbbbbX

i

N

ji

jji

NiN

ii

ppbppb

pXX

modmod2mod2

mod1

0

Page 16: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Decimal-to-residue Conversion

binarydecimalX 01110129 7,5, 21 ppP

45mod1120413111301 X 17mod1120411121302 X

2j mod pi j=4i=1i=2

j=3 j=2 j=1 j=01 3 4 2 12 1 4 2 1

pi-(25mod pi)i=1i=2

33

1

0

mod2mod2N

ji

jji

NiN pbppb

Page 17: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

• 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

Page 18: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Multiplicative Inverse• The multiplicative inverse of g of modulo pi is

denoted as gi-1 and satisfies

1 mod 1 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

Page 19: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Mixed Radix ConversionX 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, …

Page 20: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Mixed radix conversion

LL

LL

XpppXppXpX

XvXvXvXvXˆˆˆˆ

ˆˆˆˆ

121321211

332211

111ˆmod XXpX

LL

LL

XppXpXXXp

XpppXppXpXXˆˆˆˆ

ˆˆˆˆ

1232211

1

121321211

22112,1

ˆmodˆ XpXXp

221212,1

ˆmod XpXXp

Page 21: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Mixed Radix Conversion

3321

13,1

13,2

13433211

11

2

1243232211

1

ˆmod ˆˆ

ˆˆˆˆˆ

ˆˆˆˆˆ

XpXXXpp

XppXpXXXXpp

XppXppXpXXXp

LL

LL

3321313,1

13,2

ˆmod ˆˆ XpXXXpp

• Use nesting subtractions and multiplicative inverse to make sequential conversion.

Page 22: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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̂

Page 23: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Chinese Remainder Theorem

MpsXsXL

iiiii modmod

1

1

where and si

-1 is the multiplicative inverse of si mod pi, so that 1mod1

iii pss

Liii

i ppppppMs 1121

Page 24: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Chinese Remainder Theorem

MpsXsXL

iiiii modmod

1

1

X1 s1-1 mod p1

X2 s2-1 mod p2

XL sL-1 mod pL

mod M

1X

2X

LX

X

sL

s2

s1

Page 25: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Chinese Remainder Theorem 5,4,3,, 321 pppP 60543 M

1mod ..31251mod ..31541mod ..2203

331

31

333

221

21

222

111

11

111

psstsssppsstsssppsstsssp

4,0,1X

1*2 mod 3

0*3 mod 4

4*3 mod 5

20

15

12

mod 604X

Page 26: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Conventional Complex RNS

MMLRNS ZYZXZZZjYXZ ,;,,, 21

• A complex number Z is defined to be

iii pYjpXZ modmod

LZZZZZZ 33231213 ,,, iiiii YYjXXZ 21213

LZZZZZZ 33231213 ,,, iiiiiiiii YXYXjYYXXZ 122121213

Page 27: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Difficult Arithmetic Operations

• Magnitude comparison / Sign detection• Division• Base extension• Scaling / Rounding / Truncation• Overflow detection

Page 28: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Magnitude ComparisonSign 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.

Page 29: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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, and should be avoided in RNS.

Page 30: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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

Moduliextension

Page 31: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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 2’complement.– Product of one or more of the moduli in RNS.

Page 32: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Overflow Detection

• A special form of magnitude comparison.• Can be avoided by using scaling operation

during run-time.

Page 33: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

Applications

• High-speed systems• (**) FPGA-based solution• Filtering (FIR, IIR) systems• Linear transformations• Adaptive systems

Page 34: Overview of Residue Number System (RNS) for Advanced VLSI Design and VLSI Signal Processing 11-30-2002 NTUEE 吳安宇

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.