NUMERICAL EXPRESSION CONVERTER AND VECTOR PROCESSOR USING THE SAME

Abstract: In a device for converting a floating-point expression into fixed-point expression, a decimal alignment means (12) shifts the digits of the mantissa (M) of a number to form a fixed point number depending on the exponent (E). When the sign part (S) of a floating-point number is negative, the integer part of the shifted number is inverted by a bit inversion means (31). At the time of shifting, the value of a carry digit is determined by a carry determining means (32) based on the data that indicates whether there are digits on the right side of the decimal point and a truncate direction instruction given from an external unit. Thereafter, the value output from the bit inversion means (31) and the carried value determined by the means (32) are added through an adder means (33) which then outputs the sum in the fixed point system. The above constitution enables the operation speed to be increased and the circuit constitution to be simplified. Further, the above numerical expression converter can be adapted to a vector processor unit that calculates vector data.

Description: FIELD OF THE INVENTION The present invention pertains to a numeric representation converting apparatus having a function for converting, to a fixed-point number, a floating-point number consisting of a sign part, an exponent part, and a mantissa part and for outputting the result of conversion. It pertains more specifically to a numeric representation converting apparatus in which a reduction of a number of circuits needed for the conversion to a negative fixed-point number and a speed-up of operation are accomplished, and to a vector processor unit employing such an apparatus. Means normally used to represent data used in a numeric operation include fixed-point representation and floating-point representation. In fixed-point representation, the position of a decimal point is usually set at the right of an LSB, and the LSB is given a weight "1". Also, in this fixed-point representation, a negative value is represented by a complement on 2. On the other hand, floating-point representation represents a number by dividing it into a sign part, an exponent part, and a mantissa part. Most numeric operation apparatuses have a function of switching from fixed-point representation to floating-point representation and vice versa. When converting a floating-point number to a fixed-point number, the value to the right of the decimal point is either carried or truncated, since a fixed-point number is normally an integer. How a floating-point number is converted to a fixed-point number, wherein the value to the right of a decimal point is truncated, will now be discussed. For example, when converting a floating-point number "2.5" to a fixed-point number, "0.5", which is to the right of the decimal point, is truncated, thus giving a converted result of "2". When "-2.5" is to be converted, the converted result can either be "-2" or "-3". The former is obtained when, for example, the sign represents only a direction, wherein it is desired that the truncated result be close to zero. The latter is obtained when, for example, a negative bias is applied to what is originally a positive number due to a computational reason (a problem of dynamic range, etc.), wherein it is desired that the truncated value be negatively large in view of the fact that the negative bias is to be removed later to restore the positive number. BACKGROUND ART An example of a conventional numeric representation converting apparatus is shown in FIG.1. As shown in FIG.1, a sign part (S), an exponent part (E), and a mantissa part (M) of a number represented by a floating-point representation are stored in registers 10a, 10b, and 10c respectively. A weight determining circuit 11 functions as a weight determining means for determining a weight of the mantissa part (M) on the basis of the exponent part (E) of the input floating-point number. A shifter 12 functions as a decimal alignment means for performing decimal alignment by shifting the digits of the mantissa part of the input floating-point number on the basis of the weight determined above. This shifter 12 is equipped with a detecting portion 12a for detecting any numbers to the right of the decimal point. A two's complement generating circuit 13, a decrementer 14, and a first selector 15 convert an integer part of the number obtained by the above-mentioned decimal alignment to a twos complement, and also function as a converting means 20 having a rounding operation function, which converting means truncates the value to the right of the decimal point in either of two truncating directions, on the basis of an externally provided truncation direction instruction (C). As shown in FIG.2, the two's complement generating circuit 13 is comprised of a bit inverting circuit 13a for bit-inverting an integer part of the output from the shifter 2, and a adder circuit 13b for adding 1 to the output from this bit inverting circuit. Thus, the two's complement generating circuit 13 outputs the integer part of the output from the shifter 12, which integer part is represented in a twos complement form. This output from the twos complement generating circuit 13 corresponds to the value of the integer part obtained when the value to the right of the decimal point, which value is shifted in the shifter 12, is truncated in the direction approaching zero. The decrementer 14 is a circuit for subtracting 1 from the number output from the twos complement generating circuit 13. Thus the decrementer 14 outputs the value of the integer part obtained when the value to the right of the decimal point, which value is shifted in the shifter 12, is truncated in the negatively increasing direction. As shown in FIG.3, the first selector 15 is comprised of an AND circuit 15a supplied with a detection signal B and an instruction signal C, an inverter 15b for inverting the output from the AND circuit 15a, an AND circuit 15c supplied with the output from the decrementer, an AND circuit 15d supplied with the output from the twos complement generating circuit 13, and an OR circuit 15e supplied with the outputs from both of the AND circuits 15c and 15d, wherein the selection is based on the detection signal B submitted from the detecting portion 12a which belongs to the shifter 12 and on the truncation direction instruction signal C. The first selector 15 selects and outputs, when the detection signal B is 0, that is, there is no value to the right of the decimal point, or when the instruction signal C is 0, the output from the two's complement generating circuit 13; namely the value of the integer part obtained when the value to the right of the decimal point is truncated in the direction approaching zero. The first selector 15 selects and outputs, when the detection signal B is 1, meaning that there is a value to the right of the decimal point, and the instruction signal is 1, the output from the decrementer 14; namely the value of the integer part obtained when the value to the right of the decimal point is truncated in the negatively increasing direction. As shown in FIG.4, the second selector 16 is comprised of an inverter 16a for inverting the sign part (S), an AND circuit 16b supplied with the output from the selector 15, an AND circuit 16c supplied with the output from the shifter 12, and an OR circuit 16d supplied with the outputs from the AND circuits 16b and 16c. The second selector 16 selects, when the sign part (S) of the register 10a is 0, which indicates a positive number, the integer part of the value obtained by the shifter 12, which functions as the decimal alignment means. The second selector 16 selects and outputs, when the sign part (S) is 1; which indicates a negative number, the value obtained by the converting means 20 having a rounding operation function. A conversion result register 17 temporarily stores the sign part (S) of the input floating-point number and the output from the selector 16, and then finally outputs them as fixed-point numbers. A description will be given below of an operation of the numeric representation converting apparatus of the above configuration in accordance with FIG.5. The description below assumes not only that the input floating-point number is negative but also that there is a value to the right of the decimal point ("-2.5" is taken as an example). Any person skilled in the art will easily recognize that a simple truncation will be performed if the number is positive (in the case of "+2.0" or "+2.5"), or if the number is negative but there is no value to the right of the decimal point (in the case of "-2.0"). Assuming that the floating-point number "-2.5" is input into the registers 10a - 10c, it is evident that S = 1, E = 001, and M = 1010. The weight determining circuit 11 outputs "2" as an amount of shift (weight), on the basis of E = 1. This prompts the content of the shifter 12 (M = 1010) to be shifted two bits to the right, resulting in the content of the integer part of the shifter 12 becoming (0010), and the value of the detection signal B becoming "1". Subsequently, the two's complement generating circuit 13 carries out an operation (1101) + (0001) = (1110) so as to obtain a complement (1110) on the number (0010), which complement (1110) is fed, as described above, to one of the inputs of the selector 15 as an output subject to a truncation in the direction approaching zero. On the other hand, the decrementer 14 carries out an operation (1110) - (0001) = (1101), the result of this operation being fed to the other input of the selector 15 as an output subject to a truncation in the negatively increasing direction, as mentioned above. The first selector 15 performs a selective control by truncating in the direction approaching zero when the truncation direction instruction signal C is "0", and by truncating in the negatively increasing direction when the signal C is "1", with the result that the first selector 15 outputs (1110) when the truncation direction instruction signal C is "0", and outputs (1101) when the truncation direction instruction signal C is "1". The second selector 16 performs a selective control by selecting the output from the shifter 12 when the sign part S is "0", and by selecting the output from the first selector 15 when the sign part S is "1", with the result that the second selector 16 outputs either (1110) or (1101) in correspondence with the sign part S value of "1". And finally, the conversion result register 17 outputs either (11110) or (11101), the signed fixed-point numbers desired. Let us designate a delay time for one gate as being one unit. After a floating-point number is stored in each of the registers 10a - 10c, which storage is represented in FIG.6 (A), a delay of six units is incurred, as shown in FIG.6 (B), in the weight determining circuit 11, which is a kind of adder circuit; a delay of three units is incurred, as shown in FIG.6 (C), in the shifter 12; a delay of six units is incurred, as shown in FIG.6 (D), in the two's complement generating circuit 13 having the adder circuit 13b; a delay of six units is incurred, as shown in FIG.6 (E), in the decrementer 14; and a delay of three units each is incurred, as shown in FIG.6 (F) and (G), in each of the selectors 15 and 16. That is, a delay of a total of twenty seven units is incurred. Thus the presence of two adder circuits in a conventional numeric representation converting apparatus, namely, the decrementer (a kind of adder circuit) 14 and the adder circuit 13b belonging to the two's complement generating circuit 13, causes an operation time to become relatively long and makes a circuit configuration relatively complex. Accordingly, an object of the present invention is to provide a novel and useful numeric representation converting apparatus capable of eliminating the above disadvantages, and a vector processor unit employing such an apparatus. Other objects of the present invention are to speed up operations of the apparatus where a floating-point number is subject to two kinds of truncation and converted to a fixed-point number, and to simplify the circuit configuration. DISCLOSURE OF THE INVENTION The above objects of the present invention are achieved by a numeric representation converting apparatus having a function for converting a floating-point number consisting of a sign part (S), an exponent part (E), and a mantissa part (M) to a fixed-point number and outputting the converted result, which apparatus comprises: weight determining means (11) for determining a weight of a mantissa part (M) on the basis of a value of an exponent part (E) of an input floating-point number; decimal alignment means (12) for performing decimal alignment by shifting digits of a value of the mantissa part (M) of the input floating-point number on the basis of said determined weight; converting means (30) having a rounding operation function for converting a value of an integer part of a value obtained by said decimal alignment so as to represent the value in a negative representation and for truncating the value to the right of a decimal point in either of two truncating directions on the basis of an externally provided truncation direction instruction; and selecting means (16) for selecting and outputting either an integer part of a value obtained by said decimal alignment means or a value obtained by converting means having a rounding operation function, on the basis of a sign part of the input floating-point number, said apparatus characterized in that said converting means (30) comprises: bit inverting means (31) for bit-inverting an integer part of a value obtained by said decimal alignment means (12); carry digit determining means (32) for determining the value of a carry digit on the basis of information indicating the presence or absence of a value shifted to the right of a decimal point due to the digit shifting in said decimal alignment means (12), and on the basis of an externally provided truncation direction instruction; and adding means (33) for adding a value output from said bit inverting means (31) to a carry digit determined by said carry digit determining means (32). BRIEF DESCRIPTION OF THE DRAWINGS FIG.1 shows a configuration of a conventional apparatus; FIG.2 is a block diagram of a two's complement generating circuit; FIG.3 is a circuit diagram of a first selector; FIG.4 is a circuit diagram of a second selector; FIG.5 is a diagram describing an operation of the conventional apparatus shown in FIG.1; FIG.6 is an operational timing chart of FIG.1; FIG.7 shows a configuration of the present invention; FIG.8 describes a floating-point representation; FIG.9 describes a relationship between an exponent part and an amount of shift; FIG.10 describes an operation of the configuration of the present invention shown in FIG.7; FIG.11 is an operational timing chart of FIG.7; and FIG.12 shows a configuration of a vector processor unit. BEST MODE OF CARRYING OUT THE INVENTION FIG.7 shows a configuration of an embodiment of the present invention. Referring to FIG.7, parts that are the same as those in FIG.1 are given the same reference numerals and the descriptions thereof are omitted. In FIG.7, it is assumed that the sign part (S), the exponent part (E), and the mantissa part (M) stored in the registers 10a - 10c respectively contain 1 bit, 3 bits, and 4 bits, respectively, as shown in FIG.8. The weight determining circuit 11 is a subtracter circuit designed to subtract the value of the exponent part in the register 10b from a predetermined value (3 in this case) and to output an amount of shift shown in FIG.9 which corresponds with the value of the exponent part. This embodiment differs from the conventional technology in that there is provided a converting means 30 having a rounding operation function comprised of a bit inverting circuit 31, a NAND circuit 32, and an adder circuit 33. Specifically, the bit inverting circuit 31 bit-invert the integer part of the value obtained from the shifter 12, which functions as a decimal alignment means, and outputs the inverted result. The output from this bit inverting circuit 31 is fed to one of the inputs of the adder circuit 33. The output value from this bit inverting circuit 31 corresponds to the output value obtained when a truncation is carried out in the negatively increasing direction. The NAND circuit 32 is a circuit which NANDs the detection signal B from the detecting portion 12a belonging to the shifter 12, and the truncation direction instruction signal C, the output therefrom being fed to the other input of the adder circuit 33 as a carry digit ("1" when a truncation is performed in the direction approaching zero, and "0" when a truncation is performed in the negatively increasing direction ). The adder circuit 33 adds the output from the bit inverting circuit 31 to the output from the NAND circuit 32, the sum thereof being fed to the selector 16 as a negative fixed-point number to be finally output. An operation of the embodiment of the above configuration will be described below with reference to FIG.10. The description below assumes not only that the input floating-point number is negative but also that there is a value to the right of the decimal point ("-2.5" is taken as an example). Any person skilled in the art will easily recognize that a simple truncation will be performed if the number is positive (in the case of "+2.0" or "+2.5"), or if the number is negative but there is no value to the right of the decimal point (in the case of "-2.0"). Assuming that the floating-point number "-2.5" is input, it is evident that S = 1, E = 001, and M = 1010. The weight determining circuit 11 outputs "2" as an amount of shift (weight), on the basis of E = 1. This prompts the content of the shifter 2 (M = 1010) to be shifted two bits to the right, resulting in the content of the integer part of the shifter 2 becoming (0010), and the value of the detection signal B becoming "1". The bit inverting circuit 31 outputs the value (1101) obtained by bit-inverting the content (0010) of the integer part of the shifter 2. This value (1101) is fed to one of the inputs of the adder circuit 11 as a value to be output when a truncation is performed in the negatively increasing direction. The detection signal B from the detecting portion 12a of the shifter 12 is "1", while the truncation direction instruction signal C is "O" when a truncation is performed in the direction approaching zero and "1" when a truncation is performed in the negatively increasing direction. Therefore, the output from the NAND circuit 32 is "1" when a truncation is performed in the direction approaching zero and "0" when a truncation is performed in the negatively increasing direction. The output from this NAND circuit 32 is fed to the other input of the adder circuit 33 as a carry digit. Consequently, the adder circuit 33 outputs the value (1110 = "-2") in accordance with an operation (1101) + (0001) = (1110) when a truncation is performed in the direction approaching zero, while the adder circuit 33 outputs the value (1101 = "-3") in accordance with an operation (1101) + (0000) = (1101) when a truncation is performed in the negatively increasing direction. Subsequently, the output from this adder circuit 33 is forwarded to the conversion result register 17 via the selector 16, from which register the signed fixed-point number (11110) or (11101) is output. Let us designate a delay time for one gate as being one unit. After a floating-point number is stored in each of the registers 10a - 10c, which storage is represented in FIG.11 (A), a delay of six units is incurred, as shown in FIG.11 (B), in the weight determining circuit 11, which is a kind of adder circuit; a delay of three units is incurred, as shown in FIG.11 (C), in the shifter 12; a delay of one unit is incurred, as shown in FIG.11 (D), in the NAND circuit 32; a delay of six units is incurred, as shown in FIG.11 (E), in the adder circuit 33; and a delay of three units is incurred, as shown in FIG.11 (F), in the selector 16. That is, a delay totaling nineteen units is incurred. Because, in the above conventional converting apparatus, the converting means 30 having a rounding operation function includes two adder circuits 33, a relatively large delay is caused. A speed-up of the operation is achieved by reducing an operation time by about 30% as compared with that of the conventional apparatus. Also, the circuit configuration is simpler than that of the conventional apparatus. FIG. 12 shows a configuration of a vector processor unit (VPU) in which the present invention is applied. This vector processor unit is a one-chip semiconductor integrated circuit. Referring to FIG.12, a vector unit (VU) 50 is provided with a vector register 51 for storing vector data, a scalar register 52 for storing scalar data, and a mask register 53 for storing mask data. An adder portion 54, a multiplier portion 55, and a divider portion 56 in the vector unit 50 execute respective pipeline processes, namely addition, multiplication, and division of numeric data. A mask portion 57 executes a mask process at the time of a vector operation. A data output latch 58 and a data input latch 59 respectively output data to the outside and input data from the outside. A command buffer unit (CBU) 60 is provided with a command buffer (VCB) 61 for storing a command. The command read out from this command buffer 61 is fed to a decoding portion 71 within a control unit (CU) 70, where the command is decoded. On the basis of the result of this decoding, a pipeline control portion 72 performs pipeline control on the adder portion 54, the multiplier portion 55, and the divider portion 56 in the vector unit 50. A scoreboard portion 73 manages the usage of each of the registers in the vector unit 50, which registers are used in the above-mentioned pipeline control. An address unit (80) converts virtual addresses to physical addresses by using a VTR (vector translation register) 81 and a TLB (translation lookaside buffer) 82 and handles the exchange of addresses between the inside and outside of the chip. A bus control unit 85 handles exchange of data between the inside and outside of the chip. The numeric representation converting apparatus of the present invention shown in FIG.7 is provided in the adder portion 54 of the vector unit 50, and is used for converting floating-point vector data to a fixed-point number before vector data is added. In a large-scale integrated circuit capable of performing a high-speed operation like that performed by the vector processor unit, it is important that a chip area be made smaller and an operation be made faster by a simpler circuit. The above are realized by the simple circuit configuration of the present invention. POSSIBLE APPLICATION IN INDUSTRY As described above, in accordance with the numeric representation converting apparatus of the present invention, a speed-up of an operation and a simplified circuit configuration can be attained. Further, in the vector processor unit employing the present invention a chip area can be reduced and a speed-up of an operation can be achieved.

Claims: A numeric representation converting apparatus having a function of converting a floating-point number consisting of a sign part (S), an exponent part (E), and a mantissa part (M) to a fixed-point number and outputting the converted result, which apparatus comprises: weight determining means (11) for determining a weight of a mantissa part (M) on the basis of a value of an exponent part (E) of an input floating-point number; decimal alignment means (12) for performing decimal alignment by shifting digits of a value of the mantissa part (M) of the input floating-point number on the basis of said determined weight; converting means (30) having a rounding operation function for converting a value of an integer part of a value obtained by said decimal alignment so as to represent the value in a negative representation and for truncating the value to the right of a decimal point in either of two truncating directions on the basis of an externally provided truncation direction instruction; and selecting means (16) for selecting and outputting either an integer part of a value obtained by said decimal alignment means or a value obtained by converting means having a rounding operation function, on the basis of a sign part of the input floating-point number, said apparatus characterized in that said converting means (30) comprises: bit inverting means (31) for bit-inverting an integer part of a value obtained by said decimal alignment means (12); carry digit determining means (32) for determining the value of a carry digit on the basis of information indicating the presence or absence of a value shifted to the right of a decimal point due to the digit shifting in said decimal alignment means (12), and on the basis of an externally provided truncation direction instruction; and adding means (33) for adding a value output from said bit inverting means (31) to a carry digit determined by said carry digit determining means (32). A numeric representation converting apparatus as claimed in Claim 1, wherein said carry digit determining means (32) is constructed of a NAND circuit. A vector processor unit characterized in that an operation of vector data is performed by converting a floating-point vector data to a fixed-point representation by using a numeric representation converting apparatus as claimed in Claim 1. A vector processor unit as claimed in Claim 3 characterized in that a whole circuit is formed on a single semiconductor chip.

Inventors: HATTA KOICHI, HATTA, KOICHI
Applicants: FUJITSU LTD, FUJITSU LIMITED
Application year: 1992
Main classification: G06F17
IPC codes: G06F17, G06F7, H03M7