Journal of Computer and Communications
Vol.06 No.10(2018), Article ID:88000,15 pages
10.4236/jcc.2018.610002
An Efficient Overflow Detection and Correction Scheme in RNS Addition through Magnitude Evaluation
Peter Awon-natemi Agbedemnab, Stephen Akobre, Edem Kwedzo Bankas
Department of Computer Science, University for Development Studies, Navrongo, Ghana
Copyright © 2018 by authors and Scientific Research Publishing Inc.
This work is licensed under the Creative Commons Attribution International License (CC BY 4.0).
http://creativecommons.org/licenses/by/4.0/
Received: August 24, 2018; Accepted: October 22, 2018; Published: October 25, 2018
ABSTRACT
Number Systems are media for representing numbers; the popular ones being the Weighted Number Systems (WNS), which sometimes propagate carries during arithmetic computations. The other category, Un-Weighted Number Systems, of which the Residue Number System (RNS) belongs, do not carry weights but have not yet found widespread usage in general purpose computing as a result of some challenges; one of the main challenges of RNS is overflow detection and correction. The presence of errors in calculated values due to such factors as overflow means that systems built on this number system will continue to fail until serious steps are taken to resolve the issue. In this paper, a scheme for detecting and correcting overflow during RNS addition is presented. The proposed scheme used mixed radix digits to evaluate the magnitude of the addends in order to detect the occurrence of overflow in their sum. The scheme also demonstrated a simplified technique of correcting the overflow in the event that it occurs. An analysis of the hardware requirements and speed limitations of the scheme showed that it performs considerably better in relation to similar state of art schemes.
Keywords:
Number Systems, Weighted Number Systems (WNS), Residue Number System (RNS), Overflow Detection, Overflow Correction, Faults, Mixed Radix Digits (MRDs)
1. Introduction
The Residue Number System (RNS) has gained prominence in recent years due to its seemingly inherent features such as parallelism and carry-propagation free arithmetic computations. Notwithstanding the fact that, RNS is currently being applied in Digital Signal Processing (DSP) intensive computations like digital filtering, convolutions, correlations, Discrete Fourier Transform (DFT) computations, Fast Fourier Transform (FFT) computations and Direct Digital Frequency synthesis [1] [2] [3] ; researchers in the area are still working hard around the clock in order that the RNS becomes a general purpose processor. These efforts have not completely come to fruition because of challenges, including conversion to and from RNS and decimal/binary number systems, the moduli sets to use, overflow detection and correction, magnitude evaluation, and scaling.
An RNS number X, is represented as , where , a set of pairwise relatively prime integers such that and . The residue set is uniquely represented provided X lies within the legitimate range where is the Dynamic Range (DR) for the chosen moduli set. Let X and Y be two different integers within the DR, if , ( are the arithmetic operations ), results in a value that is outside the legitimate range, then overflow is said to have occurred.
Overflow in general computing occurs if a calculated value is greater than its intended storage location in memory [4] [5] ; this relates to the DR in RNS which situation usually arises during addition and multiplication operations and failure to detect it will lead to improper or wrong representation of numbers and calculated results. Thus detecting overflow is one of the fundamental issues in the design of efficient RNS systems [6] .
The conversion of an RNS number into its decimal/binary equivalent number (a process called reverse conversion) has long been mainly based on the Chinese Remainder Theorem (CRT) and the Mixed Radix Conversion (MRC) techniques with few modifications being their variants of recent times. Whiles the former deals with the modulo-M operation, the later does not but computes sequentially which tends to reduce the complexity of the architecture. Computations can be done using the MRC as follows:
(1)
where are the Mixed Radix Digits (MRDs) and computed as follows:
(2)
The MRDs are within the range , and a positive number, X, in the interval can be uniquely represented. The magnitude of a number can become crucial in the determination overflow in RNS. The sign of an RNS number is determined by partitioning M into two parts: (for positive integers) and (for negative integers).
Recently, some techniques have been developed to detect overflow without necessarily completing the reverse conversion process; in [7] , an algorithm to detect overflow in the moduli set by adding a redundant modulus 2 to this moduli set and making use of ROM and XOR gates was proposed. In [8] , a method for detecting overflow in the moduli set based on group of numbers is presented where numbers within are distributed among several groups. Then, by using the groupings, the scheme is able to diagnose in the process of addition of two numbers, whether overflow has occurred or not. The scheme in [3] evaluated the sign of the sum of two numbers X and Y and used it to detect overflow but adopted a residue-to-binary converter proposed by [9] . The scheme in [10] presented a scheme by an Operands Examination Method for overflow detection for the moduli set during RNS addition. All these schemes either relied on complete reverse conversion process as in the case of [3] , or other costly and time consuming procedures such as base extension, group number and sign detection as in [8] and [10] .
In this paper, a new technique for detecting and correcting overflow during the addition of two RNS numbers for the moduli set is presented; the technique evaluates the sign of an RNS number by performing a partial reverse conversion using the mixed radix conversion method. The sign of the addends is evaluated using only the MRDs, which is then used to detect the occurrence of overflow during RNS addition. The rest of the paper is organized as follows: Section 2 presents the proposed method, an anticipated hardware implementation (albeit theoretical) is presented in Section 3 with its realization in Section 4. Numerical illustrations are shown in Section 5 whiles the performance of the proposed scheme is evaluated in Section 6. The final part of this paper is the conclusion in Section 7.
2. Proposed Method
Given the moduli set , where , and , then
(3)
This implies
(4)
Lemma 1: Given the moduli set , where , and for every integer , the following hold true [10] :
(5)
(6)
(7)
Therefore, we can re-write (2) as;
(8)
Theorem 1: For the given moduli set, any integer if and only if
(9)
or
(10)
for any .
Proof: If it can be shown that by substituting (9) and (10) into Equation (4) that, then, it implies .
Assume (9) is true, then
Also, assume (10) is true, then
∎
Thus, from (9) and (10), it is possible to determine the sign of an RNS number X; whether (for a negative number) or (for a positive number).
The proposed method uses comparison by computing the MRDs of each of the addends to determine which half of the RNS range it belongs rather than performing a full reverse conversion. To detect overflow during addition of two addends X and Y based on the moduli set , a single bit that indicates the sign of that addend is defined. Now, based on this bit, three cases will then be considered:
1) Overflow will definitely occur if both of the addends are equal to or greater than half of the dynamic range (M/2).
2) Overflow will not occur if both of the addends are less than M/2.
3) Overflow may or may not occur if only one of the addends is equal or greater than M/2 and will require further processing to determine whether overflow will occur or not.
Let the magnitude evaluation of the addends be represented by , such that if or represents a positive number or a negative number respectively as shown in Equation (11). The evaluation of the undetermined case in (3) is also represented by a single bit λ in (12).
(11)
and,
(12)
The proposed method will then detect overflow as follows:
(13)
where refer to the logical operations (OR, AND, XOR), respectively. For clarity, “1” means overflow occurs whilst “0” means no overflow.
Correction Unit
Let Z be the sum of the two addends. By substituting the individual MRDs for both addends (X and Y), Z can be obtained as follows;
by letting , we shall have
(14)
Thus by adding the individual MRDs of the two addends, we obtain the sum Z according to (1) without having to compute separately for its MRDs. The value of Z obtained from (14) is the correct result of the addition whether overflow occurs or not. In case of overflow occurrence, the redundant modulus is employed by shifting M one bit to the left in order to accommodate the value.
3. Hardware Implementation
From Equation (8), the MRD’s , and can be represented in binary as;
(15)
(16)
(17)
Equations (15) to (17) can further be simplified as follows;
(18)
(19)
where,
(20)
and
(21)
where
(22)
(23)
Since, is a number that is smaller than , two cases are considered for . First, when is smaller than , and second, when is equal to [11] . If , we have
(24)
Else if , the following binary vector can be obtained as
(25)
Therefore, is calculated as
(26)
And finally,
(27)
Let γ and ω represent the MRDs of the two integers X and Y respectively. Thus from equations (19) to (21), we have
(28)
which implies
(29)
(30)
finally,
(31)
and so, Z is implemented as;
(32)
where,
(33)
(34)
(35)
and,
(36)
4. Hardware Realization
The hardware realization of the proposed scheme is divided into four parts as shown in Figures 1-4. First is the Partial Conversion Part (PCP) shown in Figure 1, which evaluates the MRDs based on (18), (19) and (21) with their parameters clearly defined according to (20) and (21) - (27). The PCP begins with an Operands Preparation Unit (OPU) which prepares the operands in (20), (22) and (26) by simply manipulating the routing of the bits of the residues. Also, an n-bit 2:1 Multiplexer (MUX) is used for obtaining (26). ADD1 is an n-bit Carry Propagate Adder (CPA) and is used to compute (19), meanwhile (21) is obtained by using an -bit CPA as ADD2 whose save ( ) and carry ( ) are then added using ADD3 which is also an -bit CPA. These MRDs are used to determine the sign of the RNS number in Figure 2. Thus, the critical path for the PCP unit is made up of one modulo adder and two modulo adders.
Figure 1. Partial conversion part (PCP).
Figure 2. Magnitude evaluation part (MEP).
Figure 3. Overflow detection part (ODP).
Figure 4. Overflow correction part (OCP).
Second, is the Magnitude Evaluation Part (MEP) shown in Figure 2, which evaluates whether an RNS number is positive or negative according to Equation (11). The MEP uses one AND gate and an OR gate. These are both two input monotonic gates. Next, is the Overflow Detection Part (ODP) which compares the sign bits of the two addends by using an AND gate according to (13) which is then ORed with the evaluated bit of the undetermined case in (12) as shown in Figure 3. This is where the scheme detects the occurrence of overflow during the addition of two numbers.
Lastly, in Figure 4 is the Overflow Correction Part (OCP). The OCP evaluates the individual MRDs of the two addends separately to achieve the sum Z in (14). This is done using five adders; four regular CPAs and one carry save adder (CSA). This is computed according to (29) - (36). ADD4, ADD5 and ADD6 add separately the MRDs and respectively for the two addends. The result of ADD4 is of importance because it is used in evaluating the undetermined case in (12). is a result of concatenation as well as which do not require any hardware. ADD7 is a CSA which computes the result of and whose save ( ) and carry ( ) are added using ADD 8 which is a CPA in order to get accurate sum Z whether overflow occurs or not. The schematic diagrams for the proposed scheme are presented in Figures 1-4.
The area (A) and time (D) requirements of the proposed scheme are estimated based on the unit-gate model as used in [12] and [13] for fair comparison. In this model, each two-input monotonic gate such as AND, OR, NAND, NOR has area and delay , each two-input gate XOR/XNOR has , The area and delay of an inverter is a negligible fraction of a unit, and it is thus assumed to require zero units of area and delay [14] . A 2:1 multiplexer has an area and delay ; A full adder has an area of seven gates and a delay of four gates but a CSA has a constant delay. Also, the adder requirements based on this model as presented in [14] is adopted for the comparison since the adopted adders are similar to the adders used for the proposed scheme. The results state that an estimation modulo;
Therefore, the hardware requirements of the scheme are as follows:
The estimated delay of the scheme will be as follows:
Now, in order to make an effective comparison, the proposed scheme is divided into two: Proposed Scheme I for when the OCP is not included in the comparison and Proposed Scheme II for the OCP being included in the comparison. The delay of the OCP overrides the delay of the delays of the MEP and the ODP if Proposed Scheme II is consider since they will all be computed in parallel and the critical path in that case will be dictated by the OCP. The area for the PCP and the MEP is double for two numbers X and Y but this is not the case for the delay of the two numbers since they are computed in parallel. Thus, the total area and delay of the proposed schemes are:
and,
5. Numerical Illustrations
This subsection presents numerical illustrations of the proposed scheme.
Checking overflow in the sum of 49 and 21 using RNS moduli set {3, 4, 5}
A reverse conversion of will result in the decimal number 10. Whilst the sum of the decimal numbers 49 and 21 is 70 which is obvious of overflow occurring.
Checking for RNS overflow using the proposed technique
which implies, from (11).
Also,
But , which implies from (11).
Therefore, from (13) and needs further processing.
Since , the scheme detects overflow occurring after processing.
Correction unit
Checking overflow in the sum of 10 and 11 using RNS moduli set {3, 4, 5}
RNS to decimal conversion of will result in the decimal number 21, which is correct result of 10 + 11.
Checking for RNS overflow using the proposed algorithm
which implies, since , from (11).
Also,
this implies, since , from (11).
Thus, from (13) , which implies no overflow has occurred according to the proposed scheme after processing.
Correction unit
6. Performance Evaluation
The performance of the proposed scheme is compared to schemes in [3] and [8] ; the scheme in [8] does not contain a correction unit; the scheme by [3] has a correction unit but is not included in the comparison. And so both schemes do not have the correction component in the comparison. Table 1 shows the analysis of the proposed scheme with that of similar state-of-the art schemes.
As shown in Table 1, the proposed scheme for detecting overflow (Proposed Scheme I) in the given moduli set is very cheap in terms of hardware resources
Table 1. Area, delay comparison.
and faster than the scheme by [8] but requires a little hardware resources than the scheme by [3] albeit slower than the Proposed Scheme I. However, the complete proposed scheme (Proposed Scheme II) for detecting and correcting overflow requires more hardware resources than the other compared schemes but faster than both schemes by [3] and [8] .
Clearly, Proposed Scheme I completely outperforms the similar state-of-the-art scheme by [8] for detecting overflow, but the trust of this work is to detect and correct overflow anytime it occurs; in so doing it has made tremendous gains in speed as shown in Table 1.
Table 2 shows a detailed analysis of the complexities and delay of the proposed scheme with that of the similar state-of-the-art schemes.
Table 2 reveals interesting results theoretically, from the analysis it is clear that the Proposed Scheme I requires less resources than what is required by [8] . From the table, smaller values of n shows that Proposed Scheme II requires more resources than that by [8] but drastically improves upon this requirements up to over 51% better than [8] for higher values of n (i.e. n > 4), this is clearly shown in the graph in Figure 5. The analysis from the table also shows that whilst for smaller values of n (say n = 1), the Proposed Scheme I is better than the scheme by [3] in terms of hardware resources, it tends to require up to about 18% resources more than that by [3] .
From Figure 5, the scheme by [8] sharply increases for higher values of n followed by the Proposed Scheme II whilst the scheme by [3] requires the lesser resources. Regarding the delay, the proposed schemes (Proposed I and Proposed II) completely outperforms both schemes by up to over 35% than the scheme by [8] and over 90% faster than the scheme by [3] as shown in Table 2 and in Figure 5. It is worth noting that whiles the scheme by [3] performs better in terms of hardware resources, it tends to be the worst performer for speed and the
Table 2. Area, delay analysis for various values of n.
Figure 5. Graphs of area and delay analysis of the various compared schemes.
percentage difference shows that Proposed I is more efficient. It is clear from the graphs that in terms of delay, the scheme in [3] sharply increases with increasing values of n whiles the marginal increase of the rest of the schemes are minimal.
7. Conclusion
Detecting overflow in RNS arithmetic computations is very important but can be difficult, more so, if it has to be corrected. In this paper, an ingenious technique of detecting overflow by use of the MRC method through magnitude evaluation as well correcting the overflow when it occurs was presented. This technique did not require full reverse conversion but used the MRDs to evaluate the sign of a number to detect the occurrence of overflow. With this technique, the correct value of the sum of two numbers is guaranteed whether overflow occurred or not. The scheme has been demonstrated theoretically to be very fast than similar-state-of-the-art scheme but required a little more hardware resources. However, the Proposed Scheme I, which is the one without the correction component completely outperformed the scheme in [8] in terms of both area and delay requirements. Also, results from Table 2 and Figure 5 showed that for higher values of n, the Proposed Scheme II also outperformed the scheme by [8] . Future works will focus on simulating the theoretical results and implementing it on FPGA boards.
Conflicts of Interest
The authors declare no conflicts of interest regarding the publication of this paper.
Cite this paper
Agbedemnab, P.A., Akobre, S. and Bankas, E.K. (2018) An Efficient Overflow Detection and Correction Scheme in RNS Addition through Magnitude Evaluation. Journal of Computer and Communications, 6, 15-29. https://doi.org/10.4236/jcc.2018.610002
References
- 1. Omondi, A. and Premkumar, B. (2007) Residue Number Systems: Theory and Implementation, vol. 2. Imperial College Press, London. https://doi.org/10.1142/p523
- 2. Agbedemnab, P.A. and Bankas, E.K. (2015) A Novel RNS Overflow Detection and Correction Algorithm for the Moduli Set {2^n−1,2^n,2^n+1}. International Journal of Computer Applications in Technology, 110, 30-34. https://doi.org/10.5120/19403-0925
- 3. Younes, D. and Steffan, P. (2013) Universal Approaches for Overflow and Sign Detection in Residue Number System Based on {2n − 1, 2n, 2n + 1}. The Eighth International Conference on Systems, Seville, 27 January-1 February 2013, 77-81.
- 4. Daabo, M.I. and Gbolagade, K.A. (2012) RNS Overflow Detection Scheme for the Moduli set {M − 1, M}. Journal of Computing, 4, 39-44.
- 5. Daabo, M.I. (2015) Overflow Detection Schemes for Residue Number System Architecture. PhD Thesis, University for Development Studies, Tamale, Ghana.
- 6. Debnath, R.C. and Pucknell, D.A. (1978) On Multiplicative Overflow Detection in Residue Number System. Electronics Letters, 14, 129-130. https://doi.org/10.1049/el:19780088
- 7. Askarzadeh, M., Hosseinzadeh, M. and Navi, K. (2009) A New Approach to Overflow Detection in Moduli Set 2n−3, 2n−1, 2n+1, 2n+3. 2009 Second International Conference on Computer and Electrical Engineering, 1, 439-442. https://doi.org/10.1109/ICCEE.2009.197
- 8. Rouhifar, M., Hosseinzadeh, M., Bahanfar, S. and Teshnehlab, M. (2011) Fast Overflow Detection in Moduli set {2^n-1,2^n,2^n+1}. International Journal of Computer Science Issues, 8, 407-414.
- 9. Piestrak, S.J. (1995) A High-Speed Realization of a Residue to Binary Number System Converter. IEEE Transactions on Circuits and Systems. Part II: Analog and Digital Signal Processing, 42, 661-663. https://doi.org/10.1109/82.471401
- 10. Siewobr, H. and Gbolagade, K.A. (2014) RNS Overflow Detection by Operands Examination. International Journal of Computer Applications in Technology, 85, 1-5. https://doi.org/10.5120/14938-2906
- 11. Molahosseini, A.S., Navi, K., Dadkhah, C., Kavehei, O. and Timarchi, S. (2010) Efficient Reverse Converter Designs for the New 4-Moduli Sets {2^n−1, 2^n, 2^n+1, 2^(2n+1)−1} and {2^n−1, 2^n+1, 2^n, 2^(2n)+1} Based on New CRTs. IEEE Transactions on Circuits and Systems I: Regular Papers, 57, 823-835. https://doi.org/10.1109/TCSI.2009.2026681
- 12. Zimmermann, R. (1999) Efficient VLSI Implementation of Modulo (2^n±1) Addition and Multiplication. Proceedings 14th IEEE Symposium on Computer Arithmetic, Adelaide, 14-16 April 1999, 158-167.
- 13. Chang, C.H., Low, J. and Yung, S. (2011) Simple, Fast, and Exact RNS Scaler for the Three-Moduli Set {2 ^n−1, 2^n, 2^n+1}. IEEE Transactions on Circuits and Systems I: Regular Papers, 58, 2686-2697. https://doi.org/10.1109/TCSI.2011.2142950
- 14. Sousa, L. (2015) 2^n RNS Scalers for Extended 4-Moduli Sets. IEEE Transactions on Computers, 99, 1-14.