G.A. Ruiz, M. Granda / Microelectronics Journal 42 (2011) 1090–1097 1091Okeya et al. [33] proposed an algorithm to carry out this conversionbut it requires additional memory to store some precompute<strong>de</strong>lements. In<strong>de</strong>ed, efficient MSB-to-LSB algorithms yield a MSDrepresentation [34,35] but not a CSD one because of havingconsecutive nonzero <strong>digit</strong>s.This paper presents novel, efficient standard cell-based implementationsto convert a two’s complement binary number into itsCSD representation based on two signals, H and K, functionallyequivalent to two carries. These signals were already <strong>de</strong>fined inthe implementation of 3X terms for radix-8 encoding [36], buthere they are used for the CSD <strong>recoding</strong> in a more resourcefulway. Implementations in a 130 nm standard cell CMOS technologyof previously published architectures have been comparedwith the proposed scheme <strong>de</strong>monstrating that the circuits arehighly efficient in area and speed. The remain<strong>de</strong>r of this paper isorganized as follows. In Section 2, a brief introduction and<strong>de</strong>finitions related to CSD <strong>recoding</strong> are presented. New compactalgebraic expressions for optimal CSD <strong>recoding</strong> in terms of signalsH and K and their application in the efficient implementation ofCSD reco<strong>de</strong>rs for different configurations are <strong>de</strong>scribed in Section3. Simulations and comparisons are listed in Section 4. Finally, theconclusions are stated in Section 5.2. CSD <strong>recoding</strong>The CSD representation of an integer number is a <strong>signed</strong> andunique <strong>digit</strong> representation that contains no adjacent nonzero<strong>digit</strong>s. Given an n-<strong>digit</strong> binary un<strong>signed</strong> number X¼{x 0 , x 1 , y,x n 1 } expressed asX ¼ Xn 1x i U2 i , x i Af0,1g ð1Þi ¼ 0then the (nþ1)-<strong>digit</strong> CSD representation Y¼{y 0 , y 1 ,y, y n }ofX isgiven byY ¼ Xn 1x i U2 i ¼ Xny i U2 i , y i Af1,0,1g ð2Þi ¼ 0i ¼ 0The condition that all nonzero <strong>digit</strong>s in a CSD number areseparated by zeros implies thaty i þ 1 Uy i ¼ 0, 0rirn 1 ð3ÞFrom this property, the probability that a CSD n-<strong>digit</strong> has anonzero value [13,26] is given byPð9y i 9 ¼ 1Þ¼ 1 3 þ 1 9n 1 1 n ð4Þ2As n becomes large, this probability tends to 1/3 while thisprobability becomes 1/2 in a binary co<strong>de</strong>. Using this property, thenumber of additions/subtractions is reduced to a minimum inmultipliers [14–17] and, as a result, an overall speed-up can beachieved.The adoption of a ternary number system adds some flexibilityto the CSD representation, since it allows the number of nonzero<strong>digit</strong>s to be minimized, but it requires that each <strong>digit</strong> y i must beenco<strong>de</strong>d over two bits {y s i , yd i}. Table 1 shows the two mostfrequently used encodings in practice [1]. Encoding 1 can beviewed as a two’s representation. However, encoding 2 is preferablesince it satisfies the following relationy i ¼ y d iy s ið5Þwhere y s irepresents the sign bit and y d ithe data bit. This encodingalso allows an additional valid representation of 0 when y s i¼1 andy d i¼1, which is useful in some arithmetic implementations. In thewhole paper, this encoding is used.Table 1Two most encodings used in the binary representation of a CSD <strong>digit</strong> (1¯ stands for1). In this paper, encoding 2 is used.Encoding 1 Encoding 2y i y s i yd i y s i yd i0 00 001 01 01¯1 11 10Hashemian [27] presented the binary co<strong>de</strong>d CSD (BCSD)number to avoid extra data word representation. The BCSD<strong>recoding</strong> is based on a simple binary representation B¼{b 0 ,b 1 ,y,b n 1 } of a CSD co<strong>de</strong>, which uses the same number of bitsas the original two’s complement representation. It takes advantageof the CSD property, in which no two adjacent <strong>digit</strong>s can bothbe nonzero, to assign the next position of each nonzero CSD <strong>digit</strong>as sign bit while maintaining the same size data word. Thus, if thebit i in a CSD co<strong>de</strong> is nonzero, y i a0 (which means that y i þ 1 ¼0),then the bit i is nonzero in the BCSD co<strong>de</strong>, b i a0, and thefollowing bit b i þ 1 acts as a sign bit: b i þ 1 ¼0 means y i is positiveand b i þ1 ¼1 means y i is negative. As a result, y i ¼0 is enco<strong>de</strong>d asb i ¼0, y i ¼1 as b i þ 1 b i ¼01 and y i ¼1¯ as b i þ 1 b i ¼11. A simpleconversion between a CSD coding and BCSD coding isb i ¼ y d i þys i 1b i þ 1 ¼ y d i þ 1 þys i0 0 1 0 1 0 1 1 10 0 1 0 1 1 0 0 10 0 1 1 0 1 0 0 10 1 0 1 0 1 0 0 1Fig. 1. Conversion process from binary to CSD co<strong>de</strong>.Since this conversion can be obtained by a simple operation, inthis paper the two-bit encoding representation is used to make itsreading and un<strong>de</strong>rstanding easier, and, without loss of generality,it can be straightforwardly exten<strong>de</strong>d to other representations.The conversion from a binary representation to CSD representationis mostly based on the following i<strong>de</strong>ntity2 i þ j 1 þ2 i þ j 2 þ...þ2 i ¼ 2 i þ j 2 i ð7ÞThis means that a string of 1s can be replaced by a 1, followedby 0s, followed by a 1¯ . Isolated 1s are left unchanged, but isolated0s are re-examined in such a way that, after applying Eq. (7), pairsof type 11¯ are changed to 01. For example, the binary number(001010111) 2 is equivalent in a CSD representation to 0101¯ 01¯ 001¯ ;the encoding process is graphically shown in Fig. 1. Traditionally,this encoding is performed from LSB to MSB using two adjacentbits and a carry signal according to the <strong>recoding</strong> algorithm shownin Table 2 [25,26]. Here, the carry-out c i ¼1 if and only if there aretwo of three 1s among the three inputs x iþ1 , x i and c i 1 ,thatisc i ¼ x i x i þ 1 þðx i þx i þ 1 Þc i 1 , being c 1 ¼ 0 ð8ÞThe variable D¼{d 0 , d 1 ,y,d n 1 }, which flags all nonzero <strong>digit</strong>sin the CSD representation, is <strong>de</strong>fined asd i ¼ x i c i 1 ð9Þð6Þ
1092G.A. Ruiz, M. Granda / Microelectronics Journal 42 (2011) 1090–1097Since y i takes one of the three values {0, 1, 1¯ }, two bits {y s i , yd i }are necessary to enco<strong>de</strong> it, which are <strong>de</strong>fined from Table 2 as(y d i¼ x i þ 1 ðx i c i 1 Þ¼x i þ 1 d iy s i ¼ x ð10Þi þ 1ðx i c i 1 Þ¼x i þ 1 d iFor the sake of clarity, the following example <strong>de</strong>scribes thedifferent signals used in the CSD <strong>recoding</strong>:X ¼ 001010111Carry ¼ 011111110D ¼ 010101001Y ¼ 010101001In the case of a n-bit two’s complement binary number X, theCSD representation is given byY ¼ x n 1 U2 n 1 þ Xn 2x i U2 i ¼ Xn 1y i U2 ið11Þi ¼ 0i ¼ 0here, only n CSD <strong>digit</strong>s are necessary as the value of the binarynumberislimitedto[ 2 n ,2 n 1 ]. Negative integers in CSD can beobtained trivially from their positive counterpart by changing thesigns of all nonzero <strong>digit</strong>s. For example, the CSD co<strong>de</strong> 0101represents the <strong>de</strong>cimal number 3, while 0101 represents thenumber 3. Therefore, the conversion of a negative n-<strong>digit</strong> two’scomplement binary number X into its CSD representation can beperformed from the well-known property X ¼ X þ1. Then reformulatingthe former equations for the case of a binary number X ina two’s complement representation, the conversion into its CSDrepresentation is given byt i ¼ x i x n 1 , ion 1 ð12Þc 0 i ¼ t i þ 1t i þðt i þ 1 þt i Þc 0 i 1 , being c0 1 ¼ x n 1 ð13Þwhere x n 1 represents the sign of X. From (13), c’ i propagates c i orits complement <strong>de</strong>pending on sign of the X because of all inputs arecomputed according to (12). Therefore, another way to express c’ i isc 0 i ¼ x n 1 c i ð14ÞTable 2CSD coding.Applying these <strong>de</strong>finitions, we getd i ¼ t i c 0 i 1 ¼ðx i x n 1 Þðx n 1 c i 1 Þ¼x i c i 1 ð15ÞThis means that the <strong>de</strong>finition of D is in<strong>de</strong>pen<strong>de</strong>nt of sign X. Ina similar way, the expression of Y is the same as that in (10) as(y d i¼ t i þ 1 d i ¼ t i þ 1 ðt i c 0 i 1 Þ¼ðx i þ 1 x n 1 Þððx i x n 1 Þc 0 i 1 Þ¼x i þ 1d iy s i ¼ t i þ 1d i ¼ t i þ 1 ðt i c 0 i 1 Þ¼ðx i þ 1 x n 1 Þððx i x n 1 Þc 0 i 1 Þ¼x i þ 1d ið16ÞFig. 2 shows the circuit to convert a n¼6 <strong>digit</strong> binary numberinto its CSD representation according to Eqs. (8)–(10), valid forboth un<strong>signed</strong> and two’s complement binary numbers. The onlydifference arises in the last CSD <strong>digit</strong>. By introducing an extra signextension, x n ¼0 for un<strong>signed</strong> numbers and x n ¼x n 1 for two’scomplement numbers, the last section changes <strong>de</strong>pending on thesign of X in the following general expression:8y d n 1 ¼ d n 1>< y s n 1 ¼ 0For an un<strong>signed</strong> number Xy d n ¼ d ð17Þn ¼ c n 1 ¼ x n c n 2>: y s n ¼ 0For a <strong>signed</strong> number X yd n 1 ¼ x nd i ¼ x n 1 c n 2y s n 1 ¼ x nd i ¼ x n 1 c n 2(ð18ÞFor un<strong>signed</strong> X, nþ1 CSD <strong>digit</strong>s are necessary to represent thatbinary number. However, as it is a positive number the two MSB<strong>digit</strong>s of CSD are also positives and, in<strong>de</strong>ed, only their positivedata parts are necessary as shown in Eq. (17); the negative part isalways zero. For <strong>signed</strong> numbers, only n CSD <strong>digit</strong>s are used andthe last <strong>digit</strong> is computed according to Eq. (18). As can be seen inFig. 2, the critical path of the circuit is fixed by the propagation ofthe carry signal, in a similar way to a conventional ripple-carryad<strong>de</strong>r. There is a clear similarity between the carry <strong>de</strong>finition inconventional ad<strong>de</strong>rs and the <strong>de</strong>finition of that carry in Eq. (8). Thissuggests that implementation of fast CSD converters should bebased on fast well-known carry look-ahead structures used inaddition.x i þ1 x i c i 1 y i c i Comments0 0 0 0 0 String of 0s0 0 1 1 0 End of 1s0 1 0 1 0 A single 10 1 1 0 1 String of 1s1 0 0 0 0 String of 0s1 0 1 1¯ 1 A single 01 1 0 1¯ 1 Beginning of 1s1 1 1 0 1 String of 1s3. New CSD <strong>recoding</strong>In the <strong>de</strong>finition of carry in Eq. (8), two adjoining carries sharethe same input variable. This means that the same input x i is usedin the generation of both carries c i 1 and c i . This characteristicallows the algebraic expressions of carry generation to be simplifiedin or<strong>de</strong>r to obtain efficient circuits.Fig. 2. Schematic circuit for the conversion of a binary number into its CSD representation (n¼6).