The present invention relates to complementation devices used in microprocessors, and in particular, to a method and an associated circuit for incrementing, decrementing or two's complementing a bit string.
Generally, a microprocessor includes an Arithmetic and Logic Unit (ALU) for performing the four arithmetic operations. In the ALU, every integer number X is represented in the form of a bit string using the so-called two's complement coding. Indicating with Xk a generic bit of a string of N bits representing the number X∈└−2N-1, 2N-1−1┘, the integer number X is given by
This coding is very convenient because it allows the difference operation to be performed as a sum of relative numbers using a common adder.
The two's complement of a bit string X may be easily obtained by logic circuits. In fact, indicating with
which is obtained by inverting each bit of the string X. The string YTC(X) representing the two's complement of X is simply obtained adding 1 to the one's complement of X is given by
YTC(X)=
A two's complement circuit is depicted in
X+1=
Similarly, it is possible to demonstrate that the circuit of
X−1=2N−2N+X−1=2N−1−(2N−X)=2N−1−YTC(X)=
The fact that these increment and decrement operations can be performed by a two's complement circuit has lead to the realization of the so-called DIT (Decrement, Increment, Two's complement) circuits, such as the one depicted in
Because of the importance of the DIT circuit, the architecture thereof has been studied to find two's complement circuits that imply the smallest possible number of required elementary operations and that occupy the smallest possible silicon area. In the articles by R. Hashemian “Highly Parallel Increment/Decrement Using CMOS Technology”, Proceedings of the 33rd Midwest Symposium on Circuits and Systems, Calgari, Alberta, Canada, Aug. 12-14, 1990 and by R. Hashemian and C. Chen “A New Parallel Technique For Design of Decrement/Increment and Two's Complement Circuits”, Proceedings of the 34th Midwest Symposium on Circuits and Systems, Monteray, Calif., May 14-17, 1991 techniques for forming decrement, increment and two's complement circuits are described, that offer certain advantages both in terms of silicon area consumption as well as in terms of speed.
By applying eq. 3, it is possible to note that the two's complement of the number −2N-1 is the number −2N-1 itself. This fact is due to the asymmetry of the interval X∈└−2N-1, 2N-1−1┘, thus the two's complement of −2N-1 exceeds the representation interval.
In many applications the two's complement of −2N-1 is represented with the positive integer 2N-11
YTC(−2N-1)=2N-1−1=
generating at the same time an overflow flag OF signaling that the representation interval has been exceeded.
A known two's complement circuit with overflow check is depicted in
The overflow check circuit OVERFLOW CHECK is input with the string X and with a string REF representing the number −2N-1, and activates the flag OF when the two strings coincide. The correction circuit CLIP generates an output string Y equal to the two's complement string Z when the flag OF is not active, while it produces the string 011 . . . 1 representing the number 2N-1−1 when the flag OF is active. Unfortunately, the known two's complement circuit depicted in
In view of the foregoing background, an object of the present invention is to provide a method and an associated circuit for incrementing, decrementing or two's complementing an N bit string X in a straightforward manner.
To perform these operations, the method of the invention generates an auxiliary string M of N bits as a function of the string X, and combines it logically with the string X to generate a corresponding output string Y. The least significant bit of the auxiliary string is independent from the bits of the string X, and any other bit ML of the auxiliary string.
The operation of generating the auxiliary string M for performing the operations of increment, decrement and two's complement is particularly convenient for generating an overflow flag when the number to be output exceeds the representation interval. In fact, according to the method of the invention, an overflow flag OF is generated simply by combining logically the most significant bits MN-1 and XN-1 of the strings M and X. This is a great advantage because the overflow flag is generated by a single logic gate input with the bits MN-1 and XN-1, independently from the number of bits N of the string X, while in known two's complement circuits it is generated by an N bit comparator that occupies a silicon area that is non-negligible and depends on the length of the string X.
Obviously, depending on the fact that an increment, decrement or two's complement operation is to be performed, the strings X and M are combined according to different logic operations for generating the output string Y.
The method of the invention is implemented by a circuit for incrementing, decrementing or two's complementing a string formed by a number of N bits. The circuit comprises an auxiliary circuit generating an auxiliary string of N bits as a function of the first string. The least significant bit of the auxiliary string is independent from the first string and any other bit of the auxiliary string. The method starts from the second least significant bit up to the most significant bit, and performs a logic combination of a corresponding bit of the first string or of a negated replica thereof, starting from the least significant bit up to the second most significant bit, and of the bits of the first string or of the negated replica thereof less significant than the corresponding bit. Logic circuit means generate an output string as a logic combination of the auxiliary string and of the first string.
The different aspects and advantages of the present invention will appear even more evident through a detailed description of embodiments referring to the attached drawings, wherein:
a depicts a two's complement circuit of the invention having an auxiliary circuit OR MASK;
b depicts a two's complement circuit of the invention having an auxiliary circuit AND MASK;
a is a detailed view of the auxiliary circuit depicted in
b is a detailed view of the auxiliary circuit depicted in
a is a detailed view of a second embodiment of the auxiliary circuit depicted in
b is a detailed view of a third embodiment of the auxiliary circuit of
a depicts a decrement circuit of the invention using the two's complement circuit of
b and 9c depict alternative embodiments of the decrement circuit of
a depicts an increment circuit of the invention that uses the two's complement circuit of
b and 10c depict alternative embodiments of the increment circuit of
a depicts an increment/decrement circuit of the invention that uses the circuit of
b, 11c and 11d depict alternative embodiments of the increment/decrement circuit of
a depicts a multifunction DIT circuit of the invention that uses the circuit of
b and 12c depict alternative embodiments of the multifunction DIT circuit of
Two equivalent embodiments of two's complement circuits implementing the method of the invention are depicted in
It is worth noting that the auxiliary string
According to the method of the invention, with XL-1 being the least significant bit X of the string X equal to 1, the least significant bits of the auxiliary string from the second M1 to the (L+1)-th ML generated by the circuit of
The circuit of
YTC(X)=X ⊕M (7)
An auxiliary circuit OR MASK that is easy to form is shown in
An auxiliary circuit AND MASK for the two's complement circuit of
As will be evident to those skilled in the art, it is possible to form the circuits of
The auxiliary circuit OR MASK (AND MASK) is substantially a circuit that generates a string M whose L least significant bits are equal to 0(1) and all the remaining bits are equal to 1 (0), with XL-1 being the least significant bit equal to 1 of the string X. Therefore, it is evident that the auxiliary circuit of
For better illustrating the invention, in the ensuing description reference will be made to the embodiment of
The two's complement circuit of the invention may be used for forming a circuit for decrementing, depicted in
The truth table of signals ID, TC, INV_IN and INV_OUT is TABLE 1 and the logic selection circuit SEL of
The method of the invention allows the generation of the overflow flag simply as a logic combination only of the most significant bits MN-1 and XN-1 of the auxiliary string M and of the string to be complemented X, respectively, independently from the number N of bits of the string to be complemented. A two's complement circuit of the invention with overflow check is depicted in
A great advantage of the present invention with respect to the known two's complement circuit of
A detailed scheme of an embodiment of a two's complement circuit of the invention that performs the correction of eq. 6 is depicted in
Moreover the gate of the two's complement circuit input with the most significant bits MN-1 and XN-1 and generating the bit ZN-1 is an OR gate and not a XOR gate, in order to correct the output when the string X to be complemented represents the number −2N-1. In fact, independently from the state of the flag OF, the most significant bit YN-1 of the output string may be generated by negating the bit ZN-1, as it is evident from the following table:
The two's complement circuit with overflow test of
The correction circuit CLIP generates a correction signal INVCLIP and a negated replica of the signal INV_OUT for making the array of output XOR gates perform the correction of eq. 6 of the complemented string Z. Therefore, the array of output XOR gates of the two's complement or decrement circuit of the invention is useful also when no decrement operation has been requested. This expedient allows a simplification of the structure of the correction circuit CLIP with a further saving of silicon area.
The two's complement or decrement circuit of the invention may be embodied in a multifunction DIT circuit for incrementing, decrementing or two's complementing a string as shown in
A detailed scheme of an embodiment of the multifunction DIT circuit of
The circuit of
It is possible to verify immediately that, in all other possible cases, the operating characteristics of the DIT circuit of
| Number | Date | Country | Kind |
|---|---|---|---|
| 02425538 | Aug 2002 | EP | regional |
| Number | Name | Date | Kind |
|---|---|---|---|
| 3532866 | Cliff | Oct 1970 | A |
| 3989940 | Kihara | Nov 1976 | A |
| 4153939 | Kudou | May 1979 | A |
| 4218750 | Carter et al. | Aug 1980 | A |
| 4417316 | Best | Nov 1983 | A |
| 4486851 | Christopher et al. | Dec 1984 | A |
| 4534010 | Kobayashi et al. | Aug 1985 | A |
| 4953115 | Kanoh | Aug 1990 | A |
| 5146479 | Okada et al. | Sep 1992 | A |
| 5333120 | Gilber't | Jul 1994 | A |
| Number | Date | Country | |
|---|---|---|---|
| 20040073586 A1 | Apr 2004 | US |