Parallel Algorithms for Residue Scaling and Error Correction in Residue Arithmetic

In this paper, we present two new algorithms in residue number systems for scaling and error correction. The first algorithm is the Cyclic Property of Residue-Digit Difference (CPRDD). It is used to speed up the residue multiple error correction due to its parallel processes. The second is called the Target Race Distance (TRD). It is used to speed up residue scaling. Both of these two algorithms are used without the need for Mixed Radix Conversion (MRC) or Chinese Residue Theorem (CRT) techniques, which are time consuming and require hardware complexity. Furthermore, the residue scaling can be performed in parallel for any combination of moduli set members without using lookup tables.


Introduction
Because the residue number system (RNS) operations on each residue digit are independent and carry free property of addition between digits, they can be used in highspeed computations such as addition, subtraction and multiplication.To increase the reliability of these operations, a number of redundant moduli were added to the original RNS moduli [RRNS].This will also allow the RNS system the capability of error detection and correction.The earliest works on error detection and correction were reported by several authors [1][2][3][4][5][6][7][8][9][10][11][12].Waston and Hasting [1,2] proposed the single residue digit error correction.Yau and Liu [3] suggested a modification with the table lookups using the method above.Mandelbaum [4][5][6] proposed correction of the AN code.Ramachandran [7] proposed single residue error correction.Lenkins and Altman [8][9][10] applied the concept of modulus projection to design an error checker.Etzel and Jenkins [11] used RRNS for error detection and correction in digital filters.In [12][13][14][15][16] an algorithm for scaling and a residue digital error correction based on mixed radix conversion (MRC) was proposed.Recently Katti [17] has presented a residue arithmetic error correction scheme using a moduli set with common factors, i.e. the moduli in a RNS need not have a pairwise relative prime.
In this study, we developed two new algorithms with-out using MRD (Mixed-radix digit) or CRT (Chinese remained Theorem) for speeding-up the scaling processes and simplifying the error detection and correction in RNS.The first algorithm is used for these purposes, through the residue digit difference cyclic property (CPRDD) within the range of , where 0 1 with r additional moduli.
The moduli   M is the total range.This paper is organized as follows: Section II will describe the scheme the cyclic property of residue digit difference (CPRDD).Section III describes the Target Race Distance (TRD) algorithm and followed by some examples.Section IV discusses residue scaling and error correction using the TRD and CPRDD algorithms.Finally, the conclusion is given in section V.

Error Detection and Correction Using Residue Digit Difference Cyclic Property
Any residue digit x i representation in moduli set   has its cyclic length with respect to its module number.For example, if the moduli set is (4,5,7,9), then the cyclic lengths of any residue digits  1 2 3 4 , , ,  x x x x are 4, 5, 7 and 9, respectively.Since these cyclic lengths are not equal, they are very difficult to use as tools for error detection and correction.Actually, there exists the property of common (uniform) cyclic length in RNS between residue digital-differences (RDD).Consider three moduli set     .The residue representations and their corresponding digit-differences are shown in Table 1 and defined as the difference in value between two digits, where ij s are all modulo to positive values with respect to d  j m if the cycle length of j m is assigned.Note that the residue digit-differences x x  respectively All negative values must be modulo to positive values.For example, on starred row 28, as shown in Table 1, the digit difference in value for and From the cyclic property of residue-digit difference (CPRDD) in RNS, we now have the following theorem.
Theorem 1.For a moduli set , , , , , , , , depending upon modulo operation with respect to or i j m .Proof: Consider the case respective to j m , the residue-digit difference (RDD) between two digits in where are integers., , , i j p q For simplicity, we only consider the case of i j m m  and assume j i , and the case of can be obtained in a similar way.
The related theorem and algorithm are described as follows.
1) In cycle 0, (the initial cycle), we have

Out of Range
with m j 's 0s in cycle 0, where x     means the largest integer less than or equal to x.
where Thus, the RDD has m j 's "0" in the initial cycle for each modulus, i.e., in cycle 0, For RDD = 0 (for cycles 0, , 2 , , , 1 1 0,0, ,0 with m j 's 0 s.For RDD = 1 (not necessary in cycle 1), From the above theorem, we can immediately obtain that each cycle in the residue-digit difference of x will start at location 0, and end at location m, and for   It is easily shown that there exists m i number of cycles with respect to the cyclic length of Theorem 2. The algorithm of theorem 1 and its corollaries can be extended to two or more pair-wise residuedigit differences.p M .
Proof.Since the residue-digit difference of , , , , , , representation is pair-wise, the legitimate range of this pair-wise From corollary 1, the Proof: consider a three moduli set, we have two pairwise moduli sets, whose RDD (Residue Digital Difference) is , and also pair-wise numbers

  
where is again the referenced module.
. The cyclic length is , and the number of cycles for j m is   , , , , , , , where are the nonredundant moduli and 1 k kr are the redundant moduli.Since the cyclic lengths of CPRDD are constant, it is thus easily found that the number of cycles on track ij from the starting point 0 (or other ij ) to its target position.In turn the distance of RDD's can also be found.
m  Theorem 3. The number of cycles on track ij (column ij ) from any starting point (say ) to its target position can be found using the equation below; where ij the stride distance between moduli i m and j and k = the number of cycles passing through from starting point to the destination, ij , then the number of cycles are equal to the total cycles from the starting point "0" to its target position .
Proof: Since ij is the number of cycles from 0 to ij with respect to module j , and j is the cyclic length, thus ij j is the total distance from the starting point ij to its target position .The remaining distance for on track in the be on the same row of on track .Thus, Once the RDD's of 1 2 , , n r x x  x x are found, the error detection and correction for moduli can be found just by comparing the calculated cycles or RDD with the original residue representation, pair-wise so that the error module can be detected.
The procedure for error detection by using CPRDD algorithm is summarized as follows.
1) Choose two most significant (largest) moduli as the referred moduli among the n moduli, say and .
3) Find the digit difference  are known.The value of must be less than or equal to 6) Find the corresponding from RDD 1 , RDD 2 , , and check the values of x x x x x  x , and ….If these sets' numbers are equal, then no error occurs; otherwise, error exists.We take the similar numerical as example 2-1 to verify this algorithm.(CPRDD) Example 2-2.Assume that a moduli set , , , 4,5, 7,9 m m m m  and number X whose resi- , the error detection can be described as follows.
Let us begin our procedures from the     Since the calculated results of X 1 and X 2 are not identical, there must be errors in one of these moduli.We cannot determine which one is erroneous.To locate the module where the error exists, at least one additional (redundant) module must be used.
The procedure for error correction by using CPRDD algorithm is essential the same as the error detection.However, two additional redundant moduli  2) Find as the same proce- dures of error detection steps 2-7.
3) Examine the values of .If common value exists among, , then no error occurs.If there is one and only one, say that has no common value with all other    1 k j r , then an error exits in modulus .This completes the error correction procedures.
The following example is illustrated here to verify this algorithm.

 
1, 2, 5, 7, 9 X  , and is as-4 m signed as a reference module, then From CPRDD algorithm, we can find the number of cycles for these RDD's.This completes the error correction.Note that the above CPRDD's for each residue-digit difference, ij , and ij can be processed in parallel.In addition, if the referenced module is assigned to the erroneous module by chance, e.g., 3 this algorithm will fail to locate the error.In this case, there are no values that can be found to match this condition.The way to solve the problem is, of course, to assign any other moduli, e.g., or m .
The hardware design for the proposed algorithm in Example 2-3 is shown in Figure 1.

The Target Race Distance (TRD) Scheme
The conversion or decoding technique from residue representation to X in binary is usually accomplished using the mixed-radix digit (MRD) or Chinese remained theorem (CRT).An optimal matched and parallel converter of this kind can be seen in [13].The MRD is shown by the following expression with weighted numbers: , and Optimization can be obtained using this method, as the accessed table lookup time is exactly equal to the right addition time, after immediate column stage for the tree etwork of the adders.n  However, time is still consumed reading a large number of lookup tables.Additional hardware complexity is required by the adder-tree networks.An algorithm called the target race distance was with a simpler structure was developed for high-speed conversion.
TRD algorithm Suppose each residue number in the RNS i m has its own track i , and the distance over track from 0 (starting point) to Obviously, the primary (no multiples of m i ) distance of i x is min .To obtain the X from its residue representation of , , , r x x  r x , we must find a target such that 1 2 , , , x x  x traversing the same dis-tances over tracks 1 2 respectively, i.e. when the TRD distance of each target i , , , r l l l  x is reached, then The TRD distance of X can be found from the following theorem: Theorem 4. Consider the simple case of two moduli , m m .Its residue representation and targets are x 1 and x 2 respectively.Let   1 p D be the primary distance of residue x 1 from 0 to x 1 on the track 1 , and p be the primary distance of x 2 from 0 to x 2 on track 2 .Then the TRD distance for these two residues x 1 and x 2 that have the same TRD distances can be obtained by the following equation.
where m 1 is the cyclic length of x 1 , and k 1 is number of cycles, all of the integers, Proof: It is easy to show that the above .The corresponding TRD of In addition, k i can be solved from the following equations.
are the targets of moduli TRD , , , n x x x  is the distance that has equal track lengths, i.e.
Example 3-1 Let the moduli set be     , , , 3, x x x x  1, 2, 5 .The procedures to find the TRD distance can be described as follows: 1) Find the primary distance   The final TRD distance is the common distinction of this system for targets 1 2 3 , , x x x and 4 x i.e.
   .This result can be verified as follows: assume that is the redundant moduli with a single error residue representation.The TRD theorem can be used to detect this error.We find that final TRD for 1 2 3 , 1,3, 6, 7 x x  , , x x x and 4 x does not fall into the legitimate range as follows i.e.
  TRD , , , 13 840 853 140 . If we need to locate and correct this module error, another redundant module must be added.Let us assume that 5 11 m  for this requirement in the above residue representation.
Thus, the error is located at module m 2 and must be corrected to 2 5 97 2 x   .This algorithm can also be used for multiple error corrections.However, at least three redundant moduli are required.The procedures are similar.

Scaling with Error Correction
The above proposed algorithm used for error detection and correction has the advantage of not requiring lookup tables.No CRT (Chinese residue theorem) decoding processes are required.However, it is still time consuming and requires extensive hardware complexity for each module having multiple-value inputs to the match unit and selecting a correct one as a output.To improve this drawback, an optimal matching algorithm is proposed here for the error correction.The following two theorems will be used and an example follows.Theorem 5. Let m 1 and m 2 be two relative prime numbers in RNS for module 1 and module 2 respectively.Then there must exist the relation represented by the equation x m  will be satisfied.Next consider 0 k  .Since there are two different pair combination m m  be equal to d, then d will be the integers within the range between 0 and m 2 , i.e.,   . These two expressions show that we can always select an integer value p, within the interval between 0 and   This result can be verified by substituting 7 4 5 5 3     into the above equation.Theorem 6 is very useful as shown in the following example.
In Theorem 3 of Section III, the number of cycles on track from the starting point "0" to its target position " " can be expressed by setting where ij s is the module i stride distance referring to module j.Similarly, the number of cycles on track jk from the starting point "0" to its target position " Since, from theorem 3, the cyclic length of the residue digits differences reference to module m j is constant (uniform), then there must exist a condition, Eliminating the above terms from Equations (4-3) and (4-4), , , , , 4,5, 7,9,11 , , , , , and the error , , , , 1,2,5,7,9 , the error occurs at m 3 .
Follow the same procedures of the Example 4-1 to use this algorithm.14   .Noting that it may happen that the assigned referenced memory moduli falls coincidentally with error memory module m 3 .In this occurrence, we cannot find the correct (integers) values of P 1 and P 2 within the legitimate range.It seems that this algorithm can only detect error.To complete the error correction procedure, we can simply change the referenced module to any other and follow the same procedure as before.This guarantees that the proposed algorithm in Theorem 4 will also work well in this case.The hardware structure for illustrating this algorithm is shown in Figure 3.
The proposed TRD (target Race Distance) scheme used for error correction can be used for scaling and assigning numbers in a residue number system.A redundant residue number system (RRNS) is defined as before in an RNS with r additional moduli.The moduli called the legitimate range where is the total range.In the RRNS, the negative numbers within the dynamic range are represented as states at the upper extreme of the total range, which is part of the illegitimate range.The positive members are mapped to the interval     [14].
The one-to-one correspondence between the integers of the dynamic range and the states of the legitimate range in the RRNS can be established using a polarity shift.[11], The polarity shift is defined as below.
where p X denotes the value X after a polarity shift and , 2 2 where j w is the multiplicative inverse of   [11].
, and can be repre- ,where 's k r a  are the coefficient from the Chinese Remainder Theorem (CRT), i.e, , where .
Note that the redundant digits are zeros if no error is introduced, while at least one redundant digit is not equal to zero if a single error is introduced.Therefore, it has the same meaning that is used to be the entries of the error correction., , , , , m m i j  Although the errors detection and correction described in section II have been simplified the processes due to no need of CRT conversion.It is still hardware complex and time consuming for the residue scaling operation.To improve this drawback, a direct residue-scaling algorithm can be used.It is flexible and direct to detect and prevent the errors.The flexibility means that the scaling factor can be arbitrary chosen any single module such as i , i.e. not necessarily beginning from 1 2 to k . in order.The direct capability means no requirement for CRT extension processes for decoding or lookup tables.The following theorem (theorem 7) and example are clarified.
Theorem 7. If the scaling factor K is one of the module set and the residue digits are   , respectively, then the residue digit x scaled by a factor , , can be obtained using the equation Proof: It is easy to show that when 1 2 , and Equation (4-9) is divided by on both side, we have Example 4-3.For convenient comparison of the proposed TRD algorithm to other schemes such as appeared in [14], we take the same numerical example in [11].Let the moduli set     , , , , , , and tions for correcting single residue digits errors are 1) 9 13 117 143 , or 4, The max 2 2 2 7 9 7 9 110 143 .
Thus the moduli set satisfies the necessary and sufficient conditions for correcting single errors digit.Assume After a polarity shift, Follow the same procedures as shown in Example 4-2.CPRDD is applied for correction without the need for using a table.
1) Assign the moduli 4 as the reference moduli, the following residue digit references and its correspon- .The corresponding error is therefore . The final step must use a lookup table to obtain the result, For verifying our proposed algorithm, the table of the corresponding is not required as in [13].The processes for finding and correcting a single error based on our method are described below.1) Find the residue digit difference to a selected module, say 4 as before m   53743 1,3, 4, 4,8,1 x   .For verifying that our proposed algorithm detects and corrects single error without using a table, the same numerical example is used to describe the procedure as follows: , and Furthermore, the CPRDD algorithm can be used directly and in parallel for residue scaling and error correction.Thus the process is greatly speeded up.
Example 4-4 For convenient comparison, the same numeric example as in [13] is illustrated here.Consider , , , , Since from above only k 3 does not match with all other's k i , i.e. , , , m m m m m      From above results, this checks that scaling x x   , this time we must modify the subtraction of i x and j x from the X, before the process of the scaling.If Let us consi-   x x      which has the same number to be subtracted.From CPRDD algorithm, the scaling processes are performed as before, we then have the following results by scaling factor ;

Conclusions
The arithmetic operations in the residue number system for addition, subtraction, and multiplication can be speeded up by using its parallel processing properties.However, some difficult operations, such as error detection and correction, must go through conversion or decoding processes from the residue representation to the regional binary number x.This is because the decoding technique is usually accomplished using the mixed-radix digit (MRD) or Chinese Remained Theorem (CRT), which are time consuming processes requiring hardware complexity.We proposed two algorithms for scaling and error correction without the need for lookup tables or increasing the encoding process.
The Cyclic property of the Residue-Digit Difference (CPRDD) algorithm can detect and correct errors from the RNS cyclic property.Any residue moduli set has a specific cycle length, which can be obtained from the individual residue number, difference, each pair, to a reference memory module m i .Once the cyclic length is known, then the original value x is easily found, and in turn, the errors can be detected and corrected.
The TRD (Target Race Distance) algorithm combined with CPRDD is used for scaling and for error detection and correction.The scaling results and error correction can be directly performed by these two algorithms without using MRD or CRT.Thus, the decoding process is significantly reduced, and the hardware structure is greatly simplified.Several examples are illustrated and verified for these two algorithms.
there exists a cyclic property in differences between two residue digits,

1 r and 2 r
must be added for one error correction.Note that only one redundant modulus added for error detection.

7 7 90Figure 1 .
Figure 1.The hardware implementation for the proposed error and correction location algorithm can be accomplished without using lookup tables.

2 )
Repeat the procedure 1 to find the number of cycles k 2 and k 3 and the last TRD distances (destinations),

Figure 2 4 lFigure 2 .
Figure 2 Shows the TRD's on tracks and respectively.1 2 3 , , l l l the legitimate range, but other final TRD's for 1 where k is restricted in integers.Theorem 6.If the values of m 1 and m 2 and k in the equation

2 .
Find the minimum values of p 1 and p 2 respectively from the following equation : The negative umbers are mapped to the interval 2 

Figure 3 .
Figure 3.In the block diagram using optimal matching between multiples P i m and P k m k , the residue digits are corrected by x i -x 4 = d i4 .
a single residue digit error and must fall within the illegitimate range ,

Figure 4 .
Figure 4. Hardware structure of the residue scaling number for Example 4-4.

Table 1 . Cyclic property of Residue Digit Difference.
If no errors occur, all k ij 's are equal, i.e., 34This shows that the module 3 is faulty, therefore we can correct it as follows: since , the  capability of parallel processing operations in residue scaling and error corrections, i.e., any combination moduli scaling factors for Ks of moduli set {m 1 , m 2 , , m k } can be performed simultaneously. 