JP2011134288A - Code generation device and code generation method - Google Patents

Code generation device and code generation method Download PDF

Info

Publication number
JP2011134288A
JP2011134288A JP2010009269A JP2010009269A JP2011134288A JP 2011134288 A JP2011134288 A JP 2011134288A JP 2010009269 A JP2010009269 A JP 2010009269A JP 2010009269 A JP2010009269 A JP 2010009269A JP 2011134288 A JP2011134288 A JP 2011134288A
Authority
JP
Japan
Prior art keywords
function
code
memory
constant voltage
power supply
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2010009269A
Other languages
Japanese (ja)
Inventor
Toshiki Obara
俊樹 小原
Masahiko Toshi
雅彦 都市
Katsuhiro Yoda
勝洋 依田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2010009269A priority Critical patent/JP2011134288A/en
Publication of JP2011134288A publication Critical patent/JP2011134288A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Power Sources (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a code generation device, capable of generating a program code that fluctuates power supply voltage of a memory at a time considering a voltage fluctuation time. <P>SOLUTION: The code generation device includes: an insert position calculation means which calculates an insert position for inserting a control code to a program code to be written to a memory having a plurality of areas, the control code controlling power source voltage so that the areas are switched in a state where the power source voltage is stabilized; a memory map generation means which generates a memory map based on configuration information of the memory and the insert position; and a code generation means which inserts the control code to the insert position to generate a program code. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

メモリに供給される電源電圧を制御するためのコードが挿入されたプログラムコードを用いてメモリマップを生成するコード生成装置及びコード生成方法に関する。   The present invention relates to a code generation device and a code generation method for generating a memory map using a program code in which a code for controlling a power supply voltage supplied to a memory is inserted.

近年のデジタル回路では、消費電力を削減するための様々な工夫が成されている。例えばデジタル回路の回路動作率の削減、デジタル回路へ供給されるクロックの停止(以下、クロックゲーティング)、クロック周波数の低減、デジタル回路へ供給される電源の遮断(以下、パワーゲーティング)、低電源電圧化等の方法が知られている。   In recent digital circuits, various contrivances have been made to reduce power consumption. For example, reduction of circuit operation rate of digital circuit, stop of clock supplied to digital circuit (hereinafter referred to as clock gating), reduction of clock frequency, interruption of power supplied to digital circuit (hereinafter referred to as power gating), low power supply Methods such as voltage conversion are known.

またデジタル回路に含まれるメモリにおいても、消費電力を削減するために工夫がなされている。例えばメモリでは、メモリアクセスがない場合にクロックを停止させる方法、一定時間以上動作していない場合にメモリに供給される電源電圧を遮断する方法、メモリ供給される電源電圧を低下させる方法等が知られている。   In addition, in a memory included in a digital circuit, a device is devised to reduce power consumption. For example, in the case of a memory, there are known a method of stopping the clock when there is no memory access, a method of cutting off the power supply voltage supplied to the memory when it has not been operated for a certain period of time, and a method of reducing the power supply voltage supplied to the memory. It has been.

メモリの電源電圧を低下させる方法としては、メモリが自律して電源電圧を低下させる方法と、外部のプロセッサ等から指示を受けて電源電圧を低下させる方法とが知られている。メモリの電源電圧を低下させる方法では、デジタル回路での処理の実行状態に合わせてきめ細やかに電源電圧の制御を行った方が電力の削減効果が期待できる。   As a method for reducing the power supply voltage of the memory, a method in which the memory autonomously reduces the power supply voltage and a method in which an instruction is received from an external processor or the like to reduce the power supply voltage are known. In the method of reducing the power supply voltage of the memory, a power reduction effect can be expected when the power supply voltage is finely controlled in accordance with the execution state of the processing in the digital circuit.

特開2000−215100号公報JP 2000-215100 A

しかしながらプログラムには多数の条件分岐が存在する場合が多く、どのタイミングでどのメモリの電源電圧を低下させれば良いか判定するのが困難である。   However, many conditional branches exist in the program, and it is difficult to determine which memory power supply voltage should be reduced at which timing.

またメモリの電源電圧を低下させる場合、電源電圧を変動させるための電圧変動時間が発生する。このため例えば外部から指示によりメモリの電源電圧の制御を行う場合には、電圧変動時間を考慮して電源電圧の変動を指示する必要がある。電圧変動時間は、プロセッサのクロック数にして数十から数百サイクルに相当し、電圧変動時間を考慮して電源電圧を変動させるタイミングを予測するのは極めて困難である。   Further, when the power supply voltage of the memory is lowered, a voltage change time for changing the power supply voltage is generated. Therefore, for example, when the power supply voltage of the memory is controlled by an instruction from the outside, it is necessary to instruct the fluctuation of the power supply voltage in consideration of the voltage fluctuation time. The voltage fluctuation time corresponds to several tens to several hundreds of cycles of the processor clock, and it is extremely difficult to predict the timing of changing the power supply voltage in consideration of the voltage fluctuation time.

よって本発明の目的は、電圧変動時間を考慮したタイミングでメモリの電源電圧を変動させるプログラムコードを生成することが可能なコード生成装置及びコード生成方法を提供することである。   Accordingly, an object of the present invention is to provide a code generation device and a code generation method capable of generating a program code for changing a power supply voltage of a memory at a timing in consideration of a voltage change time.

上記課題を解決するため、複数の領域を有するメモリに書き込まれるプログラムコードに、電源電圧が安定した状態で前記領域を切り替えられるように前記電源電圧を制御する制御コードを挿入する挿入位置を算出する挿入位置算出手段と、前記メモリの構造情報と前記挿入位置とに基づきメモリマップを作成するメモリマップ生成手段と、前記制御コードを前記挿入位置へ挿入してプログラムコードを生成するコード生成手段と、を有する。   In order to solve the above-described problem, an insertion position for inserting a control code for controlling the power supply voltage is calculated so that the area can be switched in a state where the power supply voltage is stable in a program code written in a memory having a plurality of areas. An insertion position calculating means; a memory map generating means for creating a memory map based on the memory structure information and the insertion position; a code generating means for generating a program code by inserting the control code into the insertion position; Have

上記手段を機能としてコンピュータに実行させるためのプログラム、そのプログラムを記憶したコンピュータ読み取り可能な記憶媒体とすることもできる。   A program for causing a computer to execute the above means as a function, or a computer-readable storage medium storing the program may be used.

電圧変動時間を考慮したタイミングでメモリの電源電圧を変動させるプログラムコードを生成することができる。   It is possible to generate a program code for changing the power supply voltage of the memory at a timing in consideration of the voltage change time.

メモリの電源電圧の制御を行うシステムの一例を示す図である。It is a figure which shows an example of the system which controls the power supply voltage of a memory. プログラムコードに含まれる関数の静的なコールグラフとメモリマップとの関係の一例を示す図である。It is a figure which shows an example of the relationship between the static call graph of the function contained in a program code, and a memory map. 本実施形態において生成されたプログラムコードのメモリマップの一例を示す図である。It is a figure which shows an example of the memory map of the program code produced | generated in this embodiment. コード生成装置を説明するための図である。It is a figure for demonstrating a code production | generation apparatus. コード生成装置の動作を説明するフローチャートである。It is a flowchart explaining operation | movement of a code generation apparatus. 関数に分岐がない場合の分割位置の算出を説明するための図である。It is a figure for demonstrating calculation of the division position when there is no branch in a function. 関数に分岐がある場合の分割位置の算出を説明するための図である。It is a figure for demonstrating calculation of the division position when a function has a branch. 図5のステップS51に示すアセンブリコード55の分割位置の算出を説明するフローチャートである。6 is a flowchart illustrating calculation of a division position of an assembly code 55 shown in step S51 of FIG. 図5のステップS52に示すメモリマップの決定を説明するフローチャートである。6 is a flowchart for explaining determination of a memory map shown in step S52 of FIG. 呼出回数情報の一例を示す図である。It is a figure which shows an example of number-of-calls information. 関数サイズ情報の一例を示す図である。It is a figure which shows an example of function size information. メモリユニットの構造情報の一例を示す図である。It is a figure which shows an example of the structure information of a memory unit. ラベル付けの一例を示す図である。It is a figure which shows an example of labeling. メモリ割当を説明する第一のフローチャートである。It is a 1st flowchart explaining memory allocation. メモリ割当を説明する第二のフローチャートである。It is a 2nd flowchart explaining memory allocation. メモリ割当を説明する第三のフローチャートである。It is a 3rd flowchart explaining memory allocation. メモリ割当を説明する第四のフローチャートである。It is a 4th flowchart explaining memory allocation. 図5のステップS53に示す制御コードの挿入を説明する第一のフローチャートである。FIG. 6 is a first flowchart illustrating insertion of a control code shown in step S53 of FIG. 図5のステップS53に示す制御コードの挿入を説明する第二のフローチャートである。It is a 2nd flowchart explaining insertion of the control code shown to step S53 of FIG. 第一の実施形態のコード生成装置により生成された電源制御入りバイナリが実装された半導体集積回路の動作の一例を説明する図である。It is a figure explaining an example of operation | movement of the semiconductor integrated circuit with which the binary with power supply control produced | generated by the code production | generation apparatus of 1st embodiment was mounted. コード生成装置に入力されるアセンブリの一例を示す図である。It is a figure which shows an example of the assembly input into a code generation apparatus. アセンブリに定義されている関数のコールグラフの一例を示す図である。It is a figure which shows an example of the call graph of the function defined in the assembly. 制御コードが挿入された後のアセンブリの一例を示す第一の図である。It is a 1st figure which shows an example of the assembly after the control code is inserted. 制御コードが挿入された後のアセンブリの一例を示す第二の図である。It is a 2nd figure which shows an example of the assembly after the control code is inserted. 割り込み処理を考慮した場合の制御コードの挿入を説明する第一のフローチャートである。It is a 1st flowchart explaining insertion of the control code when an interruption process is considered. コールグラフの一例を示す図である。It is a figure which shows an example of a call graph. 割り込み処理を考慮した場合の制御コードの挿入を説明する第二のフローチャートである。It is a 2nd flowchart explaining insertion of a control code when an interruption process is considered. 関数に割り当てるメモリが複数の場合を説明するための図である。It is a figure for demonstrating the case where the memory allocated to a function is multiple. 関数に割り当てるメモリが複数である場合のメモリ割当を説明するフローチャートである。It is a flowchart explaining memory allocation in case the memory allocated to a function is plurality. 関数に複数のメモリを割り当てられた場合の制御コードの挿入を説明するフローチャートである。It is a flowchart explaining insertion of a control code when a plurality of memories are assigned to a function. 第四の実施形態のコード生成装置の動作を説明するフローチャートである。It is a flowchart explaining operation | movement of the code generation apparatus of 4th embodiment. 図31のステップS3101に示す制御コードの挿入位置の算出を説明するフローチャートである。FIG. 32 is a flowchart for describing calculation of a control code insertion position shown in step S3101 of FIG. 31. FIG. 図32のステップS3208に示す制御コードの挿入位置の算出を説明するフローチャートである。FIG. 33 is a flowchart for describing calculation of a control code insertion position shown in step S3208 of FIG. 32. FIG. 図31のステップS3102に示すメモリマップの決定を説明するフローチャートである。FIG. 32 is a flowchart describing determination of a memory map shown in step S3102 of FIG. 31. FIG. 図31のステップS3103に示す制御コードの挿入を説明する第一のフローチャートである。FIG. 32 is a first flowchart illustrating control code insertion shown in step S3103 of FIG. 31. FIG. 図31のステップS3103に示す制御コードの挿入を説明する第二のフローチャートである。FIG. 32 is a second flowchart illustrating control code insertion shown in step S3103 of FIG. 31. FIG. 第四の実施形態のコード生成装置により生成された電源制御入りバイナリが実装された半導体集積回路の動作の一例を説明する図である。It is a figure explaining an example of operation | movement of the semiconductor integrated circuit with which the binary with power supply control produced | generated by the code production | generation apparatus of 4th Embodiment was mounted. 第五の実施形態の前提を説明するための図である。It is a figure for demonstrating the premise of 5th embodiment. 第五の実施形態のコード生成装置の機能構成を説明する図である。It is a figure explaining the function structure of the code generation apparatus of 5th embodiment. 第五の実施形態におけるメモリマップ情報の一例を示す図である。It is a figure which shows an example of the memory map information in 5th embodiment. 第五の実施形態のコード生成装置による制御コードの挿入を説明するフローチャートである。It is a flowchart explaining insertion of the control code by the code generation device of the fifth embodiment. スリープ解除コード挿入処理部とスリープコード挿入処理部の処理を説明する図である。It is a figure explaining the process of a sleep release code insertion process part and a sleep code insertion process part. 関数funcXがメイン関数funcMの場合を示す図である。It is a figure which shows the case where the function funcX is the main function funcM. 関数funcXが関数funcB1の場合を示す図である。It is a figure which shows the case where the function funxX is the function funcB1. 関数funcXが関数funcD2の場合を示す図である。It is a figure which shows the case where the function funcX is the function funcD2. 関数funcXが関数funcC3の場合を示す図である。It is a figure which shows the case where the function funcX is the function funcC3. 第六の実施形態の前提を説明するための図であるIt is a figure for demonstrating the premise of 6th embodiment. 第六の実施形態のコード生成装置の機能構成を説明する図である。It is a figure explaining the function structure of the code generation apparatus of 6th embodiment. 第六の実施形態のコード生成装置による制御コードの挿入を説明するフローチャートである。It is a flowchart explaining insertion of the control code by the code generator of 6th Embodiment. 第六の実施形態のスリープ可能表作成部によるテーブルの作成を説明するフローチャートである。It is a flowchart explaining preparation of the table by the sleep possible table preparation part of 6th Embodiment. 第七の実施形態のコード生成装置の動作を説明するフローチャートである。It is a flowchart explaining operation | movement of the code generation apparatus of 7th embodiment. 第七の実施形態におけるメモリマップの決定を説明する図である。It is a figure explaining the determination of the memory map in 7th embodiment. 関数間の呼出頻度情報の一例を示す図である。It is a figure which shows an example of the call frequency information between functions. 関数群のコード量の計算の一例を示す図である。It is a figure which shows an example of calculation of the code amount of a function group. 第七の実施形態の呼出頻度算出部の処理を説明するフローチャートである。It is a flowchart explaining the process of the calling frequency calculation part of 7th Embodiment. 呼出頻度テーブルの一例を示す図である。It is a figure which shows an example of a calling frequency table. 第七の実施形態の使用時一定電圧メモリ割当部の処理を説明するフローチャートである。It is a flowchart explaining the process of the constant voltage memory allocation part at the time of use of 7th Embodiment. 使用時一定電圧メモリのサイズ情報の一例を示す図である。It is a figure which shows an example of the size information of a fixed voltage memory at the time of use. 使用時一定電圧メモリの割り当て結果の一例を示す図である。It is a figure which shows an example of the allocation result of the fixed voltage memory at the time of use.

以下、本発明の実施形態を図面に基づいて説明する。始めに図1乃至図3を参照して本実施形態の概念について説明する。   Hereinafter, embodiments of the present invention will be described with reference to the drawings. First, the concept of the present embodiment will be described with reference to FIGS.

図1は、メモリの電源電圧の制御を行うシステムの一例を示す図である。図1に示すシステムは、メモリユニット10と、プロセッサ20と、レジスタ30とを含む。メモリユニット10とプロセッサ20とレジスタ30とは、それぞれがバス40で接続されている。   FIG. 1 is a diagram illustrating an example of a system that controls a power supply voltage of a memory. The system shown in FIG. 1 includes a memory unit 10, a processor 20, and a register 30. The memory unit 10, the processor 20, and the register 30 are connected by a bus 40.

メモリユニット10は、例えばSRAM(Static Random Access Memory)であり、電源電圧を低下させた状態で書き込まれた内容を保持することができる。メモリユニット10は、複数の領域であるメモリA〜メモリEを含む。メモリA〜メモリEは、それぞれが別々のメモリであっても良いし、1つのメモリが複数の領域に分割されたメモリ領域であっても良い。メモリA〜メモリEは、命令用メモリとデータ用メモリとに分けて使用することができ、それぞれに電源電圧を供給する電源線41が電源電圧を変動させる電圧変換器42を介して接続されている。プロセッサ20は、メモリA〜E毎に電源電圧の切り替えをレジスタ30へ設定し、電圧変換器42はレジスタ30の設定値に応じてメモリA〜メモリEの電源電圧を変動させる。   The memory unit 10 is, for example, an SRAM (Static Random Access Memory), and can hold contents written with the power supply voltage lowered. The memory unit 10 includes a memory A to a memory E that are a plurality of areas. Each of the memories A to E may be a separate memory, or may be a memory area in which one memory is divided into a plurality of areas. The memories A to E can be used separately as an instruction memory and a data memory, and a power supply line 41 that supplies a power supply voltage to each is connected via a voltage converter 42 that varies the power supply voltage. Yes. The processor 20 sets the switching of the power supply voltage for each of the memories A to E in the register 30, and the voltage converter 42 varies the power supply voltage of the memories A to E according to the set value of the register 30.

本実施形態では、プログラムコードに含まれる関数単位でメモリA〜メモリEの電源電圧の変動の制御を完結できるように、プログラムコードに電源電圧を制御するための制御コードを挿入する。   In the present embodiment, a control code for controlling the power supply voltage is inserted into the program code so that the control of fluctuations in the power supply voltage of the memories A to E can be completed in units of functions included in the program code.

図2は、プログラムコードに含まれる関数の静的なコールグラフとメモリマップとの関係の一例を示す図である。   FIG. 2 is a diagram illustrating an example of a relationship between a static call graph of a function included in a program code and a memory map.

本実施形態では、メモリユニット10において、一定の電源電圧が供給された状態である一定電圧状態とされるメモリ(以下、常時一定電圧メモリ)と、使用されないときは電源電圧が低電圧とされる低電圧状態とされるメモリ(以下、使用時一定電圧メモリ)とを設ける。尚低電圧は、一定電圧よりも低い電圧である。尚使用時一定電圧メモリは、低電圧状態であってもメモリに書き込まれた内容を保持できる。   In the present embodiment, in the memory unit 10, a memory that is in a constant voltage state (hereinafter referred to as a constant voltage memory) that is supplied with a constant power supply voltage, and a power supply voltage that is low when not in use. A memory that is in a low voltage state (hereinafter, a constant voltage memory when used) is provided. The low voltage is a voltage lower than a constant voltage. The constant voltage memory in use can hold the contents written in the memory even in a low voltage state.

本実施形態では、長時間実行されることが予測される関数は、常時一定電圧メモリへ配置される。長時間実行されることが予測される関数とは、関数の呼出階層が上位のメイン関数等である。またメイン関数等に呼び出される関数は、前半部分(以下、一定電圧部)と後半部分(以下、低電圧部)に分割される。関数の一定電圧部のコードは常時一定電圧メモリへ配置される。   In this embodiment, a function that is predicted to be executed for a long time is always placed in a constant voltage memory. A function that is predicted to be executed for a long time is a main function or the like whose function call hierarchy is higher. A function called by the main function or the like is divided into a first half part (hereinafter, a constant voltage part) and a second half part (hereinafter, a low voltage part). The code of the constant voltage part of the function is always placed in the constant voltage memory.

図2の例では、メモリAは常時一定電圧メモリであり、メイン関数funcMが配置されている。またメモリAには、メイン関数funcMに呼び出される関数func1と関数func2の一定電圧部Z1、Z2が配置されている。またメモリAには、関数func1、関数func2に呼び出されるその他の関数func3が配置されている。メモリB、メモリCは、使用時一定電圧メモリであり、関数func1と関数func2の低電圧部K1、K2が配置されている。   In the example of FIG. 2, the memory A is always a constant voltage memory, and a main function funcM is arranged. In the memory A, function func1 called by the main function funcM and constant voltage parts Z1 and Z2 of the function func2 are arranged. In the memory A, another function func3 called by the function func1 and the function func2 is arranged. The memory B and the memory C are constant voltage memories in use, and low voltage portions K1 and K2 of the functions func1 and function func2 are arranged.

本実施形態では、関数func1と関数func2を分割する際に、関数func1、関数func2において電圧変動時間内に実行可能なコードまでを一定電圧部Z1、Z2としてメモリAへ配置し、それ以降のコードを低電圧部K1、K2としてメモリB、メモリCへ配置する。そして関数func1、関数func2の先頭部分へメモリB、メモリCを一定電圧状態にするコードを挿入してプログラムコードを生成する。   In the present embodiment, when the function func1 and the function func2 are divided, the codes that can be executed within the voltage fluctuation time in the functions func1 and func2 are arranged in the memory A as constant voltage parts Z1 and Z2, and the subsequent codes Are arranged in the memory B and the memory C as the low voltage parts K1 and K2. Then, a program code is generated by inserting a code for setting the memory B and the memory C into a constant voltage state at the beginning of the functions func1 and func2.

本実施形態の電圧変動時間とは、電源電圧が一定電圧から低電圧になるまでにかかる時間、又は低電圧から一定電圧になるまでにかかる時間である。   The voltage fluctuation time in the present embodiment is the time taken for the power supply voltage to change from a constant voltage to a low voltage, or the time taken for the power supply voltage to change from a low voltage to a constant voltage.

本実施形態により生成されたプログラムコードは、例えばLSI(Large Scale Integration)等のメモリに書き込まれる。本実施形態により生成されたプログラムコードが書き込まれたLSIでは、電圧変動時間を考慮したタイミングでメモリの電源電圧を変動させる制御を実現することができ、電圧変動時間を吸収することができる。尚関数の分割とコードの挿入の詳細は後述する。   The program code generated according to the present embodiment is written in a memory such as an LSI (Large Scale Integration). In the LSI in which the program code generated according to the present embodiment is written, it is possible to realize a control for changing the power supply voltage of the memory at a timing considering the voltage change time, and to absorb the voltage change time. Details of function division and code insertion will be described later.

本実施形態により生成されたプログラムコードでは、例えば関数func1の一定電圧部Z1の先頭に、使用時一定電圧メモリであるメモリBを一定電圧状態とするための制御コードが挿入されている。よって関数func1の一定電圧部Z1の実行が終了して低電圧部Z2を実行するためのメモリをメモリAからメモリBへ切り替えたとき、メモリBは一定電圧状態となっている。よって本実施形態では、電源電圧がメモリへ安定して供給された状態でメモリの切り替えを行うことができる。   In the program code generated according to the present embodiment, for example, a control code for putting the memory B, which is a constant voltage memory in use, into a constant voltage state is inserted at the head of the constant voltage unit Z1 of the function func1. Therefore, when the execution of the constant voltage unit Z1 of the function func1 is completed and the memory for executing the low voltage unit Z2 is switched from the memory A to the memory B, the memory B is in a constant voltage state. Therefore, in this embodiment, the memory can be switched in a state where the power supply voltage is stably supplied to the memory.

図3は、本実施形態において生成されたプログラムコードのメモリマップの一例を示す図である。   FIG. 3 is a diagram illustrating an example of a memory map of program codes generated in the present embodiment.

メモリユニット10において、開始アドレスが0x0000であり終了アドレスが0x0fffのメモリAには、メイン関数funcM、メモリBを一定電圧状態とする電源制御コード、関数func1の一定電圧部Z1、メモリCを一定電圧状態とする電源制御コード、関数func2の一定電圧部Z2、その他の関数func3が配置される。開始アドレスが0x1000であり終了アドレスが0x1ffffのメモリBには、図2に示していない他の関数と、関数func1の低電圧部K1が配置される。開始アドレスが0x2000であり終了アドレスが0x2ffffのメモリCには、図2に示していない他の関数と、関数func2の低電圧部K2が配置される。   In the memory unit 10, the memory A having a start address of 0x0000 and an end address of 0x0fff has a main function funcM, a power supply control code for setting the memory B in a constant voltage state, a constant voltage unit Z1 of the function func1, and a memory C having a constant voltage. A power supply control code to be set, a constant voltage portion Z2 of the function func2, and other functions func3 are arranged. In the memory B whose start address is 0x1000 and end address is 0x1ffff, other functions not shown in FIG. 2 and the low voltage part K1 of the function func1 are arranged. In the memory C having a start address of 0x2000 and an end address of 0x2ffff, another function not shown in FIG. 2 and a low voltage part K2 of the function func2 are arranged.

図3に示すメモリマップにしたがってプログラムコードを実装すれば、電圧変動時間を考慮したタイミングでメモリB、メモリCの電源電圧を制御することができる。よってメモリB、メモリCを適切なタイミングで低電圧状態から一定電圧状態へ移行させることができる。   If the program code is implemented according to the memory map shown in FIG. 3, the power supply voltages of the memory B and the memory C can be controlled at a timing in consideration of the voltage variation time. Therefore, the memory B and the memory C can be shifted from the low voltage state to the constant voltage state at an appropriate timing.

(第一の実施形態)
以下に、図面を参照して本発明の第一の実施形態について説明する。始めに、プログラムコードを生成する第一の実施形態のコード生成装置について説明する。
(First embodiment)
Hereinafter, a first embodiment of the present invention will be described with reference to the drawings. First, the code generation apparatus according to the first embodiment for generating a program code will be described.

図4は、コード生成装置を説明するための図である。本実施形態のコード生成装置100は、プログラムコードであるアセンブリ50と後述するパラメータ60とが入力されると、アセンブリ50にメモリユニット10に供給される電源電圧を制御するための制御コードを挿入し、制御コードが挿入されたアセンブリ50をアセンブル及びリンケージして、電源制御入りバイナリ70を生成して出力する。   FIG. 4 is a diagram for explaining the code generation device. The code generation device 100 according to the present embodiment inserts a control code for controlling a power supply voltage supplied to the memory unit 10 into the assembly 50 when an assembly 50 as a program code and a parameter 60 described later are input. The assembly 50 in which the control code is inserted is assembled and linked to generate and output a binary 70 with power supply control.

本実施形態のコード生成装置100は、それぞれバスBで相互に接続されている入力装置101、出力装置102、ドライブ装置103、補助記憶装置104、メモリ装置105、演算処理装置106及びインターフェース装置107で構成される。   The code generation device 100 according to the present embodiment includes an input device 101, an output device 102, a drive device 103, an auxiliary storage device 104, a memory device 105, an arithmetic processing device 106, and an interface device 107, which are mutually connected by a bus B. Composed.

入力装置101はキーボードやマウスなどで構成され、各種信号を入力するために用いられる。出力装置102はディスプレイ装置などで構成され、各種ウインドウやデータ等を表示するために用いられる。インターフェース装置107は、モデム、LANカードなどで構成されており、ネットワークに接続する為に用いられる。   The input device 101 includes a keyboard and a mouse, and is used to input various signals. The output device 102 includes a display device and is used to display various windows and data. The interface device 107 includes a modem, a LAN card, and the like, and is used for connecting to a network.

本実施形態のコード生成プログラムは、コード生成装置100を制御する各種プログラムの少なくとも一部である。コード生成プログラムは例えば記録媒体108の配布やネットワークからのダウンロードなどによって提供される。コード生成プログラムを記録した記録媒体108は、CD−ROM、フレキシブルディスク、光磁気ディスク等の様に情報を光学的、電気的或いは磁気的に記録する記録媒体、ROM、フラッシュメモリ等の様に情報を電気的に記録する半導体メモリ等、様々なタイプの記録媒体を用いることができる。   The code generation program of this embodiment is at least a part of various programs that control the code generation device 100. The code generation program is provided by, for example, distribution of the recording medium 108 or downloading from a network. The recording medium 108 on which the code generation program is recorded is information such as a CD-ROM, a flexible disk, a magneto-optical disk, etc., a recording medium for recording information optically, electrically, or magnetically, a ROM, a flash memory, etc. Various types of recording media, such as a semiconductor memory that electrically records data, can be used.

また、コード生成プログラムを記録した記録媒体108がドライブ装置103にセットされると、コード生成プログラムは記録媒体108からドライブ装置103を介して補助記憶装置104にインストールされる。ネットワークからダウンロードされたコード生成プログラムは、インターフェース装置107を介して補助記憶装置104にインストールされる。   When the recording medium 108 on which the code generation program is recorded is set in the drive device 103, the code generation program is installed from the recording medium 108 to the auxiliary storage device 104 via the drive device 103. The code generation program downloaded from the network is installed in the auxiliary storage device 104 via the interface device 107.

補助記憶装置104は、インストールされたコード生成プログラムを格納すると共に、必要なファイル、データ等を格納する。補助記憶装置104には、例えばアセンブリ50とパラメータ60とが格納されても良い。メモリ装置105は、コンピュータの起動時に補助記憶装置104からコード生成プログラムを読み出して格納する。そして、演算処理装置106はメモリ装置105に格納されたコード生成プログラムに従って、後述するような各種処理を実現している。   The auxiliary storage device 104 stores the installed code generation program and also stores necessary files, data, and the like. For example, the assembly 50 and the parameter 60 may be stored in the auxiliary storage device 104. The memory device 105 reads and stores the code generation program from the auxiliary storage device 104 when the computer is activated. The arithmetic processing unit 106 implements various processes as described later according to the code generation program stored in the memory device 105.

本実施形態のアセンブリ50には、関数毎のアセンブリコード55が含まれる。また本実施形態のパラメータ60には、サイクル数N、メモリユニット10の構造情報62、制御コードパターン63が含まれる。サイクル数Nは、アセンブリ50に記述された一命令を一サイクルとして予め設定された値である。本実施形態のサイクル数Nは、サイクル数N分の命令を実行するのにかかる時間がメモリユニット10への電源電圧の電圧変動時間に相当するように設定されている。   The assembly 50 of this embodiment includes assembly code 55 for each function. Further, the parameter 60 of the present embodiment includes the number of cycles N, the structure information 62 of the memory unit 10, and the control code pattern 63. The number of cycles N is a value set in advance with one instruction described in the assembly 50 as one cycle. The number of cycles N in this embodiment is set so that the time taken to execute instructions for the number of cycles N corresponds to the voltage fluctuation time of the power supply voltage to the memory unit 10.

メモリユニット10の構造情報62は、メモリユニット10の有するメモリA〜メモリEにおけるそれぞれの開始アドレスと終了アドレスを示す。制御コードパターン63とは、メモリA〜メモリEへの電源電圧の制御を行うための制御コードのパターンである。制御コードパターン63は、制御コードパターン63に含まれる特定のパラメータを決定することで制御コードが決定される。制御コードパターン63には、例えばメモリA〜メモリEを一定電圧状態から低電圧状態へ又は低電圧状態から一定電圧状態へ変化させる電源制御コードパターン64、分割位置から分割された先へジャンプさせるジャンプ制御コードパターン65(図9参照)が含まれる。   The structure information 62 of the memory unit 10 indicates respective start addresses and end addresses in the memories A to E included in the memory unit 10. The control code pattern 63 is a control code pattern for controlling the power supply voltage to the memories A to E. The control code pattern 63 is determined by determining a specific parameter included in the control code pattern 63. The control code pattern 63 includes, for example, a power control code pattern 64 for changing the memory A to the memory E from a constant voltage state to a low voltage state or from a low voltage state to a constant voltage state, a jump for jumping from a divided position to a divided point A control code pattern 65 (see FIG. 9) is included.

以下に図5を参照して本実施形態のコード生成装置100の動作を説明する。図5は、コード生成装置の動作を説明するフローチャートである。尚図5で説明する各ステップの処理の詳細は後述する。   The operation of the code generation device 100 of this embodiment will be described below with reference to FIG. FIG. 5 is a flowchart for explaining the operation of the code generation device. Details of the processing of each step described in FIG. 5 will be described later.

本実施形態のコード生成装置100において、アセンブリ50とパラメータ60に含まれるサイクル数Nとが入力されると、コード生成装置100は、関数毎のアセンブリコード55の分割位置を算出する(ステップS51)。尚本実施形態では、ステップS51で算出された分割位置が制御コードが挿入される挿入位置である。   In the code generation device 100 of the present embodiment, when the assembly 50 and the number of cycles N included in the parameter 60 are input, the code generation device 100 calculates the division position of the assembly code 55 for each function (step S51). . In the present embodiment, the division position calculated in step S51 is the insertion position where the control code is inserted.

ステップS51においてアセンブリコード55の分割位置が算出されると、コード生成装置100は、分割位置とパラメータ60に含まれるメモリユニット10の構造情報62とに基づき分割されたアセンブリコード55を配置するためのメモリマップを決定する(ステップS52)。   When the division position of the assembly code 55 is calculated in step S51, the code generation device 100 arranges the assembly code 55 divided based on the division position and the structure information 62 of the memory unit 10 included in the parameter 60. A memory map is determined (step S52).

メモリマップが生成されると、コード生成装置100はパラメータ60に含まれる制御コードパターン63に代入するパラメータを決定して制御コードを生成し、アセンブリコード55の分割位置に制御コードを挿入する(ステップS53)。制御コードが挿入されたアセンブリ50をアセンブリ50Aとする。コード生成装置100は、制御コードが挿入されたアセンブリコード55を含むアセンブリ50Aをアセンブル及びリンケージして(ステップS54)、制御コードが含まれる電源制御入りバイナリ70を出力してコード生成を完了する。   When the memory map is generated, the code generation device 100 determines a parameter to be substituted for the control code pattern 63 included in the parameter 60, generates a control code, and inserts the control code at the division position of the assembly code 55 (step). S53). Assume that the assembly 50 into which the control code is inserted is an assembly 50A. The code generation apparatus 100 assembles and links the assembly 50A including the assembly code 55 into which the control code is inserted (step S54), and outputs the power-controlled binary 70 including the control code to complete the code generation.

本実施形態のコード生成装置100から出力された電源制御入りバイナリ70は、記録媒体108とは別の記録媒体に記録されても良い。   The binary 70 with power control output from the code generation apparatus 100 of the present embodiment may be recorded on a recording medium different from the recording medium 108.

次に、図6乃至図8を参照して本実施形態における関数の分割位置の算出について説明する。   Next, the calculation of the function division position in the present embodiment will be described with reference to FIGS.

本実施形態のコード生成装置100では、予め所定のサイクル数Nが設定されている。本実施形態では、一命令を実行するサイクルを一サイクルとしている。また本実施形態でのサイクル数Nは、Nサイクル分命令を実行するのにかかる時間が電圧変動時間に相当するように設定されている。   In the code generation device 100 of the present embodiment, a predetermined number of cycles N is set in advance. In this embodiment, a cycle for executing one instruction is defined as one cycle. The number of cycles N in this embodiment is set so that the time taken to execute instructions for N cycles corresponds to the voltage fluctuation time.

コード生成装置100は、アセンブリ50に含まれるアセンブリコード55においてサイクル数Nで到達し得る最も遠いアドレスを分割位置として算出する。そしてコード生成装置100は、アセンブリコード55においてNサイクル内に実行可能な命令までを一定電圧部とし、Nサイクル内では到達しない命令を低電圧部として、アセンブリコード55を分割する。   The code generation device 100 calculates the farthest address that can be reached in the number of cycles N in the assembly code 55 included in the assembly 50 as a division position. Then, the code generation device 100 divides the assembly code 55 by using the assembly code 55 as a constant voltage part up to an instruction that can be executed in the N cycle, and using an instruction that does not reach within the N cycle as a low voltage part.

尚本実施形態のコード生成装置100では、メイン関数等のように長時間実行されることが予測される関数は、予め分割しないように設定されていても良い。   In the code generation device 100 of this embodiment, a function that is predicted to be executed for a long time, such as a main function, may be set not to be divided in advance.

図6は、関数に分岐がない場合の分割位置の算出を説明するための図である。図6(A)は命令のフローを示し、図6(B)は分割の例を示す図である。   FIG. 6 is a diagram for explaining the calculation of the division position when there is no branch in the function. FIG. 6A shows an instruction flow, and FIG. 6B shows an example of division.

アセンブリ50に含まれる関数func1を例として説明する。図6(A)に示すように、関数func1の処理フローに条件分岐がない場合、命令のフローは直鎖状のフローとなる。よってNサイクルとは単純にN番目の命令のアドレスが、サイクル数Nで到達し得る最も遠いアドレス(以下、最遠アドレス)となる。   The function func1 included in the assembly 50 will be described as an example. As shown in FIG. 6A, when there is no conditional branch in the processing flow of the function func1, the instruction flow is a linear flow. Therefore, the N cycle simply means that the address of the Nth instruction is the farthest address that can be reached in the cycle number N (hereinafter, the farthest address).

コード生成装置100は、図6(B)の例1に示すように、関数func1のアセンブリコード55の開始アドレスから最遠アドレスまでを一定電圧部Z1とし、最遠アドレスから関数func1のアセンブリコード55の終了アドレスまでを低電圧部K1とするように関数func1のアセンブリコード55を分割する。よって本実施形態では、最遠アドレスがコード生成装置100により算出される分割位置となる。   As shown in Example 1 of FIG. 6B, the code generation device 100 sets the constant voltage portion Z1 from the start address to the farthest address of the assembly code 55 of the function func1, and the assembly code 55 of the function func1 from the farthest address. The assembly code 55 of the function func1 is divided so that the low-voltage part K1 is reached up to the end address of. Therefore, in the present embodiment, the farthest address is a division position calculated by the code generation device 100.

また図6(B)の例2に示すように、開始アドレスから終了アドレスまでがNサイクル内に実行可能な関数func3の場合は、分割せずに関数func3のアセンブリコード55を常時一定電圧メモリへ配置する。   As shown in Example 2 of FIG. 6B, when the function func3 is executable from the start address to the end address within N cycles, the assembly code 55 of the function func3 is always transferred to the constant voltage memory without being divided. Deploy.

図7は、関数に分岐がある場合の分割位置の算出を説明するための図である。図7(A)は命令のフローを示し、図7(B)は分割の例を示す図である。   FIG. 7 is a diagram for explaining the calculation of the division position when there is a branch in the function. FIG. 7A shows the instruction flow, and FIG. 7B shows an example of division.

関数に分岐がある場合にコード生成装置100は、Nサイクル内の命令を辿った際に、分岐点を通過して到達し得る最も遠いアドレスを最遠アドレスとする。   When there is a branch in the function, the code generation device 100 sets the farthest address that can be reached through the branch point when the instruction in N cycles is traced.

関数func1が図7(A)に示す分岐を有する関数であった場合、分岐点1を通過した後の命令のフローは、経路1と経路2とに別れる。関数func1が図7(B)に示すようなコードであった場合、分岐点1からn3サイクルへ進む経路2の方が、Nサイクル内に関数func1のアセンブリコード55の開始アドレスから離れたアドレスへ到達できる。よってコード生成装置100は、経路2においてNサイクル内に到達し得る最も遠いアドレスを最遠アドレス(分割位置)として算出する。そしてコード生成装置100は、関数func1のアセンブリコード55の開始アドレスから最遠アドレスまでを一定電圧部Z1とし、最遠アドレスから関数func1のアセンブリコード55の終了アドレスまでを低電圧部K1として分割する。   When the function func1 is a function having a branch shown in FIG. 7A, the instruction flow after passing through the branch point 1 is divided into a path 1 and a path 2. When the function func1 is a code as shown in FIG. 7B, the path 2 going from the branch point 1 to the n3 cycle is to an address away from the start address of the assembly code 55 of the function func1 within N cycles. Can reach. Therefore, the code generation device 100 calculates the farthest address that can reach the N cycle in the path 2 as the farthest address (division position). Then, the code generation device 100 divides the range from the start address of the assembly code 55 of the function func1 to the farthest address as a constant voltage unit Z1, and the range from the farthest address to the end address of the assembly code 55 of the function func1 as a low voltage unit K1. .

図8は、図5のステップS51に示すアセンブリコード55の分割位置の算出を説明するフローチャートである。尚、図8で説明する処理は、アセンブリ50に含まれる関数毎のアセンブリコード55に対して実行する。   FIG. 8 is a flowchart for explaining the calculation of the division position of the assembly code 55 shown in step S51 of FIG. The process described with reference to FIG. 8 is executed on the assembly code 55 for each function included in the assembly 50.

本実施形態のコード生成装置100は、アセンブリ50とパラメータ60に含まれるサイクル数Nが入力されると、関数の開始命令ノードと、サイクル数=0とを積んだ状態で作業用キューを初期化する(ステップS801)。   When the number of cycles N included in the assembly 50 and the parameter 60 is input, the code generation apparatus 100 according to the present embodiment initializes the work queue in a state where the start instruction node of the function and the number of cycles = 0 are stacked. (Step S801).

次にコード生成装置100は、キューから命令ノードとサイクル数とを取り出す(ステップS802)。そしてコード生成装置100は、キューから取り出した命令ノードがリターン命令であるか、又はサイクル数がNより大きくなったか否かを判断する(ステップS803)。ステップS803において、キューから取り出した命令ノードがリターン命令でなく、且つサイクル数がNより大きくない場合、コード生成装置100はステップS804へ進む。ステップS803において、キューから取り出した命令ノードがリターン命令である場合、又はサイクル数がNより大きい場合、コード生成装置100は後述するステップS807以降の処理を行う。   Next, the code generation device 100 extracts the instruction node and the cycle number from the queue (step S802). Then, the code generation device 100 determines whether the instruction node fetched from the queue is a return instruction or whether the number of cycles is greater than N (step S803). In step S803, if the instruction node fetched from the queue is not a return instruction and the number of cycles is not greater than N, the code generating apparatus 100 proceeds to step S804. In step S803, if the instruction node fetched from the queue is a return instruction, or if the number of cycles is greater than N, the code generation device 100 performs the processing in step S807 and later described later.

ステップS804において、コード生成装置100は、キューから取り出された命令ノードが条件分岐命令であるか否かを判断する。ステップS804において条件分岐命令である場合、コード生成装置100はステップS805へ進む。ステップS805において、コード生成装置100は、分岐先の命令ノードを求めてキューへ積む。ステップS804において条件分岐命令でない場合、コード生成装置100はステップS806へ進む。ステップS806においてコード生成装置100は、条件分岐命令の次の命令ノードをキューへ積む。   In step S804, the code generation device 100 determines whether the instruction node fetched from the queue is a conditional branch instruction. If the instruction is a conditional branch instruction in step S804, the code generating apparatus 100 proceeds to step S805. In step S805, the code generation device 100 obtains a branch destination instruction node and loads the instruction node on the queue. If it is not a conditional branch instruction in step S804, the code generation device 100 proceeds to step S806. In step S806, the code generation device 100 loads the instruction node next to the conditional branch instruction on the queue.

続いてコード生成装置100は、命令ノードの現アドレスが最遠アドレスよりもアセンブリコード55の開始アドレスから遠いアドレスか否かを判断する(ステップS807)。尚ステップS807で現アドレスと比較される最遠アドレスには、予め初期値が設定された仮の最遠アドレスとした。また命令ノードの現アドレスとは、最後のキューに積まれた命令ノードのアドレスである。   Subsequently, the code generation device 100 determines whether or not the current address of the instruction node is an address farther from the start address of the assembly code 55 than the farthest address (step S807). The farthest address to be compared with the current address in step S807 is a temporary farthest address having an initial value set in advance. The current address of the instruction node is the address of the instruction node loaded in the last queue.

ステップS807で現アドレスの方が、仮の最遠アドレスよりもアセンブリコード55の開始アドレスから遠いアドレスであった場合ステップS808へ進む。ステップS808においてコード生成装置100は、現アドレスを仮の最遠アドレスへ代入し、現アドレスを最遠アドレスに決定する。   If it is determined in step S807 that the current address is farther from the start address of the assembly code 55 than the temporary farthest address, the process proceeds to step S808. In step S808, the code generation device 100 substitutes the current address for the temporary farthest address, and determines the current address as the farthest address.

ステップS807において現アドレスの方が、仮の最遠アドレスよりもアセンブリコード55の開始アドレスから近いアドレスであった場合ステップS809へ進む。ステップS809においてコード生成装置100は、キューが空か否かを判断し、キューが空でない場合にはステップS803以降の処理を繰り返す。   If the current address is closer to the start address of the assembly code 55 than the temporary farthest address in step S807, the process proceeds to step S809. In step S809, the code generation device 100 determines whether or not the queue is empty. If the queue is not empty, the code generation device 100 repeats the processes in and after step S803.

ステップS809においてキューが空であった場合、コード生成装置100は、ステップS810へ進み、最遠アドレスをアセンブリコード55の分割位置に決定し、アセンブリコード55の開始アドレスから最遠アドレスまでのコード長を一定電圧部、最遠アドレスからアセンブリコード55の終了アドレスまでのコード長を低電圧部として分割位置の算出を終了する。尚アセンブリコード55の一定電圧部は常時一定電圧メモリへ配置されるコードであり、アセンブリコード55の低電圧部は使用時一定電圧メモリへ配置されるコードである。   If the queue is empty in step S809, the code generation device 100 proceeds to step S810, determines the farthest address as the division position of the assembly code 55, and the code length from the start address of the assembly code 55 to the farthest address. Is a constant voltage portion, and the code length from the farthest address to the end address of the assembly code 55 is the low voltage portion, and the calculation of the division position is completed. The constant voltage portion of the assembly code 55 is a code that is always placed in the constant voltage memory, and the low voltage portion of the assembly code 55 is a cord that is placed in the constant voltage memory when in use.

尚本実施形態では、一命令を実行するサイクルを一サイクルとしてサイクル数を取り出しているが、これに限定されない。例えばコード生成装置100は、命令コードとサイクル数とが対応付けられたテーブルを保持しており、命令コード毎にテーブルを参照してサイクル数を取り出しても良い。   In the present embodiment, the number of cycles is extracted with a cycle for executing one instruction as one cycle, but the present invention is not limited to this. For example, the code generation device 100 may hold a table in which instruction codes are associated with the number of cycles, and may retrieve the number of cycles by referring to the table for each instruction code.

次に、図9を参照してコード生成装置100におけるメモリマップの決定について説明する。図9は、図5のステップS52に示すメモリマップの決定を説明するフローチャートである。   Next, determination of a memory map in the code generation device 100 will be described with reference to FIG. FIG. 9 is a flowchart illustrating the determination of the memory map shown in step S52 of FIG.

コード生成装置100は、関数毎のアセンブリコード55を参照して低電圧部を有する関数を呼び出している回数を呼出回数情報として抽出する(ステップS901)。図10に、呼出回数情報の一例を示す。図10に示す呼出回数情報51では、低電圧部を有する関数を呼び出している関数として関数func1、関数func2が抽出されている。呼出回数情報51は、関数名と、関数毎の一定電圧部において低電圧部を有する関数を呼び出している回数、低電圧部において低電圧部を有する関数を呼び出している回数とが対応付けられた情報である。   The code generation device 100 refers to the assembly code 55 for each function and extracts the number of times the function having the low voltage unit is called as the number of calls information (step S901). FIG. 10 shows an example of the call count information. In the call count information 51 shown in FIG. 10, functions func1 and func2 are extracted as functions that call a function having a low voltage part. The number-of-calls information 51 associates a function name with the number of times a function having a low-voltage part is called in a constant voltage part for each function, and the number of times a function having a low-voltage part is called in a low-voltage part. Information.

図9に戻って、コード生成装置100は、制御コードパターン63に含まれる電源制御コードパターン64、ジャンプコードパターン65から、電源制御コードのコードサイズs_vとジャンプ制御コードのコードサイズs_jとを抽出する。   Returning to FIG. 9, the code generation device 100 extracts the code size s_v of the power control code and the code size s_j of the jump control code from the power control code pattern 64 and the jump code pattern 65 included in the control code pattern 63. .

次にコード生成装置100は、アセンブリ50のコードサイズの補正を行う(ステップS903)。コード生成装置100は、ステップS901で抽出された呼出回数情報51と、ステップS902で抽出されたコードサイズs_vとコードサイズs_jと、後述する関数サイズ情報52とに基づきアセンブリ50のコードサイズの補正を行う。   Next, the code generation device 100 corrects the code size of the assembly 50 (step S903). The code generation device 100 corrects the code size of the assembly 50 based on the number-of-calls information 51 extracted in step S901, the code size s_v and code size s_j extracted in step S902, and function size information 52 described later. Do.

以下にコードサイズの補正の詳細を説明する。   Details of the code size correction will be described below.

コード生成装置100では、アセンブリ50に含まれるアセンブリコード55の分割位置が算出されると、コード生成装置10は関数名と関数毎のアセンブリコード55のサイズに関する情報とを対応させた関数サイズ情報52を生成する。図11は、関数サイズ情報の一例を示す図である。関数サイズ情報52は、分割位置が決定されたアセンブリコード55の関数名と、関数毎の低電圧部のサイズ、一定電圧部のサイズとが対応付けられた情報である。図11に示す関数サイズ情報52では、低電圧部を有する関数の関数名である関数func1、関数func1の一定電圧部のサイズ、関数func1の低電圧部のサイズとが対応付けられている。また関数func2についても同様に、関数func2の関数名、関数func2の一定電圧部のサイズ、関数func2の低電圧部のサイズとが対応付けられている。   In the code generation device 100, when the division position of the assembly code 55 included in the assembly 50 is calculated, the code generation device 10 sets the function size information 52 in which the function name is associated with information on the size of the assembly code 55 for each function. Is generated. FIG. 11 is a diagram illustrating an example of function size information. The function size information 52 is information in which the function name of the assembly code 55 for which the division position is determined is associated with the size of the low voltage portion and the size of the constant voltage portion for each function. In the function size information 52 shown in FIG. 11, the function func1, which is the function name of the function having the low voltage part, the size of the constant voltage part of the function func1, and the size of the low voltage part of the function func1 are associated with each other. Similarly, the function func2 is associated with the function name of the function func2, the size of the constant voltage portion of the function func2, and the size of the low voltage portion of the function func2.

コード生成装置100では、アセンブリコード55を一定電圧部と低電圧部とに分割した場合、一定電圧部のアセンブリコード55を配置するメモリに、低電圧部が配置された使用時一定電圧メモリを特定するジャンプ制御コードと、使用時一定電圧メモリを一定電圧状態にさせる電源制御コードとを挿入する必要がある。   In the code generation device 100, when the assembly code 55 is divided into the constant voltage portion and the low voltage portion, the constant voltage memory in use in which the low voltage portion is arranged is specified in the memory in which the assembly code 55 of the constant voltage portion is arranged. It is necessary to insert a jump control code to be used and a power supply control code for making the constant voltage memory in a constant voltage state when in use.

そこでコード生成装置100は、低電圧部を有する関数の呼出回数情報51と、低電圧部を有する関数の関数サイズ情報52と、電源制御コードのコードサイズs_vとジャンプ制御コードのコードサイズs_jとに基づき、関数毎のアセンブリコード55のサイズを補正する。より具体的には、低電圧部を有する関数について、(一定電圧部のサイズ)は(コードサイズs_v)×(一定電圧部において低電圧部を有する関数を呼び出している回数+1)+(コードサイズs_j)を加えることで、また(低電圧部のサイズ)は(電源制御コードのコードサイズs_v)×(低電圧部において低電圧部を有する関数を呼び出している回数)を加えることで補正する。一方、低電圧部を有さない関数について、(一定電圧部のサイズ)は(コードサイズs_v)×(一定電圧部において低電圧部を有する関数を呼び出している回数)を加えて補正する。そしてコード生成装置100は、低電圧部を有する関数のアセンブリコード55について補正を行った結果をアセンブリ50のサイズに反映させることで、アセンブリ50のコードサイズを補正する。   Therefore, the code generation device 100 includes a function call information 51 having a low voltage part, a function size information 52 of a function having a low voltage part, a code size s_v of a power supply control code, and a code size s_j of a jump control code. Based on this, the size of the assembly code 55 for each function is corrected. More specifically, for a function having a low voltage part, (size of a constant voltage part) is (code size s_v) × (number of times a function having a low voltage part is called in the constant voltage part + 1) + (code size (s_j) is added, and (size of the low voltage part) is corrected by adding (code size s_v of the power supply control code) × (number of times the function having the low voltage part is called in the low voltage part). On the other hand, the function having no low voltage part is corrected by adding (code size s_v) × (number of times the function having the low voltage part is called in the constant voltage part). Then, the code generation device 100 corrects the code size of the assembly 50 by reflecting the correction result of the assembly code 55 of the function having the low voltage part on the size of the assembly 50.

アセンブリ50のコードサイズの補正が完了すると、コード生成装置100は、常時一定電圧メモリと、使用時一定電圧メモリの両方においてメモリの割当を行う(ステップS904)。メモリの割当は、パラメータ60に含まれるメモリユニット10の構造情報62に基づき行われる。図12は、メモリユニットの構造情報の一例を示す図である。構造情報62は、メモリユニット10に含まれる複数のメモリのメモリ名と、開始アドレスと、終了アドレスとが対応付けられた情報である。メモリの割当の詳細は後述する。   When the correction of the code size of the assembly 50 is completed, the code generation device 100 performs memory allocation in both the constant voltage memory and the constant voltage memory when in use (step S904). Memory allocation is performed based on the structure information 62 of the memory unit 10 included in the parameter 60. FIG. 12 is a diagram illustrating an example of the structure information of the memory unit. The structure information 62 is information in which memory names, start addresses, and end addresses of a plurality of memories included in the memory unit 10 are associated with each other. Details of the memory allocation will be described later.

図9に戻って、コード生成装置100は、メモリの割当が終了すると、アセンブリコード55の低電圧部のラベル付けを行い(ステップS905)、メモリマップ決定を完了する。コード生成装置100は、分割位置が決定されたアセンブリコード55の低電圧部の開始部分に、(関数名)_Lというラベルを付ける。図13は、ラベル付けの一例を示す図である。コード生成装置100は、例えば使用時一定電圧メモリであるメモリAに配置された関数func1のアセンブリコード55の低電圧部の開始アドレスに、関数func1_Lというラベルを付ける。関数func2についても同様に、メモリBに配置された関数func2のアセンブリコード55の低電圧部の開始アドレスに、関数func2_Lというラベルを付ける。   Returning to FIG. 9, when the allocation of the memory is completed, the code generation device 100 labels the low voltage portion of the assembly code 55 (step S905) and completes the memory map determination. The code generation device 100 labels (function name) _L at the start portion of the low voltage portion of the assembly code 55 whose division position is determined. FIG. 13 is a diagram illustrating an example of labeling. For example, the code generation device 100 labels the start address of the low voltage portion of the assembly code 55 of the function func1 arranged in the memory A, which is a constant voltage memory when in use, as a function func1_L. Similarly, for the function func2, the function func2_L is labeled at the start address of the low voltage portion of the assembly code 55 of the function func2 arranged in the memory B.

次に、図14乃至図17を参照して図9のステップS904におけるメモリの割当について説明する。本実施形態のコード生成装置100は、図14乃至図17に示す何れかの方法により、常時一定電圧メモリに対するメモリ割当と使用時一定電圧メモリに対するメモリ割当とを行えば良い。   Next, memory allocation in step S904 in FIG. 9 will be described with reference to FIGS. The code generation device 100 according to the present embodiment may always perform memory allocation to the constant voltage memory and memory allocation to the constant voltage memory when in use by any of the methods shown in FIGS. 14 to 17.

図14は、メモリ割当を説明する第一のフローチャートである。コード生成装置100は、アセンブリ50のコードサイズの補正が完了すると、アセンブリ50に含まれるアセンブリコード55をメモリユニット10の有する複数のメモリの先頭から割り当てる(ステップS1401)。次にコード生成装置100は、アセンブリ50において最初に登場するアセンブリコード55を最初のメモリ(メモリA)に割り当て、アセンブリコード55がメモリAとメモリBの境界を跨ぐか否かを判断する(ステップS1402)。   FIG. 14 is a first flowchart for explaining memory allocation. When the correction of the code size of the assembly 50 is completed, the code generation device 100 assigns the assembly code 55 included in the assembly 50 from the top of the plurality of memories included in the memory unit 10 (step S1401). Next, the code generation device 100 assigns the assembly code 55 that first appears in the assembly 50 to the first memory (memory A), and determines whether the assembly code 55 crosses the boundary between the memory A and the memory B (step). S1402).

ステップS1402においてメモリの境界を跨ぐとき、コード生成装置100は、アセンブリコード55をメモリBにのみ割り当てる(ステップS1403)。ステップS1402においてメモリの境界を跨がないとき、コード生成装置100は、アセンブリコード55をメモリAへ割り当て、アセンブリ50に含まれる全ての関数のアセンブリコード55を割り当てたか否かを判断する(ステップS1404)。ステップS1404において全てのアセンブリコード55の割り当てが完了すると、コード生成装置100はメモリ割当を終了する。   When straddling a memory boundary in step S1402, the code generation device 100 assigns the assembly code 55 only to the memory B (step S1403). When the boundary of the memory is not crossed in step S1402, the code generation device 100 assigns the assembly code 55 to the memory A, and determines whether the assembly code 55 of all the functions included in the assembly 50 is assigned (step S1404). ). When the allocation of all assembly codes 55 is completed in step S1404, the code generation device 100 ends the memory allocation.

図15は、メモリ割当を説明する第二のフローチャートである。コード生成装置100は、アセンブリ50のコードサイズの補正が完了すると、アセンブリ50に含まれる関数名をアルファベット順にソートする(ステップS1501)。次にコード生成装置100は、図14のステップS1401からステップS1404までの処理を実行する。   FIG. 15 is a second flowchart for explaining memory allocation. When the correction of the code size of the assembly 50 is completed, the code generation device 100 sorts the function names included in the assembly 50 in alphabetical order (step S1501). Next, the code generation device 100 executes the processing from step S1401 to step S1404 in FIG.

図16は、メモリ割当を説明する第三のフローチャートである。コード生成装置100は、アセンブリ50のコードサイズの補正が完了すると、メモリユニット10を走査してアセンブリ50において最初に登場するアセンブリコード55をメモリの境界を跨がずに割り当てられるメモリを求め、アセンブリコード55を割り当てる(ステップS1601)。   FIG. 16 is a third flowchart for explaining memory allocation. When the correction of the code size of the assembly 50 is completed, the code generation device 100 scans the memory unit 10 to obtain a memory to which the assembly code 55 that appears first in the assembly 50 is allocated without crossing the memory boundary. A code 55 is assigned (step S1601).

コード生成装置100は、ステップS1601の処理をアセンブリ50に含まれる全てのアセンブリコード55を割り当てたか否かを判断し(ステップS1602)、全てのアセンブリコード55を割り当てた場合にメモリ割当を終了する。   The code generation device 100 determines whether or not all the assembly codes 55 included in the assembly 50 have been assigned in the process of step S1601 (step S1602), and when all the assembly codes 55 have been assigned, the memory assignment ends.

図17は、メモリ割当を説明する第四のフローチャートである。コード生成装置100は、アセンブリ50のコードサイズの補正が完了すると、アセンブリ50に含まれるアセンブリコード55をコードサイズの大きい順にソートする(ステップS1701)。そしてコード生成装置100は、図16のステップS1601、ステップS1602の処理を実行する(ステップS1702)。   FIG. 17 is a fourth flowchart for explaining memory allocation. When the correction of the code size of the assembly 50 is completed, the code generation device 100 sorts the assembly codes 55 included in the assembly 50 in descending order of the code size (step S1701). Then, the code generation device 100 executes the processes of steps S1601 and S1602 in FIG. 16 (step S1702).

次に、コード生成装置100における制御コードの挿入について説明する。本実施形態のコード生成装置100は、低電圧部を有する関数のアセンブリコード55に、分割位置に低電圧部が割り当てられた使用時一定電圧メモリへのジャンプ制御コードを挿入する。またコード生成装置100は、アセンブリコード55の先頭部分に低電圧部が割り当てられた使用時一定電圧メモリを一定電圧状態とする電源制御コードを挿入する。さらにコード生成装置100は、アセンブリコード55の低電圧部が配置されている使用時一定電圧メモリを関数実行後に低電圧状態として良いか否かを判断し、低電圧状態として良い場合には使用時一定電圧メモリを低電圧状態とする電源制御コードを挿入する。   Next, control code insertion in the code generation device 100 will be described. The code generation apparatus 100 according to the present embodiment inserts a jump control code to a constant voltage memory in use, in which a low voltage part is assigned to a division position, into an assembly code 55 of a function having a low voltage part. In addition, the code generation device 100 inserts a power supply control code for setting the constant voltage memory in use in which the low voltage portion is assigned to the head portion of the assembly code 55 to a constant voltage state. Further, the code generation device 100 determines whether or not the constant voltage memory at the time of use in which the low voltage portion of the assembly code 55 is arranged can be in a low voltage state after executing the function. Insert a power supply control code that puts the constant voltage memory in a low voltage state.

以下に図18、図19を参照して制御コードの挿入について説明する。図18は、図5のステップS53に示す制御コードの挿入を説明する第一のフローチャートである。   The insertion of the control code will be described below with reference to FIGS. FIG. 18 is a first flowchart for explaining the insertion of the control code shown in step S53 of FIG.

コード生成装置100は、アセンブリ50に含まれる関数から低電圧部を有する関数を抽出して低電圧部を有する関数のリストL1を生成する(ステップS1801)。尚このリストL1は、例えば図9で説明したコードサイズの補正において、関数サイズ情報52を抽出する際に抽出されていても良い。   The code generation device 100 extracts a function having a low voltage part from the functions included in the assembly 50 to generate a list L1 of functions having a low voltage part (step S1801). The list L1 may be extracted when the function size information 52 is extracted in the code size correction described with reference to FIG.

コード生成装置100は、ステップS1801で作成されたリストL1から、一つの関数funcを選択し、選択した関数のアセンブリコード55を取り出してファイルfとする(ステップS1802)。   The code generation device 100 selects one function func from the list L1 created in step S1801, extracts the assembly code 55 of the selected function and sets it as a file f (step S1802).

次にコード生成装置100は、ステップS51で算出した分割位置、ステップS52で決定したメモリマップに基づき電源制御コードパターン64とジャンプ制御コードパターン65とにパラメータを埋め込む(ステップS1803)。例えばファイルfに取り出されたアセンブリコード55の低電圧部のコードがメモリBへ配置される場合、コード生成装置100は、電源制御コードパターン64に、一定電圧状態とするメモリを指定する「メモリB」をパラメータとして埋め込む。またコード生成装置100は、ジャンプ制御コードパターン65に、ジャンプ先のアドレスとして、ステップS52で決定したメモリマップを参照し求めた関数funcの低電圧部の開始アドレスを埋め込む。   Next, the code generation device 100 embeds parameters in the power control code pattern 64 and the jump control code pattern 65 based on the division position calculated in step S51 and the memory map determined in step S52 (step S1803). For example, when the code of the low voltage portion of the assembly code 55 extracted in the file f is arranged in the memory B, the code generation device 100 designates a memory to be in a constant voltage state in the power control code pattern 64 “memory B "Is embedded as a parameter. The code generating apparatus 100 embeds the start address of the low voltage part of the function func obtained by referring to the memory map determined in step S52 as the jump destination address in the jump control code pattern 65.

パラメータを埋め込むと、コード生成装置100は、パラメータを埋め込んだ電源制御コードとジャンプ制御コードとをファイルfへ挿入する(ステップS1804)。次にコード生成装置100は、ステップS1801で作成されたリストL1が空か否かを判断し(ステップS1805)、リストL1が空になるまでステップS1802〜ステップS1804を反復実行する。リストL1が空になると後述するステップS1901へ進む。   When the parameter is embedded, the code generation device 100 inserts the power control code and the jump control code in which the parameter is embedded into the file f (step S1804). Next, the code generation device 100 determines whether or not the list L1 created in step S1801 is empty (step S1805), and repeatedly executes steps S1802 to S1804 until the list L1 becomes empty. When the list L1 becomes empty, the process proceeds to step S1901 described later.

図19は、図5のステップS53に示す制御コードの挿入を説明する第二のフローチャートである。図19では、リストL1が空になった後に実行される処理を示している。   FIG. 19 is a second flowchart for explaining control code insertion shown in step S53 of FIG. FIG. 19 shows processing executed after the list L1 becomes empty.

コード生成装置100は、アセンブリ50に含まれる関数の静的コールグラフ(呼出関係図)を作成する(ステップS1901)。次にコード生成装置100は、アセンブリ50中の関数の呼出命令のアドレスと、呼び出された関数名とを対応付けたリストL2を作成する(ステップS1902)。   The code generation device 100 creates a static call graph (call relation diagram) of the functions included in the assembly 50 (step S1901). Next, the code generation device 100 creates a list L2 in which the address of the function call instruction in the assembly 50 is associated with the called function name (step S1902).

コード生成装置100は、リストL2から、一つの呼出命令のアドレスをアドレスxとして取り出し、アドレスxにて呼び出される関数名を文字列変数funcxとして取り出す(ステップS1903)。コード生成装置100は、文字列変数funcxにより指し示される関数が配置されるメモリをMxと置き、文字列変数funcを文字列変数funcxで更新する(ステップS1904)。続いてコード生成装置100は、文字列変数funcを文字列変数funcにより示される関数の呼出元関数名に置き換え、文字列変数funcxにより示される関数が配置されるメモリをMと置く(ステップS1905)。   The code generation device 100 extracts the address of one call instruction as the address x from the list L2, and extracts the function name called at the address x as the character string variable funcx (step S1903). The code generation device 100 places a memory in which the function indicated by the character string variable funcx is placed as Mx, and updates the character string variable func with the character string variable funcx (step S1904). Subsequently, the code generation device 100 replaces the character string variable func with the caller function name of the function indicated by the character string variable func, and places the memory in which the function indicated by the character string variable funcx is placed as M (step S1905). .

次にコード生成装置100は、メモリMとメモリMxとが同じメモリであるか否かを判断する(ステップS1906)。後述する反復実行を考慮すると、コード生成装置100は、呼出先関数のアセンブリコード55と、メイン関数から呼出元関数に至るまでに呼び出される関数のアセンブリコード55のいずれか、とが同じメモリに配置されるか否かを判断している。   Next, the code generation device 100 determines whether or not the memory M and the memory Mx are the same memory (step S1906). In consideration of repetitive execution, which will be described later, the code generation device 100 arranges the assembly code 55 of the called function and either the assembly code 55 of the function called from the main function to the caller function in the same memory. It is judged whether or not.

ステップS1906においてメモリMとメモリMxとが同じメモリであった場合はステップS1907に進む。   If the memory M and the memory Mx are the same in step S1906, the process proceeds to step S1907.

ステップS1906においてメモリMとメモリMxとが同じメモリでない場合、コード生成装置100は、文字列変数func(ここでは呼出元関数を指す)がメイン関数を指すものか否かを判断する(ステップS1908)。文字列変数funcがメイン関数を指すものと判断された場合、コード生成装置100は、電源制御コードパターン64にパラメータを埋め込み電源制御コードを決定する(ステップS1909)。ここで埋め込まれるパラメータは、文字列変数funcxが示す呼出先関数が配置されたメモリMxを低電圧状態へするためのパラメータである。   If the memory M and the memory Mx are not the same memory in step S1906, the code generation device 100 determines whether or not the character string variable func (here, indicating the caller function) indicates the main function (step S1908). . If it is determined that the character string variable func indicates the main function, the code generation device 100 embeds a parameter in the power control code pattern 64 and determines the power control code (step S1909). The parameter embedded here is a parameter for setting the memory Mx in which the call destination function indicated by the character string variable funcx is placed into a low voltage state.

電源制御コードパターン64にパラメータが埋め込まれると、コード生成装置100は電源制御コードをステップS1902で取り出したアドレスxの直後に挿入し(ステップS1910)、ステップS1907へ進む。   When the parameter is embedded in the power control code pattern 64, the code generation device 100 inserts the power control code immediately after the address x extracted in step S1902 (step S1910), and the process proceeds to step S1907.

ステップS1907において、コード生成装置100はリストL2が空か否かを判断し、リストL2が空だったときは制御コードの挿入を終了する。リストL2が空でなければ、ステップS1903に戻り、ステップS1903〜ステップS1906及びステップS1908〜ステップS1910の処理を繰り返す。   In step S1907, the code generation device 100 determines whether or not the list L2 is empty. When the list L2 is empty, the control code insertion is terminated. If the list L2 is not empty, the process returns to step S1903, and the processes of steps S1903 to S1906 and steps S1908 to S1910 are repeated.

尚図19では呼出元関数が複数存在している場合について説明していないが、複数存在する場合はステップS2704、ステップS2705を全ての呼出元について実行する。   Note that FIG. 19 does not describe the case where a plurality of caller functions exist, but when there are a plurality of caller functions, step S2704 and step S2705 are executed for all callers.

コード生成装置100は、アセンブリ50に制御コードが挿入されると、制御コード挿入後のアセンブリ50Aをアセンブル及びリンケージして電源制御入りバイナリ70を出力する。   When the control code is inserted into the assembly 50, the code generation apparatus 100 assembles and links the assembly 50A after the control code is inserted, and outputs the binary 70 with power control.

以下に図20を参照して本実施形態のコード生成装置100により出力された電源制御入りバイナリ70が実装されたLSI等の動作を説明する。図20は、第一の実施形態のコード生成装置により生成された電源制御入りバイナリが実装された半導体集積回路の動作の一例を説明する図である。   The operation of an LSI or the like on which the power supply controlled binary 70 output by the code generation device 100 of this embodiment is mounted will be described below with reference to FIG. FIG. 20 is a diagram for explaining an example of the operation of the semiconductor integrated circuit in which the binary with power supply control generated by the code generation device of the first embodiment is mounted.

図20では、メモリに配置された関数の実行状況と、メモリの電源電圧の状態とを対応させて示している。メモリAは常時一定電圧メモリであり、メモリB、C、Dは使用時一定電圧メモリである。   In FIG. 20, the execution state of the function arranged in the memory and the state of the power supply voltage of the memory are shown in correspondence with each other. The memory A is always a constant voltage memory, and the memories B, C, and D are constant voltage memories when in use.

メモリAに配置されたメイン関数funcMにより関数func1が呼び出されると、関数func1が実行される。関数func1の開始アドレスには、メモリBを一定電圧状態とする電源制御コードが挿入されている。よって関数func1の実行が開始されるとメモリBは一定電圧状態への移行を開始する。関数func1には、Nサイクル分の命令を実行するとメモリBへジャンプするようにジャンプ制御コードが挿入されている。よって関数func1はNサイクル後にメモリBへジャンプし、関数func1の低電圧部のアセンブリコードの実行を開始する。ここでメモリBの電圧変動時間は、Nサイクルの命令の実行に係る時間に相当する。よって関数func1がメモリBへジャンプしたときには、メモリBは一定電圧状態となっている。関数func2、関数func3も関数func1と同様である。   When the function func1 is called by the main function funcM arranged in the memory A, the function func1 is executed. A power supply control code for setting the memory B to a constant voltage state is inserted at the start address of the function func1. Therefore, when the execution of the function func1 is started, the memory B starts to shift to a constant voltage state. In the function func1, a jump control code is inserted so as to jump to the memory B when an instruction for N cycles is executed. Therefore, the function func1 jumps to the memory B after N cycles and starts executing the assembly code of the low voltage part of the function func1. Here, the voltage fluctuation time of the memory B corresponds to a time related to execution of N cycles of instructions. Therefore, when the function func1 jumps to the memory B, the memory B is in a constant voltage state. The functions func2 and func3 are the same as the function func1.

以下に図21乃至図24を参照して本実施形態のコード生成装置100の動作例について説明する。   Hereinafter, an operation example of the code generation device 100 according to the present embodiment will be described with reference to FIGS. 21 to 24.

図21は、コード生成装置に入力されるアセンブリの一例を示す図である。   FIG. 21 is a diagram illustrating an example of an assembly input to the code generation device.

コード生成装置100では、図21に示すアセンブリ50が入力されると、アセンブリコード50に制御コードを挿入する。尚アセンブリ50には、図21で定義されている関数以外の関数も含まれていても良い。   When the assembly 50 shown in FIG. 21 is input, the code generation device 100 inserts a control code into the assembly code 50. The assembly 50 may include functions other than the functions defined in FIG.

図22は、アセンブリに定義されている関数のコールグラフの一例を示す図である。関数func1、関数func2は、メイン関数funcMに呼び出される。関数func3は、関数func1と関数func2により呼び出される。   FIG. 22 is a diagram illustrating an example of a call graph of functions defined in an assembly. The functions func1 and func2 are called by the main function funcM. The function func3 is called by the function func1 and the function func2.

図23は、制御コードが挿入された後のアセンブリの一例を示す第一の図であり、図24は、制御コードが挿入された後のアセンブリの一例を示す第二の図である。図23は、常時一定電圧メモリであるメモリAに配置されるコードの例を示しており、図24は、使用時一定電圧メモリであるメモリBとメモリCに配置されるコードの例を示している。   FIG. 23 is a first diagram illustrating an example of an assembly after the control code is inserted, and FIG. 24 is a second diagram illustrating an example of the assembly after the control code is inserted. FIG. 23 shows an example of code that is always placed in the memory A that is a constant voltage memory, and FIG. 24 shows an example of code that is placed in the memory B and the memory C that are constant voltage memories when in use. Yes.

図23のコードA1、コードA2は、図19で説明した制御コードの挿入により挿入されるコードである。コードA1は、メモリBに低電圧部が配置された関数func1の実行が終了すると、メモリBを一定電圧状態から低電圧状態へ移行させる制御を行う電源制御コードである。コードA2は、メモリCに低電圧部が配置された関数func2の実行が終了すると、メモリCを一定電圧状態から低電圧状態へ移行させる制御を行う電源制御コードである。   Code A1 and code A2 in FIG. 23 are codes inserted by the insertion of the control code described in FIG. The code A1 is a power supply control code for performing control to shift the memory B from the constant voltage state to the low voltage state when the execution of the function func1 in which the low voltage unit is arranged in the memory B is completed. The code A2 is a power supply control code for performing control to shift the memory C from the constant voltage state to the low voltage state when the execution of the function func2 in which the low voltage unit is arranged in the memory C is completed.

図23のコードB1、コードB2は、図18で説明した制御コードの挿入により挿入されるコードである。コードB1は、関数func1の一定電圧部の実行開始直後に、関数func1の低電圧部が配置されたメモリBを低電圧状態から一定電圧状態へ移行させるための電源制御コードである。コードB2は、関数func1の低電圧部が配置されたメモリBへジャンプさせるジャンプ制御コードである。コードB2は、関数func1の一定電圧部の最後に挿入されている。   Code B1 and code B2 in FIG. 23 are codes inserted by the insertion of the control code described in FIG. The code B1 is a power supply control code for shifting the memory B in which the low voltage part of the function func1 is arranged from the low voltage state to the constant voltage state immediately after the execution of the constant voltage part of the function func1. The code B2 is a jump control code for jumping to the memory B in which the low voltage part of the function func1 is arranged. The code B2 is inserted at the end of the constant voltage portion of the function func1.

コードB3は、関数func2の一定電圧部の実行開始直後に、関数func2の低電圧部が配置されたメモリCを低電圧状態から一定電圧状態へ移行させるための電源制御コードである。コードB4は、関数func2の低電圧部が配置されたメモリCへジャンプさせるジャンプ制御コードである。コードB4は、関数func2の一定電圧部の最後に挿入されている。   The code B3 is a power supply control code for shifting the memory C in which the low voltage part of the function func2 is arranged from the low voltage state to the constant voltage state immediately after the execution of the constant voltage part of the function func2. The code B4 is a jump control code for jumping to the memory C in which the low voltage part of the function func2 is arranged. The code B4 is inserted at the end of the constant voltage part of the function func2.

図24のコードCは、図9のステップS905で説明した低電圧部のラベル付けにより付与されたラベルである。コードCは、メモリBに配置された関数func1の低電圧部の開始アドレスに付与されている。同様に図24のコードDは、メモリCに配置された関数func2の低電圧部の開始アドレスに付与されている。   The code C in FIG. 24 is a label given by the labeling of the low voltage part described in step S905 in FIG. The code C is given to the start address of the low voltage part of the function func1 arranged in the memory B. Similarly, the code D in FIG. 24 is given to the start address of the low voltage part of the function func2 arranged in the memory C.

以上に説明したように、本実施形態によれば、関数において、電圧変動時間と対応したNサイクル以内に実行可能なコードを常時一定電圧メモリに配置し、Nサイクル以内に実行できないコードを使用時一定電圧メモリへ配置する。そして常時一定電圧メモリに配置されたコードの先頭に、使用時一定電圧メモリを一定電圧状態へさせる制御コードを挿入する。本実施形態では、上記構成により、電圧変動時間を考慮したタイミングでメモリの電源電圧を変動させるプログラムコードを生成することができる。   As described above, according to the present embodiment, in a function, a code that can be executed within N cycles corresponding to the voltage variation time is always placed in a constant voltage memory, and a code that cannot be executed within N cycles is used. Place in constant voltage memory. Then, a control code for causing the constant voltage memory to be in a constant voltage state when in use is inserted at the head of the code always arranged in the constant voltage memory. In the present embodiment, with the above configuration, it is possible to generate a program code that varies the power supply voltage of the memory at a timing that takes into account the voltage variation time.

(第二の実施形態)
以下に図面を参照して本発明の第二の実施形態について説明する。第二の実施形態では、割り込み処理を考慮した点が第一の実施形態と相違する。よって以下の第二の実施形態の説明では、第一の実施形態との相違点についてのみ説明し、第一の実施形態と同様の機能構成を有するものには第一の実施形態の説明で用いた符号と同様の符号を付与し、その説明を省略する。
(Second embodiment)
A second embodiment of the present invention will be described below with reference to the drawings. The second embodiment is different from the first embodiment in that interrupt processing is considered. Therefore, in the following description of the second embodiment, only differences from the first embodiment will be described, and those having the same functional configuration as the first embodiment will be used in the description of the first embodiment. The same reference numerals as those used are assigned, and the description thereof is omitted.

図25は、割り込み処理を考慮した場合の制御コードの挿入を説明する第一のフローチャートである。   FIG. 25 is a first flowchart for explaining insertion of a control code in consideration of interrupt processing.

図18のステップS1805において、リストL1が空であった場合、コード生成装置100は、アセンブリ50に含まれる関数の静的コールグラフを作成する(ステップS2501)。コールグラフが作成されると、コード生成装置100は、割込ハンドラINT_HANDLERから到達可能な関数の集合を抽出し、抽出した関数を以下の集合に分割する(ステップS2502)。コード生成装置100は、抽出した関数をメイン関数funcMからのみ到達可能な関数、割込ハンドラINT_HANDLERからのみ到達可能な関数の集合、メイン関数funcMと割込ハンドラINT_HANDLERとの両方から到達可能な関数の集合に分割する。   In step S1805 of FIG. 18, when the list L1 is empty, the code generation device 100 creates a static call graph of the functions included in the assembly 50 (step S2501). When the call graph is created, the code generation device 100 extracts a set of functions that can be reached from the interrupt handler INT_HANDLER, and divides the extracted functions into the following sets (step S2502). The code generation device 100 includes a function that can reach the extracted function only from the main function funcM, a set of functions that can be reached only from the interrupt handler INT_HANDLER, and a function that can be reached from both the main function funcM and the interrupt handler INT_HANDLER. Divide into sets.

次のコード生成装置100は、メイン関数funcMと割込ハンドラINT_HANDLERとの両方から到達可能な関数の複製を生成する(ステップS2503)。そしてコード生成装置100は、メイン関数funcMからのみ到達可能な関数と、割込ハンドラINT_HANDLERからのみ到達可能な関数とから、割込ハンドラINT_HANDLERへアクセス可能とするための枝を作成し(ステップS2504)、図27で説明する処理へ進む。   The next code generation device 100 generates a copy of the function that can be reached from both the main function funcM and the interrupt handler INT_HANDLER (step S2503). The code generation device 100 creates a branch for making the interrupt handler INT_HANDLER accessible from the function that can be reached only from the main function funcM and the function that can be reached only from the interrupt handler INT_HANDLER (step S2504). Then, the process proceeds to the process described in FIG.

以下に図26を参照して図25で生成されるコールグラフについて説明する。図26は、コールグラフの一例を示す図である。図26(A)は、図25のステップS2501で生成されたコールグラフの一例を示す。また、図26(B)は、図26(A)で示されたコールグラフの、図25のステップS2504完了時点でのコールグラフを示す。   The call graph generated in FIG. 25 will be described below with reference to FIG. FIG. 26 is a diagram illustrating an example of a call graph. FIG. 26A shows an example of the call graph generated in step S2501 of FIG. FIG. 26B shows a call graph of the call graph shown in FIG. 26A when step S2504 in FIG. 25 is completed.

アセンブリ50に含まれる関数の集合は、図5のステップS2502において、メイン関数funcMからのみ到達可能な関数の集合F1、割込ハンドラINT_HANDLERからのみ到達可能な関数の集合F2、メイン関数funcMと割込ハンドラINT_HANDLERとの両方から到達可能な関数の集合F3とに分割される。   In step S2502 of FIG. 5, the set of functions included in the assembly 50 is a set of functions F1 that can be reached only from the main function funcM, a set of functions F2 that can be reached only from the interrupt handler INT_HANDLER, and a main function funcM and an interrupt. It is divided into a set of functions F3 reachable from both the handler INT_HANDLER.

関数の集合が分割されると、図5のステップS2503において集合F3の複製である集合F3aが生成し、集合F2から集合F3へ向かっていた枝の接続先を集合F3aとする。次にコード生成装置100は、図25のステップS2504において集合F1に含まれる関数及び集合F3に含まれる関数と、割込ハンドラINT_HANDLERとを接続する枝を作成する。   When the set of functions is divided, a set F3a that is a copy of the set F3 is generated in step S2503 of FIG. 5, and the connection destination of the branch from the set F2 toward the set F3 is set as the set F3a. Next, in step S2504 in FIG. 25, the code generation device 100 creates a branch connecting the function included in the set F1 and the function included in the set F3 and the interrupt handler INT_HANDLER.

尚集合F3については、割り込み用と通常(割り込みがない場合)用とで関数が二種類ある扱いになっているため、スタートするノードが2つとなる。データ構造としては、ノードの管理テーブルを二種類用意する方法と、コールグラフの隣接枝のリストを四種類(出力、入力を二種類)保持する方法が考えられる。   The set F3 is handled with two types of functions, one for interrupt and one for normal use (when there is no interrupt), so two nodes are started. As a data structure, there are a method of preparing two types of node management tables and a method of holding four types of lists (two types of output and input) of the adjacent branch of the call graph.

図27は、割り込み処理を考慮した場合の制御コードの挿入を説明する第二のフローチャートである。図27のステップS2701からステップS2709までの処理は、図19のステップS1902からステップS1910までの処理と同様であるから説明を省略する。   FIG. 27 is a second flowchart for explaining insertion of a control code when interrupt processing is considered. The processing from step S2701 to step S2709 in FIG. 27 is the same as the processing from step S1902 to step S1910 in FIG.

以上のように、本実施形態では、関数の実行中に割り込みが発生する場合を考慮して制御コードが挿入されたコードを生成することができる。   As described above, in this embodiment, it is possible to generate a code in which a control code is inserted in consideration of a case where an interrupt occurs during execution of a function.

(第三の実施形態)
以下に図面を参照して本発明の第三の実施形態について説明する。第三の実施形態では、関数に割り当てるメモリが複数の場合を考慮した点が第一の実施形態と相違する。よって以下の第三の実施形態の説明では、第一の実施形態との相違点についてのみ説明し、第一の実施形態と同様の機能構成を有するものには第一の実施形態の説明で用いた符号と同様の符号を付与し、その説明を省略する。
(Third embodiment)
A third embodiment of the present invention will be described below with reference to the drawings. The third embodiment is different from the first embodiment in that a case where a plurality of memories are allocated to functions is considered. Therefore, in the following description of the third embodiment, only differences from the first embodiment will be described, and those having the same functional configuration as the first embodiment will be used in the description of the first embodiment. The same reference numerals as those used are assigned, and the description thereof is omitted.

第一の実施形態、第二の実施形態では、制御コードが挿入される前の関数に割り当てるメモリは1つであり、関数がメモリの境界を跨がないという前提があった。本実施形態では、制御コードを挿入する前の関数に割り当てるメモリを複数とした場合を考慮している。   In the first embodiment and the second embodiment, there is a premise that there is one memory allocated to the function before the control code is inserted, and the function does not cross the memory boundary. In the present embodiment, a case is considered in which a plurality of memories are allocated to the function before the control code is inserted.

図28は、関数に割り当てるメモリが複数の場合を説明するための図である。図28では、メイン関数funcMにはメモリAが割り当てられ、関数func0にはメモリBが割り当てられ、関数func1にはメモリCが割り当てられ、関数func2にはメモリAが割り当てられ、関数func3にはメモリB、メモリCが割り当てられている。   FIG. 28 is a diagram for explaining a case where a plurality of memories are allocated to functions. In FIG. 28, a memory A is allocated to the main function funcM, a memory B is allocated to the function func0, a memory C is allocated to the function func1, a memory A is allocated to the function func2, and a memory is allocated to the function func3. B and memory C are allocated.

図28の例では、メモリBには関数func0が、メモリCには関数func1が配置されている。よってメイン関数funcMが関数func0を呼び出し、関数func0が関数func1を呼び出し、関数func1が関数func3を呼び出した場合に、関数func3の実行が完了して関数func1に復帰するときには、関数func1はメモリBもメモリCも低電圧状態とすることができない。   In the example of FIG. 28, the function func0 is arranged in the memory B, and the function func1 is arranged in the memory C. Therefore, when the main function funcM calls the function func0, the function func0 calls the function func1, and the function func1 calls the function func3, when the execution of the function func3 is completed and the function func1 returns, the function func1 also includes the memory B. The memory C cannot be in a low voltage state.

これに対し、メイン関数funcMが関数func0を呼び出し、関数func0が関数func2を呼び出し、関数func2が関数func3を呼び出した場合、関数func3の実行が完了して関数func2が復帰するときには、メモリBには関数func0が配置されているためメモリBを低電圧状態とすることができ乃至かし、メモリCにはメイン関数funcM、関数func0、関数func2のいずれも配置されていないためメモリCを低電圧状態とすることはできる。このように、関数に複数のメモリを割り当てた場合、メモリを低電圧状態にして良い条件は、メモリ毎に独立して決められる。   On the other hand, if the main function funcM calls the function func0, the function func0 calls the function func2, and the function func2 calls the function func3, when the execution of the function func3 is completed and the function func2 returns, the memory B Since the function func0 is arranged, the memory B can be in a low voltage state, and since the main function funcM, the function func0, and the function func2 are not arranged in the memory C, the memory C is in the low voltage state. It can be. As described above, when a plurality of memories are assigned to the function, the conditions under which the memory can be brought into the low voltage state are determined independently for each memory.

図29は、関数に割り当てるメモリが複数である場合のメモリ割当を説明するフローチャートである。   FIG. 29 is a flowchart for explaining memory allocation when there are a plurality of memories allocated to a function.

図29のステップS2901とステップS2902の処理は、図14のステップS1401とステップS1402の処理と同様であるから説明を省略する。   The processing in step S2901 and step S2902 in FIG. 29 is the same as the processing in step S1401 and step S1402 in FIG.

ステップS2902においてメモリの境界を跨ぐとき、コード生成装置100は、関数を複数のメモリに割り当てる(ステップS2903)。例えばコード生成装置100は、ステップS2901で割り当てられたメモリと、その次のメモリとに関数を割り当てても良い。ステップS2904の処理は図14のステップS1404の処理と同様であるから説明を省略する。   When straddling the boundary of the memory in step S2902, the code generation device 100 assigns a function to a plurality of memories (step S2903). For example, the code generation device 100 may assign a function to the memory assigned in step S2901 and the next memory. The processing in step S2904 is the same as the processing in step S1404 in FIG.

次に図30を参照して本実施形態の制御コードの挿入について説明する。図30は、関数に複数のメモリを割り当てられた場合の制御コードの挿入を説明するフローチャートである。   Next, control code insertion according to the present embodiment will be described with reference to FIG. FIG. 30 is a flowchart for explaining insertion of a control code when a plurality of memories are assigned to a function.

図30のステップS3001からステップS3003までの処理は、図19のステップS1901からステップS1903までの処理と同様であるから説明を省略する。   The processing from step S3001 to step S3003 in FIG. 30 is the same as the processing from step S1901 to step S1903 in FIG.

ステップS3004において、コード生成装置100は、文字列変数funcxにより指し示される関数が配置されるメモリの集合をMxと置き、文字列変数funcを文字列変数funcxで更新する。   In step S3004, the code generation device 100 places a set of memories in which the function indicated by the character string variable funcx is placed as Mx, and updates the character string variable func with the character string variable funcx.

ステップS3005において、文字列変数funcを、文字列変数funcにより指し示される関数の呼出元の関数名で更新する。またメモリの集合を、文字列変数funcにより指し示される関数が配置されたメモリの集合Mで更新する。よってステップS3005のメモリMとは、文字列変数funcにより指し示される関数の呼出元関数が配置されたメモリの集合を示すこととなる。そしてMx\MをMxとする。尚M、Mxは、メモリの集合を示し、\は差集合を示す演算子である。   In step S3005, the character string variable func is updated with the function name of the function caller pointed to by the character string variable func. The memory set is updated with the memory set M in which the function indicated by the character string variable func is arranged. Therefore, the memory M in step S3005 indicates a set of memories in which the caller function of the function pointed to by the character string variable func is arranged. And let Mx \ M be Mx. M and Mx are memory sets, and \ is an operator indicating a difference set.

ここでMxは、ステップS3003でリストL2から取り出された文字列変数funcが指し示す関数が配置されたメモリである。よってMx\Mは、ステップS3002でリストL2から取り出された関数が配置されたメモリのうち、メイン関数からステップS3002で取り出された関数の呼出元関数に至るまでに呼び出される関数が配置されたメモリに含まれないものとなる。   Here, Mx is a memory in which a function indicated by the character string variable func extracted from the list L2 in step S3003 is arranged. Therefore, Mx \ M is a memory in which a function to be called from the main function to the function calling source of the function extracted in step S3002 among the memory in which the function extracted from the list L2 in step S3002 is allocated. It will not be included.

次にコード生成装置100は、Mxが空集合であるか否かを判断する(ステップS3006)。Mxが空集合である場合、ステップS3002で取り出された関数が配置されたメモリの全てが、メイン関数からステップS3002で取り出された関数の呼出元関数に至るまでに呼び出される関数が配置されたメモリのいずれかに含まれることを示す。   Next, the code generation device 100 determines whether or not Mx is an empty set (step S3006). When Mx is an empty set, the memory in which all of the memory in which the function extracted in step S3002 is arranged reaches the function calling source of the function extracted in step S3002 from the main function. It is included in any of the above.

ステップS3006においてMxが空集合と判断されると、コード生成装置100は、リストL2が空か否かを判断する(ステップS3007)。ステップS3007においてリストL2が空でない場合、ステップS3003以降の処理を繰り返す。ステップS3007においてリストL2が空の場合、制御コードの挿入を終了する。   If it is determined in step S3006 that Mx is an empty set, the code generation device 100 determines whether or not the list L2 is empty (step S3007). If the list L2 is not empty in step S3007, the processing from step S3003 is repeated. If the list L2 is empty in step S3007, the control code insertion is terminated.

ステップS3006においてMxが空集合でないと判断されると、コード生成装置100は、ステップS3008に進む。ステップS3008からステップS3010の処理は、図19のステップS1908からステップS1910の処理と同様であるから説明を省略する。   If it is determined in step S3006 that Mx is not an empty set, the code generating device 100 proceeds to step S3008. The processing from step S3008 to step S3010 is the same as the processing from step S1908 to step S1910 in FIG.

以上のように本実施形態では、制御コードが挿入される前の関数のアセンブリコード55が複数のメモリに割り当てられた場合にも、第一の実施形態と同様の効果を奏することができる。   As described above, in the present embodiment, even when the assembly code 55 of the function before the control code is inserted is assigned to a plurality of memories, the same effects as in the first embodiment can be obtained.

(第四の実施形態)
以下に図面を参照して本発明の第四の実施形態について説明する。以下の第四の実施形態の説明では、第一の実施形態との相違点についてのみ説明し、第一の実施形態と同様の機能構成を有するものには第一の実施形態の説明で用いた符号と同様の符号を付与し、その説明を省略する。
(Fourth embodiment)
Hereinafter, a fourth embodiment of the present invention will be described with reference to the drawings. In the following description of the fourth embodiment, only differences from the first embodiment will be described, and those having the same functional configuration as those of the first embodiment are used in the description of the first embodiment. The same reference numerals as the reference numerals are assigned, and the description thereof is omitted.

本実施形態のコード生成装置100Aでは、始めに全てのメモリを一定電圧状態としておき、分岐があった場合に分岐先のアセンブリコード55が配置されたメモリ以外のメモリを全て低電圧状態とする制御を行う。   In the code generation device 100A of the present embodiment, all the memories are first set to a constant voltage state, and when there is a branch, all the memories other than the memory where the branch destination assembly code 55 is arranged are set to a low voltage state. I do.

図31は、第四の実施形態のコード生成装置の動作を説明するフローチャートである。尚図31に示す各ステップの処理の詳細は後述する。   FIG. 31 is a flowchart for explaining the operation of the code generation device of the fourth embodiment. Details of the processing of each step shown in FIG. 31 will be described later.

コード生成装置100Aは、アセンブリ50に含まれるアセンブリコード55と、サイクル数61とに基づき制御コードの挿入位置を算出する(ステップS3101)。制御コードの挿入位置が算出されると、コード生成装置100Aは、メモリの構造情報62と、制御コードパターン63とに基づきメモリマップを決定する(ステップS3102)。   The code generation device 100A calculates the insertion position of the control code based on the assembly code 55 included in the assembly 50 and the cycle number 61 (step S3101). When the insertion position of the control code is calculated, the code generation device 100A determines a memory map based on the memory structure information 62 and the control code pattern 63 (step S3102).

次にコード生成装置100Aは、制御コードパターン63に代入するパラメータを決定して制御コードをステップS3101で算出された位置へ挿入する(ステップS3102)。制御コードが挿入されると、コード生成装置100Aは、制御コード挿入後のアセンブリ50Aをアセンブル及びリンケージして電源制御入りバイナリ70を出力する。   Next, the code generation device 100A determines a parameter to be substituted for the control code pattern 63 and inserts the control code at the position calculated in step S3101 (step S3102). When the control code is inserted, the code generation device 100A assembles and links the assembly 50A after the control code is inserted, and outputs the binary 70 with power control.

以下に、本実施形態における制御コード挿入位置の算出について説明する。図32は、図31のステップS3101に示す制御コードの挿入位置の算出を説明するフローチャートである。尚図32で説明する処理は、アセンブリ50に含まれる関数のアセンブリコード55毎に実行される。   The calculation of the control code insertion position in the present embodiment will be described below. FIG. 32 is a flowchart for explaining the calculation of the insertion position of the control code shown in step S3101 of FIG. 32 is executed for each assembly code 55 of a function included in the assembly 50.

コード生成装置100Aは、アセンブリコード55の開始アドレスxからの命令の数をカウントするカウンタのカウンタ値を0とする(ステップS3201)。次にコード生成装置100Aは、アセンブリコード55から命令を取得し、カウンタ値をステップS3201で設定したカウント値と取得した命令のサイクル数との和とする(ステップS3202)。ステップS3201においてカウンタ値は0であるから、ステップS3202ではカウンタ値は取得した命令のサイクル数の値となる。   The code generation device 100A sets the counter value of the counter that counts the number of instructions from the start address x of the assembly code 55 to 0 (step S3201). Next, the code generation device 100A acquires an instruction from the assembly code 55, and sets the counter value as the sum of the count value set in step S3201 and the cycle number of the acquired instruction (step S3202). Since the counter value is 0 in step S3201, the counter value becomes the value of the number of cycles of the acquired instruction in step S3202.

続いてコード生成装置100Aは、カウンタ値<2Nサイクルであるか否かを判断する(ステップS3203)。カウンタ値が2Nサイクルより小さい場合、コード生成装置100Aは、取得した命令にリターン命令が含まれるか判断する(ステップS3204)。ステップS3204においてリターン命令が含まれていた場合、コード生成装置100Aは、電源Low挿入位置リストから開始アドレスxを除く(ステップS3205)。電源Low挿入位置リストとは、メモリを一定電圧状態から低電圧状態へ移行させる電源制御コードの挿入位置を示したリストである。   Subsequently, the code generation device 100A determines whether or not the counter value <2N cycles (step S3203). When the counter value is smaller than 2N cycles, the code generation device 100A determines whether a return instruction is included in the acquired instruction (step S3204). If a return instruction is included in step S3204, the code generation device 100A removes the start address x from the power supply Low insertion position list (step S3205). The power supply low insertion position list is a list showing insertion positions of power supply control codes for shifting the memory from the constant voltage state to the low voltage state.

次にコード生成装置100Aは、アセンブリコード55に含まれる全ての命令を走査したか否かを判断する(ステップS3206)。ステップS3206で全ての命令を走査したと判断されると、制御コード挿入位置の算出を終了する。ステップS3206で全ての命令を走査していないと判断されると、ステップS3202以降の処理を繰り返す。   Next, the code generation device 100A determines whether or not all instructions included in the assembly code 55 have been scanned (step S3206). If it is determined in step S3206 that all instructions have been scanned, the calculation of the control code insertion position is terminated. If it is determined in step S3206 that all the instructions have not been scanned, the processing from step S3202 is repeated.

ステップS3203において、カウンタ値が2Nサイクルより大きい場合、コード生成装置100Aは、取得した命令にリターン命令が含まれるか否かを判断する(ステップS3207)。ステップS3207においてリターン命令が存在するとき、コード生成装置100Aは、電源High挿入位置を算出する(ステップS3208)。電源High挿入位置とは、メモリを低電圧状態から一定電圧状態へ移行させる電源制御コードを挿入する位置を示す。尚ステップS3207の処理の詳細は後述する。   If the counter value is greater than 2N cycles in step S3203, the code generation device 100A determines whether or not a return instruction is included in the acquired instruction (step S3207). When there is a return instruction in step S3207, the code generation device 100A calculates the power supply high insertion position (step S3208). The power high insertion position indicates a position where a power control code for shifting the memory from the low voltage state to the constant voltage state is inserted. Details of the processing in step S3207 will be described later.

ステップS3208において電源High挿入位置が算出されると、コード生成装置100Aは、ステップS3206へ進む。   When the power supply high insertion position is calculated in step S3208, the code generating device 100A proceeds to step S3206.

ステップS3204においてリターン命令が存在しないと判断されると、コード生成装置100Aは、関数の呼出命令が存在するか否かを判断する(ステップS3209)。呼出命令が存在した場合、コード生成装置100Aは、カウンタ値を0にし(ステップS3210)、ステップS3205へ進む。呼出命令が存在しない場合、コード生成装置100AはステップS3206へ進む。   If it is determined in step S3204 that there is no return instruction, the code generation device 100A determines whether there is a function call instruction (step S3209). If there is a call instruction, the code generation device 100A sets the counter value to 0 (step S3210), and proceeds to step S3205. If there is no call instruction, the code generation device 100A proceeds to step S3206.

ステップS3207においてリターン命令が存在しない場合、コード生成装置100Aは、呼出命令が存在するか否かを判断する(ステップS3211)。ステップS3211で呼出命令が存在する場合、コード生成装置100Aは、カウンタ値を0にし、呼出命令の次のアドレスを開始アドレスxとする。そして電源Low挿入位置リストに開始アドレスxを追加する(ステップS3212)。よって電源Low挿入位置リストには、呼出命令の次のアドレスが追加される。コード生成装置100Aは、ステップS3212に続いてステップS3208へ進む。   If there is no return instruction in step S3207, the code generation device 100A determines whether there is a calling instruction (step S3211). If there is a call instruction in step S3211, the code generation device 100A sets the counter value to 0 and sets the next address of the call instruction as the start address x. Then, the start address x is added to the power supply Low insertion position list (step S3212). Therefore, the next address of the call instruction is added to the power supply Low insertion position list. The code generating apparatus 100A proceeds to step S3208 following step S3212.

ステップS3211において呼出命令が存在しない場合、コード生成装置100Aは、ステップS3206へ進む。   If the call instruction does not exist in step S3211, the code generation device 100A proceeds to step S3206.

このように本実施形態では、関数の開始アドレス(呼出命令の分岐先)あるいは呼出命令の次の命令(リターン命令の分岐先)から2Nサイクル数以内に呼出命令又はリターン命令がない限りはり、自関数が使うメモリ以外のメモリを低電圧状態とするように、制御コードの挿入位置を算出する。   As described above, according to the present embodiment, as long as there is no call instruction or return instruction within 2N cycles from the start address of the function (branch destination of the call instruction) or the instruction next to the call instruction (branch destination of the return instruction), The insertion position of the control code is calculated so that the memory other than the memory used by the function is in a low voltage state.

図33は、図32のステップS3208に示す制御コードの挿入位置の算出を説明するフローチャートである。   FIG. 33 is a flowchart for explaining the calculation of the insertion position of the control code shown in step S3208 of FIG.

コード生成装置100Aは、ステップS3208において、呼出命令又はリターン命令のNサイクル前に全メモリを一定電圧状態とするために、Nサイクル手前の位置を特定する。   In step S3208, the code generation device 100A specifies a position before N cycles so that all the memories have a constant voltage state N cycles before the call instruction or the return instruction.

コード生成装置100Aは、アセンブリコード55に含まれる該当する命令ノードと、サイクル数=0と、をキューに積む。またコード生成装置100Aは、仮の最遠アドレスを該当する命令ノードのアドレスとする(ステップS3301)。次にコード生成装置100Aは、キューから命令ノードとサイクル数とを取り出す(ステップS3302)。   The code generation device 100A loads the corresponding instruction node included in the assembly code 55 and the number of cycles = 0 in the queue. The code generation device 100A sets the temporary farthest address as the address of the corresponding instruction node (step S3301). Next, the code generation device 100A extracts the instruction node and the cycle number from the queue (step S3302).

コード生成装置100Aは、取り出した命令ノードが関数の先頭であるか、又はサイクル数がNより大きいか否かを判断する(ステップS3303)。コード生成装置100Aは、ステップS3303において命令ノードが関数の先頭でないとき、又はサイクル数がNより小さいと判断すると、ステップS3303で取り出した命令ノードよりも一つ前の命令ノードをキューに積む(ステップS3304)。   The code generation device 100A determines whether the fetched instruction node is the head of the function or the number of cycles is greater than N (step S3303). When it is determined in step S3303 that the instruction node is not the head of the function or if the number of cycles is smaller than N, the code generation device 100A loads the instruction node immediately before the instruction node extracted in step S3303 in the queue (step S3303). S3304).

コード生成装置100Aは、ステップS3303において命令ノードが関数の先頭である、又はサイクル数がNより大きいと判断すると、ステップS3302で取り出した命令ノードのアドレスの方が仮の最遠アドレスよりも関数の先頭から遠いか否かを判断する(ステップS3305)。ステップS3305において、ステップS3302で取り出したアドレスの方が仮の最遠アドレスよりも遠いと判断された場合、コード生成装置100Aは、現在のアドレス(ステップS3302で取り出したアドレス)を最遠アドレスとする(ステップS3306)。   If the code generation device 100A determines in step S3303 that the instruction node is the head of the function or the number of cycles is greater than N, the address of the instruction node extracted in step S3302 is greater than the temporary farthest address. It is determined whether or not it is far from the head (step S3305). If it is determined in step S3305 that the address extracted in step S3302 is farther than the temporary farthest address, the code generation device 100A sets the current address (the address extracted in step S3302) as the farthest address. (Step S3306).

次にコード生成装置100Aは、キューが空か否かを判断する(ステップS3307)。ステップS3307においてキューが空でない場合、ステップS3302以降の処理を繰り返す。ステップS3307においてキューが空である場合、コード生成装置100Aは、電源High挿入位置リストに最遠アドレスを追加し(ステップS3308)、処理を終了する。尚電源High挿入位置リストとは、メモリを低電圧状態から一定電圧状態へ移行させる電源制御コードの挿入位置を示したリストである。   Next, the code generation device 100A determines whether or not the queue is empty (step S3307). If the queue is not empty in step S3307, the processing from step S3302 is repeated. If the queue is empty in step S3307, the code generation device 100A adds the farthest address to the power supply high insertion position list (step S3308) and ends the process. The power high insertion position list is a list showing insertion positions of power control codes for shifting the memory from the low voltage state to the constant voltage state.

尚本実施形態のコード生成装置100Aは、図32、図33で説明した処理により、関数毎の電源High挿入位置リストをリストL10、関数毎の電源Low挿入位置リストをリストL20として生成するものとした。   The code generation device 100A according to the present embodiment generates the power high insertion position list for each function as the list L10 and the power low insertion position list for each function as the list L20 by the processing described with reference to FIGS. 32 and 33. did.

次に図34を参照して、本実施形態のメモリマップの決定について説明する。図34は、図31のステップS3102に示すメモリマップの決定を説明するフローチャートである。   Next, the determination of the memory map of this embodiment will be described with reference to FIG. FIG. 34 is a flowchart for explaining determination of the memory map shown in step S3102 of FIG.

コード生成装置100Aは、関数毎のアセンブリコード55を参照して低電圧部を有する関数の呼出回数を呼出回数情報として抽出する(ステップS3401)。次にコード生成装置100Aは、電源制御コードパターン64から電源制御コードのコードサイズs_vを抽出する(ステップS3402)。   The code generation device 100A refers to the assembly code 55 for each function and extracts the number of calls of the function having the low voltage part as the number of calls information (step S3401). Next, the code generation device 100A extracts the code size s_v of the power control code from the power control code pattern 64 (step S3402).

コード生成装置100Aは、ステップS3402で抽出されたコードサイズs_vと関数サイズ情報52とに基づきアセンブリ50のコードサイズの補正を行う(ステップS3403)。本実施形態のコード生成装置100Aは、アセンブリ50に含まれる関数のアセンブリコード55毎に、関数の呼出回数に1を加算した値とコードサイズs_vとの積をアセンブリコード55のサイズに加算した結果を補正後のコードサイズとする。   The code generation device 100A corrects the code size of the assembly 50 based on the code size s_v extracted in step S3402 and the function size information 52 (step S3403). The code generation device 100A of the present embodiment adds the product of the value obtained by adding 1 to the number of function calls and the code size s_v to the size of the assembly code 55 for each assembly code 55 of the function included in the assembly 50. Is the corrected code size.

ステップS3404とステップS3405の処理は、図9で説明したステップS904とステップS905の処理と同様であるから説明を省略する。   The processing in steps S3404 and S3405 is the same as the processing in steps S904 and S905 described with reference to FIG.

次に図35、図36を参照して本実施形態の制御コードの挿入について説明する。図35は、図31のステップS3103に示す制御コードの挿入を説明する第一のフローチャートである。   Next, control code insertion according to the present embodiment will be described with reference to FIGS. FIG. 35 is a first flowchart illustrating the insertion of the control code shown in step S3103 of FIG.

コード生成装置100Aは、制御コードパターン63に含まれる電源制御コードパターン64に、全メモリを一定電圧状態とするパラメータを埋め込む(ステップS3501)。次にコード生成装置100Aは、関数毎の電源High挿入位置リストを含むリストL10から、1つの関数の電源High挿入位置リストを取り出し、xとする(ステップS3502)。次にコード生成装置100Aは、ステップS3501でパラメータが埋め込まれた電源制御コードパターンをxへ挿入する(ステップS3503)。コード生成装置100Aは、リストL10が空か否かを判断する(ステップS3504)。   100 A of code generators embed the parameter which makes all the memories a fixed voltage state in the power supply control code pattern 64 contained in the control code pattern 63 (step S3501). Next, the code generation device 100A takes out the power high insertion position list of one function from the list L10 including the power high insertion position list for each function, and sets it as x (step S3502). Next, the code generation device 100A inserts the power control code pattern in which the parameter is embedded in step S3501 into x (step S3503). The code generation device 100A determines whether or not the list L10 is empty (step S3504).

ステップS3504においてリストL10が空である場合、コード生成装置100Aは、図36で説明する処理へ進む。ステップS3504においてリストL10が空でない場合、ステップS3502以降の処理を繰り返す。   If the list L10 is empty in step S3504, the code generation device 100A proceeds to the process described with reference to FIG. If the list L10 is not empty in step S3504, the processing from step S3502 is repeated.

図35の処理により、アセンブリ50にはメモリを一定電圧状態にするための電源制御コードが挿入される。   35, the power supply control code for putting the memory in a constant voltage state is inserted into the assembly 50.

図36は、図31のステップS3103に示す制御コードの挿入を説明する第二のフローチャートである。   FIG. 36 is a second flowchart for explaining the control code insertion shown in step S3103 of FIG.

コード生成装置100Aは、関数毎の電源Low挿入位置リストを含むリストL20から、1つの関数の電源Low挿入位置リストを取り出し、xとする(ステップS3601)。次にコード生成装置100Aは、ステップS3601で取り出されたxと対応する関数が配置されたメモリMEM(x)以外のメモリを低電圧状態とするパラメータを電源制御コードパターン64へ埋め込む(ステップS3602)。   The code generation device 100A extracts the power source Low insertion position list of one function from the list L20 including the power source Low insertion position list for each function, and sets it as x (step S3601). Next, the code generation device 100A embeds a parameter for setting a memory other than the memory MEM (x) in which the function corresponding to x extracted in step S3601 is placed in a low voltage state in the power supply control code pattern 64 (step S3602). .

コード生成装置100Aは、パラメータが挿入された電源制御コードをxの直後へ挿入する(ステップS3603)。次にコード生成装置100Aは、リストL20が空か否かを判断する(ステップS3604)。ステップS3604においてリストL20が空の場合、コード生成装置100Aは制御コードの挿入を終了し、アセンブリ50Aを出力する。ステップS3604でリストL20が空でない場合、ステップS3601以降の処理を繰り返す。   The code generation device 100A inserts the power control code in which the parameter is inserted immediately after x (step S3603). Next, the code generation device 100A determines whether or not the list L20 is empty (step S3604). If the list L20 is empty in step S3604, the code generation device 100A ends the insertion of the control code and outputs the assembly 50A. If the list L20 is not empty at step S3604, the processing after step S3601 is repeated.

図36の処理により、アセンブリ50には、不要なメモリを低電圧状態にするための電源制御コードが挿入される。   As a result of the processing in FIG. 36, a power supply control code for putting unnecessary memory into a low voltage state is inserted into the assembly 50.

以下に図37を参照して本実施形態のコード生成装置100Aにより生成された電源制御入りバイナリ70が実装されたLSI等の動作を説明する。図37は、第四の実施形態のコード生成装置により生成された電源制御入りバイナリが実装された半導体集積回路の動作の一例を説明する図である。   The operation of an LSI or the like on which the power supply controlled binary 70 generated by the code generation device 100A of the present embodiment is mounted will be described below with reference to FIG. FIG. 37 is a diagram for explaining an example of the operation of the semiconductor integrated circuit on which the binary with power supply control generated by the code generation device of the fourth embodiment is mounted.

図37では、メモリに配置された関数の実行状況と、メモリの電源電圧の状態とを対応させて示している。メモリAは常時一定電圧メモリであり、メモリB、C、Dは使用時一定電圧メモリである。   In FIG. 37, the execution state of the function arranged in the memory and the state of the power supply voltage of the memory are shown in correspondence with each other. The memory A is always a constant voltage memory, and the memories B, C, and D are constant voltage memories when in use.

図37の例では、メモリAに配置されたメモリ関数funcMによりメモリBに配置された関数func1が呼び出されNサイクル手前で、全てのメモリ(メモリA〜D)が一定電圧状態とされる。また図37では、関数func1が呼び出されると、関数func1が配置されたメモリB以外のメモリは低電圧状態とされる。そして、関数func1から関数func3が呼び出されるNサイクル手前で、再度全メモリが一定電圧状態とされる。   In the example of FIG. 37, the function func1 arranged in the memory B is called by the memory function funcM arranged in the memory A, and all the memories (memory A to D) are set to a constant voltage state before N cycles. In FIG. 37, when the function func1 is called, memories other than the memory B in which the function func1 is arranged are set to a low voltage state. Then, all the memories are set to a constant voltage state again N cycles before the function func3 is called from the function func1.

関数func3は、呼び出されてから2Nサイクル以内に関数func1に復帰するため、関数func3が呼び出された後も関数func3が配置されたメモリD以外のメモリは一定電圧状態のままとなる。   Since the function func3 returns to the function func1 within 2N cycles after being called, the memories other than the memory D in which the function func3 is arranged remain in a constant voltage state even after the function func3 is called.

以上に説明したように、本実施形態によれば、電圧変動時間を考慮したタイミングでメモリの電源電圧を変動させるプログラムコードを生成することができる。   As described above, according to the present embodiment, it is possible to generate a program code that varies the power supply voltage of the memory at a timing in consideration of the voltage variation time.

(第五の実施形態)
以下に図面を参照して本発明の第五の実施形態について説明する。以下の第五の実施形態の説明では、第一の実施形態との相違点についてのみ説明し、第一の実施形態と同様の機能構成を有するものには第一の実施形態の説明で用いた符号と同様の符号を付与し、その説明を省略する。
(Fifth embodiment)
The fifth embodiment of the present invention will be described below with reference to the drawings. In the following description of the fifth embodiment, only differences from the first embodiment will be described, and those having the same functional configuration as those of the first embodiment are used in the description of the first embodiment. The same reference numerals as the reference numerals are assigned, and the description thereof is omitted.

本発明の第五の実施形態では、メイン関数からある一定階層までは常時一定電圧メモリに配置され、常時一定電圧メモリに配置された関数の直下の関数が常時一定電圧メモリと使用時一定電圧メモリとに配置された場合について考える。   In the fifth embodiment of the present invention, a constant voltage memory is always arranged from the main function to a certain level, and a function immediately below the function arranged in the constant voltage memory is always a constant voltage memory and a constant voltage memory in use. Consider the case where they are arranged in

本実施形態では、上記場合において、常時一定電圧メモリと使用時一定電圧メモリとに配置された関数より下の階層では、呼出元関数が配置されている使用時一定電圧メモリと同一のメモリを使用し、かつ、同一の使用時一定電圧メモリを使用する複数の呼出元関数が存在する場合(呼出元関数が一つである場合も含む)に常時一定電圧メモリを使用しない前提とする。   In this embodiment, in the above case, the same memory as the constant voltage memory in use in which the caller function is arranged is used in a layer below the functions arranged in the constant voltage memory and the constant voltage memory in use in the above case. In addition, it is assumed that the constant voltage memory is not always used when there are a plurality of caller functions that use the same constant voltage memory in use (including the case where there is only one caller function).

以下に図38を参照して上記前提について説明する。図38は、第五の実施形態の前提を説明するための図である。   The above assumption will be described below with reference to FIG. FIG. 38 is a diagram for explaining the premise of the fifth embodiment.

図38に示す配置では、メイン関数funcMと、メイン関数funcMの一層下の階層である関数funcB1、関数funcB2とが常時一定電圧メモリAに配置されている。関数funcB1の直下の関数は、関数funcC1、関数funcC2である。関数funcB2の直下の関数は、関数funcC3である。関数funcC1は、常時一定電圧メモリであるメモリAと使用時一定電圧メモリであるメモリBとに、関数funcC2は、常時一定電圧メモリであるメモリAと使用時一定電圧メモリであるメモリCとに、関数funcC3は、常時一定電圧メモリであるメモリAと使用時一定電圧メモリであるメモリDとに、それぞれ配置されている。関数funcC1、関数funcC2、関数funcC3においてメモリAに配置されている部分は、それぞれの関数の一定電圧部である。   In the arrangement shown in FIG. 38, the main function funcM and the functions funcB1 and funcB2 which are layers below the main function funcM are always arranged in the constant voltage memory A. The functions immediately below the function funcB1 are the function funcC1 and the function funcC2. The function immediately below the function funcB2 is a function funcC3. The function funcC1 is a memory A which is a constant voltage memory at all times and a memory B which is a constant voltage memory when in use, and the function funcC2 is a memory A which is a constant voltage memory at all times and a memory C which is a constant voltage memory when in use. The function funcC3 is arranged in the memory A that is always a constant voltage memory and the memory D that is a constant voltage memory when in use. In the function funcC1, the function funcC2, and the function funcC3, the portion arranged in the memory A is a constant voltage portion of each function.

図38では関数funcC3の一定電圧部をC3−1と図示した。関数funcC1、関数funcC2、関数funcC3において、それぞれ、メモリB、メモリC、メモリDに配置されている部分は、それぞれの関数の低電圧部である。図38では関数funcC3の低電圧部をC3−2と図示した。   In FIG. 38, the constant voltage portion of the function funcC3 is illustrated as C3-1. In the function funcC1, the function funcC2, and the function funcC3, the portions arranged in the memory B, the memory C, and the memory D are the low voltage portions of the respective functions. In FIG. 38, the low voltage part of the function funcC3 is illustrated as C3-2.

関数funcC1の下層には、関数funcD1、関数funcD2が配置され、さらにその下層には関数funcE1、関数funcE2が配置されている。関数funcC2の下層には、関数funcD3が配置され、さらにその下層には関数funcE3が配置されている。関数funcC3の下層には、関数funcD4が配置され、さらにその下層には関数funcE4が配置されている。   A function funcD1 and a function funcD2 are arranged in the lower layer of the function funcC1, and a function funcE1 and a function funcE2 are arranged in the lower layer. A function funcD3 is arranged below the function funcC2, and a function funcE3 is arranged further below. A function funcD4 is arranged in the lower layer of the function funcC3, and a function funcE4 is arranged in the lower layer.

関数funcE1の呼出元関数は、関数funcD1と関数funcD2である。よって関数funcE1は、関数funcD1と関数funcD2と同一の使用時一定電圧メモリであるメモリBのみに配置されている。関数funcE2の呼出元関数は、関数funcD2と関数funcD3であり、これらの関数の配置されているメモリは、それぞれメモリB、メモリCと異なる。したがって、どちらのメモリのみを使用している状態でも関数呼出が正常に行えるように、関数funcE2は、常時一定電圧メモリであるメモリAおよび、使用時一定電圧メモリであるメモリB又はメモリCの何れかに配置される。   The caller functions of the function funcE1 are the function funcD1 and the function funcD2. Therefore, the function funcE1 is arranged only in the memory B that is the constant voltage memory in use, which is the same as the functions funcD1 and funcD2. The caller functions of the function funcE2 are a function funcD2 and a function funcD3. The memories in which these functions are arranged are different from the memory B and the memory C, respectively. Therefore, the function funcE2 is a memory A that is a constant voltage memory at all times and a memory B or a memory C that is a constant voltage memory when in use so that the function call can be normally performed in a state where only either memory is used. Placed in the crab.

図38の例では関数funcE2は、メモリAと関数funcD2と同一の使用時一定電圧メモリであるメモリBとに配置されている。関数funcD1、関数funcD2は、それぞれの呼出元関数である関数funcC1と同一の使用時一定電圧メモリであるメモリBに配置されている。   In the example of FIG. 38, the function funcE2 is arranged in the memory A and the memory B, which is the same constant voltage memory in use as the function funcD2. The function funcD1 and the function funcD2 are arranged in the memory B, which is a constant voltage memory in use, which is the same as the function funcC1 that is the caller function.

メモリCにおいても、関数funcE3、関数funcD3は、どちらの関数も、メモリC以外に配置されている関数から関数呼出を行われる可能性がある。このため関数funcE3、関数funcD3は、常時一定電圧メモリAおよび、それぞれの呼出元関数と同一のメモリCに配置されている。メモリDにおいても、関数funcE4、関数funcD4はそれぞれの呼出元関数と同位置のメモリDに配置されている。   Even in the memory C, the function funcE3 and the function funcD3 may be function-called from a function other than the memory C. For this reason, the function funcE3 and the function funcD3 are always arranged in the constant voltage memory A and the same memory C as the respective caller functions. Also in the memory D, the function funcE4 and the function funcD4 are arranged in the memory D at the same position as each caller function.

図38に示す配置において、例えば関数funcD3からメイン関数funcMに復帰するまでの経路は、以下の2通りが考えられる。
(1)関数funcD3(メモリC)→関数funcC2(低電圧部)(メモリC)→関数funcC2(一定電圧部)(メモリA)→関数funcB1(メモリA)→メイン関数funcM(メモリA)
(2)関数funcD3(メモリC)→関数funcC3(低電圧部C3−2)(メモリD)→関数funcC3(一定電圧部C3−1)(メモリA)→関数funcB2(メモリA)→メイン関数funcM(メモリA)
In the arrangement shown in FIG. 38, for example, the following two routes from the function funcD3 to the return to the main function funcM can be considered.
(1) Function funcD3 (memory C) → function funcC2 (low voltage part) (memory C) → function funcC2 (constant voltage part) (memory A) → function funcB1 (memory A) → main function funcM (memory A)
(2) Function funcD3 (memory C) → function funcC3 (low voltage part C3-2) (memory D) → function funcC3 (constant voltage part C3-1) (memory A) → function funcB2 (memory A) → main function funcM (Memory A)

このうち、まず(1)の経路でメイン関数funcMまで復帰するように動作した場合について考える。   Of these, first, consider the case of operating to return to the main function funcM through the path (1).

関数funcC2でメモリCを使用する。よって第一の実施形態のコード生成装置100は図5のステップS53において、関数funcD3から復帰後の位置にメモリCを低電圧状態とするコードは挿入しない。しかし、関数funcC2より後ではメモリCを使用しないため、第一の実施形態のコード生成装置100は、関数funcC2から復帰後の位置にメモリCを低電圧状態とするコードは挿入する。したがって、メモリCが低電圧状態となってからメイン関数funcMまで戻ることになる。   The memory C is used by the function funcC2. Therefore, the code generating apparatus 100 according to the first embodiment does not insert a code for setting the memory C in the low voltage state at the position after the return from the function funcD3 in step S53 of FIG. However, since the memory C is not used after the function funcC2, the code generation device 100 according to the first embodiment inserts a code for setting the memory C in a low voltage state at a position after the return from the function funcC2. Therefore, the memory function C returns to the main function funcM after the low voltage state.

次に、(2)の経路でメイン関数funcMまで復帰するように動作した場合について考える。   Next, consider a case where the operation is performed so as to return to the main function funcM through the path (2).

関数funcD3から関数funcC3の低電圧部C3−2に復帰した以降は、メモリCは不使用である。しかしながら、関数funcD3にはメモリCを低電圧状態とするコードは挿入されていない。また関数funcC3、関数funcB2、メイン関数funcMにおいてメモリCは関係せず制御の対象外である。このためメモリCが一定電圧状態のままメイン関数funcMまで戻ることになる。   After returning from the function funcD3 to the low voltage part C3-2 of the function funcC3, the memory C is not used. However, a code for setting the memory C to a low voltage state is not inserted in the function funcD3. Further, in the function funcC3, the function funcB2, and the main function funcM, the memory C is not related and is out of control. For this reason, the memory C returns to the main function funcM in a constant voltage state.

そこで本実施形態では、関数の呼出関係に従って下層の関数からメイン関数へ復帰する際に、使用時一定電圧メモリに配置された関数の実行後その使用時一定電圧メモリが使用されないことが確認できる場合に限り、該当する使用時一定電圧メモリを低電圧状態とする。尚本実施形態において、下層の関数からメイン関数へ復帰する際に、一度使用された使用時一定電圧メモリが再度使用する場合は、再び該当する使用時一定電圧メモリを一定電圧状態とする電源制御コードを通る。このため本実施形態では、一度使用された使用時一定電圧メモリが再度使用されるか否かを判別できる。   Therefore, in the present embodiment, when returning from the lower layer function to the main function according to the function calling relationship, it can be confirmed that the constant voltage memory is not used after the function placed in the constant voltage memory is used. Only in the case of use, the corresponding constant voltage memory during use is set to a low voltage state. In this embodiment, when returning from the lower layer function to the main function, if the once-used constant voltage memory is used again, the power control is performed so that the corresponding constant voltage memory when used again becomes the constant voltage state. Go through the code. For this reason, in the present embodiment, it is possible to determine whether or not the once-used constant voltage memory is used again.

本実施形態では、このようにメイン関数に戻るまでの間に再び使用されることのない使用時一定電圧メモリを低電圧状態とすることで、消費電力の低減に貢献することができる。   In the present embodiment, the constant voltage memory in use that is not used again before returning to the main function is set to a low voltage state in this way, thereby contributing to reduction of power consumption.

図39は、第五の実施形態のコード生成装置の機能構成を説明する図である。本実施形態のコード生成装置100Bは、コード取得部110、配置判定部120、スリープ解除コード挿入処理部130、スリープコード挿入処理部140を有する。   FIG. 39 is a diagram illustrating the functional configuration of the code generation device according to the fifth embodiment. The code generation device 100B of this embodiment includes a code acquisition unit 110, an arrangement determination unit 120, a sleep release code insertion processing unit 130, and a sleep code insertion processing unit 140.

コード取得部110は、本実施形態のコード生成装置100Bに入力されるアセンブリ50から関数のアセンブリコードを取得する。配置判定部120は、後述するメモリマップ情報57に基づき、取得した関数のアセンブリコードが使用時一定電圧メモリと常時一定電圧メモリの両方に配置されているか否かを判定する。   The code acquisition unit 110 acquires an assembly code of a function from the assembly 50 input to the code generation device 100B of the present embodiment. The arrangement determination unit 120 determines whether or not the assembly code of the acquired function is arranged in both the constant voltage memory in use and the constant voltage memory at all times based on memory map information 57 described later.

尚本実施形態のコード生成装置100Bは、図40に示すように、図3に示す物理領域をメモリマップ情報57のテーブルとして有している。図40は、第五の実施形態におけるメモリマップ情報の一例を示す図である。   Note that the code generation device 100B of the present embodiment has the physical area shown in FIG. 3 as a table of the memory map information 57 as shown in FIG. FIG. 40 is a diagram illustrating an example of memory map information according to the fifth embodiment.

スリープ解除コード挿入処理部130は、配置判定部120による判定結果に基づき、使用時一定電圧メモリの低電圧状態が解除されるようにする。例えばスリープ解除コード挿入処理部130は、電源制御コードによりメモリが低電圧状態(以下、スリープ状態)から一定電圧状態となるように、スリープ解除コードを生成し、関数のコードへ挿入する。スリープ解除コード挿入処理部130の処理の詳細は後述する。   The sleep release code insertion processing unit 130 releases the low voltage state of the constant voltage memory during use based on the determination result by the arrangement determination unit 120. For example, the sleep release code insertion processing unit 130 generates a sleep release code so as to change the memory from a low voltage state (hereinafter referred to as a sleep state) to a constant voltage state by the power supply control code, and inserts the sleep release code into the function code. Details of the processing of the sleep release code insertion processing unit 130 will be described later.

スリープコード挿入処理部140は、メモリマップ情報57と電源制御コードパターン64とに基づき、関数のアセンブリコードに電源制御コードを挿入し、使用時一定電圧メモリが低電圧状態となるようにする。ここで挿入される電源制御コードは、メモリをスリープ状態とする電源制御コード(以下、スリープコード)である。スリープコード挿入処理部140の処理の詳細は後述する。   The sleep code insertion processing unit 140 inserts the power control code into the function assembly code based on the memory map information 57 and the power control code pattern 64 so that the constant voltage memory is in a low voltage state when in use. The power supply control code inserted here is a power supply control code (hereinafter referred to as a sleep code) that puts the memory into a sleep state. Details of the processing of the sleep code insertion processing unit 140 will be described later.

本実施形態のコード生成装置100Bにおいて、スリープ解除コードとスリープコードとが挿入された関数のアセンブリコードは、電源制御コード挿入後のアセンブリ50Aとして出力される。   In the code generation device 100B of this embodiment, the assembly code of the function in which the sleep release code and the sleep code are inserted is output as the assembly 50A after the power supply control code is inserted.

次に図41を参照して本実施形態のコード生成装置100Bによる制御コードの挿入について説明する。図41は、第五の実施形態のコード生成装置による制御コードの挿入を説明するフローチャートである。   Next, control code insertion by the code generation device 100B of this embodiment will be described with reference to FIG. FIG. 41 is a flowchart for explaining insertion of a control code by the code generation device of the fifth embodiment.

図41に示す処理は、図5のステップS53において実行される処理である。尚本実施形態のコード生成装置100Bは、図5のステップS51、ステップS52と同様の処理を実行した後に、図41に示す処理を開始する。そして図41に示す処理が完了すると、制御コードが挿入されたアセンブリ50Aが出力される。コード生成装置100Bは、アセンブリ50Aが出力された後、図5のステップS54と同様の処理を行い、電源制御入りバイナリ70を出力する。本実施形態のコード生成装置100Bは、図41に示す処理を各関数毎に実行する。   The process shown in FIG. 41 is a process executed in step S53 of FIG. Note that the code generation device 100B according to the present embodiment starts the processing shown in FIG. 41 after executing the same processing as steps S51 and S52 of FIG. When the process shown in FIG. 41 is completed, the assembly 50A in which the control code is inserted is output. After the assembly 50A is output, the code generation device 100B performs the same processing as step S54 in FIG. 5 and outputs the binary 70 with power control. The code generation device 100B of the present embodiment executes the process shown in FIG. 41 for each function.

本実施形態のコード生成装置100Bは、ステップS51においてコード取得部110により、関数毎のアセンブリコード55を取得し、分割位置を算出する。以下の説明では、関数funcXのアセンブリコードを取得したものとする。   In step S51, the code generation device 100B according to the present embodiment acquires the assembly code 55 for each function by the code acquisition unit 110, and calculates the division position. In the following description, it is assumed that the assembly code of the function funcX has been acquired.

コード生成装置100Bは、ステップS52において、分割位置とパラメータ60に含まれるメモリユニット10の構造情報62とに基づき分割されたアセンブリコード55を配置するためのメモリマップを決定し、メモリマップ情報57を出力する。   In step S52, the code generation device 100B determines a memory map for arranging the divided assembly code 55 based on the division position and the structure information 62 of the memory unit 10 included in the parameter 60, and sets the memory map information 57. Output.

次にコード生成装置100Bは、ステップS53へ進む。尚図41におけるステップS4101からステップS4106までの処理は、配置判定部120とスリープ解除コード挿入処理部130とにより実行される処理である。またステップS4107からステップS4109までの処理は、スリープコード挿入処理部140により実行される処理である。   Next, the code generation device 100B proceeds to step S53. Note that the processing from step S 4101 to step S 4106 in FIG. 41 is processing executed by the arrangement determination unit 120 and the sleep release code insertion processing unit 130. The processing from step S4107 to step S4109 is processing executed by the sleep code insertion processing unit 140.

コード生成装置100BがステップS53の実行を開始すると、配置判定部120は、分割されたアセンブリコード55と、メモリマップ情報57とに基づき、関数funcXのアセンブリコード55が使用時一定電圧メモリと常時一定電圧メモリとの両方を使用するか否かを判定する(ステップS4101)。   When the code generation device 100B starts executing step S53, the arrangement determining unit 120 always maintains the constant function voltage memory and the assembly code 55 of the function funcX based on the divided assembly code 55 and the memory map information 57. It is determined whether or not to use both of the voltage memory (step S4101).

ステップS4101において、関数funcXが使用時一定電圧メモリと常時一定電圧メモリのいずれかのみを使用する場合、後述するステップS4106へ進む。   In step S4101, when the function funcX uses only one of the constant voltage memory in use and the constant voltage memory at all times, the process proceeds to step S4106 described below.

ステップS4101において、使用時一定電圧メモリと常時一定電圧メモリとの両方を使用する場合、コード生成装置100Bは、ステップS51で算出した分割位置に従って関数funcXのアセンブリコード55を分割する(ステップS4102)。分割されたアセンブリコード55の前半部分を一定電圧部Xa、後半部分を低電圧部Xbとする。   If both the constant voltage memory in use and the constant voltage memory are used in step S4101, the code generation device 100B divides the assembly code 55 of the function funcX according to the division position calculated in step S51 (step S4102). The first half of the divided assembly code 55 is a constant voltage portion Xa, and the second half is a low voltage portion Xb.

続いて、コード生成装置100Bは、ステップS52で決定したメモリマップに基づき電源制御コードパターン64とジャンプ制御コードパターン65とにパラメータを埋め込む(ステップS4103〜4106)。   Subsequently, the code generation device 100B embeds parameters in the power control code pattern 64 and the jump control code pattern 65 based on the memory map determined in step S52 (steps S4103 to 4106).

スリープ解除コード挿入処理部130は、一定電圧部Xaの先頭の電源制御コードパターン64に、一定電圧状態とするメモリを指定する「低電圧部Xbが配置された使用時一定電圧メモリ」をパラメータとして埋め込む(ステップS4103)。本実施形態では、一定電圧状態とするパラメータが埋め込まれた電源制御コードパターンをスリープ解除コードとする。本実施形態のスリープ解除コードは、例えば低電圧部Xbが配置されたメモリを一定電圧状態(使用できる状態)とする。   The sleep release code insertion processing unit 130 uses, as a parameter, a “constant voltage memory in use in which the low voltage part Xb is arranged” that specifies a memory to be in a constant voltage state in the power supply control code pattern 64 at the head of the constant voltage part Xa. Embed (step S4103). In this embodiment, a power control code pattern in which a parameter for setting a constant voltage state is embedded is set as a sleep release code. The sleep release code of the present embodiment sets, for example, a memory in which the low voltage unit Xb is arranged to a constant voltage state (a usable state).

次にコード生成装置100Bは、関数funcXの低電圧部Xbの開始アドレスを表すラベルfuncX_Lを挿入する(ステップS4104)。さらにコード生成装置100Bは、ジャンプ制御コードパターン65に、関数funcXの低電圧部の開始アドレスを示すラベルfuncX_Lを埋め込む(ステップS4105)。   Next, the code generation device 100B inserts a label funcX_L representing the start address of the low voltage part Xb of the function funcX (step S4104). Further, the code generation device 100B embeds a label funcX_L indicating the start address of the low voltage part of the function funcX in the jump control code pattern 65 (step S4105).

以上により、関数funcXのアセンブリコード55に使用時一定電圧メモリを使用できるようにするためのスリープ解除コードが挿入される。   As described above, the sleep release code is inserted into the assembly code 55 of the function funxX so that the constant voltage memory can be used during use.

次にコード生成装置100Bは、関数funcX内の関数呼出について、使用時一定電圧メモリを低電圧状態とするためのスリープコードを挿入する処理を実行する(ステップS4106)。尚ステップS4106の処理では、以下に説明するステップS4107〜4109の処理を行う。   Next, the code generation device 100B executes a process of inserting a sleep code for setting the constant voltage memory in use into a low voltage state for the function call in the function funcX (step S4106). In the process of step S4106, the processes of steps S4107 to 4109 described below are performed.

本実施形態のコード生成装置100Bは、関数funcX内の命令(コード)を一命令ごと走査し、call命令か否かを判定する(ステップS4107)。ステップS4107において命令がcall命令でない場合、ステップS4106の処理を終了する。   The code generation device 100B according to the present embodiment scans each instruction (code) in the function funcX and determines whether the instruction is a call instruction (step S4107). If the instruction is not a call instruction in step S4107, the process of step S4106 is terminated.

ステップS4107において命令がcall命令の場合、スリープコード挿入処理部140は、呼出先関数が配置されているメモリ(以下、呼出先メモリ)が、関数funcXのcall命令が配置されたメモリと同一のメモリ又は常時一定電圧メモリであるか否かを判断する(ステップS4108)。ステップS4108において、呼出先関数が配置されているメモリがcall命令が配置されたメモリと同一のメモリ又は常時一定電圧メモリである場合、ステップS4106の処理を終了する。   If the instruction is a call instruction in step S4107, the sleep code insertion processing unit 140 determines that the memory in which the call destination function is arranged (hereinafter called the call destination memory) is the same memory as the memory in which the call instruction of the function funcX is arranged. Alternatively, it is determined whether or not the memory is always a constant voltage (step S4108). In step S4108, when the memory in which the callee function is arranged is the same memory as the memory in which the call instruction is arranged or the constant voltage memory, the processing in step S4106 is terminated.

ステップS4108において、呼出先メモリがcall命令が配置されたメモリと同一のメモリ又は常時一定電圧メモリでない場合、スリープコード挿入処理部140は、関数funcXのcall命令の次に呼出先メモリの電源を低電圧とする電源制御コードを挿入し(ステップS4109)、ステップS4106の処理を終了する。   In step S4108, when the call destination memory is not the same memory as the memory in which the call instruction is arranged or the constant voltage memory, the sleep code insertion processing unit 140 lowers the power of the call destination memory next to the call instruction of the function funcX. A power supply control code for voltage is inserted (step S4109), and the process of step S4106 is terminated.

例えば、関数funcXのアセンブリコード55中の低電圧部XbのコードがメモリYへ配置されており、関数funcXのアセンブリコード55中で、メモリZに配置された関数funcYを呼び出す場合を考える。   For example, consider a case where the code of the low voltage part Xb in the assembly code 55 of the function funxX is arranged in the memory Y and the function funcY arranged in the memory Z is called in the assembly code 55 of the function funcX.

コード生成装置100Bは、関数funcYの実行後に関数funcXに復帰する際に、メモリZを低電圧状態とする。すなわちスリープコード挿入処理部140は、電源制御コードパターン64に、低電圧状態とするメモリを指定する「メモリZ」をパラメータとして埋め込んでスリープコードを生成する。そしてスリープコード挿入処理部140は、関数funcXのアセンブリコード55中の関数funcYを呼び出す関数呼出命令の直後に生成したスリープコードを挿入する。   When the code generating apparatus 100B returns to the function funcX after executing the function funcY, the code generating apparatus 100B sets the memory Z to a low voltage state. In other words, the sleep code insertion processing unit 140 generates a sleep code by embedding “memory Z” that designates a memory to be set in the low voltage state in the power control code pattern 64 as a parameter. Then, the sleep code insertion processing unit 140 inserts the sleep code generated immediately after the function call instruction for calling the function funcY in the assembly code 55 of the function funcX.

以下に、図42乃至図46を参照して、図41に示す処理についてさらに説明する。   The processing shown in FIG. 41 will be further described below with reference to FIGS.

図42は、スリープ解除コード挿入処理部とスリープコード挿入処理部の処理を説明する図である。   FIG. 42 is a diagram for explaining processing of the sleep release code insertion processing unit and the sleep code insertion processing unit.

図41のステップS4101において、関数funcXが常時一定電圧メモリか使用時一定電圧メモリのいずれかのみを使用する場合、スリープ解除コード挿入処理部130はスリープ解除コードを挿入しない。また関数funcXが常時一定電圧メモリと使用時一定電圧メモリとを使用する場合、関数funcXは、一定電圧部Xaと低電圧部Xbとに分割される。スリープ解除コード挿入処理部130は、一定電圧部Xaの先頭に、低電圧部Xbが配置されたメモリを一定電圧状態とするスリープ解除コードを挿入する。尚図42では、低電圧部Xbが配置された使用時一定電圧メモリをメモリXBとした。   In step S4101, the sleep release code insertion processing unit 130 does not insert the sleep release code when the function funcX always uses only the constant voltage memory or the constant voltage memory when in use. When the function funcX always uses a constant voltage memory and a constant voltage memory when in use, the function funcX is divided into a constant voltage part Xa and a low voltage part Xb. The sleep release code insertion processing unit 130 inserts a sleep release code that puts the memory in which the low voltage unit Xb is arranged into a constant voltage state at the head of the constant voltage unit Xa. In FIG. 42, the constant voltage memory in use in which the low voltage portion Xb is arranged is the memory XB.

スリープコード挿入処理部140は、関数funcXのアセンブリコード55にcall命令が存在する場合、呼出先メモリがcall命令が配置されたメモリと同一のメモリ又は常時一定電圧メモリであるか否かを判断する。呼出先メモリがcall命令が配置されたメモリと同一のメモリ又は常時一定電圧メモリである場合、スリープコード挿入処理部140はスリープコードを挿入しない。   When the call instruction is present in the assembly code 55 of the function funcX, the sleep code insertion processing unit 140 determines whether the call destination memory is the same memory as the memory in which the call instruction is arranged or a constant voltage memory at all times. . When the call destination memory is the same memory as the memory in which the call instruction is arranged or the constant voltage memory at all times, the sleep code insertion processing unit 140 does not insert the sleep code.

呼出先メモリがcall命令が配置されたメモリと同一のメモリ又は常時一定電圧メモリでない場合、スリープコード挿入処理部140は関数funcXのcall命令の次に呼出先メモリを低電圧状態とするスリープコードを挿入する。   When the call destination memory is not the same memory as the memory in which the call instruction is arranged or the constant voltage memory at all times, the sleep code insertion processing unit 140 generates a sleep code for setting the call destination memory to the low voltage state after the call instruction of the function funcX. insert.

図42のように、関数funcXのcall命令がメモリXに配置されており、呼出先メモリがメモリYである場合、スリープコード挿入処理部140は関数funcXのcall命令の次にメモリYを低電圧状態とするスリープコードを挿入する。   As shown in FIG. 42, when the call instruction of the function funcX is arranged in the memory X and the call destination memory is the memory Y, the sleep code insertion processing unit 140 applies the memory Y to the low voltage next to the call instruction of the function funcX. Insert the sleep code to be in the state.

このようにスリープコードを挿入することで、関数funcYから関数funcXに復帰する際にメモリYを低電圧状態とすることができ、消費電力の低減に貢献することができる。   By inserting the sleep code in this way, the memory Y can be brought into a low voltage state when returning from the function funcY to the function funcX, which can contribute to a reduction in power consumption.

以下にスリープ解除コード挿入処理部130とスリープコード挿入処理部140の処理について、図38を例としてさらに説明する。   Hereinafter, the processes of the sleep release code insertion processing unit 130 and the sleep code insertion processing unit 140 will be further described with reference to FIG. 38 as an example.

図43は、関数funcXがメイン関数funcMの場合を示す図である。   FIG. 43 is a diagram illustrating a case where the function funcX is the main function funcM.

メイン関数funcMは常時一定電圧メモリのみ使用するように配置されており、低電圧部が割り当てられる使用時一定電圧メモリへのジャンプ制御コードと、低電圧部が割り当てられた使用時一定電圧メモリを一定電圧状態とする電源制御コードの挿入は不要である。したがって、関数funcXがメイン関数funcMの場合、図41では、ステップS4101からステップS4106へ進む。   The main function funcM is always arranged to use only the constant voltage memory, and the jump control code to the constant voltage memory in use to which the low voltage part is assigned and the constant voltage memory in use to which the low voltage part is assigned are constant. It is not necessary to insert a power supply control code to be in a voltage state. Therefore, when the function funcX is the main function funcM, the process proceeds from step S4101 to step S4106 in FIG.

ステップS4107において、メイン関数funcMには、関数funcB1を呼び出すcall命令が存在する。よってステップS4108へ進む。ステップS4108では、呼出先関数である関数funcB1が配置されているメモリは、常時一定電圧メモリである。よって使用時一定電圧メモリを低電圧状態とする電源制御コードを挿入は不要となり、ステップS4106の処理を終了する。   In step S4107, the main function funcM includes a call instruction for calling the function funcB1. Therefore, the process proceeds to step S4108. In step S4108, the memory in which the function funcB1, which is a call destination function, is always a constant voltage memory. Therefore, it is not necessary to insert a power supply control code for setting the constant voltage memory in a low voltage state when in use, and the process of step S4106 is terminated.

図44は、関数funcXが関数funcB1の場合を示す図である。   FIG. 44 is a diagram illustrating a case where the function funcX is the function funcB1.

関数funcB1も、メイン関数funcMと同様に常時一定電圧メモリに配置されており、使用時一定電圧メモリへのジャンプ制御コードと低電圧部が割り当てられた使用時一定電圧メモリを一定電圧状態とする電源制御コードの挿入は不要である。   Similarly to the main function funcM, the function funcB1 is also always placed in the constant voltage memory, and the power supply that puts the constant voltage memory in use in a constant voltage state to which the jump control code to the constant voltage memory in use and the low voltage part are assigned is used. There is no need to insert a control code.

したがって、関数funcXが関数funcB1の場合、図41では、ステップS4101からステップS4106へ進む。   Therefore, when the function funcX is the function funcB1, in FIG. 41, the process proceeds from step S4101 to step S4106.

ステップS4107において、関数funcB1には、関数funcC1を呼び出すcall命令が存在する。よってステップS4108へ進む。ステップS4108において、関数funcC1は使用時一定電圧メモリBに配置されている。メモリBは、関数funcB1が配置されているメモリと同一ではなく、また常時一定電圧メモリではない。よってステップS4109へ進む。   In step S4107, the function funcB1 includes a call instruction for calling the function funcC1. Therefore, the process proceeds to step S4108. In step S4108, the function funcC1 is placed in the constant voltage memory B when in use. The memory B is not the same as the memory in which the function funcB1 is arranged, and is not always a constant voltage memory. Therefore, the process proceeds to step S4109.

関数funcC1が実行された後にメイン関数funcMに戻るまでにメモリBは使用されない。よってステップS4109において、関数funcB1のcall命令の次にメモリBを低電圧状態とする電源制御コードが挿入される。   After the function funcC1 is executed, the memory B is not used before returning to the main function funcM. Therefore, in step S4109, the power supply control code for setting the memory B in the low voltage state is inserted after the call instruction of the function funcB1.

図45は、関数funcXが関数funcD2の場合を示す図である。   FIG. 45 is a diagram illustrating a case where the function funcX is the function funcD2.

関数funcD2は、使用時一定電圧メモリのみ使用するように配置されている。したがって、他の使用時一定電圧メモリを一定電圧状態とする電源制御コードの挿入は不要である。したがって、関数funcXが関数funcD2の場合、図41では、ステップS4101からステップS4106へ進む。   The function funcD2 is arranged to use only a constant voltage memory when in use. Therefore, it is not necessary to insert a power supply control code for making the constant voltage memory in a constant voltage state during other use. Therefore, when the function funcX is the function funcD2, in FIG. 41, the process proceeds from step S4101 to step S4106.

ステップS4107において、関数funcD2には、関数funcE1、関数funcE2と関数funcE3を呼び出すcall命令が存在する。よってステップS4108へ進む。   In step S4107, the function funcD2 includes a call instruction that calls the function funcE1, the function funcE2, and the function funcE3. Therefore, the process proceeds to step S4108.

ステップS4108において、関数funcE1、関数funcE2は関数funcD2と同一の使用時一定電圧メモリBに配置されている。すなわち関数funcE1、関数funcE2が関数funcD2に復帰した後もメモリBを使用するため、関数funcD2にメモリBを低電圧状態とする電源制御コードを挿入せずにステップS4106の処理を終了する。   In step S4108, the function funcE1 and the function funcE2 are placed in the same constant voltage memory B during use as the function funcD2. That is, since the function B is used even after the functions funcE1 and funcE2 return to the function funcD2, the process of step S4106 is terminated without inserting the power supply control code for setting the memory B in the low voltage state into the function funcD2.

一方、関数funcE3は関数funcD2と別の使用時一定電圧メモリCに配置されている。よってステップS4109へ進む。関数funcE3が関数funcD2へ復帰した後はメモリBを使用するため、ステップS4109では、関数funcD2における関数funcE3のcall命令の次にメモリCを低電圧状態とする電源制御コードが挿入される。   On the other hand, the function funcE3 is arranged in a constant voltage memory C at the time of use different from the function funcD2. Therefore, the process proceeds to step S4109. Since the memory B is used after the function funcE3 returns to the function funcD2, in step S4109, a power supply control code for setting the memory C to a low voltage state is inserted after the call instruction of the function funcE3 in the function funcD2.

図46は、関数funcXが関数funcC3の場合を示す図である。   FIG. 46 is a diagram illustrating a case where the function funcX is the function funcC3.

関数funcC3は、常時一定電圧メモリであるメモリAと、使用時一定電圧メモリであるメモリDとを使用するように配置されている。したがって、図41のステップS4101からステップS4102以降の処理へ進む。   The function funcC3 is arranged so as to always use the memory A that is a constant voltage memory and the memory D that is a constant voltage memory when in use. Accordingly, the process proceeds from step S4101 to step S4102 and subsequent steps in FIG.

関数funcC3は、関数サイズ情報52に基づき一定電圧部C3−1と低電圧部C3−2に分割される。一定電圧部C3−1はメモリAへ、低電圧部C3−2はメモリDへ割り当てられる。   The function funcC3 is divided into a constant voltage part C3-1 and a low voltage part C3-2 based on the function size information 52. The constant voltage unit C3-1 is allocated to the memory A, and the low voltage unit C3-2 is allocated to the memory D.

関数funcC3が分割されると、スリープ解除コード挿入処理部130は、低電圧部C3−2が配置されるメモリDを一定電圧状態とするためのスリープ解除コードを一定電圧部C3−1の先頭に挿入する。またスリープ解除コード挿入処理部130は、低電圧部C3−2の先頭にラベル付けを行い、一定電圧部C3−1の最後にメモリDへのジャンプ制御コードを挿入する。   When the function funcC3 is divided, the sleep release code insertion processing unit 130 sets a sleep release code for setting the memory D in which the low voltage unit C3-2 is arranged to a constant voltage state at the head of the constant voltage unit C3-1. insert. The sleep release code insertion processing unit 130 labels the beginning of the low voltage unit C3-2 and inserts the jump control code to the memory D at the end of the constant voltage unit C3-1.

関数funcC3には、関数funcD3と関数funcD4を呼び出すcall命令が存在する。関数funcD4は、関数funcC3と同一の使用時一定電圧メモであるメモリDに配置されており、関数funcD4は復帰後メモリDを使用する。よってスリープコード挿入処理部140は、関数funcC3のアセンブリコード中に関数funcD4のcall命令の次にメモリDを低電圧状態とするスリープコードは挿入しない。   The function funcC3 includes a call instruction that calls the function funcD3 and the function funcD4. The function funcD4 is arranged in the memory D, which is a constant voltage memo when in use, which is the same as the function funcC3, and the function funcD4 uses the memory D after returning. Therefore, the sleep code insertion processing unit 140 does not insert the sleep code for setting the memory D in the low voltage state after the call instruction of the function funcD4 in the assembly code of the function funcC3.

一方、関数funcD3は関数funcC3と別の使用時一定電圧メモリであるメモリCに配置されており、関数funcD3から関数funcC3に復帰した後はメモリCを使用しない。よってスリープコード挿入処理部140は、関数funcC3のアセンブリコード中において、関数funcD3のcall命令の直後にメモリCを低電圧状態とするスリープコードを挿入する。   On the other hand, the function funcD3 is arranged in a memory C, which is a constant voltage memory when used, different from the function funcC3, and the memory C is not used after returning from the function funcD3 to the function funcC3. Therefore, the sleep code insertion processing unit 140 inserts a sleep code for setting the memory C in a low voltage state immediately after the call instruction of the function funcD3 in the assembly code of the function funcC3.

以上に説明したように、本実施形態では、呼出元関数が配置されたメモリと呼出先関数が配置された呼出先メモリとが異っており、呼出先関数から呼出元関数へ復帰した後に呼出先メモリが再度使用されない場合に、呼出元関数のアセンブリコード55中のcall命令の直後に呼出先メモリを低電圧状態とするスリープコードを挿入する。本実施形態では、これにより呼出先関数が呼出元関数に復帰する際に呼出先メモリを低電圧状態とすることができ、消費電力の低減に貢献することができる。   As described above, in the present embodiment, the memory in which the caller function is arranged is different from the callee memory in which the callee function is arranged, and the call is made after returning from the callee function to the caller function. When the destination memory is not used again, a sleep code for putting the destination memory in a low voltage state is inserted immediately after the call instruction in the assembly code 55 of the caller function. In the present embodiment, this allows the callee memory to be in a low voltage state when the callee function returns to the caller function, thereby contributing to the reduction of power consumption.

(第六の実施形態)
以下に図面を参照して本発明の第六の実施形態について説明する。以下の第六の実施形態の説明では、第五の実施形態との相違点についてのみ説明し、第五の実施形態と同様の機能構成を有するものには第五の実施形態の説明で用いた符号と同様の符号を付与し、その説明を省略する。
(Sixth embodiment)
The sixth embodiment of the present invention will be described below with reference to the drawings. In the following description of the sixth embodiment, only differences from the fifth embodiment will be described, and those having the same functional configuration as the fifth embodiment were used in the description of the fifth embodiment. The same reference numerals as the reference numerals are assigned, and the description thereof is omitted.

本発明の第六の実施形態では、第五の実施形態同様、メイン関数からある一定階層までは常時一定電圧メモリに配置され、常時一定電圧メモリに配置された関数の直下の関数が常時一定電圧メモリと使用時一定電圧メモリとに配置された場合について考える。   In the sixth embodiment of the present invention, as in the fifth embodiment, the main function up to a certain level is always placed in a constant voltage memory, and the function directly below the function placed in the constant voltage memory is always a constant voltage. Consider the case where the memory and the constant voltage memory are in use.

また、上記場合において、常時一定電圧メモリと使用時一定電圧メモリとに配置された関数より下の階層では、呼出元関数が配置されている使用時一定電圧メモリと同一のメモリを使用し、かつ、同一の使用時一定電圧メモリを使用する複数の呼出元関数が存在する場合(呼出元関数が一つである場合も含む)に常時一定電圧メモリを使用しない前提も、第五の実施形態同様である。   Further, in the above case, in the hierarchy below the functions arranged in the constant voltage memory and the constant voltage memory in use, the same memory as the constant voltage memory in use in which the caller function is arranged is used, and Assuming that the constant voltage memory is not always used when there are a plurality of caller functions that use the same constant voltage memory when used (including the case where there is only one caller function), the same as in the fifth embodiment It is.

図47は、第六の実施形態の前提を説明するための図である。図47(A)は、本実施形態における関数の呼出関係を示している。図47(B)は、図47(A)に示す呼出関係に基づきメモリマップを生成した結果を示している。図47の状態において、第五の実施形態のコード生成装置100Bにより制御コードの挿入を行うと、以下のようにメモリB、Cが低電圧状態となるようにスリープコードが挿入される。   FIG. 47 is a diagram for explaining the premise of the sixth embodiment. FIG. 47A shows a function call relationship in the present embodiment. FIG. 47B shows the result of generating a memory map based on the call relationship shown in FIG. In the state of FIG. 47, when the control code is inserted by the code generation device 100B of the fifth embodiment, the sleep code is inserted so that the memories B and C are in the low voltage state as follows.

メモリBが低電圧状態となるとき:
(1)関数funcA2から関数funcMAINに復帰するとき
(2)関数funcA5から関数funcMAINに復帰するとき
(3)関数funcB1から関数funcA1に復帰するとき
(4)関数funcB2から関数funcA3に復帰するとき
(5)関数funcD1から関数funcC1に復帰するとき
(6)関数funcC2から関数funcB3に復帰するとき
When memory B is in a low voltage state:
(1) When returning from function funcA2 to function funcMAIN (2) When returning from function funcA5 to function funcMAIN (3) When returning from function funcB1 to function funcA1 (4) When returning from function funcB2 to function funcA3 (5) ) When returning from function funcD1 to function funcC1 (6) When returning from function funcC2 to function funcB3

メモリCが低電圧状態となるとき:
(1)関数funcA1から関数funcMAINに復帰するとき
(2)関数funcA3から関数funcMAINに復帰するとき
(3)関数funcA4から関数funcMAINに復帰するとき
(4)関数funcC1から関数funcB1に復帰するとき
(5)関数funcB5から関数funcB4に復帰するとき
When memory C is in a low voltage state:
(1) When returning from function funcA1 to function funcMAIN (2) When returning from function funcA3 to function funcMAIN (3) When returning from function funcA4 to function funcMAIN (4) When returning from function funcC1 to function funcB1 (5) ) When returning from function funcB5 to function funcB4

上記のタイミングでメモリB、メモリCが低電圧状態となるように制御コードが挿入されたプログラムにおいて、関数funcMAIN、関数funcA1、関数funcB1、関数funcC1、関数funcD1の順に関数が呼び出される場合を考える。   Consider a case in which functions are called in the order of function funcMAIN, function funcA1, function funcB1, function funcC1, and function funcD1 in the program in which the control code is inserted so that the memory B and memory C are in a low voltage state at the above timing.

この場合、関数funcD1から関数funcC1に復帰するときにメモリBは低電圧状態となる。続いて、関数funcC1から関数funcB1に復帰しようとするが、このときメモリBは既に低電圧状態となっている。   In this case, when returning from the function funcD1 to the function funcC1, the memory B is in a low voltage state. Subsequently, an attempt is made to return from the function funcC1 to the function funcB1, but at this time, the memory B is already in a low voltage state.

したがって、このプログラムを実行しているプロセッサが関数funcC1から関数funcB1へ復帰するという命令を実行しようした場合に、プロセッサはメモリBへアクセスすることができない。このためプロセッサは命令を得ることができず、正しく動作しなくなる虞がある。   Therefore, when the processor executing this program tries to execute an instruction to return from the function funcC1 to the function funcB1, the processor cannot access the memory B. As a result, the processor cannot obtain instructions and may not operate correctly.

本実施形態では、どのようなメモリマップが得られた場合でも、プロセッサが命令を得て正しく動作することができるように制御コードを生成する。   In this embodiment, regardless of what memory map is obtained, control code is generated so that the processor can obtain instructions and operate correctly.

図48は、第六の実施形態のコード生成装置の機能構成を説明する図である。本実施形態のコード生成装置100Cは、第五の実施形態のコード生成装置100Bの有する各部に加え、スリープ可能表作成部150を有する。   FIG. 48 is a diagram illustrating the functional configuration of the code generation device according to the sixth embodiment. The code generation device 100C of the present embodiment includes a sleepable table creation unit 150 in addition to the units included in the code generation device 100B of the fifth embodiment.

本実施形態のコード生成装置100Cは、このスリープ可能表作成部150により作成されたテーブルに基づき制御コードを挿入する。   The code generation device 100C of this embodiment inserts a control code based on the table created by the sleep capable table creation unit 150.

本実施形態のスリープ可能表作成部150は、関数呼出関係情報58、メモリマップ57により、関数fに至るまでに使用しうる全ての使用時一定電圧メモリの集合を示すテーブルであるUPFM(f)を作成する。また本実施形態のスリープ可能表作成部150は、UPFM(f)に基づき、関数gから関数fへ復帰するときに、関数gの配置されているメモリを低電圧状態にしてもよい否かを示すテーブルであるPowerOff(f,g)を作成する。作成された上記2つのテーブルは、本実施形態のコード生成装置100Cの有する補助記憶装置104又はメモリ装置105の所定の領域へ記憶される。スリープ可能表作成部150による上記2つのテーブルの作成の詳細は後述する。   The sleep capable table creation unit 150 according to the present embodiment is a table indicating a set of all constant voltage memories in use that can be used up to the function f by the function call relation information 58 and the memory map 57, UPFM (f) Create Also, the sleep capable table creation unit 150 of the present embodiment determines whether or not the memory in which the function g is placed may be in a low voltage state when returning from the function g to the function f based on UPFM (f). A PowerOff (f, g), which is a table to be shown, is created. The two created tables are stored in a predetermined area of the auxiliary storage device 104 or the memory device 105 included in the code generation device 100C of the present embodiment. Details of creation of the two tables by the sleep capable table creation unit 150 will be described later.

尚本実施形態の関数呼出関係情報58は、アセンブリ50に含まれる各関数における呼出関係を示すものである。本実施形態の関数呼出関係情報58は、予めコード生成装置100Cに与えられるものであっても良いし、コード生成装置100Cがアセンブリ50から生成したものであっても良い。   Note that the function call relationship information 58 of this embodiment indicates the call relationship in each function included in the assembly 50. The function call relationship information 58 of the present embodiment may be given in advance to the code generation device 100C, or may be generated from the assembly 50 by the code generation device 100C.

次に図49を参照して本実施形態のコード生成装置100Cによる制御コードの挿入について説明する。図49は、第六の実施形態のコード生成装置による制御コードの挿入を説明するフローチャートである。   Next, control code insertion by the code generation device 100C of the present embodiment will be described with reference to FIG. FIG. 49 is a flowchart for explaining insertion of a control code by the code generation device of the sixth embodiment.

図49に示す処理は、図5のステップS53において実行される処理である。尚本実施形態のコード生成装置100Cは、図5のステップS51、ステップS52と同様の処理を実行した後に、図49に示す処理を開始する。そして図49に示す処理が完了すると、制御コードが挿入されたアセンブリ50Aが出力される。   The process shown in FIG. 49 is a process executed in step S53 of FIG. Note that the code generation device 100C of the present embodiment starts the processing shown in FIG. 49 after executing the same processing as in steps S51 and S52 of FIG. When the process shown in FIG. 49 is completed, the assembly 50A in which the control code is inserted is output.

コード生成装置100Cは、アセンブリ50Aが出力された後、図5のステップS54と同様の処理を行い、電源制御入りバイナリ70を出力する。本実施形態のコード生成装置100Cは、図49に示す処理を各関数毎に実行する。   After the assembly 50A is output, the code generation device 100C performs the same processing as step S54 in FIG. 5 and outputs the binary 70 with power control. The code generation device 100C according to the present embodiment executes the processing illustrated in FIG. 49 for each function.

本実施形態のコード生成装置100Cは、ステップS51においてコード取得部110により、関数毎のアセンブリコード55を取得し、分割位置を算出する。以下の説明では、関数funcXのアセンブリコードを取得したものとする。   In step S51, the code generation device 100C of the present embodiment acquires the assembly code 55 for each function by the code acquisition unit 110, and calculates the division position. In the following description, it is assumed that the assembly code of the function funcX has been acquired.

コード生成装置100Cは、ステップS52において、分割位置とパラメータ60に含まれるメモリユニット10の構造情報62とに基づき分割されたアセンブリコード55を配置するためのメモリマップを決定し、メモリマップ情報57を出力する。   In step S52, the code generation device 100C determines a memory map for arranging the divided assembly code 55 based on the division position and the structure information 62 of the memory unit 10 included in the parameter 60, and sets the memory map information 57. Output.

次にコード生成装置100Cは、ステップS53へ進み、ステップS4901以降の処理を実行する。尚図49におけるステップS4901からステップS4906までの処理は、配置判定部120、スリープ解除コード挿入処理部130、スリープ可能表作成部150により実行される処理である。またステップS4908からステップS4910までの処理は、スリープコード挿入処理部140により実行される処理である。   Next, the code generation device 100 </ b> C proceeds to step S <b> 53, and executes the processing after step S <b> 4901. Note that the processing from step S4901 to step S4906 in FIG. 49 is processing executed by the placement determination unit 120, the sleep release code insertion processing unit 130, and the sleep capable table creation unit 150. The processing from step S4908 to step S4910 is processing executed by the sleep code insertion processing unit 140.

コード生成装置100CがステップS53の実行を開始すると、スリープ可能表作成部150は、ステップS50を実行してPowerOff(f,g)を作成する(ステップS4901)。尚ステップS50の詳細は後述する。   When the code generating device 100C starts executing step S53, the sleep capable table creating unit 150 executes step S50 and creates PowerOff (f, g) (step S4901). Details of step S50 will be described later.

ステップS4902からステップS4907までの処理は、図41のステップS4101からステップS4106までの処理と同様であるから説明を省略する。   The processing from step S4902 to step S4907 is the same as the processing from step S4101 to step S4106 in FIG.

ステップS4907の処理では、スリープコード挿入処理部140が、以下に説明するステップS4908〜4910の処理を行う。   In the process of step S4907, the sleep code insertion processing unit 140 performs the processes of steps S4908 to 4910 described below.

本実施形態のコード生成装置100Cは、関数funcX内の命令(コード)を一命令ごと走査し、call命令か否かを判定する(ステップS4908)。ステップS4908において命令がcall命令でない場合、ステップS4907の処理を終了する。   The code generation device 100C according to the present embodiment scans each instruction (code) in the function funcX and determines whether the instruction is a call instruction (step S4908). If the instruction is not a call instruction in step S4908, the process of step S4907 ends.

ステップS4908において命令がcall命令の場合、スリープコード挿入処理部140は、PowerOff(f,g)を参照してスリープコードの挿入が可能か否かを判断する(ステップS4909)。ステップS4909において、スリープコードの挿入が不可能である場合、ステップS4907の処理を終了する。ステップS4909において、スリープコードの挿入が可能である場合、スリープコード挿入部140は、関数funcXのcall命令の次に呼出先メモリの電源を低電圧とする電源制御コードを挿入し(ステップS4910)、ステップS4907の処理を終了する。   When the instruction is a call instruction in step S4908, the sleep code insertion processing unit 140 refers to PowerOff (f, g) and determines whether or not the sleep code can be inserted (step S4909). If the sleep code cannot be inserted in step S4909, the process of step S4907 ends. If the sleep code can be inserted in step S4909, the sleep code insertion unit 140 inserts a power control code for setting the power of the callee memory to a low voltage next to the call instruction of the function funcX (step S4910). The process of step S4907 ends.

このように本実施形態では、UPFM(f)に基づき生成されたPowerOff(f,g)から、スリープコードの挿入が可能と判断された場合にのみ、スリープコードを挿入する。   As described above, in the present embodiment, the sleep code is inserted only when it is determined from the PowerOff (f, g) generated based on UPFM (f) that the sleep code can be inserted.

ここで、スリープ可能表作成部150によるUPFM(f)と、PowerOff(f,g)の作成について説明する。初めに、UPFM(f)について説明する。   Here, creation of UPFM (f) and PowerOff (f, g) by the sleep capable table creation unit 150 will be described. First, UPFM (f) will be described.

本実施形態のUPFM(f)は、関数fに至るまでに使用しうる全ての使用時一定電圧メモリの集合を示すテーブルである。UPFM(f)は以下の式(1)のように定義される。   UPFM (f) of this embodiment is a table showing a set of all constant voltage memories in use that can be used up to the function f. UPFM (f) is defined as the following formula (1).

Figure 2011134288
Figure 2011134288

ここで、Using_PFM(f)はメモリマップ情報57において関数fが使用する使用時一定電圧メモリ名の集合である。   Here, Usage_PFM (f) is a set of constant voltage memory names in use used by the function f in the memory map information 57.

例えば関数fが関数funcMAINであった場合、UPFM(f)は以下のようになる。   For example, when the function f is the function funcMAIN, UPFM (f) is as follows.

UPFM(funcMAIN):=φ   UPFM (funcMAIN): = φ

すなわち、関数funcMAINに至るまでに使用しうる全ての使用時一定電圧メモリの集合UPFM(funcMAIN)は、空集合となる。   That is, the set UPFM (funcMAIN) of all in-use constant voltage memories that can be used up to the function funcMAIN is an empty set.

また関数fが関数funcA1であった場合、UPFM(f)は以下のようになる。   When the function f is the function funcA1, UPFM (f) is as follows.

UPFM(funcA1):=UPFM(funcMAIN)∪ Using_PFM(funcA1)={C}   UPFM (funcA1): = UPFM (funcMAIN) ∪Using_PFM (funcA1) = {C}

すなわち、関数funcA1に至るまでに使用しうる全ての使用時一定電圧メモリの集合UPFM(funcA1)は、メモリCのみとなる。   That is, the set UPFM (funcA1) of all in-use constant voltage memories that can be used up to the function funcA1 is only the memory C.

また関数fが関数funcB1であった場合、UPFM(f)は以下のようになる。   When the function f is the function funcB1, UPFM (f) is as follows.

UPFM(funcB1):=UPFM(funcA1)∪UPFM(funcA2)∪ Using_PFM(funcB1)={B,C}   UPFM (funcB1): = UPFM (funcA1) ∪UPFM (funcA2) ∪Using_PFM (funcB1) = {B, C}

すなわち、関数funcB1に至るまでに使用しうる全ての使用時一定電圧メモリの集合UPFM(funcB1)は、メモリB、メモリCとなる。   That is, the set UPFM (funcB1) of all the constant voltage memories in use that can be used up to the function funcB1 is the memory B and the memory C.

また関数fが関数funcC1であった場合、UPFM(f)は以下のようになる。   When the function f is the function funcC1, UPFM (f) is as follows.

UPFM(funcC1):=UPFM(funcA1)∪UPFM(funcB1)∪ Using_PFM(funcC1)={B,C}   UPFM (funcC1): = UPFM (funcA1) ∪UPFM (funcB1) ∪Using_PFM (funcC1) = {B, C}

すなわち、関数funcC1に至るまでに使用しうる全ての使用時一定電圧メモリの集合UPFM(funcC1)は、メモリB、メモリCとなる。   That is, the set UPFM (funcC1) of all the constant voltage memories that can be used up to the function funcC1 is the memory B and the memory C.

次にPowerOff(f,g)について説明する。本実施形態のPowerOff(f,g)は、関数gから関数fへ復帰するときに、関数gの配置されているメモリを低電力状態にしてよいか否かを示すテーブルであり、以下の式(2)のように定義される。   Next, PowerOff (f, g) will be described. The PowerOff (f, g) of the present embodiment is a table indicating whether or not the memory in which the function g is placed may be put into a low power state when returning from the function g to the function f. It is defined as (2).

Figure 2011134288
Figure 2011134288

PowerOff(f,g)において、例えば関数fが関数funcA1、関数gが関数funcB1の場合について考える。この場合、Using_PFM(funcB1)={B}、UPFM(funcA1)={C}であり、関数funcB1と関数funcA1との間に共通の要素は存在しない。すなわち、
Using_PFM(funcB1)∩UPFM(funcA1)=φ
となり、
PowerOff(funcA1,funcB1):=True
となる。よって関数funcB1は、関数funcB1が配置されたメモリBを低電圧状態とするスリープコードを関数funcA1のcall命令の直後に挿入することができる。
In PowerOff (f, g), for example, consider a case where the function f is a function funcA1 and the function g is a function funcB1. In this case, Using_PFM (funcB1) = {B}, UPFM (funcA1) = {C}, and there is no common element between the function funcB1 and the function funcA1. That is,
Using_PFM (funcB1) ∩UPFM (funcA1) = φ
And
PowerOff (funcA1, funcB1): = True
It becomes. Therefore, the function funcB1 can insert a sleep code that puts the memory B in which the function funcB1 is placed into a low voltage state immediately after the call instruction of the function funcA1.

次に、PowerOff(f,g)において、例えば関数fが関数funcB1、関数gが関数funcC1の場合について考える。この場合、Using_PFM(funcC1)={C}、UPFM(funcB1)={B,C}であり、関数funcC1と関数funcB1との間に共通の要素{C}が存在する。すなわち、
Using_PFM(funcC1)∩UPFM(funcB1)≠φ
となり、
PowerOff(funcB1,funcC1):=False
となる。よって関数funcC1は、関数funcC1が配置されたメモリCを低電圧状態とするスリープコードを関数funcC1のcall命令の直後に挿入することができない。
Next, in PowerOff (f, g), for example, consider a case where the function f is a function funcB1 and the function g is a function funcC1. In this case, Using_PFM (funcC1) = {C}, UPFM (funcB1) = {B, C}, and a common element {C} exists between the function funcC1 and the function funcB1. That is,
Using_PFM (funcC1) ∩UPFM (funcB1) ≠ φ
And
PowerOff (funcB1, funcC1): = False
It becomes. Therefore, the function funcC1 cannot insert a sleep code for setting the memory C in which the function funcC1 is placed into a low voltage state immediately after the call instruction of the function funcC1.

次に、図50を参照して図49のステップS50におけるスリープ可能表作成部150のUPFM(f)とPowerOff(f,g)の作成について説明する。図50は、第六の実施形態のスリープ可能表作成部によるテーブルの作成を説明するフローチャートである。本実施形態では、関数の呼出関係図を幅優先探索することにより、UPFM(f)とPowerOff(f,g)とを作成する。尚幅優先探索とは、メイン関数を始点とし、メイン関数の一階層下の関数の全ての関数、続いてメイン関数の二階層下の関数の全ての関数、・・・という順序で呼出関係を順次辿っていく探索方法を指す。   Next, creation of UPFM (f) and PowerOff (f, g) of the sleep capable table creation unit 150 in step S50 of FIG. 49 will be described with reference to FIG. FIG. 50 is a flowchart for explaining table creation by the sleep capable table creation unit of the sixth embodiment. In this embodiment, UPFM (f) and PowerOff (f, g) are created by performing a breadth-first search on the function call relationship diagram. In breadth-first search, the main function is the starting point, all functions of the function one layer below the main function, then all functions of the function two layers below the main function, and so on, are called in order. Refers to the search method to follow.

本実施形態のスリープ可能表作成部150は、まずキューQの初期化を行う(ステップS5001)。尚キューQは、関数名を保存するための、先入れ先出しのデータ構造である。   The sleep capable table creation unit 150 of the present embodiment first initializes the queue Q (step S5001). The queue Q is a first-in first-out data structure for storing a function name.

次にスリープ可能表作成部150は、初期データの設定として、キューQにf_MAINを投入した状態とし(ステップS5002)、次にUPFM(f_MAIN)を空集合φに初期化する(ステップS5003)。尚f=f_MAIN以外のUPFM(f)の初期値は空集合とは区別される未定義状態とする。   Next, the sleep capable table creation unit 150 sets f_MAIN to the queue Q as the initial data setting (step S5002), and then initializes UPFM (f_MAIN) to the empty set φ (step S5003). The initial value of UPFM (f) other than f = f_MAIN is in an undefined state that is distinguished from the empty set.

続いてスリープ可能表作成部150は、キューQが空であるかを判定する(ステップS5004)。そしてスリープ可能表作成部150は、ステップS5004において、キューQが空でなければ、ステップS5005へ進む。   Subsequently, the sleep capable table creation unit 150 determines whether or not the queue Q is empty (step S5004). If the queue Q is not empty in step S5004, the sleep capable table creation unit 150 proceeds to step S5005.

ステップS5004においてキューQが空でない場合、スリープ可能表作成部150はキューQから関数を取り出し、取り出した関数を関数fとする(ステップS5005)。続いてスリープ可能表作成部150は、関数呼出関係情報58を参照し、関数fの呼出先関数(子関数)を得る(ステップS5006)。尚ステップS5006において、関数fの呼出先関数を関数f1,f2,・・・,fnとする。   If the queue Q is not empty in step S5004, the sleep capable table creation unit 150 extracts a function from the queue Q and sets the extracted function as a function f (step S5005). Subsequently, the sleep capable table creating unit 150 refers to the function call relation information 58 and obtains a call destination function (child function) of the function f (step S5006). In step S5006, the call destination function of the function f is assumed to be functions f1, f2,.

スリープ可能表作成部150は、以下に説明するステップS5007〜ステップS5015の処理により、ステップS5006で得た呼出先関数g=f1,f2,・・・,fnについてのPowerOff(f,g)とUPFM(g)を作成する。またスリープ可能表作成部150は、ステップS5007〜ステップS5015に於いて、キューQに関数f1,f2,・・・,fnの呼出先関数(子関数)を積む。ここでキューQに積んだ関数はステップS5004を経由し、ステップS5005にて取り出され、ステップS5007〜ステップS5015に於いて、また関数f1,f2,・・・,fnそれぞれの呼出先関数の呼出先関数(孫関数)を積む。本実施形態では、これを繰り返すことにより全ての関数fについてUPFM(f)を、また全ての関数fから関数gへの呼び出しについてPowerOff(f,g)を求めている。   The sleep capable table creation unit 150 performs PowerOff (f, g) and UPFM on the callee functions g = f1, f2,..., Fn obtained in step S5006 by the processing in steps S5007 to S5015 described below. Create (g). In addition, in step S5007 to step S5015, the sleep capable table creating unit 150 loads the call destination functions (child functions) of the functions f1, f2,. Here, the function loaded in the queue Q is taken out in step S5005 via step S5004, and in steps S5007 to S5015, the call destinations of the call destination functions of the functions f1, f2,. Stacks functions (grandchild functions). In this embodiment, by repeating this, UPFM (f) is obtained for all functions f, and PowerOff (f, g) is obtained for calls from all functions f to function g.

以下にステップS5007からステップS5015までの各ステップについて説明する。   The steps from step S5007 to step S5015 will be described below.

本実施形態のスリープ可能表作成部150は、関数f1,f2,・・・,fnを指し示すカウンタ変数iを1に初期化する(ステップS5007)。以下では、関数gとして、i番目の関数fiが選択されているものとして説明する。次にスリープ可能表作成部150は、式(2)に基づき現時点でのPowerOff(f,fi)を計算する(ステップS5008)。   The sleep capable table creating unit 150 of the present embodiment initializes a counter variable i indicating the functions f1, f2,..., Fn to 1 (step S5007). In the following description, it is assumed that the i-th function fi is selected as the function g. Next, the sleep capable table creation unit 150 calculates the current PowerOff (f, fi) based on the equation (2) (step S5008).

ステップS5008において、スリープ可能表作成部150は、UPFM(f)とUsing_PFM(fi)とが共通部分(共通の要素)を持つか否かを判定する。ステップS5008において、共通部分を持たない場合、PowerOff(f,fi):=Trueと設定する(ステップS5009)。ステップS5008において、共通部分を持つ場合、PowerOff(f,fi):=Falseと設定する(ステップS5010)。   In step S5008, the sleep capable table creation unit 150 determines whether UPFM (f) and Usage_PFM (fi) have a common part (common element). If there is no common part in step S5008, PowerOff (f, fi): = True is set (step S5009). If there is a common part in step S5008, PowerOff (f, fi): = False is set (step S5010).

続いてスリープ可能表作成部150は、ステップS5011〜ステップS5014にて、UPFM(fi)を更新する。ステップS5011からステップS5014の処理は、同一の階層の関数同士の間に呼出関係が存在する場合に実行される処理である。   Subsequently, the sleep capable table creating unit 150 updates UPFM (fi) in steps S5011 to S5014. The processing from step S5011 to step S5014 is processing executed when a call relationship exists between functions in the same hierarchy.

スリープ可能表作成部150は、UPFM(fi)の仮の値として、集合T:=UPFM(f)∪Using_PFM(fi)を計算する(ステップS5011)。   The sleep capable table creating unit 150 calculates a set T: = UPFM (f) ∪Using_PFM (fi) as a temporary value of UPFM (fi) (step S5011).

次にスリープ可能表作成部150は、集合TをUPFM(f)と比較する(ステップS5012)。ステップS5012において、集合TとUPFM(f)とが等しければ、UPFM(fi)の更新の必要がないので、ステップS5015へ進む。   Next, the sleep capable table creation unit 150 compares the set T with UPFM (f) (step S5012). If it is determined in step S5012 that the set T is equal to UPFM (f), there is no need to update UPFM (fi), and the process advances to step S5015.

ステップS5012において、集合TとUPFM(f)とが等しくなければ、UPFM(f)を集合Tに置き換えて更新する(ステップS5013)。またスリープ可能表作成部150は、再計算の対象に入れるために、キューQにfiを積む(ステップS5014)。これは、この更新がPowerOff(f,g)に影響するためである。   If the set T and UPFM (f) are not equal in step S5012, UPFM (f) is replaced with the set T and updated (step S5013). In addition, the sleep capable table creation unit 150 loads fi in the queue Q to be included in the recalculation target (step S5014). This is because this update affects PowerOff (f, g).

尚、f=f_MAIN以外のUPFM(f)の初期値は空集合とは区別される未定義状態であり、必ず一度はステップS5013、ステップS5014を通過してキューQに挿入される。そのため、全ての関数fについてUPFM(f)を、また全ての関数fから関数gへの呼び出しについてPowerOff(f,g)を求めることができる。   Note that the initial value of UPFM (f) other than f = f_MAIN is an undefined state that is distinguished from an empty set, and is always inserted into the queue Q once through steps S5013 and S5014. Therefore, UPFM (f) can be obtained for all functions f, and PowerOff (f, g) can be obtained for calls from all functions f to function g.

スリープ可能表作成部150は、ステップS5015においてカウンタ変数iがnと等しくなれば、関数f1,f2,・・・,fnについてステップS5008〜ステップS5014の処理を実行したことになるので、ステップS5004へ戻る。ステップS5015において、カウンタ変数iがnと等しくない場合は、iをインクリメントした後(ステップS5016)にステップS5008へ戻る。   If the counter variable i becomes equal to n in step S5015, the sleep capable table creating unit 150 has executed the processing from step S5008 to step S5014 for the functions f1, f2,..., Fn. Return. If the counter variable i is not equal to n in step S5015, i is incremented (step S5016), and then the process returns to step S5008.

スリープ可能表作成部150は、ステップS5004においてキューQが空であると判定した場合に処理を終了する。   The sleep capable table creating unit 150 ends the process when it is determined in step S5004 that the queue Q is empty.

本実施形態では、以上の構成により、プロセッサが命令を得て正しく動作することができるように制御コードを生成することができる。また本実施形態では、不要な制御コードを挿入しないため、制御コードの挿入回数を低減し、且つ効率的に各メモリの電源制御を行うことができる。   In the present embodiment, with the above configuration, the control code can be generated so that the processor can obtain an instruction and operate correctly. In the present embodiment, since unnecessary control codes are not inserted, the number of control code insertions can be reduced, and power control of each memory can be performed efficiently.

(第七の実施形態)
以下に図面を参照して本発明の第七の実施形態について説明する。本実施形態のコード生成装置は、制御コードの挿入を低減させるようにメモリマップを決定する。尚本実施形態において、第一乃至第六の実施形態と同様の機能構成を有するものには、第一乃至第六の実施形態の説明で用いた符号と同様の符号を用いる。
(Seventh embodiment)
The seventh embodiment of the present invention will be described below with reference to the drawings. The code generation device according to the present embodiment determines the memory map so as to reduce the insertion of the control code. In addition, in this embodiment, the code | symbol similar to the code | symbol used in description of 1st thru | or 6th embodiment is used for what has the function structure similar to 1st thru | or 6th embodiment.

本発明の第七の実施形態では、第五及び第六の実施形態と同様に、メイン関数からある一定階層までが常時一定電圧メモリに配置され、常時一定電圧メモリに配置された関数の直下の関数が常時一定電圧メモリと使用時一定電圧メモリとに配置された場合について考える。   In the seventh embodiment of the present invention, as in the fifth and sixth embodiments, the main function up to a certain level is always placed in the constant voltage memory, and immediately below the function placed in the constant voltage memory at all times. Consider the case where functions are always placed in a constant voltage memory and a constant voltage memory when in use.

また、上記場合において、常時一定電圧メモリと使用時一定電圧メモリとに配置された関数より下の階層では、呼出元関数が配置されている使用時一定電圧メモリと同一のメモリを使用し、かつ、同一の使用時一定電圧メモリを使用する複数の呼出元関数が存在する場合(呼出元関数が一つである場合も含む)に常時一定電圧メモリを使用しないという前提も、第五及び第六の実施形態同様である。   Further, in the above case, in the hierarchy below the functions arranged in the constant voltage memory and the constant voltage memory in use, the same memory as the constant voltage memory in use in which the caller function is arranged is used, and The assumption that the constant voltage memory is not always used when there are a plurality of caller functions that use the same constant voltage memory in use (including the case where there is one caller function) is also the fifth and sixth. This is the same as the embodiment.

本実施形態では、更に消費電力を削減することを目的としている。例えば第六の実施形態では、どのようなメモリマップでも第五の実施形態相等の電力を実現できる。しかし、関数呼出のパターン次第では、さらなる電力削減の余地が存在する。例えば、図47(B)のメモリマップの場合について考える。   The purpose of this embodiment is to further reduce power consumption. For example, in the sixth embodiment, any memory map can realize the power of the fifth embodiment phase or the like. However, depending on the pattern of function calls, there is room for further power reduction. For example, consider the case of the memory map of FIG.

図47(B)のメモリマップにおいて、関数funcMAIN、関数funcA2、関数funcB1、関数funcD1という経路で各関数呼び出された場合、メモリBが一定電圧状態となるのみである。しかし、関数funcMAIN、関数funcA1、関数funcB1、関数funcC1、関数funcD1という経路で呼び出された場合、関数funcB1の低電圧部の実行を開始するタイミングから関数funcC1へ復帰するまでの間は、メモリB、C共に一定電圧状態となる。すなわちこのとき使用していないメモリCも一定電圧状態となる。   In the memory map of FIG. 47B, when each function is called through a path of function funcMAIN, function funcA2, function funcB1, and function funcD1, the memory B is only in a constant voltage state. However, when the function funcMAIN, the function funcA1, the function funcB1, the function funcC1, and the function funcD1 are called in the path, the memory B, Both C are in a constant voltage state. That is, the memory C that is not used at this time is also in a constant voltage state.

このように、常時一定電圧メモリと使用時一定電圧メモリとに配置された関数より下の階層では、呼出元関数が配置されている使用時一定電圧メモリと同一のメモリを使用するという制約だけでは、消費電力削減の余地のあるメモリマップが決定されることがある。   In this way, in the hierarchy below the functions arranged in the constant voltage memory at the time of use and the constant voltage memory at the time of use, only the restriction of using the same memory as the constant voltage memory at the time of use at which the caller function is arranged is used In some cases, a memory map that has room for power consumption reduction is determined.

そこで本実施形態のコード生成装置100Dは、さらに消費電力の削減することができるメモリマップを決定する。   Therefore, the code generation device 100D of this embodiment determines a memory map that can further reduce power consumption.

図51は、第七の実施形態のコード生成装置の動作を説明するフローチャートである。   FIG. 51 is a flowchart for explaining the operation of the code generation device of the seventh embodiment.

本実施形態のコード生成装置100Dにおいて、アセンブリ50とパラメータ60に含まれるサイクル数Nとが入力されると、コード生成装置100Dは、関数毎のアセンブリコード55の分割位置を算出する(ステップS5101)。尚本実施形態では、ステップS5101で算出された分割位置が制御コードが挿入される挿入位置である。   In the code generation device 100D of the present embodiment, when the assembly 50 and the cycle number N included in the parameter 60 are input, the code generation device 100D calculates the division position of the assembly code 55 for each function (step S5101). . In the present embodiment, the division position calculated in step S5101 is the insertion position where the control code is inserted.

ステップS5101においてアセンブリコード55の分割位置が算出されると、コード生成装置100Dは、分割位置とパラメータ60に含まれるメモリユニット10の構造情報62とに基づき分割されたアセンブリコード55を配置するためのメモリマップを決定する(ステップS5102)。本実施形態におけるメモリマップの決定の詳細は後述する。   When the division position of the assembly code 55 is calculated in step S5101, the code generation device 100D arranges the assembly code 55 divided based on the division position and the structure information 62 of the memory unit 10 included in the parameter 60. A memory map is determined (step S5102). Details of the determination of the memory map in this embodiment will be described later.

メモリマップが生成されると、コード生成装置100はパラメータ60に含まれる制御コードパターン63に代入するパラメータを決定して制御コードを生成し、アセンブリコード55の分割位置に制御コードを挿入する(ステップS5103)。コード生成装置100Dは、制御コードが挿入されたアセンブリコード55を含むアセンブリ50Aをアセンブル及びリンケージして(ステップS5104)、制御コードが含まれる電源制御入りバイナリ70を出力してコード生成を完了する。   When the memory map is generated, the code generation device 100 determines a parameter to be substituted for the control code pattern 63 included in the parameter 60, generates a control code, and inserts the control code at the division position of the assembly code 55 (step). S5103). The code generation device 100D assembles and links the assembly 50A including the assembly code 55 into which the control code is inserted (step S5104), and outputs the power-controlled binary 70 including the control code to complete the code generation.

以下に、図52を参照して本実施形態のメモリマップの決定について説明する。図52は、第七の実施形態におけるメモリマップの決定を説明する図である。   The determination of the memory map of this embodiment will be described below with reference to FIG. FIG. 52 is a diagram for explaining determination of a memory map in the seventh embodiment.

本実施形態のコード生成装置100Dは、親関数選択部521、常時一定電圧メモリ割当部522、合計コードサイズ計算部523、呼出頻度算出部524、使用時一定電圧メモリ割当部525、割当調整・アドレス計算部526を有する。コード生成装置100Dは、上記各部によりメモリマップを決定する。   The code generation device 100D of this embodiment includes a parent function selection unit 521, a constant voltage memory allocation unit 522, a total code size calculation unit 523, a call frequency calculation unit 524, a constant voltage memory allocation unit 525 in use, an allocation adjustment / address A calculation unit 526 is included. The code generation device 100D determines a memory map by the above-described units.

本実施形態の親関数選択部521は、各関数間の呼出頻度情報ρを作成し、この呼出頻度情報に従って親関数を1つ特定する。本実施形態の呼出頻度情報ρは、ソースコード上での呼出回数や実行履歴上での呼出回数、あるいはその重み付け和等に基づき作成される。   The parent function selection unit 521 of the present embodiment creates call frequency information ρ between functions, and specifies one parent function according to the call frequency information. The call frequency information ρ of the present embodiment is created based on the number of calls on the source code, the number of calls on the execution history, or the weighted sum thereof.

図53は、関数間の呼出頻度情報の一例を示す図である。図53に示すように、呼出頻度情報ρでは、呼出元関数(親関数)と、呼出先関数(子関数)と、呼出元関数が呼出先関数を呼び出す回数(スコア)とが対応付けられている。本実施形態の親関数選択部521は、一つの子関数に対して複数の親関数が存在する場合には、最も関係の強い関数、すなわちスコアが最も大きい関数を親関数として選択する。   FIG. 53 is a diagram illustrating an example of call frequency information between functions. As shown in FIG. 53, in the call frequency information ρ, the caller function (parent function), the callee function (child function), and the number of times the caller function calls the callee function (score) are associated with each other. Yes. When there are a plurality of parent functions for one child function, the parent function selection unit 521 of the present embodiment selects the function having the highest relationship, that is, the function having the highest score as the parent function.

常時一定電圧メモリ割当部522は、常時一定電圧メモリへの関数割当を行う。本実施形態の常時一定電圧メモリ割当部522は、常時一定電圧メモリに全体を割り当てる関数の階層数を決定する。次に常時一定電圧メモリ割当部522は、常時一定電圧メモリとするメモリを決定する。次に常時一定電圧メモリ割当部522は、常時一定電圧メモリに一定電圧部を割り当てる関数の候補を抽出する。そして常時一定電圧メモリ割当部522は、全体を常時一定電圧メモリに割り当てる関数に対するメモリの割当と、一定電圧部を常時一定電圧メモリに割り当てる関数に対するメモリの割当とを決定する。   The always constant voltage memory allocation unit 522 performs function allocation to the always constant voltage memory. The constant voltage memory allocation unit 522 of the present embodiment determines the number of function hierarchies that allocate the entire constant voltage memory. Next, the constantly constant voltage memory allocation unit 522 determines a memory to be always a constant voltage memory. Next, the constant voltage memory allocation unit 522 extracts function candidates that allocate the constant voltage unit to the constant voltage memory. Then, the constant voltage memory allocation unit 522 determines the memory allocation for the function that allocates the whole to the constant voltage memory and the memory allocation for the function that always allocates the constant voltage unit to the constant voltage memory.

合計コードサイズ計算部523は、常時一定電圧メモリに全体が割り当てられる関数の直下の階層に存在する関数を代表とする関数群を作成し、関数サイズ情報52に基づき関数群のコード量を計算する。   The total code size calculation unit 523 creates a function group represented by a function that exists in the layer immediately below the function that is always assigned to the constant voltage memory as a whole, and calculates the code amount of the function group based on the function size information 52. .

図54は、関数群のコード量の計算の一例を示す図である。合計コードサイズ計算部523による計算結果は、出力テーブル54として出力される。出力テーブル54では、常時一定電圧メモリに全体が配置される関数である関数funcMAINの直下の関数である関数funcA1、関数funcA2、関数funcA3、関数funcA4、関数funcA5を代表とする関数群が作成されている。そして各関数群と、各関数群の合計コード量とが対応付けられている。尚本実施形態において、この関数群は、代表とする関数そのものとその子孫関数のみを含むものとなる。   FIG. 54 is a diagram illustrating an example of calculation of the code amount of the function group. The calculation result by the total code size calculation unit 523 is output as the output table 54. In the output table 54, a function group represented by the function funcA1, the function funcA2, the function funcA3, the function funcA4, and the function funcA5, which are functions immediately below the function funcMAIN, which is a function that is always arranged in the constant voltage memory, is created. Yes. Each function group is associated with the total code amount of each function group. In this embodiment, this function group includes only the representative function itself and its descendant functions.

呼出頻度算出部524は、出力テーブル54と呼出頻度情報ρとを参照し、使用時一定電圧メモリに割り当てる関数群の間の呼出頻度Qを算出した呼出頻度テーブルTを作成する。本実施形態の呼出頻度算出部524の処理の詳細は後述する。   The call frequency calculation unit 524 refers to the output table 54 and the call frequency information ρ, and creates a call frequency table T in which the call frequency Q between the functions assigned to the constant voltage memory in use is calculated. Details of the processing of the call frequency calculation unit 524 of this embodiment will be described later.

使用時一定電圧メモリ割当部525は、関数サイズ情報52、出力テーブル54、呼出頻度Qを参照して、関数の集合毎に使用時一定電圧メモリに割り当てる。使用時一定電圧メモリ割当部525の処理の詳細は後述する。   The in-use constant voltage memory allocation unit 525 refers to the function size information 52, the output table 54, and the call frequency Q, and allocates each function set to the in-use constant voltage memory. Details of the processing of the constant voltage memory allocation unit 525 in use will be described later.

割当調整・アドレス計算部526は、使用時一定電圧メモリ割当部525による割当結果を参照して不要なものを削除する等の修正を行い、各関数の一定電圧部と低電圧部の開始アドレスを計算する。不要なものとは、例えば使用時一定電圧メモリ割当部525による割当の結果、全ての呼出元関数が同一メモリに配置されているもの等である。   The allocation adjustment / address calculation unit 526 makes corrections such as deleting unnecessary ones by referring to the allocation result by the constant voltage memory allocation unit 525 when in use, and sets the start addresses of the constant voltage unit and the low voltage unit of each function. calculate. The unnecessary ones are, for example, those in which all the caller functions are arranged in the same memory as a result of the assignment by the constant voltage memory assignment unit 525 in use.

そして割当調整・アドレス計算部526は、各関数の低電圧部のサイズを更新する。そして割当調整・アドレス計算部526は、各関数の一定電圧部、低電圧部の開始アドレスを計算する。   Then, the allocation adjustment / address calculation unit 526 updates the size of the low voltage part of each function. Then, the allocation adjustment / address calculation unit 526 calculates the start address of the constant voltage portion and the low voltage portion of each function.

以下に図55を参照して本実施形態の呼出頻度算出部524の処理について説明する。図55は、第七の実施形態の呼出頻度算出部の処理を説明するフローチャートである。   The processing of the call frequency calculation unit 524 of this embodiment will be described below with reference to FIG. FIG. 55 is a flowchart for explaining the processing of the call frequency calculation unit of the seventh embodiment.

本実施形態では、関数fを代表とする関数群Fと関数gを代表とする関数群G間の呼出頻度Q(f,g)は、以下の式(3)で与えるものとする。   In this embodiment, the call frequency Q (f, g) between the function group F represented by the function f and the function group G represented by the function g is given by the following expression (3).

Figure 2011134288
Figure 2011134288

ここで、p(φ,ψ)は、関数ψから関数φへの呼出回数(スコア)であり、呼出頻度情報ρから取得される。本実施形態では、この呼出頻度Q(f,g)を、常時一定電圧メモリに配置する階層の次の階層の各関数を代表とする関数群全てのペアについて計算する。また呼出頻度算出部524は、出力テーブル54の関数フィールドの各値(常時一定電圧に配置する階層の次の階層の関数の名前)をf[1],・・・,f[L_MAX]として参照する。   Here, p (φ, ψ) is the number of calls (score) from the function ψ to the function φ, and is obtained from the call frequency information ρ. In the present embodiment, this call frequency Q (f, g) is calculated for all pairs of function groups represented by the functions of the next layer after the layer always placed in the constant voltage memory. Further, the call frequency calculation unit 524 refers to each value of the function field of the output table 54 (the name of the function of the next layer after the layer always placed at a constant voltage) as f [1],..., F [L_MAX]. To do.

L_MAXは、常時一定電圧メモリに配置され関数の次の階層の関数の数である。また出力テーブル54は、L_MAX×L_MAX要素の2次元配列Qとして格納されることを前提としている。したがって、本実施形態では、前述の関数fと関数gは、ともにf[1],・・・,f[L_MAX]を名前とする関数を順次選択し、走査する(但し、fとgで同じものは選択されない)。   L_MAX is the number of functions in the next layer of functions that are always placed in the constant voltage memory. The output table 54 is assumed to be stored as a two-dimensional array Q of L_MAX × L_MAX elements. Therefore, in the present embodiment, the functions f and g described above are sequentially selected and scanned with the functions named f [1],..., F [L_MAX] (however, the same applies to f and g). Is not selected).

呼出頻度算出部524は、変数iを1に初期化する(ステップS5501)。続いて呼出頻度算出部524は、変数jをi+1にセットする(ステップS5502)。続いて呼出頻度算出部524は、式(3)で与えられる呼出頻度Q(f[i],f[j])を計算し(ステップS5503)、2次元配列Q[i,j]に格納する(ステップS5504)。呼出頻度算出部524は、iとjがそれぞれL_MAX以下である間、ステップS5503、ステップS5504の処理を反復する(ステップS5505〜ステップS5508)。本実施形態の呼出頻度算出部524は、以上のようにして呼出頻度Qを算出する。   The call frequency calculation unit 524 initializes the variable i to 1 (step S5501). Subsequently, the call frequency calculation unit 524 sets the variable j to i + 1 (step S5502). Subsequently, the call frequency calculation unit 524 calculates the call frequency Q (f [i], f [j]) given by Expression (3) (step S5503) and stores it in the two-dimensional array Q [i, j]. (Step S5504). The call frequency calculation unit 524 repeats the processing of step S5503 and step S5504 while i and j are each equal to or less than L_MAX (steps S5505 to S5508). The call frequency calculation unit 524 of the present embodiment calculates the call frequency Q as described above.

図56は、算出された呼出頻度Qの一例を示す図である。図56を参照してf[i]を出力テーブル54の関数群F_A3とし、f[j]を出力テーブル54の関数群F_A4とした場合の呼出頻度Q(F_A3,F_A4)について説明する。   FIG. 56 is a diagram showing an example of the calculated call frequency Q. With reference to FIG. 56, the call frequency Q (F_A3, F_A4) when f [i] is the function group F_A3 of the output table 54 and f [j] is the function group F_A4 of the output table 54 will be described.

関数群F_A3={f_A3,f_B3}であり、関数群F_A4={f_A4,f_B4}である。尚f_A3は関数funcA3、f_A4は関数funcA4、f_B3は関数funcB3、f_B4は関数funcB4を示す。   The function group F_A3 = {f_A3, f_B3}, and the function group F_A4 = {f_A4, f_B4}. Note that f_A3 is a function funcA3, f_A4 is a function funcA4, f_B3 is a function funcB3, and f_B4 is a function funcB4.

したがって呼出頻度Qは、呼出頻度情報ρに基づき、
Q(F_A3,F_A4)={p(f_A3,f_A4)+p(f_A4,f_A3)}+{p(f_A3,f_B4)+p(f_B4,f_A3)}+{p(f_B3,f_A4)+p(f_A4,f_B3)}+{p(f_B3,f_B4)+p(f_B4,f_B3)}=(0+0)+(0+0)+(0+0)+(13+0)=13
と計算される。尚呼出頻度情報ρにないものは0として計算される。このようにして、出力テーブル54の全ての関数群間の呼出頻度Qを算出し、呼出頻度テーブルTを作成する。図56は、呼出頻度テーブルの一例を示す図である。
Therefore, the call frequency Q is based on the call frequency information ρ,
Q (F_A3, F_A4) = {p (f_A3, f_A4) + p (f_A4, f_A3)} + {p (f_A3, f_B4) + p (f_B4, f_A3)} + {p (f_B3, f_A4) + p (f_A4, f_B3) } + {P (f_B3, f_B4) + p (f_B4, f_B3)} = (0 + 0) + (0 + 0) + (0 + 0) + (13 + 0) = 13
Is calculated. Those not included in the call frequency information ρ are calculated as 0. In this way, the call frequency Q between all the function groups in the output table 54 is calculated, and the call frequency table T is created. FIG. 56 is a diagram illustrating an example of a call frequency table.

次に、本実施形態の使用時一定電圧メモリ割当部525の処理について説明する。本実施形態の使用時一定電圧メモリ割当部525は、関数サイズ情報52、出力テーブル54、呼出頻度テーブルTを参照して、使用時一定電圧メモリに関数を割り当てる。   Next, the processing of the constant voltage memory allocation unit 525 in use according to this embodiment will be described. The in-use constant voltage memory allocation unit 525 of this embodiment allocates a function to the in-use constant voltage memory with reference to the function size information 52, the output table 54, and the call frequency table T.

図57は、第七の実施形態の使用時一定電圧メモリ割当部の処理を説明するフローチャートである。   FIG. 57 is a flowchart for explaining processing of the constant voltage memory allocating unit in use according to the seventh embodiment.

使用時一定電圧メモリ割当部525は、配列M_rest[m]を使用時一定電圧メモリmのサイズで初期化する(ステップS5701)。尚mは、使用時一定電圧メモリの名前を表す。   The in-use constant voltage memory allocation unit 525 initializes the array M_rest [m] with the size of the in-use constant voltage memory m (step S5701). Here, m represents the name of the constant voltage memory when in use.

続いて使用時一定電圧メモリ割当部525は、ステップS5702〜ステップS5704において、一つの関数群を割り当てるメモリを特定する。   Subsequently, in-use constant voltage memory allocation unit 525 specifies a memory to which one function group is allocated in steps S5702 to S5704.

具体的には、使用時一定電圧メモリ割当部525は、出力テーブル54を走査して合計コード量(関数群に含まれる全ての関数の低電圧部のサイズの合計)が最大である関数群を選ぶ。そしてその関数群の代表関数を関数f_Mとする(ステップS5702)。   Specifically, the constant voltage memory allocation unit 525 during use scans the output table 54 to obtain a function group having the maximum total code amount (the sum of the sizes of the low voltage parts of all functions included in the function group). Choose. A representative function of the function group is set as a function f_M (step S5702).

次に使用時一定電圧メモリ割当部525は、関数f_Mを代表関数とする関数群が配置できる使用時一定電圧メモリを見つける(ステップS5703)。ここで使用時一定電圧メモリ割当部525は、配列M_rest[m]が関数f_Mを代表関数とする関数群の合計コード量以上となるような使用時一定電圧メモリmを見つける。ステップS5703で見つかったメモリmは、関数群f_Mの各関数の低電圧部を配置するメモリとされる。   Next, the in-use constant voltage memory allocation unit 525 finds out-of-use constant voltage memory in which a function group having the function f_M as a representative function can be arranged (step S5703). Here, the in-use constant voltage memory allocation unit 525 finds the in-use constant voltage memory m such that the array M_rest [m] is equal to or greater than the total code amount of the function group having the function f_M as a representative function. The memory m found in step S5703 is a memory in which the low voltage part of each function of the function group f_M is arranged.

尚本実施形態では、使用時一定電圧メモリのサイズは、図58に示すように関数サイズ情報52から取得されても良い。図58は、使用時一定電圧メモリのサイズ情報の一例を示す図であり、使用時一定電圧メモリのサイズ情報S1が示されている。   In the present embodiment, the size of the constant voltage memory in use may be acquired from the function size information 52 as shown in FIG. FIG. 58 is a diagram showing an example of the size information of the constant voltage memory at the time of use, and the size information S1 of the constant voltage memory at the time of use is shown.

次に使用時一定電圧メモリ割当部525は、メモリmについて、配列M_rest[m]を配列M_rest[m]から関数f_Mを代表関数とする関数群を構成する各関数の低電圧部のサイズを減じた値に更新する(ステップS5704)。   Next, the in-use constant voltage memory allocation unit 525 reduces the size of the low-voltage part of each function that constitutes a function group having the function M_rest [m] as the representative function for the memory m from the array M_rest [m]. The value is updated (step S5704).

次に使用時一定電圧メモリ割当部525は、ステップS5705〜ステップS5710にて、ステップS5702〜ステップS5704で割り当てたメモリmに配置する関数群を特定する。   Next, in-use constant voltage memory allocation unit 525 specifies a function group to be arranged in memory m allocated in steps S5702 to S5704 in steps S5705 to S5710.

使用時一定電圧メモリ割当部525は、まず関数群の代表関数の集合F={f|Q(f_M,f)>0}を算出する(ステップS5705)。この集合Fは、関数f_Mを代表とする関数群に所属する関数から呼び出されるか、または関数f_Mを代表とする関数群に所属する関数を呼び出すような関数の集合である。   The in-use constant voltage memory allocation unit 525 first calculates a representative function set F = {f | Q (f_M, f)> 0} of the function group (step S5705). The set F is a set of functions that are called from functions belonging to a function group typified by the function f_M or that call a function belonging to a function group typified by the function f_M.

使用時一定電圧メモリ割当部525は、集合Fが空集合か否かを判断する(ステップS5706)。ステップS5706において集合Fが空集合でない場合、関数f_Mを代表とする関数群に所属する関数から呼び出されるか、または関数f_Mを代表とする関数群に所属する関数を呼び出すような関数は存在する。   In use, the constant voltage memory allocation unit 525 determines whether the set F is an empty set (step S5706). If the set F is not an empty set in step S5706, there is a function that is called from a function belonging to a function group represented by the function f_M or a function belonging to a function group represented by the function f_M.

集合Fが空集合でない場合、使用時一定電圧メモリ割当部525は、呼出頻度Q(f_M,f)が最大となる関数fを代表とする関数群を選択する(ステップS5707)。但し、呼出頻度Q(f_M,f)が最大のものが複数存在する場合は、関数fを代表とする関数群のサイズ合計s(f)(各関数の低電圧部のサイズの合計)が最大のものを選択する。   When the set F is not an empty set, the constant voltage memory allocation unit 525 in use selects a function group represented by the function f having the maximum call frequency Q (f_M, f) (step S5707). However, when there are a plurality of calls having the maximum calling frequency Q (f_M, f), the total size s (f) of the function group represented by the function f (the total size of the low voltage portions of each function) is the maximum. Choose one.

次に使用時一定電圧メモリ割当部525は、その関数fを代表とする関数群のサイズ合計s(f)が配列M_rest[m]以下であるか否かを判断する(ステップS5708)。ステップS5708でサイズ合計s(f)が配列M_rest[m]以下であった場合、使用時一定電圧メモリ割当部525は、関数fを代表とする関数群の各関数の低電圧部を配置するメモリとしてメモリmを使用し、配列M_rest[m]を配列M_rest[m]からサイズ合計s(f)を減じた値に更新する(ステップS5709)。   Next, the in-use constant voltage memory allocation unit 525 determines whether or not the total size s (f) of the function group represented by the function f is equal to or smaller than the array M_rest [m] (step S5708). When the total size s (f) is equal to or smaller than the array M_rest [m] in step S5708, the in-use constant voltage memory allocation unit 525 stores the low voltage portion of each function of the function group represented by the function f. And the array M_rest [m] is updated to a value obtained by subtracting the total size s (f) from the array M_rest [m] (step S5709).

そして使用時一定電圧メモリ割当部525は、関数fを代表とする関数群の低電圧部を配置するメモリが決定したか否かにかかわらず、集合Fから関数fを取り除く(ステップS5710)。ステップS5708でサイズ合計s(f)が配列M_rest[m]以下でない場合、ステップS5710へ進む。使用時一定電圧メモリ割当部525は、これを集合Fが空集合となるまでステップS5706以降の処理を繰り返す。   Then, the constant voltage memory allocation unit 525 in use removes the function f from the set F regardless of whether or not the memory in which the low voltage part of the function group represented by the function f is determined is determined (step S5710). If the size total s (f) is not equal to or smaller than the array M_rest [m] in step S5708, the process proceeds to step S5710. In use, the constant voltage memory allocation unit 525 repeats the processing from step S5706 until the set F becomes an empty set.

ステップS5706において集合Fが空集合であった場合、関数f_Mを代表とする関数群に所属する関数から呼び出されるか、または関数f_Mを代表とする関数群に所属する関数を呼び出すような関数は存在しない。したがって使用時一定電圧メモリ割当部525は、未割り当ての関数群が存在するか否かを判断する(ステップS5711)。ステップS5711において、未割り当ての関数が存在する場合、使用時一定電圧メモリ割当部525はステップS5702へ戻り、その関数群のうち合計コード量の大きい物から割り当てを続ける。ステップS5711において未割り当ての関数群の存在しない場合、使用時一定電圧メモリ割当部525は、全ての関数群のメモリ割当が完了しているので、処理を終了する。   If the set F is an empty set in step S5706, there is a function that is called from a function belonging to a function group represented by the function f_M or a function belonging to a function group represented by the function f_M. do not do. Therefore, the in-use constant voltage memory allocation unit 525 determines whether there is an unallocated function group (step S5711). If there is an unassigned function in step S5711, the constant voltage memory allocating unit 525 during use returns to step S5702, and the assignment is continued from the function group having a large total code amount. If there is no unassigned function group in step S5711, the in-use constant voltage memory allocating unit 525 ends the processing because the memory allocation of all function groups has been completed.

以下に、具体例を挙げて使用時一定電圧メモリ割当部525の処理を説明する。   Hereinafter, the processing of the constant voltage memory allocation unit 525 in use will be described with a specific example.

使用時一定電圧メモリ割当部525は、まず出力テーブル54から関数群の合計コード量が最大である、関数群F_A2(合計コード量4KB)を選択する。そして使用時一定電圧メモリ割当部525は、サイズ情報S1を参照して関数群F_A2を配置可能な使用時一定電圧メモリであるメモリB(サイズ8KB)を見つけ、関数群F_A2をメモリBへ割り当てる。このときメモリBの残りのメモリサイズは4KBとなる。   In use, the constant voltage memory allocation unit 525 first selects the function group F_A2 (total code amount 4 KB) having the maximum total code amount of the function group from the output table 54. The in-use constant voltage memory allocation unit 525 refers to the size information S1 to find the memory B (size 8 KB) that is the in-use constant voltage memory capable of arranging the function group F_A2, and allocates the function group F_A2 to the memory B. At this time, the remaining memory size of the memory B is 4 KB.

ここで、関数群F_A2と呼出関係のある関数群(呼出頻度Q(F_A2,G)>0を満たす関数群G)は、関数群F_A1と関数群F_A3である。このうち、関数群F_A2との呼出頻度Qは、関数群F_A1の方が大きい。関数群F_A1の合計コード量(2KB)は、メモリBの残りメモリサイズ(4KB)以下であり、メモリBに割り当て可能なので、使用時一定電圧メモリ割当部525は、関数群F_A1をメモリBへ割り当てる。   Here, the function groups having the calling relationship with the function group F_A2 (the function group G satisfying the calling frequency Q (F_A2, G)> 0) are the function group F_A1 and the function group F_A3. Among these, the call frequency Q with the function group F_A2 is larger in the function group F_A1. Since the total code amount (2 KB) of the function group F_A1 is equal to or less than the remaining memory size (4 KB) of the memory B and can be allocated to the memory B, the constant voltage memory allocation unit 525 in use allocates the function group F_A1 to the memory B. .

関数群F_A1が割り当てられたため、関数群F_A2と呼出関係がある関数群のうち、未割り当ての関数群は関数群F_A3のみとなる。関数群F_A3の合計コード量は2KBであり、メモリBの残りのメモリサイズと同じであるから、関数群F_A3はメモリBへ割り当て可能である。よって使用時一定電圧メモリ割当部525は、関数群F_A3をメモリBへ割り当てる。このときメモリBの残りのメモリサイズは0KBとなり、割り当て可能なメモリはメモリCのみとなる。   Since the function group F_A1 is assigned, the function group F_A3 is the only unassigned function group among the function groups having a calling relationship with the function group F_A2. Since the total code amount of the function group F_A3 is 2 KB, which is the same as the remaining memory size of the memory B, the function group F_A3 can be allocated to the memory B. Therefore, the in-use constant voltage memory allocation unit 525 allocates the function group F_A3 to the memory B. At this time, the remaining memory size of the memory B is 0 KB, and the only memory that can be allocated is the memory C.

この時点で関数群F_A2と呼出関係がある関数群のうち、未割り当ての関数群は存在しない。したがって使用時一定電圧メモリ割当部525は、未割り当ての関数群F_A4、関数群F_A5のうち、合計コード量が最大である関数群F_A5(合計コード量3KB)をメモリC(メモリサイズ8KB)に割り当てる。このときメモリCの残りのメモリサイズは5KBとなる。   At this time, there is no unassigned function group among the function groups having a calling relationship with the function group F_A2. Accordingly, the constant voltage memory allocation unit 525 in use allocates the function group F_A5 (total code amount 3 KB) having the maximum total code amount to the memory C (memory size 8 KB) among the unassigned function groups F_A4 and F_A5. . At this time, the remaining memory size of the memory C is 5 KB.

ここで関数群F_A5と呼出関係がある関数群のうち、未割り当ての関数群は関数群F_A4のみとなる。関数群F_A4の合計コード量は2KBであり、メモリCに割り当て可能である。よって使用時一定電圧メモリ割当部525は、関数群F_A4をメモリCへ割り当てる。   Of the function groups having a calling relationship with the function group F_A5, the unassigned function group is only the function group F_A4. The total code amount of the function group F_A4 is 2 KB and can be assigned to the memory C. Therefore, the in-use constant voltage memory allocation unit 525 allocates the function group F_A4 to the memory C.

以上で全ての関数群が割り当て済みとなる。このようにして関数群を使用時一定電圧メモリに割り当てた結果を図59に示す。図59は、使用時一定電圧メモリの割り当て結果の一例を示す図である。   All the function groups are already assigned. FIG. 59 shows the result of assigning the function group to the constant voltage memory during use in this way. FIG. 59 is a diagram illustrating an example of a result of allocation of the constant voltage memory during use.

図59では、関数群F_A1、関数群F_A2、関数群F_A3は、使用時一定電圧メモリであるメモリBへ割り当てられている。また関数群F_A4、関数群F_A5は使用時一定電圧メモリであるメモリCへ割り当てられている。   In FIG. 59, the function group F_A1, the function group F_A2, and the function group F_A3 are allocated to the memory B that is a constant voltage memory when in use. The function group F_A4 and the function group F_A5 are assigned to the memory C which is a constant voltage memory when in use.

本実施形態では、以上に説明したように、呼出関係のある関数群同士の呼出頻度等に基づきメモリマップを決定するため、関数が複数のメモリにまたがって配置されることを抑制することができる。したがって本実施形態では、メモリを低電圧状態とする制御コードを挿入する回数を低減することができ、且つ効率的に各メモリの電源制御を行うことができる。このため本実施形態では、更なる消費電力の削減に貢献することができる。   In the present embodiment, as described above, since the memory map is determined based on the calling frequency between function groups having a calling relationship, it is possible to suppress the function from being arranged across a plurality of memories. . Therefore, in this embodiment, the number of insertions of the control code for setting the memory in the low voltage state can be reduced, and the power supply control of each memory can be performed efficiently. For this reason, in this embodiment, it can contribute to the reduction of the further power consumption.

また本実施形態は、例えば第五の実施形態や第六の実施形態等と組み合わせることにより、さらなる消費電力の削減に貢献することができる。   Moreover, this embodiment can contribute to further reduction of power consumption by combining with the fifth embodiment, the sixth embodiment, or the like.

本発明の実施形態は、以下に記載する付記のような構成が考えられる。
(付記1)
複数の領域を有するメモリに書き込まれるプログラムコードに、電源電圧が安定した状態で前記領域を切り替えられるように前記電源電圧を制御する制御コードを挿入する挿入位置を算出する挿入位置算出手段と、
前記メモリの構造情報と前記挿入位置とに基づきメモリマップを作成するメモリマップ生成手段と、
前記制御コードを前記挿入位置へ挿入してプログラムコードを生成するコード生成手段と、を有するコード生成装置。
(付記2)
前記挿入位置算出手段は、
一命令コードを一サイクルとして定められたサイクル数が実行される時間を前記電源電圧の変動にかかる時間として前記挿入位置を算出する付記1記載のコード生成装置。
(付記3)
前記プログラムコードをリンクして前記電源電圧を制御する制御コードが含まれるバイナリを出力するリンク手段を有する付記1又は2記載のコード生成装置。
(付記4)
前記挿入位置算出手段において算出された挿入位置において前記プログラムコードを分割する分割手段を有する付記1乃至3の何れか一項に記載のコード生成装置。
(付記5)
前記分割手段は、
前記プログラムコードの開始アドレスから前記挿入位置までのプログラムコードを前半部分とし、前記挿入位置以降のプログラムコードを後半部分として分割し、
前記コード生成手段は、
前記前半部分は常に電源電圧が供給されている領域へ配置され、
前記後半部分は使用時に電源電圧が供給される領域へ配置されるようにプログラムコードを生成する付記4記載のコード生成装置。
(付記6)
前記制御コードを前記プログラムコードへ挿入するコード挿入手段を有し、
前記コード挿入手段は、
前記前半部分の先頭へ前記後半部分が配置された領域へ電源電圧を供給させるための制御コードを挿入する付記5記載のコード生成装置。
(付記7)
前記コード挿入手段は、
前記前半部分の最後に前記後半部分が配置された領域へジャンプさせる制御コードを挿入する付記5又は6記載のコード生成装置。
(付記8)
前記プログラムコードは割込ハンドラを含み、
前記コード挿入手段は、
前記プログラムコードに対して呼出関係図を生成し、メイン関数と前記割込ハンドラとの両方から到達できる関数のノードを複製し、
前記割込ハンドラから複製された前記ノードへと関連付ける付記1乃至7の何れか一項に記載のコード生成装置。
(付記9)
前記プログラムコードのコードサイズを、前記制御コードのコードサイズに基づき前記制御コードを挿入した後のコードサイズに補正するコードサイズ補正手段を有する付記1乃至8の何れか一項に記載のコード生成装置。
(付記10)
前記コード生成手段は、
関数の呼出関係に従って下層に配置された関数からメイン関数へ復帰するまでの間に、一度使用された前記使用時に電源電圧が供給される領域が再度使用されない場合に、
前記使用時に電源電圧が供給される領域に配置された関数を呼び出す関数のコードに、前記使用時に電源電圧が供給される領域の電圧を前記電源電圧よりも低い電圧とする制御コードを挿入する付記1乃至9の何れか一項に記載のコード生成装置。
(付記11)
前記コード生成手段は、
関数毎のアセンブリコードを取得するコード取得手段と、
前記コード取得手段にて取得した関数のコードが前記使用時に電源電圧が供給される領域と前記常に電源電圧が供給される領域とに配置されているかを判定する配置判定手段と、
前記配置判定手段の判定を受けて、前記前半部分の先頭へ前記後半部分が配置された領域へ電源電圧を供給させるための制御コードを挿入するスリープ解除コード挿入手段と、
前記関数の命令が関数呼出命令であり且つ前記関数呼出命令により呼び出される関数が配置されている領域が、前記関数呼出命令が配置された領域と同一の領域又は前記常に電源電圧が供給される領域でない場合に、前記関数呼出命令の直後に前記使用時に電源電圧が供給される領域の電圧を電源電圧より低い電圧とする制御コードを挿入するスリープコード挿入手段と、を有する付記1乃至10の何れか一項に記載のコード生成装置。
(付記12)
前記コード生成手段は、
関数毎のアセンブリコードを取得するコード取得手段と、
メイン関数から前記関数に至るまでに使用する全ての使用時一定電圧メモリの集合である第一の集合と、前記関数が呼び出す呼出先関数が使用する使用時一定電圧メモリの集合である第二の集合とに共通部分が存在するか否かを示す情報が、前記関数が呼び出す呼出先関数それぞれについて格納されたテーブルを作成するスリープコード挿入可能表作成手段と、
前記コード取得手段にて取得した関数のコードが前記使用時に電源電圧が供給される領域と前記常に電源電圧が供給される領域とに配置されているかを判定する配置判定手段と、
前記配置判定手段の判定を受けて、前記前半部分の先頭へ前記後半部分が配置された領域へ電源電圧を供給させるための制御コードを挿入するスリープ解除コード挿入手段と、
前記関数の命令が関数呼出命令であって、且つ前記テーブルにおいて前記第一の集合と前記第二の集合とが前記共通部分が存在しない場合に、前記関数呼出命令の直後に前記使用時に電源電圧が供給される領域の電圧を電源電圧より低い電圧とする制御コードを挿入するスリープコード挿入手段と、を有する付記1乃至10の何れか一項に記載のコード生成装置。
(付記13)
前記メモリマップ作成手段は、
呼出頻度情報に従って、親関数を一つ特定する親関数決定手段と、
常時一定電圧メモリへの関数割り当てを実行する常時一定電圧メモリ割当手段と、
使用時一定電圧メモリに割り当てる関数群の使用時一定電圧メモリのコード量の合計を求めるコード量計算手段と、
前記使用時一定電圧メモリに割り当てる関数群間の呼出頻度を算出したテーブルを作成する呼出頻度算出手段と、
前記コード量計算手段により計算された前記コード量の合計と、前記呼出頻度算出手段で作成したテーブルとを元に、関数群毎に使用時一定電圧メモリへ割り当てる使用時一定電圧メモリ割当手段と、
前記使用時一定電圧メモリ割当手段の結果を参照し、前記常時一定電圧メモリ割当手段による割り当てを修正し、各関数の一定電圧部、低電圧部の開始アドレスを計算する割当調整・アドレス計算手段と、を有する付記1乃至12の何れか一項に記載のコード生成装置。
(付記14)
複数の領域を有するメモリに書き込まれるプログラムコードに、電源電圧が安定した状態で前記領域を切り替えられるように前記電源電圧を制御する制御コードを挿入する挿入位置を算出する挿入位置算出手順と、
前記メモリの構造情報と前記挿入位置とに基づきメモリマップを作成するメモリマップ生成手順と、
前記制御コードを前記挿入位置へ挿入してプログラムコードを生成するコード生成手順と、を実行するコード生成方法。
(付記15)
半導体集積回路へ実装されるプログラムコードを生成するコード生成装置において実行されるコード生成プログラムであって、
前記コード生成装置に、
複数の領域を有するメモリに書き込まれるプログラムコードに、電源電圧が安定した状態で前記領域を切り替えられるように前記電源電圧を制御する制御コードを挿入する挿入位置を算出する挿入位置算出ステップと、
前記メモリの構造情報と前記挿入位置とに基づきメモリマップを作成するメモリマップ生成ステップと、
前記制御コードを前記挿入位置へ挿入してプログラムコードを生成するコード生成ステップと、を実行させるコード生成プログラム。
In the embodiment of the present invention, the following configurations described below are conceivable.
(Appendix 1)
Insertion position calculating means for calculating an insertion position for inserting a control code for controlling the power supply voltage so that the area can be switched in a state where the power supply voltage is stable in a program code written in a memory having a plurality of areas;
Memory map generating means for creating a memory map based on the structure information of the memory and the insertion position;
A code generation unit configured to generate a program code by inserting the control code into the insertion position;
(Appendix 2)
The insertion position calculating means includes
The code generation device according to appendix 1, wherein the insertion position is calculated by using a time for which a predetermined number of cycles are executed as one instruction code as a time required for fluctuation of the power supply voltage.
(Appendix 3)
The code generation device according to appendix 1 or 2, further comprising link means for linking the program code and outputting a binary including a control code for controlling the power supply voltage.
(Appendix 4)
The code generation device according to any one of appendices 1 to 3, further comprising a dividing unit that divides the program code at the insertion position calculated by the insertion position calculating unit.
(Appendix 5)
The dividing means includes
The program code from the start address of the program code to the insertion position is the first half, and the program code after the insertion position is divided as the second half,
The code generation means includes
The first half portion is always arranged in a region to which a power supply voltage is supplied,
The code generation device according to appendix 4, wherein the second half portion generates a program code so as to be arranged in a region where a power supply voltage is supplied during use.
(Appendix 6)
Code insertion means for inserting the control code into the program code;
The code insertion means includes
The code generation device according to appendix 5, wherein a control code for supplying a power supply voltage to an area where the latter half portion is arranged at the head of the first half portion is inserted.
(Appendix 7)
The code insertion means includes
The code generation device according to appendix 5 or 6, wherein a control code for jumping to a region where the latter half portion is arranged is inserted at the end of the first half portion.
(Appendix 8)
The program code includes an interrupt handler,
The code insertion means includes
Generate a call relationship diagram for the program code, duplicate the function node that can be reached from both the main function and the interrupt handler,
The code generation device according to any one of appendices 1 to 7 associated with the node copied from the interrupt handler.
(Appendix 9)
The code generation device according to any one of appendices 1 to 8, further comprising code size correction means for correcting the code size of the program code to a code size after the control code is inserted based on the code size of the control code. .
(Appendix 10)
The code generation means includes
When the area to which the power supply voltage is supplied once in use is not used again before returning to the main function from the function arranged in the lower layer according to the function calling relationship,
Supplementary note for inserting a control code for setting a voltage in a region to which a power supply voltage is supplied during use to a voltage lower than the power supply voltage in a function code for calling a function arranged in the region to which a power supply voltage is supplied during use The code generation device according to any one of 1 to 9.
(Appendix 11)
The code generation means includes
Code acquisition means for acquiring assembly code for each function;
An arrangement determining means for determining whether the code of the function acquired by the code acquiring means is arranged in a region where a power supply voltage is supplied during use and the region where the power supply voltage is always supplied;
In response to the determination of the arrangement determination means, a sleep release code insertion means for inserting a control code for supplying a power supply voltage to an area where the latter half portion is arranged at the head of the first half portion,
The area where the instruction of the function is a function call instruction and the function called by the function call instruction is arranged is the same area as the area where the function call instruction is arranged or the area where the power supply voltage is always supplied If not, sleep code insertion means for inserting a control code for setting a voltage in a region to which a power supply voltage is supplied at the time of use immediately after the function call command to a voltage lower than the power supply voltage. The code generation device according to claim 1.
(Appendix 12)
The code generation means includes
Code acquisition means for acquiring assembly code for each function;
A first set which is a set of all constant voltage memories in use used from the main function to the function, and a second set which is a set of constant voltage memories in use used by a callee function called by the function Sleep code insertable table creating means for creating a table in which information indicating whether or not a common part exists in a set is stored for each call destination function called by the function;
An arrangement determining means for determining whether the code of the function acquired by the code acquiring means is arranged in a region where a power supply voltage is supplied during use and the region where the power supply voltage is always supplied;
In response to the determination of the arrangement determination means, a sleep release code insertion means for inserting a control code for supplying a power supply voltage to an area where the latter half portion is arranged at the head of the first half portion,
When the instruction of the function is a function call instruction and the common part does not exist between the first set and the second set in the table, a power supply voltage at the time of use immediately after the function call instruction 11. The code generation device according to claim 1, further comprising: a sleep code insertion unit that inserts a control code that sets a voltage in a region to which the voltage is supplied to be lower than a power supply voltage.
(Appendix 13)
The memory map creating means includes
A parent function determining means for specifying one parent function according to the call frequency information;
A constant voltage memory allocation means for performing constant function allocation to a constant voltage memory;
A code amount calculation means for calculating a total code amount of the constant voltage memory when using the function group assigned to the constant voltage memory when using;
A call frequency calculation means for creating a table that calculates a call frequency between function groups assigned to the constant voltage memory in use;
Based on the total amount of code calculated by the code amount calculation means and the table created by the call frequency calculation means, a constant voltage memory allocation unit for use that allocates to a constant voltage memory for usage for each function group;
Allocation adjustment / address calculation means for referring to the result of the constant voltage memory allocation means in use, correcting the allocation by the constant voltage memory allocation means at all times, and calculating the start address of the constant voltage portion and the low voltage portion of each function; The code generation device according to any one of appendices 1 to 12, which includes:
(Appendix 14)
An insertion position calculation procedure for calculating an insertion position for inserting a control code for controlling the power supply voltage so that the area can be switched in a state where the power supply voltage is stable in a program code written in a memory having a plurality of areas;
A memory map generation procedure for creating a memory map based on the structure information of the memory and the insertion position;
A code generation method for executing a code generation procedure for generating a program code by inserting the control code into the insertion position.
(Appendix 15)
A code generation program that is executed in a code generation device that generates a program code to be mounted on a semiconductor integrated circuit,
In the code generator,
An insertion position calculating step for calculating an insertion position for inserting a control code for controlling the power supply voltage so that the area can be switched in a state where the power supply voltage is stable in a program code written in a memory having a plurality of areas;
A memory map generating step of creating a memory map based on the structure information of the memory and the insertion position;
A code generation step of executing a code generation step of generating the program code by inserting the control code into the insertion position.

本発明の実施形態は、具体的に開示された実施例に限定されるものではなく、特許請求の範囲から逸脱することなく、種々の変形や変更が可能である。   The embodiments of the present invention are not limited to the specifically disclosed examples, and various modifications and changes can be made without departing from the scope of the claims.

50 アセンブリ
52 関数サイズ情報
55 アセンブリコード
60 パラメータ
62 構造情報
63 制御コードパターン
64 電源制御コードパターン
70 電源制御入りバイナリ
100、100A、100B、100C、100D コード生成装置
50 Assembly 52 Function Size Information 55 Assembly Code 60 Parameter 62 Structure Information 63 Control Code Pattern 64 Power Control Code Pattern 70 Power Control Binary 100, 100A, 100B, 100C, 100D Code Generator

Claims (9)

複数の領域を有するメモリに書き込まれるプログラムコードに、電源電圧が安定した状態で前記領域を切り替えられるように前記電源電圧を制御する制御コードを挿入する挿入位置を算出する挿入位置算出手段と、
前記メモリの構造情報と前記挿入位置とに基づきメモリマップを作成するメモリマップ生成手段と、
前記制御コードを前記挿入位置へ挿入してプログラムコードを生成するコード生成手段と、を有するコード生成装置。
Insertion position calculating means for calculating an insertion position for inserting a control code for controlling the power supply voltage so that the area can be switched in a state where the power supply voltage is stable in a program code written in a memory having a plurality of areas;
Memory map generating means for creating a memory map based on the structure information of the memory and the insertion position;
A code generation unit configured to generate a program code by inserting the control code into the insertion position;
前記挿入位置算出手段は、
一命令コードを一サイクルとして定められたサイクル数が実行される時間を前記電源電圧の変動にかかる時間として前記挿入位置を算出する請求項1記載のコード生成装置。
The insertion position calculating means includes
2. The code generation device according to claim 1, wherein the insertion position is calculated by taking a time for which a predetermined number of cycles are executed as one instruction code as a time required for fluctuation of the power supply voltage.
前記プログラムコードをリンクして前記電源電圧を制御する制御コードが含まれるバイナリを出力するリンク手段を有する請求項1又は2記載のコード生成装置。   3. The code generation apparatus according to claim 1, further comprising a linking unit that links the program code and outputs a binary including a control code for controlling the power supply voltage. 前記挿入位置算出手段において算出された挿入位置で前記プログラムコードを分割する分割手段を有する請求項1乃至3の何れか一項に記載のコード生成装置。   The code generation apparatus according to claim 1, further comprising a dividing unit that divides the program code at the insertion position calculated by the insertion position calculating unit. 前記コード生成手段は、
関数の呼出関係に従って下層に配置された関数からメイン関数へ復帰するまでの間に、一度使用された前記使用時に電源電圧が供給される領域が再度使用されない場合に、
前記使用時に電源電圧が供給される領域に配置された関数を呼び出す関数のコードに、前記使用時に電源電圧が供給される領域の電圧を前記電源電圧よりも低い電圧とする制御コードを挿入する請求項1乃至4の何れか一項に記載のコード生成装置。
The code generation means includes
When the area to which the power supply voltage is supplied once in use is not used again before returning to the main function from the function arranged in the lower layer according to the function calling relationship,
A control code for inserting a voltage in a region to which a power supply voltage is supplied during use into a code lower than the power supply voltage is inserted into a function code for calling a function arranged in the region to which the power supply voltage is supplied during use. Item 5. The code generation device according to any one of Items 1 to 4.
前記コード生成手段は、
関数毎のアセンブリコードを取得するコード取得手段と、
前記コード取得手段にて取得した関数のコードが前記使用時に電源電圧が供給される領域と前記常に電源電圧が供給される領域とに配置されているかを判定する配置判定手段と、
前記配置判定手段の判定を受けて、前記前半部分の先頭へ前記後半部分が配置された領域へ電源電圧を供給させるための制御コードを挿入するスリープ解除コード挿入手段と、
前記関数の命令が関数呼出命令であり且つ前記関数呼出命令により呼び出される関数が配置されている領域が、前記関数呼出命令が配置された領域と同一の領域又は前記常に電源電圧が供給される領域でない場合に、前記関数呼出命令の直後に前記使用時に電源電圧が供給される領域の電圧を電源電圧より低い電圧とする制御コードを挿入するスリープコード挿入手段と、を有する請求項1乃至5の何れか一項に記載のコード生成装置。
The code generation means includes
Code acquisition means for acquiring assembly code for each function;
An arrangement determining means for determining whether the code of the function acquired by the code acquiring means is arranged in a region where a power supply voltage is supplied during use and the region where the power supply voltage is always supplied;
In response to the determination of the arrangement determination means, a sleep release code insertion means for inserting a control code for supplying a power supply voltage to an area where the latter half portion is arranged at the head of the first half portion,
The area where the instruction of the function is a function call instruction and the function called by the function call instruction is arranged is the same area as the area where the function call instruction is arranged or the area where the power supply voltage is always supplied If not, sleep code insertion means for inserting a control code for setting a voltage in a region where a power supply voltage is supplied during use immediately after the function call instruction to a voltage lower than the power supply voltage is provided. The code generation device according to any one of the above.
前記コード生成手段は、
関数毎のアセンブリコードを取得するコード取得手段と、
メイン関数から前記関数に至るまでに使用する全ての使用時一定電圧メモリの集合である第一の集合と、前記関数が呼び出す呼出先関数が使用する使用時一定電圧メモリの集合である第二の集合とに共通部分が存在するか否かを示す情報が、前記関数が呼び出す呼出先関数それぞれについて格納されたテーブルを作成するスリープコード挿入可能表作成手段と、
前記コード取得手段にて取得した関数のコードが前記使用時に電源電圧が供給される領域と前記常に電源電圧が供給される領域とに配置されているかを判定する配置判定手段と、
前記配置判定手段の判定を受けて、前記前半部分の先頭へ前記後半部分が配置された領域へ電源電圧を供給させるための制御コードを挿入するスリープ解除コード挿入手段と、
前記関数の命令が関数呼出命令であって、且つ前記テーブルにおいて前記第一の集合と前記第二の集合とが前記共通部分が存在しない場合に、前記関数呼出命令の直後に前記使用時に電源電圧が供給される領域の電圧を電源電圧より低い電圧とする制御コードを挿入するスリープコード挿入手段と、を有する請求項1乃至5の何れか一項に記載のコード生成装置。
The code generation means includes
Code acquisition means for acquiring assembly code for each function;
A first set which is a set of all constant voltage memories in use used from the main function to the function, and a second set which is a set of constant voltage memories in use used by a callee function called by the function Sleep code insertable table creating means for creating a table in which information indicating whether or not a common part exists in a set is stored for each call destination function called by the function;
An arrangement determining means for determining whether the code of the function acquired by the code acquiring means is arranged in a region where a power supply voltage is supplied during use and the region where the power supply voltage is always supplied;
In response to the determination of the arrangement determination means, a sleep release code insertion means for inserting a control code for supplying a power supply voltage to an area where the latter half portion is arranged at the head of the first half portion,
When the instruction of the function is a function call instruction and the common part does not exist between the first set and the second set in the table, a power supply voltage at the time of use immediately after the function call instruction 6. The code generation device according to claim 1, further comprising: a sleep code insertion unit that inserts a control code that sets a voltage in a region to which the voltage is supplied to be lower than a power supply voltage.
前記メモリマップ作成手段は、
呼出頻度情報に従って、親関数を一つ特定する親関数決定手段と、
常時一定電圧メモリへの関数割り当てを実行する常時一定電圧メモリ割当手段と、
使用時一定電圧メモリに割り当てる関数群の使用時一定電圧メモリのコード量の合計を求めるコード量計算手段と、
前記使用時一定電圧メモリに割り当てる関数群間の呼出頻度を算出したテーブルを作成する呼出頻度算出手段と、
前記コード量計算手段により計算された前記コード量の合計と、前記呼出頻度算出手段で作成したテーブルとを元に、関数群毎に使用時一定電圧メモリへ割り当てる使用時一定電圧メモリ割当手段と、
前記使用時一定電圧メモリ割当手段の結果を参照し、前記常時一定電圧メモリ割当手段による割り当てを修正し、各関数の一定電圧部、低電圧部の開始アドレスを計算する割当調整・アドレス計算手段と、を有する請求項1乃至7の何れか一項に記載のコード生成装置。
The memory map creating means includes
A parent function determining means for specifying one parent function according to the call frequency information;
A constant voltage memory allocation means for performing constant function allocation to a constant voltage memory;
A code amount calculation means for calculating a total code amount of the constant voltage memory when using the function group assigned to the constant voltage memory when using;
A call frequency calculation means for creating a table that calculates a call frequency between function groups assigned to the constant voltage memory in use;
Based on the total amount of code calculated by the code amount calculation means and the table created by the call frequency calculation means, a constant voltage memory allocating unit in use for allocating to a constant voltage memory in use for each function group;
Allocation adjustment / address calculation means for referring to the result of the constant voltage memory allocation means in use, correcting the allocation by the constant voltage memory allocation means at all times, and calculating the start address of the constant voltage portion and the low voltage portion of each function; The code generation device according to claim 1, comprising:
複数の領域を有するメモリに書き込まれるプログラムコードに、電源電圧が安定した状態で前記領域を切り替えられるように前記電源電圧を制御する制御コードを挿入する挿入位置を算出する挿入位置算出手順と、
前記メモリの構造情報と前記挿入位置とに基づきメモリマップを作成するメモリマップ生成手順と、
前記制御コードを前記挿入位置へ挿入してプログラムコードを生成するコード生成手順と、を実行するコード生成方法。
An insertion position calculation procedure for calculating an insertion position for inserting a control code for controlling the power supply voltage so that the area can be switched in a state where the power supply voltage is stable in a program code written in a memory having a plurality of areas;
A memory map generation procedure for creating a memory map based on the structure information of the memory and the insertion position;
A code generation method for executing a code generation procedure for generating a program code by inserting the control code into the insertion position.
JP2010009269A 2009-01-19 2010-01-19 Code generation device and code generation method Pending JP2011134288A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010009269A JP2011134288A (en) 2009-01-19 2010-01-19 Code generation device and code generation method

Applications Claiming Priority (5)

Application Number Priority Date Filing Date Title
JP2009009065 2009-01-19
JP2009009065 2009-01-19
JP2009266575 2009-11-24
JP2009266575 2009-11-24
JP2010009269A JP2011134288A (en) 2009-01-19 2010-01-19 Code generation device and code generation method

Publications (1)

Publication Number Publication Date
JP2011134288A true JP2011134288A (en) 2011-07-07

Family

ID=44346905

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010009269A Pending JP2011134288A (en) 2009-01-19 2010-01-19 Code generation device and code generation method

Country Status (1)

Country Link
JP (1) JP2011134288A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014021984A (en) * 2012-07-16 2014-02-03 Samsung Electronics Co Ltd Apparatus and method for managing power based on data

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04143819A (en) * 1989-12-15 1992-05-18 Hitachi Ltd Power consumption control method, semiconductor integrated circuit device, and microprocessor
JPH086881A (en) * 1994-06-22 1996-01-12 Chubu Nippon Denki Software Kk Memory control method and memory control system of communication processor
JPH0844622A (en) * 1994-07-29 1996-02-16 Hitachi Ltd Information processor
JPH0922318A (en) * 1995-07-06 1997-01-21 Hitachi Ltd Processor and control method therefor
JP2000003268A (en) * 1998-06-11 2000-01-07 Mitsubishi Electric Corp Method for deciding optimization of memory map
JP2000215100A (en) * 1999-01-21 2000-08-04 Nec Corp Power-saving memory management system
JP2001356916A (en) * 2000-06-13 2001-12-26 Mitsubishi Heavy Ind Ltd Memory blocking compiler and program executing method
JP2003296123A (en) * 2002-01-30 2003-10-17 Matsushita Electric Ind Co Ltd Device and method for changing instruction to give power control information, program and circuit for changing instruction, and microprocessor to execute changed instruction
JP2008040606A (en) * 2006-08-02 2008-02-21 Hitachi Ltd Low power consumption memory management method and computer using its method

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04143819A (en) * 1989-12-15 1992-05-18 Hitachi Ltd Power consumption control method, semiconductor integrated circuit device, and microprocessor
JPH086881A (en) * 1994-06-22 1996-01-12 Chubu Nippon Denki Software Kk Memory control method and memory control system of communication processor
JPH0844622A (en) * 1994-07-29 1996-02-16 Hitachi Ltd Information processor
JPH0922318A (en) * 1995-07-06 1997-01-21 Hitachi Ltd Processor and control method therefor
JP2000003268A (en) * 1998-06-11 2000-01-07 Mitsubishi Electric Corp Method for deciding optimization of memory map
JP2000215100A (en) * 1999-01-21 2000-08-04 Nec Corp Power-saving memory management system
JP2001356916A (en) * 2000-06-13 2001-12-26 Mitsubishi Heavy Ind Ltd Memory blocking compiler and program executing method
JP2003296123A (en) * 2002-01-30 2003-10-17 Matsushita Electric Ind Co Ltd Device and method for changing instruction to give power control information, program and circuit for changing instruction, and microprocessor to execute changed instruction
JP2008040606A (en) * 2006-08-02 2008-02-21 Hitachi Ltd Low power consumption memory management method and computer using its method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2014021984A (en) * 2012-07-16 2014-02-03 Samsung Electronics Co Ltd Apparatus and method for managing power based on data

Similar Documents

Publication Publication Date Title
CN107450972B (en) Scheduling method and device and electronic equipment
US6011917A (en) Method and computer system for generating process management computer programs from process models
KR101900796B1 (en) Agile communication operator
KR19990077379A (en) Distributed system for communication and compiler device used there
CN105224370A (en) A kind of method and apparatus of loading ELF document
CN103645930B (en) Assembly level is across the construction method of file Scheduling Framework
CN102455931A (en) Method and system for developing Android platform engineering
CN102722387A (en) Dynamic patching method and device
CN102375734A (en) Application product development system, method and device and operation system, method and device
CN101650663A (en) Database system and upgrading method thereof
JP5199212B2 (en) Program generation method and system operation method
CN103645888A (en) System and method for automatically building operation system
JP2011134288A (en) Code generation device and code generation method
WO2015132634A1 (en) Method for generating upgrade campaigns to upgrade virtualization facilities
CN105786525A (en) Method and device for transplanting code from process model to thread model
CN113961523A (en) Business file splitting and summarizing method, device and equipment
CN105786613A (en) Method for improving utilization rate of internal memory
CN116974689A (en) Cluster container scheduling method, device, equipment and computer readable storage medium
CN105279195A (en) Method and apparatus for webpage application to call browser function
ES2909553T3 (en) Real-time data exchange between program modules
CN115658140A (en) SDK packaging method, device, terminal and storage medium
CN111966744B (en) Workflow deployment method and device, computer equipment and storage medium
JP6349837B2 (en) Scheduler apparatus, scheduling method therefor, arithmetic processing system, and computer program
JP6387626B2 (en) Information processing system, information processing method, and scheduling program
CN100495328C (en) Device for developing computer system and its method

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20121005

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20130416

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130521

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20130718

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20140114