BACKGROUND OF THE INVENTION
The present invention relates generally to a residue circuit. More specifically, the invention relates to a residue circuit for calculating a remainder the case where a divisor is 3.
As an example of the conventionally available such type residue circuit, there is a circuit, in which remainders in division of dividends by a divisor of 3 are preliminarily stored employing a read-only-memory (ROM) and the dividends are input as address signal for reading out the preliminarily stored remainders from the ROM.
As alternative example, there is a circuit as illustrated in FIG. 9. The shown circuit includes a data input Di, a load signal LD, a clock C1, a subtrahend counter 27 taking an operation enabling signal E2 as input for outputting a counter value Cout, a divisor counter 28 taking the operation enabling signal E2 as input for outputting a carry Cr0, and a judgement portion 29 taking the counter value Cout and the carrier Cr0 as inputs for outputting the operation enabling signal E3.
FIGS. 10A to 10E are timing charts showing operation of the circuit set forth above. Initially, a dividend is loaded in the subtrahend counter 27 by operating the load signal LD. The judgement portion 29 makes judgement of the sizes of the dividend and the divisor of 3 that the operation enabling signal E3 is output when the dividend is greater than or equal to the divisor.
In response to the operation enabling signal E3, the subtrahend counter 27 initiates subtracting operation. In conjunction therewith, the divisor counter 28 performing counting up until the divisor is reached. The judgement portion 29 compares the counter value Cout of the subtrahend counter 27 and the divisor again at the timing where the carry signal Cri is input so as to continue further counting when the counter value Cout is greater than or equal to the divisor and, otherwise, to terminate counting by terminating the operation enabling signal E3. Upon termination of the counter operation, the counter value Cout of the subtrahend counter 27 becomes the remainder to be obtained.
In case of the conventional circuit employing the ROM, the ROM having a memory capacity of (number of bits of the divisor ×2 powered by number of bit of dividends) becomes necessary for each dividend. Therefore, according to increasing of number of dividend to be stored, required memory capacity becomes huge.
On the other hand, in case of the circuit illustrated in FIG. 9, since repeated counting process is performed, it takes a long period to obtain the remainder and thus is not suitable for high speed operation.
SUMMARY OF THE INVENTION
Therefore, it is an object of the present invention to provide a residue circuit which permits to obtain a result of operation with a small scale circuit at high speed.
According to one aspect of the invention, a residue circuit for calculating a remainder through division of a dividend of a binary number consisted of a plurality of bits, comprises:
first adding means for summing 3 bits in even number bits of even bit of the dividend to generate a summing output and a carry output;
second adding means for summing 3 bits in odd number bits of even bit of the dividend to generate a summing output and a carry output;
third adding means for summing the summing output of the first adding means and the carry output of the second adding means for generating a summing output and a carry output;
fourth adding means for summing the summing output of the second adding means, the carry output of the first adding means and the carry output of the third means for generating a summing output and a carry output; and
a remainder generation means for outputting a remainder with respect to the divisor 3 according to a bit pattern of the summing output of the third adding means, the summing output and the carry output of the fourth adding means.
According to another aspect of the invention, a residue circuit for calculating a remainder of a division for a binary dividend of 0th to nth bits and having at least four bits, comprises:
a plurality of weight 1 adding means setting weights for respective even number bits of the dividend being 1 and for odd number bits of the dividend being 2, for generating a weight 1 signal at a summing output and a weight 2 signal at a carry output through addition of signals of weight 1;
a plurality of weight 2 adding means for summing signals of weight 2 for generating a weight 2 signal at a summing output and a weight 1 signal at a carry output;
the first and second adding means repeatedly performing summing processes for the signals having the same weights until the total number of signals of the summing outputs and the carry outputs becomes m which is smaller than the n; and
further comprising a remainder generation means for outputting a remainder with respect to a divisor 3 according to the pattern of the m bits.
BRIEF DESCRIPTION OF THE DRAWINGS
The present invention will be understood more fully from the detailed description given herebelow and from the accompanying drawings of the preferred embodiment of the invention, which, however, should not be taken to be limitative to the invention, but are for explanation and understanding only.
In the drawings:
FIGS. 1A and 1B are illustrations showing a principle of the present invention;
FIG. 2 is an illustration showing a principle of the present invention;
FIG. 3. is an illustration showing a principle of the present invention;
FIG. 4 is a block diagram of one embodiment of the invention;
FIG. 5A is an illustration showing one embodiment of a modulus 3 generation circuit of FIG. 4;
FIG. 5B is an illustration showing a relationship between an input and an output of a ROM in the case where the modulus 3 circuit is constructed by the ROM;
FIG. 6 is a circuit diagram of another embodiment of the modulus 3 generation circuit;
FIG. 7 is a block diagram of another embodiment of the present invention;
FIG. 8 is an explanatory illustration of an example of application of a residue circuit of the present invention;
FIG. 9 is a block diagram of the conventional residue circuit; and
FIGS. 10A to 10E are timing charts showing the operation of the circuit of FIG. 9.
DESCRIPTION OF THE PREFERRED EMBODIMENT
The present invention will be discussed hereinafter in detail with reference to the accompanying drawings.
FIGS. 1A, 1B, 2 and 3 are illustrations showing the principle of the present invention. The principle of the invention will be discussed with reference to these drawings.
Referring to FIG. 1A, there is illustrated an example of 7-bit dividend having 0th bit to 6th bit is illustrated. With taking respective of weights (decimal values) for respective bits, a relationship to the remainder when the weights are divided by 3 is illustrated in FIG. 1A.
Namely, it will be appreciated that when "1" is present in a bit portion of the weight "1" as the 0th bit , the remainder is "1", and on the other hand, when "1" is present in a bit portion of the weight "2" as the 1st bit, the remainder is "2". in general, when "1" is present in the even number bit including 0th bit , the remainder is "1", and when "1" is present in the odd number bit, the remainder is "2".
As an example, consideration is given for a decimal value 44, the binary expression and remainders of division for respective weights by 3, the relationship between respective weights and the remainder becomes as illustrated in FIG. 1B. In the dividend 44, only even number bit, in which "1" is present, is the 2nd bit. Therefore, the total remainder of the even number bits becomes "1". On the other hand, the odd number bits, in which "1" is present, are 3rd and 5th bits. Therefore, the sum of the remainders of the odd number bits becomes 4 (=2 +2). This remainder 4 has a remainder 1 with respect to the divisor 3, the final remainder when the dividend 44 is divided by the divisor 3 becomes the sum of 1 of the total of remainder of the even number bits and 1 of the total remainder of the odd number bits, and thus becomes 2 (=1+1).
Therefore, it should be easily appreciated that, by dividing the binary bit pattern into groups of the even number bits (remainder is 1) and the odd number bits (remainder is 2), by deriving a sum of all bits in the even number bit group and a sum of bits in the odd number bit group for obtaining the results of summing for respective groups (sum output and carry output), and by further repeating the summing process, the remainder with respect to the divisor 3 can be finally obtained.
Accordingly, the results of summing of the even number bit group, each of which will have the remainder "1" and of the odd number bit group, each of which will have the remainder "2", are shown in FIGS. 2 and 3. FIG. 2 show a manner of summing of bits expressing the remainder "1", in which is shows the result of summing in the case where inputs are given for a three-input full adder in such a manner of 1+1+0 and 1+0+0.
As can be clear from these examples, the result of summing for the bits expressing the remainder "1" will provide a signal indicative of the remainder "1" in the summing output (S) and a signal indicative of the remainder "2" in the carry output (CRY).
FIG. 3 shows a manner of summing between the bits expressing the remainder "2", in which is shows the result of summing in the case where inputs are given for a full adder in such a manner of 2+2+0 and 2+0+0.
As can be clear from these examples, the result of summing for the bits expressing the remainder "2" will provide a signal indicative of the remainder "2" in the summing output (S) and a signal indicative of the remainder "1" in the carry output (CRY).
On the basis of the fact discussed with respect to FIGS. 1 to 3, a circuit for calculating the remainder with respect to a practical division for 6-bit dividend by the divisor 3.
At first, the even number bit group (three bits, i.e. 0th, 2nd and 4th bits in the shown embodiment) are taken as inputs A to C for full adder 41. Then, the signal indicative of the remainder "1" is obtained in the summing output S and the signal indicative of the remainder "2" is obtained in the carry output CRY are obtained respectively.
It should be noted that, in FIG. 4, FIGS. "1" and "2" labeled on signal lines for respective inputs and outputs of the full adders 41-44 represent the remainders. Hereinafter, these remainders "1" and "2" will be taken as weight for respective signals and will be expressed as weights 1 and 2.
Secondly, the odd number bit group (three bits, i.e. 1st, 3rd and 5th bits in the shown embodiment) are taken as inputs A to C for a full adder 42. Then, the signal indicative of the remainder "2" is obtained in the summing output S and the signal indicative of the remainder "1" is obtained in the carry output CRY are obtained respectively.
Then, the signal S of the weight "1" of the full adder 41 and the signal CRY of the weight "1" of the full adder 42 are applied to two inputs A and B of a full adder 43. The summing output S of the signal of weight "1" and the carry output CRY of the signal of weight "2" are obtained by the full adder 43.
On the other hand, the signal CRY of the weight "2" of the full adder 41, the signal S of the weight "2" of the full adder 42, and the carry signal CRY of the weight "2" of the full adder 43 are applied to three inputs A to C of the full adder 44 to obtain the signal of the weight "2" in the summing output S and the signal of the weight "1" in the carry output CRY.
Thus, when three signals indicative of the weights "1" and "2" are finally obtained, the summing operation is terminated. Then, three-bit signal is input to three inputs a to c of a modulus 3 generation circuit 45. This modulus 3 generation circuit 45 generates the remainder which is determined in straightforward manner depending upon the bit pattern of the three inputs a to c. The modulus 3 generation circuit 45 is adapted to output the remainder and comprises a ROM having 3-bit address input.
FIG. 5A shows one embodiment of the modulus 3 generation circuit which comprises a ROM having 3 input addresses (each figure represents the weight). FIG. 5B shows a relationship between the three input addresses a, b and c and the remainder output OUT of the ROM set forth above.
FIG. 6 is a circuit diagram of another embodiment of the modulus 3 generation circuit 45. In the shown embodiment, a combined logic circuit is employed in place of the ROM in the former embodiment three inputs a, b and c and their inverted signals are input to a combined circuit of AND gates 61 to 68 and OR gates 69 to 71. The remainder "0" is obtained from the output of the OR gate 69, the remainder "1" is obtained from the output of the OR gate 70, and the remainder "2" is obtained from the output of the OR gate 71.
FIG. 7 is a circuit diagram showing the embodiment of the present invention, in which the dividend is 12 bits. Even in this embodiment, the FIGS. "1" and "2" out for the input and output signals lines of full adders 71 to 82 represent weights "1" and "2", respectively.
The full adders 71 and 72 perform summing of even number bits (weight "1") of the dividend, and the full adders 73 and 74 performs summing of the odd number bits (weight "2"). The full adder 75 adds the signals S of weight "1" of the former stage full adders 71 and 72. On the other hand, the full adder 76 adds the signals CRY of the weight "2" of the former stage full adders 71 and 72, and the signal CRY of the weight "2" of the full adder 75.
The full adder 77 adds the signals S of weight "2" of the former stage full adders 73 and 74. On the other hand, the full adder 78 adds the signals CRY of the weight "1" of the former stage full adders 73 and 74, and the signal CRY o f the weight "1" of the full adder 77.
Similarly, in the next and subsequent stages, summing processes are performed with the those having the same weights in consideration of the weights of the signals in respective full adders 79 to 82. The above-mentioned summing processes are repeated until the 3 bit signal is finally obtained. The final 3 bit signal is input to the modulus 3 generation circuit 45 to obtain the remainder output OUT.
It should be noted that although all of the summing processes are performed by means of the full adders in the foregoing embodiments, it is possible to replace the adder 43 with two-input half adder, and to replace the adders 75, 77 and 81 with half adders.
Also, though summing processes are repeated until finally converged into 3-bit signals, the number of bits to be finally converged can be 2 bits or 4 bits. In case that the finally converging number of bits is 2 bits or 4bits, the construction of the modulus 3 generation circuit may be modified correspondingly. In short, repeating summing process of the weights having the same value until a number of bits becomes smaller than the number of bits of the dividend to derive the modulus 3 output based on the pattern of the finally obtained bit number. The process set forth above permits to use the memory (ROM) of small capacity while achieving high speed operation.
One example of application of the above-mentioned residue circuit will be discussed with reference to FIG. 8. In a time division multiplexing communication system, a data transmission method is performed by dividing one frame period into time slots of 0 to m and by assigning data of three channels 0 to 3 for respective time slots, as shown in FIG. 8.
In this case, it becomes necessary to know the channel of the data contained in a certain time slot in one frame. As shown in FIG. 8, the remainder obtained by time slot numbers 0 to m (indicated by binary number) by the number of channels, i.e. 3, will represents the channel number. Accordingly, by applying the time slot numbers 0 to m to the residue circuit of FIGS. 4 and 7 in binary number, channel numbers can be instantly output at the output thereof.
As set forth above, according to the present invention, since the residue circuit can be formed with the adders and ROM or combined logic circuit, the circuit construction becomes simple and high speed operation becomes possible.
Although the invention has been illustrated and described with respect to exemplary embodiment thereof, it should be understood by those skilled in the art that the foregoing and various other changes, omissions and additions may be made therein and thereto, without departing from the spirit and scope of the present invention. Therefore, the present invention should not be understood as limited to the specific embodiment set out above but to include all possible embodiments which can be embodies within a scope encompassed and equivalents thereof with respect to the feature set out in the appended claims.