Technical note. Overflow detection in a redundant residue number system

2
Technical note OVERFLOW DETECTION IN A REDUNDANT RESIDUE NUMBER SYSTEM Indexing terms: Filters and filtering, Redundant residue number systems Abstract: A new approach, based on redundancy techniques to detect residue arithmetic overflow, is presented. The detection, when applied to residue systems having residue-to-binary decoders, only requires an additional residue encoder to function. Introduction The use of a residue number system (RNS) to implement digital filtering has received attention during the last few years [1-5]. However, its advantage of high-speed pro- cessing is often offset by the difficulty of detecting over- flow. Recently, an approach using a redundant residue number system (RRNS) for overflow detection has been reported [3], in which a mixed radix conversion is required. The conversion process is known to be time con- suming as the mixed radix digits must be generated sequentially [5]. Here a new approach which makes use of an existing residue-to-binary decoder is proposed. Overflow detection The dynamic range of a standard RNS consisting of a set of moduli {m l5 m 2 , ..., m L ) is defined as [ —(M l)/2, (M - l)/2] if M is odd, and [-M/2, M/2 - 1] if M is even, where M = J~]f = j m,. With one additional modulus m 0 , the RNS becomes an RRNS when the dynamic range remains intact. For this case, m 0 is called the redundant modulus. Due to the complement coding, negative states are mapped to the top of the illegitimate range [M, MT), where MT = Mm 0 . If we want the dynamic range to be mapped onto the legitimate range [0, M), a modular addi- tion, namely a polarity shift [3, 4], is required. Suppose the residue set {y 0 , y^, ..., y L } is the result of modular arithmetic in the RRNS; then, after the polarity shift, we obtain {z 0 , z x ,..., z L ), where C is the appropriate constant required for the shift. z,. = <j/,. + C> m . (1) According to the Chinese remainder theorem [6], two natural integers Z MT and Z M can, respectively, be decoded from the residue sets {z 0 , z v , ..., z L } and {z x , z 2 , ..., z L }. An interesting result is discovered as follows. Let z' Q = <Z ¥ > mo . If Z MT e [0, M), then z' o = z 0 because Z MT = Z M (z 0 is redundant). If Z MT e [M, MT), then z' o =/= z 0 because Z MT ^ M and Z M < M (z 0 becomes nonredundant). Con- sequently, the comparison of z 0 and z' o will indicate whether or not the arithmetic result Z MT has overflowed (i.e. in the illegitimate range). Based on these discussions, an RRNS for overflow detection is set up as shown in Fig. 1. Due to the addition of the polarity shift, the actual arithmetic result Y M must be recovered by subtracting the constant from Z M . It is noted that the modulo m 0 residue encoder will require a significant amount of hardware to implement if Z M is a large value. The problem, however, can be solved by choos- ing m 0 to be a form of 2 k , where k is a positive integer. input residue encoder residue encoder residue encoder modular arithmetic modular arithmetic modular arithmetic polarity shift polarity shift polarity shift residue - to-binary decoder residue encoder subtraction | compare | overflow indication Fig. 1 RRNS for overflow detection With this, the encoding process simply becomes an extrac- tion of the least k significant bits of Z M . In order to eliminate the subtraction, an alternative structure is proposed as depicted in Fig. 2. It can be easily shown that As a result, z' = <<Y + C> >m (2) From eqn. 2, the value z' o can directly be evaluated from Y M , which implies that the RRNS will decode Y M instead of Z M . The advantage of this structure is that all addi- tional operations such as residue encoding and polarity shift for the overflow detection can be completely separat- ed from the original RNS. However, on the other hand, we will face the difficulty of implementing eqn. 2 when Y M is large. Numerical examples As an illustration, an RRNS consisting of three moduli, m 0 = 2, m, = 3 and m 2 = 5, is chosen, where m 0 is the redundant modulus. For the system, we have M = 15, MT = 30 and C = 7 (residue digits = {1, 1, 2}). By use of the RRNS, three arithmetic operations confined to the IEE PROCEEDINGS, Vol. 131, Pt. E, No. 3, MAY 1984 97

Transcript of Technical note. Overflow detection in a redundant residue number system

Page 1: Technical note. Overflow detection in a redundant residue number system

Technical noteOVERFLOW DETECTION IN AREDUNDANT RESIDUE NUMBER SYSTEM

Indexing terms: Filters and filtering, Redundantresidue number systems

Abstract: A new approach, based on redundancytechniques to detect residue arithmetic overflow, ispresented. The detection, when applied to residuesystems having residue-to-binary decoders, onlyrequires an additional residue encoder to function.

Introduction

The use of a residue number system (RNS) to implementdigital filtering has received attention during the last fewyears [1-5]. However, its advantage of high-speed pro-cessing is often offset by the difficulty of detecting over-flow. Recently, an approach using a redundant residuenumber system (RRNS) for overflow detection has beenreported [3], in which a mixed radix conversion isrequired. The conversion process is known to be time con-suming as the mixed radix digits must be generatedsequentially [5]. Here a new approach which makes use ofan existing residue-to-binary decoder is proposed.

Overflow detection

The dynamic range of a standard RNS consisting of a setof moduli {ml5 m2, . . . , mL) is defined as [ —(M — l)/2,(M - l)/2] if M is odd, and [ - M / 2 , M/2 - 1] if M iseven, where M = J~]f= j m,. With one additional modulusm0, the RNS becomes an RRNS when the dynamic rangeremains intact. For this case, m0 is called the redundantmodulus. Due to the complement coding, negative statesare mapped to the top of the illegitimate range [M, MT),where MT = Mm0. If we want the dynamic range to bemapped onto the legitimate range [0, M), a modular addi-tion, namely a polarity shift [3, 4], is required.

Suppose the residue set {y0, y^, ..., yL} is the result ofmodular arithmetic in the RRNS; then, after the polarityshift, we obtain {z0, z x , . . . , zL), where C is the appropriateconstant required for the shift.

z,. = <j/,. + C>m. (1)

According to the Chinese remainder theorem [6], twonatural integers ZMT and ZM can, respectively, be decodedfrom the residue sets {z0, zv, . . . , zL} and {zx, z2, . . . , zL}.An interesting result is discovered as follows. Let z'Q =<Z¥>mo. If ZMT e [0, M), then z'o = z0 because ZMT = ZM

(z0 is redundant). If ZMT e [M, MT), then z'o =/= z0 becauseZMT ^ M and ZM < M (z0 becomes nonredundant). Con-sequently, the comparison of z0 and z'o will indicatewhether or not the arithmetic result ZMT has overflowed(i.e. in the illegitimate range).

Based on these discussions, an RRNS for overflowdetection is set up as shown in Fig. 1. Due to the additionof the polarity shift, the actual arithmetic result YM mustbe recovered by subtracting the constant from ZM. It isnoted that the modulo m0 residue encoder will require asignificant amount of hardware to implement if ZM is alarge value. The problem, however, can be solved by choos-ing m0 to be a form of 2k, where k is a positive integer.

input

residueencoder

residueencoder

residueencoder

modulararithmetic

modulararithmetic

modulararithmetic

polarityshift

polarityshift

polarityshift

residue - to-binary decoder

residue encoder subtraction

| compare |

overflow indication

Fig. 1 RRNS for overflow detection

With this, the encoding process simply becomes an extrac-tion of the least k significant bits of ZM.

In order to eliminate the subtraction, an alternativestructure is proposed as depicted in Fig. 2. It can be easilyshown that

As a result,

z' = <<Y + C> >m (2)

From eqn. 2, the value z'o can directly be evaluated fromYM, which implies that the RRNS will decode YM insteadof ZM. The advantage of this structure is that all addi-tional operations such as residue encoding and polarityshift for the overflow detection can be completely separat-ed from the original RNS. However, on the other hand, wewill face the difficulty of implementing eqn. 2 when YM islarge.

Numerical examples

As an illustration, an RRNS consisting of three moduli,m0 = 2, m, = 3 and m2 = 5, is chosen, where m0 is theredundant modulus. For the system, we have M = 15,MT = 30 and C = 7 (residue digits = {1, 1, 2}). By use ofthe RRNS, three arithmetic operations confined to the

IEE PROCEEDINGS, Vol. 131, Pt. E, No. 3, MAY 1984 97

Page 2: Technical note. Overflow detection in a redundant residue number system

dynamic range [ - 7 , 7] are evaluated to demonstrate theprinciple of the detection scheme.

input

residueencoder

residueencoder

residueencoder

modulararithmetic

modulararithmetic

modulararithmetic

polan'ty

\ \

shift

z 0

\

residue

polarity shiftand

residue encoding

\ 1

26

- to -binary

}

decoder]

YM

| compare ]

overflow indication

Fig. 2 Alternative RRNS for overflow detection

Case 1: y = 5 + (-2)

modular arithmetic: (y0, yx, y2) = (1, 2, 0) + (0, 1, 3)

= (1 ,0 ,3 )

polarity shift: (z0 , zx,z2) = (1, 0, 3) + (1, 1, 2)

= (0, 1, 0)

residue decoding: Z M = 10

conclusion: z0 = 0 and z'o = 0,no overflow because z'o = z0

subtraction: YM = ZM — 7 = 3

Case 2: y = 5 x (— 2)

modular arithmetic: (y0, yx, y2) = (1, 2, 0) x (0, 1, 3)

= (0, 2, 0)

polarity shift: (z0, zl, z2) = (0, 2, 0) + (1, 1, 2)

= (1,0,2)

residue decoding: ZM = 12

conclusion: z0 = 1 and z'o = 0,overflow for the reason z'o =/= z0

(y = — 10 after multiplication)

Case 3: y = {-5) x (-5)

modular arithmetic: (j/0, j ^ , y2) = (1, 1, 0) x (1, 1, 0)

= (1, 1, 0)

polarity shift: (z0, Zl,z2) = (1, 1, 0) + (1, 1, 2)

= (0, 2, 2)

residue decoding: ZM = 2

conclusion: z0 = 0 and ZQ = 0no overflow (wrong!){y = 25 after multiplication)

In case 3, the wrong conclusion is reached though itappears not to be. This multiplication will give the value25 which is obviously out of the range [ — 7, 7]. The failurecomes from the fact that the value 25 is not only an invalidnumber to the original RNS but also to the RRNS ofwhich the permissible range is [ - 1 5 , 14]. To solve theproblem, we can increase the redudant modulus such thatthe RRNS can cover all arithmetic results. In other words,if the maximum number of the dynamic range is A, whichis the possible largest value of an operand, then it must bem0 ^ A in order to have correct detection.

Conclusion

With the aid of a residue-to-binary convertor which mustbe included in an RNS if a conventional digital-to-analogue convertor is employed to obtain real-time results,the detection of residue arithmetic overflow can easily beaccomplished. The success of the detection depends on theefficient implementation of the decoder though theapproach still requires an additional residue encoder.

References

1 JENKINS, W.K., and LEON, B.J.: The use of residue number systemsin the design of finite impulse response digital filters', IEEE Trans.,1977,CAS-24, pp. 191-201

2 BARANIECKA, A., and JULLIEN, G.A.: 'On decoding techniques forresidue number system realizations of digital signal processing hard-ware', ibid., 1978, CAS-25, pp. 935-936

3 ETZEL, M.H., and JENKINS, W.K.: 'Redundant residue numbersystems for error detection and correction in digital filters', ibid., 1980,ASSP-28, pp. 538-545

4 JENKINS, W.K., and ETZEL, M.H.: 'Properties of complement codesfor redundant residue number systems', Proc. IEEE, 1981, 69, pp.132-133

5 JENKINS, W.K.: 'Techniques for residue-to-analog conversion forresidue-encoded digital filters', IEEE Trans., 1978, CAS-25, pp.555-562

6 McCLELLAN, J.H., and RADER, CM.: Number theory in digitalsignal processing (Prentice Hall, 1979), pp. 21-22

8th June 1983

Department of ElectronicsChinese University of Hong KongShatinNTHong Kong

L.C. TAIC.F. CHEN

3092E

98 IEE PROCEEDINGS, Vol. 131, Pi. E, No. 3, MAY 1984