Document not found! Please try again

Necessary and Sufficient Conditions for Parallel, Constant ... - CiteSeerX

2 downloads 0 Views 94KB Size Report
This note presents necessary and sufficient conditions for parallel and constant time conversions from one digit-set into another, and thus also for constant time ...
Necessary and Sufficient Conditions for Parallel, Constant Time Conversion and Addition Peter Kornerup Dept. of Mathematics and Computer Science Odense University, Denmark E-mail: [email protected]

Abstract This note presents necessary and sufficient conditions for parallel and constant time conversions from one digit-set into another, and thus also for constant time addition. In the integer domain it is generally believed that such conversion and addition is possible if the target digit-set is redundant and complete. This is also the case when the digit-set is a contiguous set of integers. However, when this is not the case then such conversion and addition in the integer domain is not possible in general, and when more general rings are considered, the same problem may be present.

1. Introduction It has been known for a long time that addition of radix represented numbers in the integer domain can be performed in constant time by a digit parallel process, if only the digit-set employed is contiguous and redundant, as demonstrated by Avizienis [1]. In [2] the generalized problems of digit-set conversions were investigated, and it was similarly shown how these could be performed in constant time under the same conditions in the integer domain. During work on generalizing these results to radix polynomials over general rings, revising and extending [4] into [5], it was realized that redundancy by itself is not sufficient to assure that digit-set conversion can be performed in parallel, constant time, the target digit-set must be of a certain structure. Note that addition can be considered a special case of digitset conversion, since trivial pairwise addition of the digits of two radix polynomials yields a radix representation of the sum of these, employing digits from a larger digit-set. Hence the essential problem of addition is converting this polynomial back into the original digit-set, as the sum is usually required to be represented in the same digit-set as used for the operands.

 This paper was presented at ARITH14, April 1999, in Adelaide, Australia. A few misprints have since been corrected.

Although the following discussion and results apply to radix polynomials over general commutative rings, as illustration of such conversions we shall show a few examples from the integer domain. First consider conversion of the 1201333 into radix 3 polynomial given by the digit string 12 the system with digits from the set E = f?1 : : 2g, i.e., a contiguous and redundant digit-set. Rewriting in parallel each digit into a “place value” in the set f?1 : : 1g and a carry in f0 : : 1g, and then adding these we find 1 1 0 1 0 2

2  1 0  1

 1 2 0  1  1 0 1 0 0 0  1 0

1 1 0 1

1 3 1 0 1 2 0

2 f?1 : : 3g 2 f?1 : : 1g 2 f0 : : 1g 2 f?1 : : 2g

Now consider conversions of 11    123 , respectively 11    113 , into the digit-set f?1; 0; 1; 4g for radix 3: 1 1 4 or 

1  1  1

1  1  1

  

1  1  1

2  1  1

1 1 1 1 or 1 1

  

1 1 1 1 0 4

where in the latter case any digit string 11 can be substituted by 04. Thus the effect of changing the least significant digit can ripple arbitrarily far to the left. However, adding an extra digit 5 makes constant time conversion possible from any string over the digitset f?3; ?2; 0; 1; 2; 5g so here 11    123 converts into 11    053 with bounded carry propagation. This is due to f?3; ?2; 0; 1; 2; 5g = f0; 1; 5g + 3f?1; 0g and that f?1; 0; 1; 4; 5g = f0; 1; 5g + f?1; 0g, so that any carry can be absorbed. There is also an alternative decomposition of the digit-set f?1; 0; 1; 4; 5g = f?1; 0; 4g + f0; 1g, allowing parallel conversion from f?1; 0; 2; 3; 4; 7g. Surprisingly, changing the digit 4 into 5 also allows parallel conversion into the digit-set f?1; 0; 1; 5g from any string over the set f?1 : : 3g, although there is no apparent structure (decompositions) like the above. Due to the redundancy there are many possible results, depending on

the use of intermediate digit-sets, and choices in rewriting the digits of the source operand, e.g., 1 1 1  1 or 1 

 2 0 1 1 3 2 1  1 0  1  1 5  1 0   1 0 1 1  1  1 0

2 f?1 : : 3g 2 f?1; 0; 1; 5g 2 f?1; 0; 1; 5g

Normally in such a conversion the outgoing carry is chosen such that that the remaining “place value” can absorb whatever incoming carry is being determined by the right context. Alternatively, the carry could be determined be right as well as left context, whereas it does not seem to make sense if the carry is determined exclusively by left context. Note that the carry into position i uniquely determines the residue class of the new digit at position i. Since the target digit-set may contain more than one member of a given residue class, there may be a choice of outgoing carry. The essential problem is to limit the carry propagation, i.e., determine a minimal constant k such that the carry into position i + k is independent of the carry into position i. But there does not seem to be any simple way to determine such a k by a simple inspection of the digit-sets involved. In the following we shall explore the possibility of introducing context by grouping radix digits into digits of a higher radix k , and performing the digit-set conversion in radix k . We shall show that it is possible to perform conversion based on right context with bounded carry propagation, if and only if for some value of k the base converted digit-sets of radix k allow a suitable decomposition as above. With left context it is shown similarly, that provided a (more complicated) decomposition of the target digit-set exists, then such conversion is also possible. But so far no example has been found where left context actually is needed, when the target digit-set is assumed to be complete for the ring. Note that in such parallel conversions, the source digitset is determined by the target digit-set, although there might be several source digit-sets that can be converted into a given target set. If conversion from other, and possibly a larger digit set is needed, then several “layers” of conversions will be necessary, as discussed in [2, 3, 4, 5].

2. Notation In general we will follow the notation from [2, 4]. With radix and digit-set D from some ring R, P [ ; D] is the set Pn?1 of radix polynomials of the form P = 0 dj j . Define for k  1

D(k) =

o nP k?1 d i j d 2 D ; i i i=0

i.e., the set of radix k digits formed by grouping k digits from D. Digits from D(k) will be denoted similarly with an upper index, d(k) . We assume that the zero element of R is a member of any digit-set.

3. Limited Carry Propagation. For a discussion of parallel, constant time conversion, it is necessary to define what is meant by this. We shall here assume that it is possible to implement some kind of logic, which will calculate the values of a set of consecutive output digits, in terms of a bounded set of consecutive input digits. An array of such identical logic units will then in parallel be able to perform the conversion in constant time. This is formalized as follows: Definition 1 Parallel, constant time conversion of P 2 P [ ; D] into Q 2 P [ ; E ] is possible if and only if there

exists a bounded “input window” defined by constants `; r, `  0; r  1, an “output window” defined by a constant k  1, together with function fP : D`+k+r ! E k Pna?vector 1 mk?1 e j j such that for P = 0 dj and Q = 0 j

[eki+k?1 ;    ; eki ] = f (dki+k+`?1 ;    ; dki?r );

(1)

for i 2 [0 : : m ? 1], with ej 2 E and dj 2 D, where P is possibly extended with some zero-valued digits. The mapping from an input window to an output window may be pictured as z

left context }|

{

z

right context }|

{

   dki+k+`?1    dki+k dki+k?1    dki dki?1    dki?r    |

z

{z

}|

{

eki+k?1    eki

}

In the definition we may assume that k  ` + r, since otherwise we may combine several “units” into one, such that this condition is satisfied. We may also assume that k = ` + r, since we can just increase the value of r. Since E may be redundant there may be more than one valid conversion from P to Q, but f selects a particular resulting vector [eki+k?1 ;    ; eki ]. Now base convert P 2 P [ ; D] into P (k) 2 P [ k ; D(k) ]

dX kX ?1 k e?1 d(ik) [ k ]i where d(ik) = dki+j j 2 D(k) ; Pk = i=0 j =0 Pmk?1 ei [ ]i can similarly be base converted and Q = 0 n

( )

into

Q(k) =

k?1 mX ?1 X e(ik) [ k ]i where e(ik) = eki+j j j =0 i=0 k

2Ek; ( )

= fb(dki+k+`?1 ;    ; dki ;    ; dki?r ), and by (1), ei where fb() is the equivalent of f (), just mapping into E (k) by evaluation of the polynomial specified by the digit string eki+k?1    eki resulting from f (). ( )

k satisfy the carry-relation k) = d(k) + c(k) : e(ik) + k c(i+1 i i (k) for i = 1;    ; m ? 1. Obviously, ci can only depend on a bounded window of digits dj , say c(ik) = (dki+u ;    ; dki ;    ; dki?v ) The digits and carries ci

( )

but by (1) we have

k) ? c(k) = d(k) ? e(k) k c(i+1 i i i = g(dki+k+`?1 ;    ; dki ;    ; dki?r ) for some function g . Thus we find that u = ` ? 1 and v = r,

hence

c(ik) = (dki+`?1 ;    ; dki?r ); (k) (k) and since k  ` + r then ci+1 is independent of ci .

(2)

Observe that (2) only defines carries occurring at positions with index of the form ki. Since the digit-set E may be redundant, carries occurring at other positions may even belong to a larger set as we will see later. For a peculiar example where left context is needed, assume that d 2 D where d is not in E , nor is any other element from the same residue class as d, but d i 2 E for some i  1. Then conversion of the polynomial P = d[ ]0 yields Q 2 P [ ; E ] with Q = 0[ ]0 +(d i )[ ]?i where the (k) carry is c0 = ?d for any k used. This conversion will then require knowledge of some left context, since the right context (all zeroes) cannot determine the value of the carry. But the conversion requires a polynomial containing a negative power of , which may not even exist in R. It is natural to require that the target digit-set E is complete for R, i.e., that any element of R can be represented using exclusively non-negative powers of . It is then easy to see that a necessary condition for completeness is that the digit-set contains a complete residue set modulo [ ].

4. Carry Determined by Right Context In this section we consider the case where ` = 0.

Theorem 1 Given digit-sets D and E for radix in a ring R, then parallel and constant time conversion from P [ ; D] into P [ ; E ] is possible with carries determined by a bounded right context, if and only if there exists an integer k  1 and digits sets  and C in R such that:

D(k)   + k C and  + C  E (k) : (3) Furthermore, if D contains a complete residue set modulo then  contains a complete residue set modulo k , and if = E then C 6= f0g. Hence if E is a there exist d 2 D; d 2 complete digit-set for radix in the ring R, then it is also redundant.

Proof: For the if-part, let P be any polynomial in P [ ; D] and base convert it into a polynomial P (k) 2 P [ k ; D(k) ] by grouping digits of P and evaluating these into digits from D(k) . By (3) there exist functions  and such that for any Pn?1 (k) k i (k) (k) (k) di 2 D from P = i=0 di ( ) , digits s(ik) and k) can be chosen by s(k) =  (d(k) ) 2  and c(k) = c(i+1 i i i+1

(d(ik) ) 2 C satisfying

d(ik) =

k?1 X j =0

k) ; dki+j j = si(k) + k c(i+1 k

k

where it may be observed that si and ci+1 are chosen independent of any left context. (k) By (3), si + c 2 E (k) for any c 2 C , and then in (k) (k) (k) particular also for c = ci = (di?1 ). Hence ei = ( )

( )

s(ik) + c(ik) 2 E (k) and it is thus possible to convert P (k) into a polynomial Q(k) 2 P [ k ;  + C ]  P [ k ; E (k) ]

by a parallel, constant time conversion of digits, where carries are absorbed in a neighboring position. Each digit e(ik) 2  + C  E (k) of Q(k) can now be represented (possibly not uniquely) by a polynomial in P 0;k?1 [ ; E ], thus concluding the if-part. Now assume that conversion of P 2 P [ ; D] into Q 2 P [ ; E ] can be performed by a parallel, constant time algorithm, using functions f , with ` = 0 and k = r  1, where the converted digits ei of Q can be expressed by (1) (k) and the carry ci by (2) so that

c(ik) = (dki?1 ;    ; dki?k ):

From the carry relation of the base converted polynomials P (k) 2 P [ k ; D(k) ] and Q(k) 2 P [ k ; E (k) ]

d(ik) ? k (dk(i+1)?1 ;    ; dki ) = e(ik) ? (dki?1 ;    ; dk(i?1) ): we note that the left side is exclusively dependent on dk(i+1)?1 ;    ; dki , hence when defining the function  by

(ak?1 ;    ; a0 ) = then ei

kX ?1 0

ai i ? k (ak?1 ;    ; a0 ); ai 2 D

k can be written as

( )

(4)

e(ik) = (dk(i+1)?1 ;    ; dki ) + (dki?1 ;    ; dk(i?1) ); and there exist sets  and C  = fs j s = (ak?1 ;    ; a0 ); ai 2 Dg; C = fc j c = (ak?1 ;    ; a0 ); ai 2 Dg satisfying  + C  E (k) , since the arguments of  and are disjoint. Note that 0 2 C since (0;    ; 0) = 0.

By definition (4) of  , for any sequence ak?1 ;    ; a0 of digits from D

kX ?1 0

ai i = (ak?1 ;    ; a0 ) + k (ak?1 ;    ; a0 )

so D k   + k C , which concludes the only-if part. For the final part of the theorem, first note that there are trivial cases of constant time conversion, e.g., where D is a subset of E . If D contains a complete residue system modulo then D(k) contains a complete residue system modulo k . Since D(k)  + k C then  must contain a complete residue system modulo k . Let d 2 D where d 2 = E, and consider conversion of the polynomial P = d [ ]k?1 . Thus after base conversion P (k) = d k?1 [ ]0 , and since d 2= E implies (d; 0;    ; 0) 6= 0 then C 6= f0g. If E is a complete digit-set for radix in R, then by Lemma 2.6 in [4], E must be redundant. In fact if Conjecture 2.9 of [4] holds, then E will always be redundant, even if it is not 2 complete. ( )

Returning to the example from the introduction of conversion into the digit-set E = f?1; 0; 1; 5g for radix = 3, we notice that with k = 2, E (2) = f?4 : : 5; 8; 14 : : 16; 20g, so  + C  E (2) when choosing  = f?4 : : 4g and C = f0; 1g. Thus constant time conversion is possible in radix 9 from any D(2) , D(2)   + 2 C = f?4 : : 4g + 9f0; 1g = f?4 : : 13g into E (2) . In particular it is then possible to convert from D = f?1 : : 3g into E = f?1; 0; 1; 5g since then D(2) = f?4 : : 12g, so returning to the previous example in radix 3, we may perform it through base conversion into radix 9,  2 0 1 1 3 1 2 1  1 5 1 6    1 4 1 3 1 0 0 1    4 1 3 1 2 1  1 0 1  1 5  1 0 0 1 

2 f?1 : : 3g 2 f?4 : : 12g 2 f?4 : : 4g 2 f0; 1g 2 f?4 : : 5g 2 f?1; 0; 1; 5g



=3 =9 =9 =9 =9 =3

where we note that the radix 9 conversion is unique, since f?4 : : 4g is nonredundant, but the conversion back to radix 3 is non-unique. The equivalent conversion in radix 3 is 1  2 1 1 1 1  or 1  1

2  1 0  1  1

 1 2 0  1  1 0 1 0  1 1  1 0  0  1 1

1 4 1 5  1

1  2 1  1  1

3 0 0 0

2 f?1 : : 3g 2 f?1; 0; 1; 5g 2 f?1; 0; 1; 5g

where it is noted that a carry of ?1 occurs internally in one of the groups. For practical applications of Theorem 1, it is in general fairly easy to perform a search for a suitable value of k ,

generating E (k) for increasing values of k , looking for possible decompositions of the form  + C  E (k) . Also, it is easy to spot situations where no such decomposition will be possible for any value of k . The reader is encouraged to try with the digit-set E = f?1; 0; 1; 4g for = 3 from the introduction.

5. Dependence on Left Context We shall here assume that the digit set E is complete for the ring R. First we consider a fixed string of k = ` + r digits with `  1:

dk?1 ;    ; dk?r ; d`?1 ;    ; d0

where the two groups of digits can be evaluated as polynomials

r) = d(high

r?1 X j =0

dk?r+j j

and

`) = d(low

`?1 X j =0

dj j ;

and define the following sets of outgoing, respectively incoming carries:

Cdout = k?1 ;;dk?r 

(a`?1 ;    ; a0 ; dk?1 ;    ; dk?r ) j [a`?1;    ; a0 ] 2 D` Cdin`?1 ;;d0 = f (d`?1 ;    ; d0 ; ak?1 ;    ; ak?r ) j [ak?1 ;    ; ak?r ] 2 Dr g ; where we note that 0 2 Cdin`?1 ;;d0 , since E is complete so

(d`?1 ;    ; d0 ; 0;    ; 0) = 0. Using these definitions we define the following sets:

dk?1 ;;dk?r = ?d`?1 ;;d0 =

r g ? r C out fdhigh d ?1 ;;d ? ` in fdlow g + Cd ?1 ;;d0 ( )

k

( )

`

k r

(5) (6)

where fdg denotes the singleton set consisting of d. Note that dk?1 ;;dk?r is the set of “high order” parts left after the carry has been sent out, as also determined by the left context, and similarly ?d`?1 ;;d0 is the set of “low order” parts obtained after receiving whatever carry has been determined together with the right context. Assuming that parallel, constant time conversion is possible, by the carry relation for any s 2 dk?1 ;;dk?r and a 2 ?d`?1 ;;d0 we have

s ` +a 2 E (k)

for all

[dk?1 ;    ; dk?r ; d`?1 ;    ; d0 ] 2 Dk

and thus dk?1 ;;dk?r ` + ?d`?1 ;;d0  E (k) . Since the two sets of parameters are independent it follows that

[

dk?1 ;;dk?r ` +

dk?1 ;;dk?r

[

?d`?1;;d0  E (k) ;

d`?1 ;;d0

or

 r ` + ?(`)  E (k) ( )

by defining

(r) =

(7)

[

dk?1 ;;dk?r dk?1 ;;dk?r  [  (r) = fdhigh g ? r Cdout ;  ;d k?1 k?r dk?1 ;;dk?r (r )  D[ ? r C ?(`) = ?d`?1 ;;d0 d`?1 ;;d0  [  (`) fdlow g + Cdin`?1 ;;d0 = d`?1 ;;d0  D(`) + C;

(r) ` + D(`) + C  E (k) together with (10) is sufficient to employ only right context, since then (r) ` + D(`) can be used as  in Theorem 1. Hence for left context to be needed, ?(`) must be a proper subset of D(`) + C , so except for the trivial cases where C = f0g (i.e., no carries needed), by (9) (8)

where C is the set of possible carries

C=

[

d`?1 ;;d0

Cdin`?1 ;;d0 =

[

dk?1 ;;dk?r

Note that the above expression for (r) for ` = 0 coincides with  from the previous section, and also ?(0) = C . The bounds (7) and (10) then reduce to the previous bounds of Theorem 1, using D(0) = f0g. If instead of (8) the stronger condition ?(`) = D(`) + C holds, such that (7) becomes

Cdout : k?1 ;;dk?r

Since 0 2 Cdin`?1 ;;d0 we have 0 2 C , and from the definition (8) of ?(k) it is then also seen that D(`)  ?(k) and hence: D(`)  ?(k)  D(`) + C: (9)

Intuitively, ?(`) is the set of “low-order” parts after inclusion of acceptable incoming carries, and (r) is the set of “high-order” parts after carries have been emitted. From (5) it is seen that

r) ` + d(`) d(k) = d(high low `) g 2 dk?1 ;;dk?r ` + k Cdout + fd(low k?1 ;;dk?r so by taking the union over dk?1 ;    ; dk?r ; d`?1 ;    ; d0 , the following bounds on D(k) are obtained: D(k)  (r) ` + D(`) + k C (10)  (r) ` + ?(`) + k C; (11) which together with (7) repeated here for convenience

(r) ` + ?(`)  E (k) then form necessary conditions for parallel, constant time conversion. Now suppose given E and D, constants k; `; r with k = ` + r and sets (r) , ?(`) and C can be found satisfying the above, then it is easy to see, in analogy with the proof of Theorem 1, that the conditions (7) and (11) are also sufficient conditions for parallel, constant time conversion. However, the parameters of these conditions seem to be too involved for practical applications.

D(`)  ?(`)  D(`) + C

with

`1

is a necessary condition for left context to be needed. But so far no example of a complete digit-set E has been found, where it was not sufficient to use right context for the carry, and thus possible to use Theorem 1. It remains an open problem whether such examples exist, or right context will always be sufficient.

References [1] A. Avizienis. Signed-Digit Number Representations for Fast Parallel Arithmetic. IRE Transactions on Electronic Computers, EC-10:389–400, September 1961. [2] P. Kornerup. Digit-Set Conversions: Generalizations and Applications. IEEE Transactions on Computers, C-43(6):622– 629, May 1994. [3] M.D. Ercegovac and T. Lang. On Recoding in Arithmetic Algorithms. J. VLSI Signal Processing, 14:283–294, 1996. [4] A. M. Nielsen and P. Kornerup. On Radix Representation of Rings. In Proc. 13th IEEE Symposium on Computer Arithmetic, pages 34–43. IEEE Computer Society, July 1997. [5] A. M. Nielsen and P. Kornerup. Redundant Radix Representation of Rings. IEEE Transactions on Computers, Vol. 48(11), November 1999.

Suggest Documents