0% found this document useful (0 votes)
112 views13 pages

Residue Number System: Dr. Arunachalam V Associate Professor, SENSE

The document discusses residue number system (RNS) which represents numbers based on their remainders when divided by several relatively prime moduli. It provides examples of: 1) Representing a number in RNS using its remainders modulo different moduli, such as 105 being represented as (2|3|2) modulo (7|5|3). 2) How the dynamic range of an RNS is determined by the product of the moduli and how numbers in that range can be represented. 3) How operations like addition, subtraction and multiplication can be performed independently on each remainder/digit in an RNS representation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views13 pages

Residue Number System: Dr. Arunachalam V Associate Professor, SENSE

The document discusses residue number system (RNS) which represents numbers based on their remainders when divided by several relatively prime moduli. It provides examples of: 1) Representing a number in RNS using its remainders modulo different moduli, such as 105 being represented as (2|3|2) modulo (7|5|3). 2) How the dynamic range of an RNS is determined by the product of the moduli and how numbers in that range can be represented. 3) How operations like addition, subtraction and multiplication can be performed independently on each remainder/digit in an RNS representation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Residue Number System

Dr. Arunachalam V
Associate Professor, SENSE
Why RNS ?
• By converting arithmetic on large numbers to arithmetic on a collection of
smaller numbers, residue number system (RNS) representations produce
significant speedup for some classes of arithmetic -intensive algorithms in
signal processing applications.
• RNS arithmetic is a valuable tool for theoretical studies of limits of fast
arithmetic.
Introduction
• What number has reminders of 2, 3 and 2 when divided by the numbers 7,
5 and 3 respectively?
105x + 23 (23, 128, 233, …)
• The puzzle essentially asks us to convert the coded representation (2|3|2) of
a RNS, based on the moduli (7|5|3) in to a standard decimal format.
Representation of a number in RNS
• In a RNS, a number is represented by the list of its residues with respect
to k pairwise relatively prime moduli > > ∙ ∙ ∙> > .
• The residue of with respect to the ith modulus is akin to digit and
the entire k-residue representation of can be viewed as a k-digit number,
where the digit set for the ith position is [0, ].
• Notationally, = =
• Also specify the RNS representation of by enclosing the list of residues,
or digits, in parentheses.
• For example = 2|3|2 | | represents the puzzle by Sun Tzu.
• The list of moduli can be deleted from the subscript when we have agreed
on a default set.
• In many of the examples, we use the following RNS is assumed:
RNS (8|7|5|3)
Dynamic range (M)
• It is the product of the k-pairwise relatively prime moduli and it describes
the number of different representable values in this range = ×∙∙∙
× ×
• For example, M for RNS(8|7|5|3) is 8 × 7 × 5 × 3 = 840 ,
• Because of the equality, − = − the 840 available values can
be used to represent numbers 0 through 839, -420 through +419, or any
other interval of 840 consecutive integers.
• In effect, negative numbers are represented using a complement system
with the complementation constant M.
Some examples for RNS (8|7|5|3)
Complementing a RNS number

• Given the RNS representation of x, the representation of -x can be found by


complementing each of the digits with respect to its modules (0 digits
are left unchanged).
• Thus 21 = 5 0 1|0 |
• We find -21 as
• −21 = 8 − 5 0 5 − 1|0 | = 3 0 4|0 |
Weighted representation of a number

• Any RNS can be viewed as a weighted representation.


• For example RNS (8|7|5|3), the weights associated with the four positions
are :
• 7×5×3 = 105; 8×5×3 = 120; 8×7×3 = 168; 8×7×5 = 280
• As an example, (1|2|4|0)RNS represents the number:
• 105 × 1 + 120 × 2 + 168 × 4 + 280 × 0 = 1689 =9
Representational efficiency

• In practice, each residue must be represented or encoded in binary.


• For example RNS, such a representation would require 11 bits.
• mod of 8 needs 3 bits, mod of 7 and 5 needs each 3 bits and mod of 3 needs
2 bits
• To determine the number representation efficiency of our 4-modulus RNS,
we note that 840 different values are being represented using 11 bits,
compared to (2^11) i.e. 2048 values possible with binary representation.
• Thus, the representational efficiency is 840/2048 = 41%
• Since log2 840 = 9.714, about 1.3 bits of 11 bits goes to waste.
Addition, subtraction and multiplication in RNS

• Addition, subtraction and multiplication can be performed by


independently operating on each digit.
• x = +5 ; (5|5|0|2)
• y = -1 ; (7|6|4|2)
• x + y =?
• x + y = 4 ; ((5+7)8 = 4 | (5+6)7 = 4 | (0+4)5 = 4 | (2+2)3 = 1) = (4|4|4|1)
• x - y =?
• x - y = 6 ; ((5-7)8 = -2 or 6 | (5-6)7 = -1 or 6 | (0-4)5 = -4 or 2 | (2-2)3 = 0)
= (6|6|1|0)
• x × y =?
• x × y = 4 ; ((5×7)8 = 3 | (5×6)7 = 2 | (0×4)5 = 0 | (2×2)3 = 1) = (3|2|0|1)
Adder, subtractor and multiplier
Reference
1. Chapter 4.1 of Behrooz Parhami, “Computer Arithmetic: Algorithms and
Hardware Design”, (2/e) Oxford University Press 2015.
Next Class
CHOOSING THE RNS MODULI

You might also like