Background of the Invention
The present invention relates to a rounding operation circuit used in an image signal processor.
According to the amendment of the recommendation H.261 of the CCITT p.times.64 bits/sec. television phone coding system, chances are that a system for DCT (discrete cosine transform) coding between motion compensating frames will be adopted. In this recommendation, an allowable range of the inverted DCT operating error is defined in order to suppress the mismatch of the coded image attended with transmission and reception. These are based on the content of "CCITT SGXV WP XV/1 Specialist Group on Coding for Visual Telephony, Doc, #584, (1988-11)".
In the reverse DCT operation, there is included a so-called rounding operation which cuts off the most significant 16 bits after 1 is added to, for example, the fifteenth bit of 31 bits as counted from below. As this rounding method, various means are conceivable, but it is reported that the foregoing reverse DCT operating error becomes minimal by carrying out the rounding operation symmetrically relative to the positive and negative (that is, rounding to the hearest whole number for absolute value, and cutting away zero and including one for binary number). For example, when the position of the decimal point lies at the eighth bit and the two's complement's 16-bit long signal, if it is positive, then "00000000, 10000000" (=0.5) is added and, if it is negative, then "00000000 01111111" (=0.4961) is added and the numbers lying at the places of the resulting number which are lower than the decimal point are cut away so that they can be rounded. These processes are proposed in a document 1, "Reverse DCT Operation in Motion Picture Processing VISP-LSI" Mochizuki et al, 1990, Telecommunication Association, National Conference Proceedings".
Next, a description is made with reference to the "RND" instruction of the chapter "Assembly Language Instructions" of the document 2 titled "Texas Instrument Third-Generation TMS320 User's Guide 1988, 9".
The instruction format is designated as "RND <src><dst>". Upon this specification, the result of the rounding operation of the source operand (,src.) is stored into a destination register (<dst>). In this case, the figure is rounded so that it becomes the nearest number of the single precision floating decimal point (that is, the eighth digit below the decimal point of the integer). In the case of the right middle value (that is, x. xxxxxxx5, where x denotes the integer value from 0 up to 9), the rounding operation is carried out in the positive direction.
These processes are specifically described hereinafter.
As shown above, the rounding operation is achieved by representing the hexadecimal number by the decimal system.
Next, description is made with reference to the "RND" instruction of the chapter "Instruction Set Details" included within a third document "DSP56000 Digital Signal Processor User's Manual 1986".
The instruction format is designated as "RND<dst>". Upon this designation, the result of the rounding operation of the designation register <dst> is stored into the destination register <dst> as it is. The rounding operation of this processor is achieved by adding a constant (hereinafter referred to as a "rounding constant") to the bit to be rounded. In this case, the rounding constant is determined by the value of the scaling bit of the status register. Next, a correspondence between the place of this example where the rounding operation is carried out and the added value is shown in Table 1 below:
According to the RND instruction of the document 2 processor, which is the aforementioned prior art, since a negative number "x, xxxxxxx5" is rounded in the positive direction, it is not possible to round the absolute number by counting fractions over 1/2 as one and cutting away the rest, which in turn makes it impossible to round at the desired bit position. Further, also in the document 3, since the negative number is rounded, it is impossible to round by counting its fractions over 1/2 as one and cutting away the rest leading to the same result.
Summary of the Invention
Accordingly, an object of the present invention is to remove such a drawback and to provide a rounding operation circuit which allows the fractions over 1/2 of the absolute value to be counted as one and its rest to be cut away.
According to the present invention, there is provided a rounding operation circuit for performing a rounding operation on a first input signal represented in a two's complement form, comprising decoder means for receiving a second input signal designating a rounding position of said first input signal and for outputting a decoded signal in which a bit corresponding to said rounding position takes logic "1" and remaining bits take logic "0" when said first input signal is positive and in which a bit or bits less significant that said bit corresponding to said rounding position takes logic "1" and remaining bit or bits take logic "0" when said first input signal is negative; operational means for performing an adding operation on said first input signal and said decoded signal and for outputting a resultant signal; and rounding-down means performing such a rounding-down operation on said resultant signal that bits of said resultant signal less significant than said rounding position take logic "0".
Furthermore, in a preferred embodiment of the present invention, the second input signal for specifying the rounding position of the first input signal comprises four bits, or the value for specifying the rounding position comprises 16 bits having an immediate value.
In other words, since the rounding operation circuit of the present invention allows the symmetrical rounding operation intended for both the positive and the negative values to be achieved with a single instruction, it has an advantage that a faster and more accurate operation can be achieved than- when the operation is achieved using the conventional arithmetic logic means.
The present invention will be clearly understood from the following detailed description with reference to the accompanying drawings.
Brief Description of the Drawings
FIG. 1 is a block diagram of the rounding operation circuit embodying the present invention; and
FIG. 2 is a block diagram of a rounding-down circuit shown in FIG. 1.
Description of the Preferred Embodiments
FIG. 1 is a block diagram of a first embodiment of the present invention, in which 1 denotes a first 16-bit long input signal, 2 a second 4-bit long input signal, 3 a decoder circuit into which 5 bits are entered and from which 16 bits are emitted, 4 a 16 bit long output signal of the decoder circuit, 5 a most significant bit of the first input signal, 6 an arithmetic logical operation unit or adder, 7 the output of the adder, 8 a rounding-down circuit with the second 4-bit long input signal as the input. In FIG. 2 is illustrated a circuit diagram showing an arrangement of the rounding-down circuit 8 which comprises a decoder 11 and a plurality of, sixteen in this case, AND gates 12. The following Table 2 is a truth table of the decoder 3.
The second input signal bit at the left column of the table 2 represents the bit arrangement from 0 to 15 which are added with the positive sign "0" while the second input signal bit at the right column represents the bit arrangement of the complement which is added with the negative sign "1". For the output of the decoder 3, when the input signal is positive, the rounding bit position is "1" and the rest is "0" while when the input signal is negative, the bits less significant than the bit at the rounding position are "1" and the rest is "0".
Referring now to the operation of the rounding operation circuit according to the present invention, the second input signal 2 having an information regarding the position of the rounded bit of the input signal 1 is entered to a decoder circuit 3, which decodes the input signals 2 and the most significant bit 5 of the first input signal 1 according to the truth table 2, thereby to generate an output signal 4. The output signal 4 and the first input signal 1 are added to each other by means of the arithmetic logic means 6 to generate an output signal 7. In accordance with the input signal 2, the less significant bits than the rounding position in accordance with the input signal 2 are all turned to 0 by means of the rounding-down circuit 8 (FIG. 2), and the result is emitted as the output signal 9. Incidentally, the truth table of the decoder circuit 11 of FIG. 2 is represented in the following table 3.
Alternatively, according to a second embodiment of the present invention, different from the first embodiment, a second 16-bit long input signal 2a and a decoder circuit 3a comprise a 16-bit input and a 16-bit output. In this case, the truth table of the decoder 3a is shown in Table 4 in which the value specifying the rounding position has an immediate value.
The operation of the operation circuit according to the second circuit will be described with reference also to FIG. 1, using the parenthesized numerals. The input signal 2a having the information regarding the position at the rounded bit of the rounded input signal 1 is entered to the decoder circuit 3a, which decodes the input signals 2a and 5 according to the truth table 4 to generate the output signal 4. The output signal 4 and the input signal 1 are added by means of the arithmetic logic means 6 and the result is emitted as the output signal 7. The bits less significant than the rounded bits according to the input signal 2a are all turned into zero by the rounding-down circuit 8 and the result is emitted as the output signal 9. Incidentally, the truth table of the decoder circuit 11a is illustrated in the following table 5.