The present application claims priority from Japanese application JP 2007-282959 filed on Oct. 31, 2007, the content of which is hereby incorporated by reference into this application.
The present invention relates to a microcontroller provided with a floating-point arithmetic logic unit, more specifically, to technology which is effective when applied to a microcontroller and a controlling system using the same, where the microcontroller inputs an external signal, calculates a control signal to control an apparatus as a control object with the use of the internal floating-point arithmetic logic unit, and consequently outputs the control signal externally.
For example, in a controlling system (ECU) of a vehicle, etc., a control signal is generated based on information inputted from a sensor and outputted to an actuator, and the actuator operates based on the control signal. In the controlling system, a microcontroller, a driver IC, etc. are mounted. In the microcontroller mounted in the controlling system, the program was frequently described by using a fixed-point type variable in the past. The fixed-point representation is expressed by fixing in advance the number of bits used for an integer part and the number of bits used for a fraction part. The fixed-point representation can express a narrower range of value than the floating-point representation; however the fixed-point representation has an advantage that a high speed calculation is possible. In many cases, a microcontroller takes in an analog signal from a sensor and digitizes it by a built-in A/D converter. Since the built-in A/D converter has the precision of at most 10-12 bits, an internal variable is also expressed by a fixed-point type of 8 bits or 16 bits; therefore, high-speed operation, reduction of memory usage, and reduction of program codes are possible. As data representation inside a microcontroller, there is no data type which indicates a fixed point explicitly, and an integer type (16 bits and 32 bits), a character type (8 bits), etc. are usually used. A programmer itself is required to remember in which position each variable has decimal point. In addition and subtraction of the fixed-point type variables with different decimal point positions, it is necessary to carry out radix point alignment, and to include arithmetic processing, such as a division for the radix point alignment, in a program, requiring troublesome labor in programming. On the other hand, in the case of the floating point representation, automatic radix point alignment is carried out by the microcontroller itself; therefore, a programmer's labor is simplified.
Recent years, the microcontroller provided with a floating-point processor has increased in number, requiring a high data precision, enlarging a program size, and increasing request for an easy programming. These facts have stimulated the increase of the floating point operation. When a single precision floating-point representation is used, a 32-bit data area will be necessary, and the number of bits of variables and data of a program will increase compared with a fixed point expression, therefore, the amount of RAM or ROM used will increase. For example, it is often practiced in a controlling system that a table for determining a next control amount based on plural sensor values is stored in ROM as a control table. At this time, the control table expressed by a single precision floating point requires 4 times as many storage regions, compared with the case where the control table is expressed by an 8-bit fixed point. As a ROM which stores the control table, a flash memory for storing a program or constant data may be used in the exterior of the microcontroller in one case, and a nonvolatile ROM may be used in the interior of the microcontroller in another case. However, in any case, the prices of a microcontroller and also a controlling system increase as the storage capacity of the memory increases.
Document 1 discloses an invention in which, in order to reduce the amount of ROM used for a control table of a floating point, attention is paid to the fact that much data having the same value exists in the table, and a floating-point data is replaced by an index with fewer bits and a conversion table of the index and the actual value is provided separately. Accordingly, the amount of ROM used is reduced. Document 2 discloses an invention in which, when a floating point representation and fixed point representation coexist inside a microcontroller, data is held always in both expressions for the same data in order to save the labor of the calculation in conversion each time.
The present inventors have examined that the control table is comprised of a small number of bits as the signal taken in by an A/D converter and the data of the control table is converted to a floating point when the data is used for operation inside. In this case, when reading the control table, the floating-point conversion is carried out with the program code of several instructions, therefore, the quantity of the program code increases and the processing time in conversion increases, causing the problem that performance falls. For example, in order to read an integer type variable stored in a memory and to convert into a floating type variable, the following steps are required:
(1) loading a variable from a memory to an integer register,
(2) moving the variable from the integer register to a special register of floating point,
(3) reading the variable from the special register, converting and storing the variable in a floating-point register, and
(4) performing division (multiplication) in the decimal point position using a floating-point arithmetic logic unit for fraction alignment. The above processing requires four instructions in number of instruction, ten-odd cycles in number of cycle when floating-point division is used, and about eight cycles in total even when multiplication of the inverse number is used instead of the division. Whenever an element of a large-scale control table is read, the above-described steps, especially the processing of division or multiplication, are required. Therefore, it is seen that the program code increases and many processing cycles are required. Some kinds of instruction set architecture can practice the above-described steps (2) and (3) by one instruction. However, in any cases, compared with a case where the control table of fixed point is used and operation is also practiced in fixed point, or compared with a case where the control table of floating point is used and floating-point arithmetic is practiced, the case where the control table of fixed point is used and floating-point arithmetic is practiced brings about the overhead of the increase in the program code and the increase in the processing cycle.
The present invention has been made in view of the above circumstances and provides a microcontroller which can suppress the increase in the amount of program code for carrying out a floating-point arithmetic, in particular in the amount of program code due to a variable.
The present invention also provides a microcontroller which can reduce the processing overhead for converting fixed-point data into floating-point data.
The present invention further provides the controlling system which can reduce the capacity of a control table used for floating-point arithmetic, and reduce the overhead of control processing using the storage information of the control table.
The above and other purposes and the new feature of the present invention will become clear from the description of the present specification and the accompanying drawings.
The following briefly explains an outline of typical one of the inventions disclosed by the present application.
Namely, the present invention provides a microcontroller comprising: a floating-point converter which inputs data including integer data and corresponding decimal point position data as fixed-point data into a controlling system and converts the inputted fixed-point data into floating-point data by acquiring a fraction part, an exponent part, and a sign from the inputted fixed-point data; and a floating-point arithmetic logic unit which receives the output of the floating-point converter and performs operation of the floating-point data. The floating-point converter acquires the exponent part by performing addition and subtraction of the decimal point position data and the shift amount of the fraction part for the integer data.
The following briefly explains effects obtained by typical one of the inventions disclosed by the present application.
That is, it is possible to suppress the increase in the amount of program code for performing a floating-point arithmetic, in particular the increase in the amount of program code due to a variable.
It is possible to lessen the processing overhead for converting fixed-point data into floating-point data.
It is possible to suppress the capacity of the control table used for floating-point arithmetic and to reduce the overhead of control processing using the storage information of the control table.
First, an outline is explained about a typical embodiment of the invention disclosed in the present application. A numerical symbol in parentheses referring to a component of the drawing in the outline explanation about the typical embodiment only illustrates what is included in the concept of the component to which the numeral symbol is attached.
(1) A microcontroller comprises: a central processing unit which carries out an instruction and performs integer arithmetic; a floating-point converter which inputs data including integer data and corresponding decimal point position data as fixed-point data and converts the inputted fixed-point data into floating-point data by acquiring a fraction part, an exponent part, and a sign from the inputted fixed-point data; and a floating-point arithmetic logic unit which receives the output of the floating-point converter and carries out operation of the floating-point data.
Since the floating-point converter is employed, the increase in the amount of code due to a variable included in the program code for the floating-point arithmetic logic unit can be suppressed. Since the floating-point converter performs the conversion by inputting integer data and corresponding decimal point position data as fixed-point data, the use of decimal point position data in the conversion process does not necessitate multiplication or division for the fraction alignment to the floating-point data after the conversion, resulting in the reduced overhead of the transform processing.
(2) In the microcontroller of the item (1), the floating-point converter acquires the exponent part (EXP) by performing addition and subtraction between the decimal point position data (EXP2) and the shift amount of the fraction part for the integer data (INTDAT). The exponent part can be easily acquired by performing addition and subtraction.
(3) In the microcontroller of the item (2), the integer data includes plural bytes and the decimal point position data includes at least number of bits equal to a digit number of the integer data and the number of factorial of a factorial value of two. The decimal point position data can be expressed with few numbers of bits to the integer data.
(4) In the microcontroller of the item (3), the floating-point data is in conformity with the IEEE 754 standard for floating point representation, and the floating-point converter acquires the exponent part of the floating-point data by adding or subtracting the decimal point position data to and from the value of the exponent part to the integer data. The exponent part can be easily acquired by addition and subtraction.
(5) In the microcontroller of the item (2), the floating-point converter is activated by a floating point conversion instruction executed by the central processing unit, reads the integer data of the fixed-point data from an integer register (33) specified by an instruction operand of the instruction, and stores the converted floating-point data to a floating-point register (35) specified by the instruction operand of the instruction. The conversion to the floating type can be performed by the process in which the central processing unit executes the floating point conversion instruction.
(6) In the microcontroller of the item (5), the integer register and the floating-point converter are coupled by a first bus, and the floating-point converter and the floating-point register are coupled by a second bus. At the time of the conversion by the floating-point converter, control of the data path becomes very easy.
(7) In the microcontroller of the item (6), the floating-point converter inputs a decoded result of the instruction operand of the floating point conversion instruction as the decimal point position data. Although the instruction code length of the floating point conversion instruction increases, specification of the decimal point position data does not require any other instruction.
(8) In the microcontroller of the item (6), the floating-point converter is inputted the decimal point position data stored in a predetermined register (40) by the central processing unit. In this case, the decimal point position data can be specified without increasing the instruction code length of the floating point conversion instruction. Since it is common to arrange uniformly the decimal point position of the fixed-point data used for a group of processing, it is not necessary to redo the register setup each time for every floating-point conversion.
(9) The microcontroller of the item (2) has a first operation mode and a second operation mode which are selectively employed when the central processing unit executes a data transfer instruction to transfer data from a memory to the floating-point register of the floating-point arithmetic logic unit. In the first operation mode, data in the memory is directly loaded to the floating-point register. In the second operation mode, data in the memory is converted into floating-point data by the floating-point converter and the converted data is stored in the floating-point register. The floating-point data stored in the memory can be directly used for the floating-point arithmetic.
(10) The microcontroller of the item (9) further comprises: a selector (51) which selects a first path along which the data read from the memory by the data transfer instruction is provided to the floating-point register when the first operation mode is specified, and which selects a second path along which the data read from the memory by the data transfer instruction is provided to the floating-point converter when the second operation mode is specified. It is possible to easily practice the data path selection between in the case where the floating-point data taken from the memory is used for the floating-point arithmetic directly and in the case where the floating-point data converted by the floating-point converter is used for the floating-point arithmetic.
(11) In the microcontroller of the item (9), the first operation mode and the second operation mode can be switched over according to a flag value set in a mode register (50).
(12) The microcontroller of the item (9) further comprises: a data table (61) which has operation mode designating data and necessary decimal point position data corresponding to a memory address. The data table (61) inputs a memory access address by the data transfer instruction and outputs the operation mode designating data and the decimal point position data corresponding to the memory address concerned. One of the first operation mode and the second operation mode is selected based on the output of the data table. The floating-point converter acquires the necessary decimal point position data from the output of the data table. In accordance with the acquisition of data as a conversion target, the corresponding operation mode designating data and the necessary decimal point position data can be obtained automatically.
(13) In the microcontroller of the item (9), the floating-point converter inputs decimal point position data stored in a predetermined register by the central processing unit.
(14) The microcontroller of the item (1) further comprises: a direct memory access controller which is subject to condition setting by the central processing unit; and a memory which stores the integer data. The direct memory access controller can transfer the integer data from the memory to the floating-point converter in response to a transfer request. The floating-point conversion can be realized not only by the execution of the conversion instruction by the central processing unit, but also by the direct memory access transfer control.
(15) In the microcontroller of the item (14), the direct memory access controller can transfer to the memory the floating-point data converted by the floating-point converter and stored in a floating-point register. The operation mode which stores beforehand plural conversion results in a memory to be used in floating-point arithmetic also becomes selectable.
(16) In the microcontroller of the item (15), the floating-point converter inputs decimal point position data stored in a predetermined register by the central processing unit. It becomes possible to specify the decimal point position data when the central processing unit sets up the transfer condition to the direct memory access controller.
(17) In the microcontroller of the item (16), the direct memory access controller has the predetermined register. Specification of the decimal point position data becomes easy.
(18) A controlling system comprises: a control unit (70); an actuator (71) of which control amount is determined by the control unit; and a sensor (72) which detects state of a control object of the actuator. The control unit includes a program memory (90) storing a control program in which a variable is expressed by floating-point representation; a control table memory (91) storing control data expressed by a fixed-point integer; a floating-point converter (32); and a floating-point arithmetic logic unit (38). The floating-point converter gets input data including control data and corresponding decimal point position data. The input data is read from the control table memory based on input from the sensor. The floating-point converter converts the input data into floating-point data by acquiring a fraction part, an exponent part, and a sign in a floating-point type from the input data. The floating-point arithmetic logic unit gets output of the floating-point converter and carries out floating-point data operation based on the control program.
Since the floating-point converter is employed, the increase in the amount of code due to a variable included in the program code for the floating-point arithmetic logic unit can be suppressed. Since the floating-point converter performs the conversion by inputting integer data and corresponding decimal point position data as fixed-point data, the use of decimal point position data in the conversion process does not necessitate multiplication or division for the fraction alignment to the floating-point data after the conversion, resulting in the reduced overhead of the conversion processing. Since what is necessary is that a control table memory has, as the integer data, the control data to be used to determine the control amount in a controlling system, the storage capacity of the control table memory can be suppressed.
(19) In the controlling system of the item (18), the floating-point converter acquires the exponent part by performing addition and subtraction of the decimal point position data and the shift amount of the fraction part for the integer data. The exponent part can be easily acquired by addition and subtraction.
(20) The controlling system of the item (18) further comprises: a central processing unit which reads out control data from the control table memory based on input from the sensor and which provides the read-out control data to the floating-point converter.
(21) In the controlling system of the item (20), the floating-point converter inputs, as the decimal point position data, a decoded result of an instruction operand of floating point conversion instruction executed by the central processing unit.
(22) In the controlling system of the item (20), the floating-point converter inputs the decimal point position data stored in a predetermined register by the central processing unit.
(23) In the controlling system of the item (18), the program memory, the floating-point converter, and the floating-point arithmetic logic unit are formed over a same semiconductor chip. This formation contributes to miniaturization of the controlling system.
The embodiment is explained further in full detail. Hereafter, the best mode for carrying out the present invention is explained in detail based on the accompanying drawings. In all the drawings for explaining the best mode for inventing, the same symbol is attached to the member which has the same function, and the duplicated explanation thereof is omitted.
Although not restricted in particular, the microcontroller (MCON) 1 includes a central processing unit (CPU) 2, a floating-point processing unit (FPU) 3, and a cache unit (CAU) 4, as a processor core. The CPU 2 executes a fetched instruction and performs integer arithmetic. The FPU 3 executes a floating-point arithmetic instruction and performs floating-point arithmetic. Moreover, the FPU 3 converts to the fixed-point data supplied into the floating-point data. The cache unit 4 includes a cache memory (CACHE) 5, a translation look-aside buffer (TLB) 6, and a cache-TLB control circuit (CTCNT) 7. The cache memory stores temporarily an instruction and data which are with high use frequency. The TLB 6 holds temporarily a conversion pair of a logical address and a physical address which are with high use frequency. The CTCNT 7 performs: address conversion control to the address information outputted from the CPU 2; control of the replacement and fill operation of cache entry, corresponding to cache hit/cache miss of the cache memory to an access request by the CPU 2; control of the replacement and fill operation, corresponding to TLB hit/TLB miss of the TLB 6; and other controls. In
The CAU 4 is coupled to a bus state controller (BSC) 10 via an address bus A10 and a data bus D10. The BSC 10 is coupled to an external bus interface circuit (EXBIF) 12 via an address bus A12 and a data bus D12. The EXBIF 12 is coupled to external devices, such as an external memory, via an external address bus A20 and an external data bus D20. A random access memory (RAM) 15 and a read-only memory (ROM) 16 are coupled to the address bus A12 and the data bus D12. The BSC 10 is coupled to peripheral circuit modules 20-24 via a peripheral address bus A13 and a peripheral data bus D13. The peripheral circuit module 20 is a clock pulse generator (CPG) which generates a synchronous clock signal inside the MCON 1. The peripheral circuit module 21 is an interruption control circuit (INTC), and outputs an interrupt signal to the CPU 2 in response to an interruption request signal from the inside and outside of the MCON 1. The peripheral circuit module 22 is an analog/digital converter (ADC) which converts an analog signal from the outside into a digital signal. The peripheral circuit module 23 is a timer counter unit (TMU). The peripheral circuit module 24 is a serial interface circuit (SCI). The BSC 10 is coupled to a direct memory access controller (DMAC) 11 via an address bus A11 and a data bus D11. A transfer condition for the direct memory access controller (DMAC) 11 is set up by the CPU 2. By receiving a transfer request, the direct memory access controller (DMAC) 11 performs a data transfer control, according to the transfer condition, by dual addressing mode such as in transfer between a memory and a memory, or a single addressing mode such as in transfer between a memory and a register. The BSC 10 performs a bus control, such as a number of bus cycle, a data width, and a path selection, according to the access address supplied from the bus A10.
The following explains the conversion function in converting fixed-point data into floating-point data using the FPU 3.
The floating-point converter 32 has a sign-and-fraction processing unit (PROC) 36 and a subtractor (SUB) 37 which calculates the exponent part. Since the integer type expression usually expresses a negative value by a two's complement, the symbol can be distinguished by investigating whether a highest-order bit is “1” or “0”, and the sign-and-fraction processing unit 36 outputs one-bit sign information SIGN. The sign-and-fraction processing unit 36 calculates an exponent part EXP1 and a fraction part FRACTION. Since the processing by the sign-and-fraction processing unit 36 which calculates the sign SIGN, the exponent part EXP1, and the fraction part FRACTION is known technology, the explanation about the portion is made simply. The sign-and-fraction processing unit 36 calculates the place of “1” in the highest order from the inputted integer representation, and shifts the bit to the left so that the bit may come to the highest-order bit. In the floating point representation, since the hidden bit which omits the highest order “1” is used, the sign-and-fraction processing unit 36 shifts the bit to the left by one more bit, and fills “0” into the vacant right bit portion. As a result, a final fraction part FRACTION is calculated. In the case of a negative value whose highest-order bit is “1”, the complement is calculated by subtracting one and the absolute value is calculated, then the same treatment is taken. The sign-and-fraction processing unit 36 calculates the exponent part EXP1 by the digit number of the place of “1” in the highest order. The subtractor 37 inputs the exponent part EXP1 calculated and the decimal point position data EXP2, reduces the decimal point position data EXP2 from the exponent part EXP1, and calculates the exponent part EXP in the final floating point representation. When the decimal point position to the integer data INTDAT is located on the right, the decimal point position data is given as a complement. Accordingly, even in a case where the decimal point position is located on the lowest right-hand side of the integer data, the exponent part EXP can be calculated by subtraction with the subtractor 37. When the complement is adopted for the decimal point position data EXP2, an adder may be used instead of the subtractor.
The sign information SIGN, the exponent part EXP, and the fraction part FRACTION which are obtained as described above are combined to 32-bit data and outputted to the floating-point register 35. The floating-point data loaded to the floating-point register 35 is treated as a target of floating-point arithmetic to be performed by a floating-point arithmetic logic unit (FPALU) 38. The floating-point arithmetic logic unit 38 also treats the floating-point data loaded to the other floating-point registers (not shown) as a target of the arithmetic, if needed. A floating-point control circuit (FPCNT) 39 decodes the floating point instruction supplied from the CPU 2, and controls the arithmetic operation by the floating-point arithmetic logic unit 38.
Although the present example has explained as subtraction, the present example can be alternatively realized taking a complement and using an adder. Accordingly, the value 1.1011×21 of the converted floating point is outputted to the floating-point register (FLREG) 35.
As it can be understood from the explanation of
Since the constitution of
According to the constitution of
According to this example, in addition to performing the floating-point conversion of data in the control table and storing the data in the floating-point register, it is possible to perform the floating-point conversion of the data of one row of the table collectively and to store the data in the RAM. It is also possible to perform the floating-point conversion of data of one column of the table collectively and to store the data in the RAM. Alternatively, using a scatter-gather function, still more intricate conversion and transfer are possible, such as performing the floating-point conversion of data in the neighborhood of the aimed point of an n-dimension table collectively, and storing the data in the RAM.
The control table 91 of the ROM 16 is comprised of fixed-point data of 8-bit or 16-bit integer representation. The control program 90 is similarly stored in the ROM. From the state of the control object acquired by the sensor, the control amount is determined according to the control program 90, with reference to the control table 91, and is outputted from an I/O as a control signal. The variable of the program is expressed in a floating point. As explained with reference to
Accordingly, it becomes possible to reduce the size of the ROM 16. Since the control program employs a variable of a floating-point number, the control program is highly precise and manual coding can be decreased as much as possible. Moreover, the increase in the code size for conversion and the cycle overhead of the conversion process can be also reduced.
In the above, the invention accomplished by the present inventors has been specifically explained based on the embodiments. However, it cannot be overemphasized that the present invention is not restricted to the embodiments, and it can be changed variously in the range which does not deviate from the gist.
For example, the circuit module which the microcontroller has is not restricted to
Number | Date | Country | Kind |
---|---|---|---|
2007-282959 | Oct 2007 | JP | national |