Method of estimating power consumption of microprocessor

Abstract: This invention provides a method of estimating the power consumption of a microprocessor with the use of an instruction file that is simple and easy to prepare. A microprocessor (3, 4) reads instructions out of a main memory (2) or an instruction cache (1) and executes them. A group of instructions that include at least one target instruction whose power consumption is to be estimated is repeatedly executed in simulations, to find the power consumption of the microprocessor on the target instruction in a cache miss state, as well as the power consumption of the microprocessor on the target instruction in a cache hit state, according to the power consumption of the microprocessor in given cycles.

Description: BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a method of estimating the power consumption of a microprocessor on each instruction the microprocessor reads out of a main memory or an instruction cache and executes. 2. Description of the Prior Art Computer technologies and semiconductor integrated circuits have made great progress recently, and accordingly, electronic equipment, in particular, personal computers have improved their compactness and portability. Under these circumstances, an important subject is to improve the processing speed of microprocessors as well as reducing the power consumption thereof. To achieve a reduction in power consumption, it is necessary to correctly evaluate the power consumption of a microprocessor when designing the same. An example of a technique of evaluating the power consumption of a microprocessor is disclosed in "Power Analysis of Embedded Software; A First Step towards Software Power Minimization" of Vivek Tiwari, Shard Malik, and Andrew Wolfe in IN IEEE-94, pp. 384 - 390 (1994). This is a method of evaluating the power consumption of a microprocessor including software. This method pays attention to the kind of each instruction to be executed by a microprocessor and estimates the power consumption of the microprocessor. Namely, the method finds out the individual power consumption of different instructions to be executed by the microprocessor in advance, applies the found power consumption to each instruction that is still in an assembler program, and estimates total power to be consumed by the instructions when they are actually executed by the microprocessor. This method executes a given instruction by the microprocessor and measures the power consumption thereof with a power meter connected to the microprocessor. If the microprocessor employs an instruction cache, it is necessary to separate cache-hit power consumption from cache-miss power consumption. These two kinds of power consumption are unable to find out with the use of a single instruction file. Namely, it is necessary to prepare an instruction file 101 of Fig. 1 for measuring the cache-miss power consumption of each instruction, as well as an instruction file 102 of Fig. 2 for measuring the cache-hit power consumption of each instruction. The instruction file 101 consists of a state setting section 103 for setting a microprocessor in a cache miss state, and a target instruction executing section 104 for executing target instructions for which power consumption is going to be estimated. The instruction file 102 consists of a state setting section 103 for setting a microprocessor in a cache hit state, and a target instruction executing section 104 for executing target instructions for which power consumption is going to be estimated. The state setting section 103 of Fig. 1 disables cached instructions and establishes a cache miss state, and the state setting section 103 of Fig. 2 executes, in advance, codes used by the instruction executing section 104 and establishes a cache hit state. As a result, the instruction files 101 and 102 are each long and intricate, and therefore, are difficult to prepare. In this way, the prior art of finding out the power consumption of a microprocessor, which has an instruction cache, on each instruction involves long and intricate instruction files to set measuring environments for the microprocessor. Such instruction files are very difficult to make because they need time and labor to prepare. From the article "Power Analysis of Embedded Software: A First Step Towards Software Power Minimization" by Vivek Tiwari et al., IEEE Transactions on Very Large Scale integration (VLSI) Systems, 2 (1994) December No. 4, pages 437-445 New York, US, it is known to form a power analysis of software, in order to verify if a design meeds specified power constraints. SUMMARY OF THE INVENTION In view of these problems, an object of the present invention is to provide a method of estimating the power consumption of a microprocessor on each instruction, employing an instruction file that is simple and easy to prepare. This object is solved by the subject-matter of the independent claims. An advantageous embodiment is described in the dependent claim. In order to accomplish the object, an embodiment of the present invention provides a method of estimating the power consumption of a microprocessor on each instruction the microprocessor reads out of a main memory or an instruction cache and executes through pipelined processing stages. The method includes a step of consecutively executing, at least two times, a group of target instructions whose number is at least twice as large as the number of instructions to be simultaneously transferred from the main memory to the instruction cache, a step of finding the power consumption of the microprocessor in each cycle in a given range of cycles in each of the first and second executions of the instruction group, a step of accumulating the power consumption in each cycle for a given number of cycles in a given range of cycles in the first execution of the instruction group, to find out the power consumption in each cycle in the second execution of the instruction group, to find out the power consumption of the microprocessor for the given number of cycles in the first execution of the instruction group and the power consumption in each cycle in the second execution of the in the second of the instruction group, to estimate the power consumption of the microprocessor of reading a cache-hit instruction out of the instruction cache and executing the same, as well as the power consumption of the microprocessor of reading a cache-missed instruction out of the main memory and executing the same. The instructions are executed in transistor- or gate-level simulations. According to another embodiment of the present invention, the estimated power consumption (Ph) of the microprocessor on a cache-hit instruction is obtained as the power consumption thereof in a given cycle in the second execution of the instruction group. On the other hand, the estimated power consumption (Pm) of the microprocessor on a cache-missed instruction is obtained as follows: Pm = {the sum of power consumption for "I+N" cycles starting from the "P+N"th cycle in the first execution of the instruction group} - {(I-1) x Ph} where P is the number of the pipelined processing stages, I is the number of instructions to be simultaneously transferred from the main memory to the instruction cache when a cache miss occurs, and N is the total number of stalls to occur when executing the I instructions simultaneously transferred to and stored in the instruction cache. Still another embodiment of the present invention provides a method of estimating the power consumption of a microprocessor on a target instruction the microprocessor reads out of a main memory or an instruction cache and executes through pipelined processing stages. The method includes a step of executing, at least twice, the target instruction, a step of finding the power consumption of the microprocessor in one cycle in a given range of cycles in each of the first and second executions of the target instruction, a step of accumulating the power consumption in one cycle for a given number of cycles in the given range of cycles in the first execution of the target instruction, to find out the power consumption of the microprocessor for the given number of cycles, and a step of using the power consumption for the given number of cycles in the first execution of the target instruction and the power consumption in one cycle in the second execution of the target instruction, to estimate the cache-hit power consumption of the microprocessor of reading the target instruction out of the instruction cache and executing the same, as well as the cache-missed power consumption of the microprocessor of reading the target instruction out of the main memory and executing the same. The instruction is executed in transistor- or gate-level simulations. Still another embodiment of the present invention provides a system for estimating the power consumption of a microprocessor on each instruction the microprocessor reads out of a main memory or an instruction cache and executes. The system has a unit for entering a string of machine language instructions that include consecutive target instructions and a jump instruction to jump to the first one of the target instructions, the number of the target instructions being at least twice as large as the number of instructions simultaneously read out of the main memory, a unit for carrying out transistor- or gate-level simulations to simulate the microprocessor of reading the machine language instructions out of the main memory or the instruction cache and executing them, a unit for estimating the power consumption of the microprocessor on a cache-missed instruction according to the first execution of the consecutive target instructions, and a unit for estimating the power consumption of the microprocessor on a cache-hit instruction according to the second execution of the consecutive target instructions. BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 shows the structure of an instruction file for a cache miss state, according to a prior art; Fig. 2 shows the structure of an instruction file for a cache hit state, according to the prior art; Fig. 3 shows pipelined processing: stages involving cache misses in a microprocessor according to an embodiment of the present invention; Fig. 4 shows pipelined processing stages involving cache hits in a microprocessor according to an embodiment of the present invention; Fig. 5 shows the structure of a microprocessor according to an embodiment of the present invention; Fig. 6 shows the structure of another microprocessor according to an embodiment of the present invention; Fig. 7 shows a general instruction file used by a method of estimating the power consumption of a microprocessor according to the present invention; Fig. 8 shows the internal conditions of an instruction cache; Fig. 9 shows the internal conditions of an instruction cache; Fig. 10 shows modified pipelined processing stages based on Fig. 4; Fig. 11 shows modified pipelined processing stages based on Fig. 3; Fig. 12 shows a system for estimating the power consumption of a microprocessor according to the present invention; Fig. 13 shows an instruction file used by a method of estimating the power consumption of a microprocessor according to the present invention; Fig. 14 shows another instruction file used by a method of estimating the power consumption of a microprocessor according to the present invention; and Fig. 15 shows a flow of executing the instruction file of Fig. 14. DETAILED DESCRIPTION OF THE EMBODIMENTS A method of estimating the power consumption of a microprocessor according to the present invention will be explained with reference to the drawings. Figures 3 and 4 show pipelined processing stages in a microprocessor to which the method of the present invention is applied. The microprocessor that executes target instructions for which power consumption is estimated is a microprocessor 3 of Fig. 5 having an internal instruction cache 1 and an external main memory 2, or a microprocessor 4 of Fig. 6 having an external instruction cache 1 and an external main memory 2. The microprocessor executes the target instructions through the pipelined processing stages shown in Figs. 3 and 4. The target instructions are listed in an instruction file of Fig. 7, which is used to simulate the power consumption of the microprocessor on each instruction. In the instruction file, the target instructions are consecutively arranged, and a jump instruction is arranged at the end of the target instructions so that the target instructions are repeatedly executed. The number of the target instructions in the instruction file is within the number of instructions to be stored in the instruction cache 1 of Figs. 5 and 6. Any one of the microprocessors 3 and 4 of Figs. 5 and 6 executes instructions in five pipelined processing stages, i.e., a fetch stage (F), a decode stage (D), an execution stage (E), a data cache access stage (M), and a register write stage (W). Each stage is completed in one cycle. If an instruction cache miss occurs, four instructions are simultaneously read out of the main memory 2 in two cycles. Any cache miss causes a decode stall (Ds). In the structure mentioned above, the target instructions of Fig. 7 are repeatedly executed due to the jump instruction. In a first execution of the instructions, the instruction cache 1 holds no instructions as shown in Fig. 8. Namely, all instructions are stored in the main memory 2 at this moment, and therefore, a cache miss occurs on every fourth instruction. More precisely, in the first execution, a cache miss occurs at first as shown in Fig. 3, and therefore, four target instructions are transferred from the main memory 2 to the instruction cache 1 and are stored therein. Thereafter, among the four target instructions, three that follow the first one are read out of the instruction cache 1 into the microprocessor, to produce cache hits. The same things happen thereafter. Namely, a cache miss occurs, and three cache hits follow. These are repeated. Any cache-missed instruction is executed in a pipeline of the fetch stage F, decode stall Ds, decode stage D, execution stage E, data cache access stage M, and register write stage W, as shown in Fig. 3. On the other hand, any cache-hit instruction is executed in a pipeline of the fetch stage F, decode stage D, execution stage E, data cache access stage M, and register write stage W, as shown in Fig. 3. In this way, the microprocessor operates along the pipelines shown in Fig. 3. In a second execution of the instructions of Fig. 7, the target instructions are stored in the instruction cache 1 in order of the first execution, as shown in Fig. 9. Then, every target instruction produces a cache hit. Consequently, every target instruction is executed through a pipeline of the fetch stage F, decode stage D, execution stage E, data cache access stage M, and register write stage W. In this case, the microprocessor operates along the pipelines shown in Fig. 4. To find power consumption during the execution of cache-hit instructions, four cycles between the sixth and ninth cycles of the pipelined processing stages of Fig. 4 are extracted. These four cycles correspond to the number of instructions to be simultaneously transferred from the main memory 2 to the instruction cache 1. Hatched stages of Fig. 4 are moved into an upper dotted area of the same figure, to provide a pattern of Fig. 10. It is understood from Fig. 10 that each cycle involves five stages, i.e., the fetch stage F, decode stage D, execution stage E, data cache access stage M, and register write stage W that are required to execute one cache-hit instruction. This means that the extracted four cycles have executed four instructions, or that each cycle has executed one instruction. Finding the power consumption of the microprocessor in any one of the four cycles leads to find the power consumption of the microprocessor on any cache-hit instruction the microprocessor reads out of the instruction cache 1 and executes. On the other hand, to find power consumption in a cache miss state, five cycles are extracted starting from the sixth cycle, as shown in Fig. 3. The five cycles correspond to four instructions to be simultaneously transferred from the main memory 2 to the instruction cache 1 when a cache miss occurs, plus one stall that occurs when simultaneously transferring the four instructions to the instruction cache 1. The sixth cycle is equal to the number of the pipelined processing stages including the decode stall Ds. Hatched stages of Fig. 3 are moved to an upper dotted area of the same figure, to provide a pattern of Fig. 11. The pattern of Fig. 11 involves four sets of the five stages, i.e., the fetch stage F, decode stage D, execution stage E, data cache access stage M, and register write stage W, and one decode stall stage Ds that occurs whenever a cache miss occurs. This means that the extracted five cycles involve one cache miss and three cache hits. Since the power consumption of the microprocessor on each cache-hit instruction is obtainable as mentioned above, the power consumption of the microprocessor on each cache-missed instruction is obtainable by finding the power consumption of the extracted five cycles and by calculating {(the sum of power consumption for the five cycles) - (the power consumption in one cache-hit cycle) x 3}. This technique is applicable to a general case with the number of pipelined processing stages of a microprocessor being P, the number of instructions to be simultaneously transferred from a main memory to an instruction cache under a cache miss state being I, and the total number of stalls that occur when executing the I instructions simultaneously transferred to and stored in the instruction cache being N. Namely, the power consumption of the microprocessor on each cache-hit instruction is obtained as the power consumption of the microprocessor in one cycle on or after the "P+1"th cycle in a second execution of instructions. On the other hand, a cache miss occurs at intervals of I cycles, N stalls occur on a cache miss, and "I-1" cache hits and one cache miss occur in "I+N" cycles starting from the "P+n"th cycle. Therefore, the power consumption of the microprocessor on each cache-missed instruction is obtained by calculating {the sum of power consumption for "I+N" cycles starting from the "P+N"th cycle in a first execution of instructions} - {(the power consumption in a cache-hit cycle) x (I-1)}. To achieve the above-mentioned method, the present invention employs a system for simulating CPU operations at transistor or gate levels. The transistor-level simulations achieve fine operations to improve estimating accuracy, and therefore, take a long simulation time and many resources. On the other hand, the gate-level simulations are effective to carry out large-scale simulations in a short time. These simulations may be achieved with simulators available on the market, for example "Power Mill" of Synopsys Co. Figure 12 shows a system for estimating power consumption according to the present invention. The system consists of a computer 5, a storage unit 7 such as a disk unit, input units 9 such as a mouse and a keyboard, and output units including a monitor 11 and a printer 13. The system incorporates a simulation program for simulating the operations of CPU and memories at transistor or gate levels. The simulation program may be prepared by amending an existing one according to requirements. A string of instructions such as those mentioned above are converted into machine language instructions at first. Instead, machine language instructions may directly be edited, or assembly language instructions are written, assembled, and edited. For example, the processes of Figs. 3 and 4 are written in an assembly language, to provide an infinite loop of Fig. 13. Here, the number of IUEs per loop must be larger than twice the number of instructions to be simultaneously read out of a main memory. When executed, the target instructions cause cache misses as shown in Fig. 3. When a jump instruction is executed to enter a second execution, the target instructions are always fetched from the instruction cache and are again executed as shown in Fig. 4. Although one repetition of the loop is sufficient for measuring power consumption, the infinite loop will cause no problem because it is achieved through simulations. If required, the loop may be terminated by a proper timer interrupt. Thereafter, the machine language instructions are entered into a simulation program, which provides power consumption according to a current passing through each internal node. In this way, the power consumption of a microprocessor in given cycles of executing the instruction file of Fig. 7 is simulated, to find out the power consumption of the microprocessor on each instruction. The instruction file of the present invention used for estimating power consumption is simple and small compared with those of the prior art, and therefore, involves greatly reduced labor and time to prepare. Although the embodiments mentioned above relate to pipelined processing stages for executing instructions, the present invention is also applicable to executing instructions without pipelines. In this case, a target instruction is repeatedly executed at least twice with the use of a repetition instruction such as a jump instruction, to calculate the power consumption of a microprocessor on the instruction in cache miss and cache hit states. This technique is also achievable with a simple instruction file. Namely, this is the simplest form of the present invention. There are only two instructions, the first one being a target instruction and the second one being a jump instruction to jump to the target instruction. These instructions may be written in an assembler language to form an infinite loop of Fig. 14. When executed, the target instruction first causes a cache miss and is executed as shown in Fig. 15. Then, the jump instruction is executed, and the target instruction is fetched from an instruction cache and is again executed. The infinite loop may cause no problem because the loop is achieved in a simulation. The infinite loop may be terminated with a proper timer interrupt. In summary, the present invention repeatedly executes a group of instructions whose power consumption is to be estimated, and finds out the power consumption of each instruction in an instruction cache miss state and in an instruction cache hit state according to power consumption in given cycles. Accordingly, the present invention is capable of simplifying and reducing an instruction file used to find out the power consumption of each instruction, thereby reducing labor and time for preparing the instruction file. Various modifications will become possible for those skilled in the art after receiving the teachings of the present disclosure without departing from the scope thereof.

Claims: A method for estimating the power consumption of a microprocessor (3, 4) when said microprocessor (3, 4) executes through pipelined processing stages (P) a target instruction which the microprocessor (3, 4) reads out of either a main memory (2) or an instruction cache (1), said target instructions being executed in transistor- or gate-level simulation, comprising the steps of: executing at least two consecutive times a sequence of identical target instructions stored in an instruction file, the number of target instructions in said instruction file being at least twice the number I of instructions simultaneously transferred from the main memory (2) to the instruction cache (1), said instruction cache holding no instructions prior to the first time execution of said sequence of target instructions and said instruction cache holding all target instructions in the order of the first time execution of said sequence of target instructions prior to the second time execution of said sequence of target instructions, whereby the first time execution of said sequence of target instructions comprises at least one cache-missed execution of the target instruction and whereby the second time execution of said sequence of target instructions comprises only cache-hit executions of the target instruction; determining the power consumption of the microprocessor for a given number of cycles within the first time execution and the second time execution of the sequence of target instruction; determining the power consumption of the microprocessor for one cache-hit execution of said target instruction as the average consumption over the given number of cycles within the second time execution of the sequence of target instruction; determining the power consumption of the microprocessor for one cache-missed execution of the target instruction by subtracting from the power consumption for said given number of cycles within the first time execution of the sequence of target instructions the power consumption of (I-1) cache-hit executions of the target instruction. The method as claimed in claim 1, wherein the given number of cycles starts from the 'P+N'th cycle in the first execution of the sequence of target instructions, where N is the total number of stalls to occur when executing the I instructions simultaneously transferred to the instruction cache. A system for estimating the power consumption of a microprocessor (3, 4) when said microprocessor (3, 4) executes through pipelined processing stages (P) a target instruction which the microprocessor (3, 4) reads out of either a main memory (2) or an instruction cache (1), said target instructions being executed in transistor- or gate-level simulation, according to the method of claim 1 or 2 comprising: means for entering a string of machine language instructions into said instruction file; means for carrying out transistor- or gate-level simulations to simulate the microprocessor to read the machine language instructions out of either of the main memory or the instruction cache and to execute them; means for determining the power consumption of the microprocessor on a cache-missed execution of an instruction according to the first time execution of the sequence of target instructions; and means for estimating the power consumption of the microprocessor on a cache-hit instruction according to the second time execution of the sequence of target instructions.

Inventors: KAGESHIMA ATSUSHI, KAGESHIMA, ATSUSHI
Applicants: TOSHIBA KK, KABUSHIKI KAISHA TOSHIBA
Application year: 1997
Main classification: G06F11
IPC codes: G06F11, G06F9, G06F1, G06F17, G06F12