Rounding operation circuit

Abstract: A rounding operation circuit for arithmetic logic means of a signal processor provided for counting fractions over 1/2 as one and disregarding the rest for the positive and negative number, which comprises a decoder circuit (3) having an (n+ 1)-long input to which a first input signal (1) represented by two's complement and a second n-bit long input signal (2) for specifying the rounded position of the first signal are entered, when the first input signal is positive, a signal in which the bit at the rounded position is "1" and the rest is "0" is emitted based on the second input signal and, when the first input signal is negative, a signal in which the bits less significant than the bit at the rounded position are all "1" and the rest is "0" is emitted; arithmetic logic means (6) for adding the output signal (4) of this decoder circuit and the first input signal; and a rounding-down circuit (8) for counting 1 and cutting away 0 positively and negatively symmetrically to any rounding position, to allow a fast and accurate rounding operation.

Description: 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 x 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 nearest 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" (= .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. Prior to the execution of the instruction: <src> = 07333C16EEFh = 1.79755599e + 02 <dst> = 0h After the execution of the instruction: <src> = 0733C16EEFh = 1.79755599e + 02 <dst> = 0733C16F00h = 1.79755600e + 02 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: Status Register 1 Status Register 2 Scaling Mode Rounding position Rounding Constant [55...24,23,22...0] 0 0 no scaling 23 0...0 1 10...0 0 1 scale down 24 0 ...1 0 00...0 1 0 scale up 22 0...0 0 1 ...0 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. The Japanese publication JP-A-4084318 describes a circuit for obtaining a rounding calculation with one instruction according to the preamble of the independent claims. 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 6-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 6 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.

Claims: A rounding operation circuit for performing a rounding operation on a first input signal (1) represented in a two's complement form, comprising decoder means (3) for receiving a second input signal (2) 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 (6) for performing an adding operation on said first input signal and said decoded signal and for outputting a resultant signal (7), characterized by a rounding-down means (8) 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". The circuit according to claim 1 wherein said second input signal for specifying the rounding position of said first input signal comprises four bits. The circuit according to claim 1 wherein said second input signal for specifying the rounding position of said first input signal is comprised of 16 bits in which the value specifying the rounding position has an immediate value. A rounding circuit for rounding input data (1) represented in a two's complement form to produce rounded data, comprising a decoder (3) supplied with control data (2) indicative of a rounding position of said input data and outputting first decoded data when said input data is positive and second decoded data when said input data is negative, said first decoded data consisting of a bit that takes a first logic level and corresponds to said rounding position and remaining bits that take a second logic level, said second decoded data consisting of a bit or bits that take said first logic level and are less significant than said bit corresponding to said rounding position and remaining bit or bits that take said second logic level, and operational unit (6) adding said input data with the decoded data derived from said decoder and outputting added data, characterized by a rounding-down circuit (8) producing said rounded data to said added data and said control data, said rounded data having a bit or bits that are less significant than a bit corresponding to said rounding position and rounded down to said second logic level.

Inventors: TORIUMI YOSHITAKA, TORIUMI, YOSHITAKA
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1993
Main classification: G06F7
IPC codes: G06F7