以下では、本発明を適用した具体的な実施の形態について、図面を参照しながら詳細に説明する。各図面において、同一又は対応する要素には同一の符号が付されており、説明の明確化のため、必要に応じて重複説明は省略される。Hereinafter, specific embodiments to which the present invention is applied will be described in detail with reference to the drawings. In each drawing, the same or corresponding elements are denoted by the same reference numerals, and redundant description is omitted as necessary for clarification of the description.
<発明の実施の形態1>
本実施の形態では、コンピュータに実行される命令シーケンスを含むプログラムを不揮発性メモリに記録する場合について説明する。図1は、本実施の形態に係るコンピュータ1及びライタ5の構成例を示している。コンピュータ1は、例えば、マイクロコントローラ、マイクロプロセッサ、DSP(Digital Signal Processor)等である。図1に示されたコンピュータ1は、不揮発性メモリ10、逆置換部11、逆置換テーブル12、及び命令処理部13を含む。<Embodiment 1 of the Invention>
In this embodiment, a case where a program including an instruction sequence executed by a computer is recorded in a nonvolatile memory will be described. FIG. 1 shows a configuration example of acomputer 1 and awriter 5 according to the present embodiment. Thecomputer 1 is, for example, a microcontroller, a microprocessor, a DSP (Digital Signal Processor) or the like. Thecomputer 1 shown in FIG. 1 includes anon-volatile memory 10, aninverse replacement unit 11, an inverse replacement table 12, and aninstruction processing unit 13.
不揮発性メモリ10は、例えばフラッシュメモリ又はMRAMであり、記録しているデータビット値によってデータ読み出し時の消費電力が異なる特徴を持つ。不揮発性メモリ10は、ビットパターン置換されたプログラムP2を記録している。プログラムP2は、ライタ5によって元プログラムP1に対してビットパターン置換処理を行うことによって生成され、不揮発性メモリ10に格納される。ここで、ライタ5によるビットパターン置換処理は、元プログラムP1中での出現頻度が相対的に高いビットパターンを持つ第1のビット列を、同一ビット長であって、かつ不揮発性メモリ10からの読み出し時に必要な電力が相対的に小さいビットパターンを持つ第2のビット列に置換するように行われている。このようにビットパターンが置換されたプログラムP2を不揮発性メモリ10に記録することで、元プログラムP1をそのまま記録する場合に比べて、不揮発性メモリ10からの読み出しに必要な消費電力を低減できる。Thenonvolatile memory 10 is, for example, a flash memory or an MRAM, and has a feature that power consumption at the time of data reading differs depending on a recorded data bit value. Thenonvolatile memory 10 records the program P2 with the bit pattern replaced. The program P2 is generated by performing a bit pattern replacement process on the original program P1 by thewriter 5, and stored in thenonvolatile memory 10. Here, the bit pattern replacement process by thewriter 5 reads the first bit string having a bit pattern having a relatively high appearance frequency in the original program P1 from thenonvolatile memory 10 with the same bit length. At times, the necessary power is replaced with a second bit string having a relatively small bit pattern. By recording the program P2 with the bit pattern replaced in thenonvolatile memory 10 in this way, it is possible to reduce the power consumption required for reading from thenonvolatile memory 10 as compared with the case where the original program P1 is recorded as it is.
逆置換部11は、逆置換テーブル12を参照することで、不揮発性メモリ10から読み出されたプログラムP2に対してビットパターン逆置換処理を行う。これにより、逆置換部11は、元プログラムP1を復元する。つまり、ビットパターン逆置換処理は、上述したライタ5によるビットパターン置換処理の逆の処理である。逆置換テーブル12は、不揮発性メモリ10への書き込み前に行われるビットパターン置換処理における元プログラムP1と置換後のプログラムの間のビット列(ビットパターン)の対応関係を規定する。逆置換テーブル12は、不揮発性メモリに保持されてもよいし、揮発性メモリに保持されてもよい。例えば、逆置換テーブル12は、逆置換前のビット列をアドレスとして入力すると逆置換後のビット列を出力できるように、SRAM(Static Random Access Memory)を用いたルックアップテーブルとして構成されてもよい。逆置換テーブル12を揮発性メモリに保持する場合、コンピュータ1の動作時に、不揮発性メモリ10又は他の不揮発性メモリ(不図示)から揮発性メモリに逆置換テーブル12をロードすればよい。逆置換部11によるビットパターン逆置換処理の具体例、及び逆置換テーブル12の具体例については後述する。Thereverse replacement unit 11 refers to the reverse replacement table 12 to perform a bit pattern reverse replacement process on the program P2 read from thenonvolatile memory 10. As a result, thereverse replacement unit 11 restores the original program P1. That is, the bit pattern reverse replacement process is the reverse of the bit pattern replacement process performed by thewriter 5 described above. The reverse replacement table 12 defines a correspondence relationship between bit sequences (bit patterns) between the original program P1 and the replaced program in the bit pattern replacement processing performed before writing to thenonvolatile memory 10. The reverse replacement table 12 may be held in a non-volatile memory or in a volatile memory. For example, the reverse substitution table 12 may be configured as a lookup table using SRAM (Static Random Access Memory) so that a bit string after reverse substitution can be output when a bit string before reverse substitution is input as an address. When the reverse replacement table 12 is held in the volatile memory, the reverse replacement table 12 may be loaded into the volatile memory from thenonvolatile memory 10 or another nonvolatile memory (not shown) during the operation of thecomputer 1. A specific example of the bit pattern reverse replacement processing by thereverse replacement unit 11 and a specific example of the reverse replacement table 12 will be described later.
命令処理部13は、逆置換部11によって復元されたプログラムP1に含まれる命令群を取得し、これらの命令を解読して実行する。具体的には、命令処理部13は、CPU、キャッシュメモリ、メインメモリ等を含む。CPUは、命令をフェッチ及び解読(デコード)し、デコードされた命令に応じた処理(演算、ロード/ストア)を行う。Theinstruction processing unit 13 acquires a group of instructions included in the program P1 restored by thereverse replacement unit 11, and decodes and executes these instructions. Specifically, theinstruction processing unit 13 includes a CPU, a cache memory, a main memory, and the like. The CPU fetches and decodes (decodes) the instruction, and performs processing (operation, load / store) according to the decoded instruction.
なお、図1の例では、不揮発性メモリ10がコンピュータ1の内部に含まれているが、不揮発性メモリ10は、コンピュータ1の外部に配置されてもよい。例えば、コンピュータ1がマイクロコントローラである場合、不揮発性メモリ10は、命令処理部13とは別のIC(Integrated Circuit)チップに配置されてもよい。In the example of FIG. 1, thenonvolatile memory 10 is included in thecomputer 1, but thenonvolatile memory 10 may be disposed outside thecomputer 1. For example, when thecomputer 1 is a microcontroller, thenon-volatile memory 10 may be arranged on an IC (Integrated Circuit) chip different from theinstruction processing unit 13.
次に、図1に示されたライタ5の構成について説明する。ライタ5は、元プログラムP1に含まれる出現頻度の高いビットパターンを不揮発性メモリ10からの読み出しに要する消費電力が小さいビットパターンに対応付けるとともに、ビットパターン置換処理を行ってプログラムP2を生成する。ライタ5は、計測部50、テーブル生成部51、置換テーブル52、置換部53、書き込み処理部54を含む。Next, the configuration of thewriter 5 shown in FIG. 1 will be described. Thewriter 5 associates a bit pattern with a high appearance frequency included in the original program P1 with a bit pattern with low power consumption required for reading from thenonvolatile memory 10, and generates a program P2 by performing bit pattern replacement processing. Thewriter 5 includes ameasurement unit 50, atable generation unit 51, a replacement table 52, areplacement unit 53, and awrite processing unit 54.
計測部50は、元プログラムP1におけるビットパターン毎の出現頻度を計測する。一例として4ビット単位でビットパターン置換が行われる場合を考える。この場合、計測部50は、元プログラムP1を各々が4ビット長の複数のビット列(第1のビット列)に分割し、各ビット列のビットパターンを判別し、ビットパターン毎の出現頻度を計測すればよい。具体的には、4ビット長のビット列が取り得るビットパターンは全部で16通りであるから、計測部50は、各ビット列が16通りのいずれであるかを判別し、16通りのパターン毎の出現数を数えればよい。The measuringunit 50 measures the appearance frequency for each bit pattern in the original program P1. As an example, consider a case where bit pattern replacement is performed in units of 4 bits. In this case, themeasurement unit 50 divides the original program P1 into a plurality of bit strings (first bit strings) each having a length of 4 bits, determines the bit pattern of each bit string, and measures the appearance frequency for each bit pattern. Good. Specifically, since there are 16 bit patterns that can be taken by a 4-bit long bit string, themeasurement unit 50 determines which of the 16 bit patterns is present, and appears for each of the 16 patterns. Just count the numbers.
テーブル生成部51は、計測部50によるビットパターン出現頻度の計測結果に基づいて、置換前の元プログラムP1に含まれるビットパターン(第1のビット列)と置換後のプログラムP2に含まれるビットパターン(第2のビット列)との対応関係を決定する。例えば、4ビット単位でビットパターン置換が行われる場合、テーブル生成部51は、置換前の16通りのビットパターンと置換後の16通りのビットパターンの対応関係を決定すればよい。Based on the measurement result of the bit pattern appearance frequency by themeasurement unit 50, thetable generation unit 51 uses the bit pattern (first bit string) included in the original program P1 before replacement and the bit pattern (first bit string) included in the replacement program P2 ( The correspondence relationship with the second bit string) is determined. For example, when bit pattern replacement is performed in units of 4 bits, thetable generation unit 51 may determine the correspondence between 16 bit patterns before replacement and 16 bit patterns after replacement.
より、具体的に述べると、テーブル生成部51は、元プログラムP1中での出現頻度が相対的に高いビットパターンに対して、不揮発性メモリ10からの読み出し時に必要な電力が相対的に小さいビットパターンを優先的に割り当てるように、置換前後のビットパターンの対応関係を決定する。言い換えると、元プログラムP1中での出現頻度が相対的に高いビットパターンを持つ第1のビット列は、データビット値1及び0のうち不揮発性メモリ10からの読み出しに要する電力が低い一方のビット値を相対的に多く含むビットパターンを持つ第2のビット列に対応付けられる。More specifically, thetable generation unit 51 is a bit whose power required for reading from thenonvolatile memory 10 is relatively small with respect to a bit pattern having a relatively high appearance frequency in the original program P1. Correspondence between bit patterns before and after replacement is determined so that patterns are preferentially assigned. In other words, the first bit string having a bit pattern with a relatively high appearance frequency in the original program P1 is one of the bit values of the data bitvalues 1 and 0 that require low power for reading from thenonvolatile memory 10 Are associated with the second bit string having a bit pattern including a relatively large amount of.
置換前後でのビットパターンの対応関係の決定には、様々なバリエーションが考えられる。第1の例として、元プログラムP1中で最も出現頻度が高いビットパターンは、不揮発性メモリ10からの読み出しに要する電力が最も低いビットパターンに対応付けてもよい。不揮発性メモリ10からの読み出しに要する電力が最も低いビットパターンは、データビット値1及び0のうち不揮発性メモリ10からの読み出しに要する電力が低い一方のビット値を最も多く含むビットパターンである。例えば、値1より値0のほうが不揮発性メモリ10からの読み出しに要する電力が小さい場合、元プログラムP1中で最も出現頻度が高いビットパターンを、値0のみを含むビットパターン(i.e. 0000)に対応付ければよい。There are various possible variations in determining the correspondence between bit patterns before and after replacement. As a first example, the bit pattern having the highest appearance frequency in the original program P1 may be associated with the bit pattern having the lowest power required for reading from thenonvolatile memory 10. The bit pattern having the lowest power required for reading from thenonvolatile memory 10 is a bit pattern including the most bit value of one of the data bitvalues 1 and 0 having the lowest power required for reading from thenonvolatile memory 10. For example, when the value 0 is smaller than thevalue 1 and the power required for reading from thenonvolatile memory 10 is smaller, the bit pattern having the highest appearance frequency in the original program P1 corresponds to the bit pattern including only the value 0 (ie 0000). You can attach it.
第2の例として、元プログラムP1中での出現頻度の高いビットパターンから順に、不揮発性メモリ10からの読み出しに要する電力が相対的に低いビットパターンと対応付けてもよい。言い換えると、元プログラムP1中での出現頻度の高いビットパターンから順に、データビット値1及び0のうち不揮発性メモリ10からの読み出しに要する電力が低い一方のビット値を相対的に多く含むビットパターンと対応付けてもよい。この場合、テーブル生成部51は、元プログラムP1中での出現頻度が高い順にビットパターンを整列したリストと、不揮発性メモリ10からの読み出しに要する電力が低い順にビットパターンを整列したリストとを照合し、2つのリストにおける同一順位のビットパターンどうしを対応付ければよい。As a second example, in order from the bit pattern with the highest appearance frequency in the original program P1, it may be associated with the bit pattern with relatively low power required for reading from thenonvolatile memory 10. In other words, in order from the bit pattern having a high frequency of appearance in the original program P1, a bit pattern that includes a relatively large amount of one of the data bitvalues 1 and 0 that has a low power required for reading from thenonvolatile memory 10 May be associated. In this case, thetable generation unit 51 collates the list in which the bit patterns are arranged in descending order of appearance frequency in the original program P1 with the list in which the bit patterns are arranged in order from the low power required for reading from thenonvolatile memory 10. Then, the bit patterns having the same rank in the two lists may be associated with each other.
不揮発性メモリ10からの読み出しに要する電力が低い順にビットパターンを整列したリストは、例えば、外部からライタ5に供給すればよい。また、テーブル生成部51は、各ビットパターンに関して不揮発性メモリ10からの読み出し電力の実測値又は推定値を取得し、これに基づいて各ビットパターンの順位を決定してもよい。また、テーブル生成部51は、不揮発性メモリ10からの読み出し電力の推定値を各ビットパターンについて計算してもよい。この場合、値1及び0それぞれの1ビット読み出しに要する電力値を基準値としてテーブル生成部51に与えればよい。For example, a list in which bit patterns are arranged in ascending order of power required for reading from thenonvolatile memory 10 may be supplied to thewriter 5 from the outside. In addition, thetable generation unit 51 may acquire an actual measurement value or an estimated value of read power from thenonvolatile memory 10 with respect to each bit pattern, and determine the order of each bit pattern based on this value. Thetable generation unit 51 may calculate an estimated value of the read power from thenonvolatile memory 10 for each bit pattern. In this case, the power value required for 1-bit reading of each of thevalues 1 and 0 may be given to thetable generation unit 51 as a reference value.
第3の例として、ビットパターンの置換は、全てのビットパターンに対してではなく、一部のビットパターンに対してのみ行ってもよい。置換対象とされないビットパターンに関しては、ビットパターン置換前後で同一のビットパターンを対応付ければよい。例えば、出現頻度が基準レベル以上であったビットパターンと、これらを置換するために必要なその他のビットパターンを置換対象としてもよい。また、例えば、出現頻度の順位が基準値以上であったビットパターンと、これらを置換するために必要なその他のビットパターンを置換対象としてもよい。As a third example, bit pattern replacement may be performed only for a part of bit patterns, not for all bit patterns. For bit patterns that are not to be replaced, the same bit pattern may be associated before and after bit pattern replacement. For example, a bit pattern whose appearance frequency is equal to or higher than a reference level and other bit patterns necessary for replacing them may be replaced. Further, for example, a bit pattern whose appearance frequency rank is equal to or higher than a reference value and other bit patterns necessary for replacing them may be set as replacement targets.
さらに、置換前後でのビットパターンの対応関係は、上述したいくつかの例に限定されない。つまり、ビットパターン置換後のプログラムP2は、元プログラムP1と比べて、データビット値1及び0のうち不揮発性メモリ10からの読み出しに要する電力が低い一方のビット値を多く含む状態となっていればよい。したがって、置換前後の対応関係の決定は、置換後のプログラムP2がこのような状態となるように決定されていればよい。Furthermore, the correspondence between bit patterns before and after replacement is not limited to the above-described examples. In other words, the program P2 after the bit pattern replacement may be in a state in which one of the bit values of the data bitvalues 1 and 0, which requires less power for reading from thenonvolatile memory 10, is lower than the original program P1. That's fine. Therefore, the correspondence relationship before and after replacement may be determined so that the program P2 after replacement is in such a state.
さらに、テーブル生成部51は、置換前後でのビットパターンの対応関係を示す置換テーブル52及び逆置換テーブル12を生成する。置換テーブル52は、後述する置換部53によって使用される。逆置換テーブル12は、ビットパターン逆置換処理のためにコンピュータ1に供給される。逆置換テーブル12については既に説明したのでここでは説明を省略する。Furthermore, thetable generation unit 51 generates a replacement table 52 and an inverse replacement table 12 that indicate the correspondence between bit patterns before and after replacement. The replacement table 52 is used by areplacement unit 53 described later. The reverse replacement table 12 is supplied to thecomputer 1 for bit pattern reverse replacement processing. Since the reverse replacement table 12 has already been described, the description thereof is omitted here.
置換テーブル52は、不揮発性メモリ10への書き込み前に行われるビットパターン置換処理における元プログラムP1と置換後のプログラムP2の間のビット列(ビットパターン)の対応関係を規定する。置換テーブル52は、不揮発性メモリに保持されてもよいし、揮発性メモリに保持されてもよい。例えば、置換テーブル52は、置換前のビット列をアドレスとして入力すると置換後のビット列を出力できるように、SRAMを用いたルックアップテーブルとして構成されてもよい。The replacement table 52 defines the correspondence of bit strings (bit patterns) between the original program P1 and the replaced program P2 in the bit pattern replacement process performed before writing to thenonvolatile memory 10. The replacement table 52 may be held in a non-volatile memory or may be held in a volatile memory. For example, the replacement table 52 may be configured as a look-up table using an SRAM so that when a bit string before replacement is input as an address, the bit string after replacement can be output.
置換部53は、元プログラムP1を分割単位と同じビット長で分割し、置換テーブル52で定められた対応関係に従って元プログラムP1に含まれる各ビット列(第1のビット列)のビットパターンを置換する。そして、置換部53は、ビットパターン置換によって得られたビット列(第2のビット列)を順番に連結することで、置換後のプログラムP2を生成する。Thereplacement unit 53 divides the original program P1 by the same bit length as the division unit, and replaces the bit pattern of each bit string (first bit string) included in the original program P1 according to the correspondence relationship defined in the replacement table 52. Then, thereplacement unit 53 generates the replaced program P2 by sequentially connecting the bit strings (second bit strings) obtained by the bit pattern replacement.
書き込み処理部54は、置換部53によって生成されたプログラP2を不揮発性メモリ10に書き込む。Thewrite processing unit 54 writes the program P2 generated by thereplacement unit 53 into thenonvolatile memory 10.
図1に示したライタ5は、コンピュータ1用の専用デバイスであってもよい。また、ライタ5は、基板に実装されたコンピュータ1に書き込みを行うデバイス(書き込み処理部54に相当)と、プログラムP2を生成して当該デバイスに供給するPC(Personal Computer)及びアプリケーションプログラム(計測部50、テーブル生成部51、置換部53に相当)の組合せであってもよい。Thewriter 5 shown in FIG. 1 may be a dedicated device for thecomputer 1. Thewriter 5 includes a device (corresponding to the write processing unit 54) for writing to thecomputer 1 mounted on the board, a PC (Personal Computer) and an application program (measurement unit) that generates the program P2 and supplies the program P2. 50, equivalent to thetable generation unit 51 and the replacement unit 53).
図2及び3は、ライタ5及びコンピュータ1の動作フローを示すフローチャートである。まず、図2を用いてライタ5の動作フローを説明する。ステップS11では、計測部50は、元プログラムP1におけるビットパターン毎の出現頻度を計測する。ステップS12では、テーブル生成部51は、ビットパターン毎の出現頻度に基づいて、元プログラムP1のビットパターン(元ビットパターン)と置換後のプログラムP2のビットパターン(書き込みビットパターン)との対応関係を示す置換テーブル52及び逆置換テーブル12を生成する。ステップS13では、置換部53は、置換テーブル52に従って、元プログラムP1に対するビットパターン置換処理を行う。ステップS14では、書き込み処理部54は、ビットパターンを置換されたプログラムP2を不揮発性メモリ10に書き込む。2 and 3 are flowcharts showing the operation flow of thewriter 5 and thecomputer 1. First, the operation flow of thewriter 5 will be described with reference to FIG. In step S11, the measuringunit 50 measures the appearance frequency for each bit pattern in the original program P1. In step S12, thetable generation unit 51 determines the correspondence between the bit pattern (original bit pattern) of the original program P1 and the bit pattern (write bit pattern) of the replaced program P2 based on the appearance frequency for each bit pattern. A replacement table 52 and a reverse replacement table 12 are generated. In step S13, thereplacement unit 53 performs a bit pattern replacement process for the original program P1 according to the replacement table 52. In step S <b> 14, thewrite processing unit 54 writes the program P <b> 2 whose bit pattern has been replaced into thenonvolatile memory 10.
次に、図3を用いてコンピュータ1の動作フローを説明する。ステップS21では、命令処理部13は、ビットパターンを置換されたプログラムP2を不揮発性メモリ10から読み出す。例えば、命令処理部13は、読み出すべき命令に対応するメモリアドレスを不揮発性メモリ10へ送ればよい。不揮発性メモリ10は、与えられたメモリアドレスに応答して、当該アドレスに配置されている命令(ビットパターンが置換された命令)を逆置換部11に出力する。ステップS22では、逆置換部11は、逆置換テーブル12に従って、プログラムP2に対するビットパターン置換処理を行う。具体的には、不揮発性メモリ10から読み出された命令(ビットパターンが置換された命令)をライタ5での元プログラムP1の分割単位と同じビット長で分割し、逆置換テーブル12で定められた対応関係に従って各ビット列(第2のビット列)のビットパターンを逆置換する。これにより、逆置換部11は、元プログラムP1に含まれる命令を復元する。ステップS23では、命令処理部13は、復元された元プログラムP1(つまり復元された命令)を解読して実行する。Next, the operation flow of thecomputer 1 will be described with reference to FIG. In step S <b> 21, theinstruction processing unit 13 reads the program P <b> 2 whose bit pattern has been replaced from thenonvolatile memory 10. For example, theinstruction processing unit 13 may send the memory address corresponding to the instruction to be read to thenonvolatile memory 10. In response to the given memory address, thenonvolatile memory 10 outputs the instruction (instruction with the bit pattern replaced) located at the address to thereverse replacement unit 11. In step S <b> 22, thereverse replacement unit 11 performs a bit pattern replacement process for the program P <b> 2 according to the reverse replacement table 12. Specifically, an instruction read from the non-volatile memory 10 (an instruction in which the bit pattern is replaced) is divided by the same bit length as the division unit of the original program P1 in thewriter 5, and is determined by the reverse replacement table 12. The bit pattern of each bit string (second bit string) is reversely replaced according to the corresponding relationship. Thereby, thereverse replacement unit 11 restores the instruction included in the original program P1. In step S23, theinstruction processing unit 13 decodes and executes the restored original program P1 (that is, the restored instruction).
以上に述べたことから理解されるように、本実施の形態は、命令処理部13によって使用される元プログラムP1を、ビットパターンが置換されたプログラムP2として不揮発性メモリ10に記録しておくことができる。プログラムP2では、元プログラムP1中での出現頻度が相対的に高いビットパターンが、不揮発性メモリ10からの読み出しに要する消費電力が相対的に小さいビットパターンに置換されている。したがって、不揮発性メモリ10に記録されるプログラムP2は、元プログラムP1に比べて、不揮発性メモリ10からの読み出しに要する消費電力が小さいビット値を多く含む。このため、本実施の形態は、不揮発性メモリ10からのプログラム読み出しに要する消費電力を低減することができる。As can be understood from the above description, in this embodiment, the original program P1 used by theinstruction processing unit 13 is recorded in thenonvolatile memory 10 as the program P2 in which the bit pattern is replaced. Can do. In the program P2, a bit pattern that has a relatively high frequency of appearance in the original program P1 is replaced with a bit pattern that requires relatively little power consumption for reading from thenonvolatile memory 10. Therefore, the program P2 recorded in thenon-volatile memory 10 includes many bit values that require lower power consumption for reading from thenon-volatile memory 10 than the original program P1. For this reason, the present embodiment can reduce the power consumption required for reading the program from thenonvolatile memory 10.
また、コンピュータ1に逆置換部11を配置することによって、不揮発性メモリ10へのプログラムの格納時にビットパターン置換が行われた場合であっても、命令処理部13には復元された元プログラムP1が供給される。したがって、本実施の形態は、命令処理部13の設計変更および機能追加を必須としない。このため、本実施の形態は、命令処理部13の消費電力を増加させることなく、不揮発性メモリ10からのプログラム読み出しに要する電力を低減することができる。In addition, by arranging thereverse replacement unit 11 in thecomputer 1, the restoredoriginal program P 1 is stored in theinstruction processing unit 13 even when bit pattern replacement is performed when the program is stored in thenonvolatile memory 10. Is supplied. Therefore, this embodiment does not require design change and function addition of theinstruction processing unit 13. For this reason, the present embodiment can reduce the power required to read the program from thenonvolatile memory 10 without increasing the power consumption of theinstruction processing unit 13.
さらに、本実施の形態では、元プログラムP1と置換されたプログラムP2の間のビットパターン置換を、置換前後のビット列が同一ビット長となるように行っている。つまり、ビット長の圧縮及び伸張を行っていない。このため、プログラムP2に含まれる命令(ビットパターンが置換された命令)の不揮発性メモリ10上でのアドレスを元プログラムP1の対応する命令のアドレスと同一とすることができる。したがって、本実施の形態は、命令処理部13から不揮発性メモリ10へのメモリアドレス転送経路にアドレス変換機構を追加する必要がないという利点がある。Furthermore, in this embodiment, the bit pattern replacement between the original program P1 and the replaced program P2 is performed so that the bit strings before and after replacement have the same bit length. In other words, bit length compression and decompression are not performed. For this reason, the address on thenonvolatile memory 10 of the instruction (instruction in which the bit pattern is replaced) included in the program P2 can be made the same as the address of the corresponding instruction in the original program P1. Therefore, this embodiment has an advantage that it is not necessary to add an address conversion mechanism to the memory address transfer path from theinstruction processing unit 13 to thenonvolatile memory 10.
以上に述べた効果を集約することによって、本実施の形態は、簡潔で電力消費の小さい逆置換部11を用いることで、命令処理部13の消費電力を増加させることなく、不揮発性メモリ10からのプログラム読み出しに要する電力を低減することができるため、コンピュータ1の消費電力を低減することができる。By consolidating the effects described above, the present embodiment uses thereverse replacement unit 11 that is simple and consumes less power, so that the power consumption of theinstruction processing unit 13 can be increased without increasing the power consumption of theinstruction processing unit 13. Since the power required for reading the program can be reduced, the power consumption of thecomputer 1 can be reduced.
続いて以下では、置換テーブル52及び逆置換テーブル12の生成、ビットパターンの置換処理及び逆置換処理の具体例について説明する。図4は、本実施の形態に係るコンピュータ1のより具体的な構成例を示すブロック図である。図4の例では、元プログラムP1に含まれる命令は固定長の8ビット命令であると仮定している。また、ビットパターンの置換及び逆置換は、4ビット長のビット列を単位として行われる。さらに、不揮発性メモリ10は、記録されたビット値が1である場合の方が0である場合に比べて読み出し時の消費電力が大きいと仮定する。Subsequently, specific examples of the generation of the replacement table 52 and the reverse replacement table 12, the bit pattern replacement process, and the reverse replacement process will be described below. FIG. 4 is a block diagram illustrating a more specific configuration example of thecomputer 1 according to the present embodiment. In the example of FIG. 4, it is assumed that the instruction included in the original program P1 is a fixed-length 8-bit instruction. Also, bit pattern replacement and reverse replacement are performed in units of a 4-bit long bit string. Further, it is assumed that thenon-volatile memory 10 consumes more power when reading when the recorded bit value is 1 than when it is 0.
図4の例では、逆置換テーブル12は、SRAMを用いたルックアップテーブル(LUT)121に配置される。4ビット単位でビット置換を行う場合、ビットパターンは全部で16通りである。このため、LUT121は、16個の4ビットデータを記憶できる容量を有していればよい。In the example of FIG. 4, the reverse replacement table 12 is arranged in a lookup table (LUT) 121 using SRAM. When bit substitution is performed in units of 4 bits, there are 16 bit patterns in total. Therefore, theLUT 121 only needs to have a capacity capable of storing 16 pieces of 4-bit data.
さらに、図4の例では、逆置換部11は、2つのマルチプレクサ111及び112を含む。各マルチプレクサは、LUT121に接続された16個のデータ入力端子(4ビット幅)と、不揮発性メモリ10の出力端子に接続された1個のデータ選択端子(4ビット幅)と、命令処理部13に接続された1個のデータ出力端子(4ビット幅)を有する。マルチプレクサ111のデータ選択端子は、不揮発性メモリ10の8ビット出力のうち上位4ビットを選択信号として受信する。マルチプレクサ111は、データ選択端子に与えられた選択信号に対応する1つのビット列を、LUT121からの16通りのビット列の中から選択する。選択されたビット列は、マルチプレクサ111のデータ出力端子から出力され、命令処理部13に供給される。マルチプレクサ112は、不揮発性メモリ10の8ビット出力のうち下位4ビットを選択信号として受信し、マルチプレクサ111と同様に動作する。Furthermore, in the example of FIG. 4, thereverse replacement unit 11 includes twomultiplexers 111 and 112. Each multiplexer includes 16 data input terminals (4 bit width) connected to theLUT 121, one data selection terminal (4 bit width) connected to the output terminal of thenonvolatile memory 10, and theinstruction processing unit 13. One data output terminal (4 bits wide) connected to the. The data selection terminal of themultiplexer 111 receives the upper 4 bits of the 8-bit output of thenonvolatile memory 10 as a selection signal. Themultiplexer 111 selects one bit string corresponding to the selection signal given to the data selection terminal from among the 16 bit strings from theLUT 121. The selected bit string is output from the data output terminal of themultiplexer 111 and supplied to theinstruction processing unit 13. Themultiplexer 112 receives the lower 4 bits of the 8-bit output of thenonvolatile memory 10 as a selection signal, and operates in the same manner as themultiplexer 111.
次に、図5を用いて、ビットパターンの出現頻度の計測と、置換テーブル52及び逆置換テーブル12の生成の具体例について説明する。図5に示された計測結果の一例は、8ビット固定長命令を含む元プログラムP1を4ビット単位で分割し、4ビット列が取り得る16通りのパターンの出現頻度を計測して得られる。図5の例では、元プログラムP1において出現頻度の多いビットパターンから順に、不揮発性メモリ10からの読み出し電力が小さいビットパターンと対応付けられている。例えば、出現数が最も多い元のビットパターン"1111"は、読み出し電力が最も小さい書き込みビットパターン"0000"に対応付けられている。また、出現数が2番目に多い元のビットパターン"1101"は、値1を1つだけ含む書き込みビットパターン"0001"に対応付けられている。そして、出現数が最も少ない元のビットパターン"0000"は、読み出し電力が最も大きい書き込みビットパターン"1111"に対応付けられている。Next, a specific example of the measurement of the occurrence frequency of the bit pattern and the generation of the replacement table 52 and the reverse replacement table 12 will be described with reference to FIG. An example of the measurement result shown in FIG. 5 is obtained by dividing the original program P1 including an 8-bit fixed-length instruction in units of 4 bits and measuring the appearance frequencies of 16 patterns that can be taken by a 4-bit string. In the example of FIG. 5, bit patterns with a low read power from thenon-volatile memory 10 are sequentially associated with bit patterns having a high appearance frequency in the original program P1. For example, the original bit pattern “1111” having the highest number of appearances is associated with the write bit pattern “0000” having the lowest read power. The original bit pattern “1101” having the second highest number of appearances is associated with the write bit pattern “0001” including only onevalue 1. The original bit pattern “0000” having the smallest number of appearances is associated with the write bit pattern “1111” having the largest read power.
図5に示す測定結果に基づいて、テーブル生成部51は、置換テーブル52及び逆置換テーブル12を生成する。図5に示された置換テーブル52は、置換すべき元のビット列をアドレスとして与えられることによって、置換後のビット列を出力するルックアップテーブル(LUT)として動作する。同様に、図5に示された逆置換テーブル12は、逆置換すべき置換されたビット列をアドレスとして与えられることによって、逆置換後の元のビット列を出力するLUTとして動作する。Based on the measurement result shown in FIG. 5, thetable generation unit 51 generates the replacement table 52 and the reverse replacement table 12. The replacement table 52 shown in FIG. 5 operates as a look-up table (LUT) that outputs a bit string after replacement when an original bit string to be replaced is given as an address. Similarly, the reverse permutation table 12 shown in FIG. 5 operates as an LUT that outputs the original bit string after reverse permutation, given the permuted bit string to be permuted as an address.
図6は、ライタ5が有する置換部53によるビットパターン置換処理の具体例を示している。例えば、元プログラムP1のアドレス0000H番地に記録されている元の8ビット命令の上位4ビットは"1111"である。この4ビット値 "1111"を16進数のアドレス(FH)として図6に示された置換テーブル52に与えると、FH番地に記録されている4ビット値"0000"が置換後のビット列として得られる。したがって、元プログラムP1の4ビット値"1111"は、"0000"に置換される。同様にして、元プログラムP1のアドレス0000H番地に記録されている元の8ビット命令の下位4ビット"0001"は、置換テーブル52の1H番地に記憶されている"0111"に置換される。これらのビット操作によって、元の8ビット命令"1111_0001"は、"0000_0111"に置換される。FIG. 6 shows a specific example of bit pattern replacement processing by thereplacement unit 53 of thewriter 5. For example, the upper 4 bits of the original 8-bit instruction recorded ataddress 0000H of the original program P1 is “1111”. When this 4-bit value “1111” is given to the replacement table 52 shown in FIG. 6 as a hexadecimal address (FH), the 4-bit value “0000” recorded at the address FH is obtained as a bit string after replacement. . Therefore, the 4-bit value “1111” of the original program P1 is replaced with “0000”. Similarly, the lower 4 bits “0001” of the original 8-bit instruction recorded ataddress 0000H of the original program P1 are replaced with “0111” stored ataddress 1H of the replacement table 52. By these bit operations, the original 8-bit instruction “1111 — 0001” is replaced with “0000 — 0111”.
図7は、コンピュータ1が有する逆置換部11によるビットパターン逆置換処理の具体例を示している。逆置換部11は、不揮発性メモリ10から読み出された置換された8ビット命令を受信し、この命令の上位4ビットをマルチプレクサ111によって逆置換し、下位4ビットをマルチプレクサ112によって逆置換する。これにより、逆置換部11は、元の8ビット命令を復元して命令処理部13に供給する。例えば、図6の置換されたプログラムP2のアドレス0000H番地に記録されている置換された8ビット命令の上位4ビットは"0000"である。この4ビット値 "0000"を16進数のアドレス(0H)として図7に示された逆置換テーブル12(LUT121)に与えると、0H番地に記録されている4ビット値"1111"が元のビット列として得られる。したがって、置換されたプログラムP2の4ビット値"0000"は、"1111"に逆置換される。同様にして、置換されたプログラムP2のアドレス0000H番地に記録されている置換された8ビット命令の下位4ビット"0111"は、逆置換テーブル12(LUT121)の7H番地に記憶されている"0001"に逆置換される。これらのビット操作によって、置換された8ビット命令"0000_0111"は、元の8ビット命令"1111_0001"に復元される。FIG. 7 shows a specific example of bit pattern reverse replacement processing by thereverse replacement unit 11 of thecomputer 1. Thereverse replacement unit 11 receives the replaced 8-bit instruction read from thenonvolatile memory 10, reversely replaces the upper 4 bits of this instruction with themultiplexer 111, and reversely replaces the lower 4 bits with themultiplexer 112. As a result, thereverse replacement unit 11 restores the original 8-bit instruction and supplies it to theinstruction processing unit 13. For example, the upper 4 bits of the replaced 8-bit instruction recorded ataddress 0000H of the replaced program P2 in FIG. 6 is “0000”. When this 4-bit value “0000” is given to the reverse substitution table 12 (LUT 121) shown in FIG. 7 as a hexadecimal address (0H), the 4-bit value “1111” recorded at address 0H is the original bit string. As obtained. Therefore, the 4-bit value “0000” of the replaced program P2 is reversely replaced with “1111”. Similarly, the lower 4 bits “0111” of the replaced 8-bit instruction recorded at theaddress 0000H of the replaced program P2 are stored in the reverse replacement table 12 (LUT 121) at theaddress 7H in “0001”. "Reversely replaced with By these bit operations, the replaced 8-bit instruction “0000 — 0111” is restored to the original 8-bit instruction “1111 — 0001”.
次に、図8A及び8Bを参照して、本実施の形態によって得られる省電力効果について説明する。図4に示した逆置換部11(つまりマルチプレクサ111及び112)及び小容量なSRAMで構成されたLUT121によるビットパターン逆置換動作に要する電力を1と仮定する。さらに、小容量なSRAMよりも一般的に読み出し電力の大きい不揮発性メモリ10からの1ビット値0の読み出し電力を5と仮定し、不揮発性メモリ10からの1ビット値1の読み出し電力を15と仮定する。これらの仮定を適用すると、ある元プログラムP1を不揮発性メモリ10に記録した場合に想定される読み出し電力は図8Aに示すように計算される。そして、置換されたプログラムP2を不揮発性メモリ10に記録した場合に想定される読み出し電力は図8Bに示すように計算される。つまり、本実施の形態を採用せずに、元プログラムP1を不揮発性メモリ10から読み出して実行する場合は、54,880の電力を消費する。これに対して、本実施の形態を採用する場合、逆置換部11及びLUT121の動作電力として命令の総数に相当する1,084の電力を消費するが、不揮発性メモリ10からの読み出し電力が31,840に低減される。このため、本実施の形態を採用し、置換されたプログラムP2を不揮発性メモリ10から読み出して実行する場合は、32,924の消費電力で済む。Next, the power saving effect obtained by the present embodiment will be described with reference to FIGS. 8A and 8B. It is assumed that the power required for the bit pattern reverse replacement operation by theLUT 121 configured by the reverse replacement unit 11 (that is, themultiplexers 111 and 112) and the small capacity SRAM shown in FIG. Further, it is assumed that the read power of 1-bit value 0 from thenon-volatile memory 10 generally having a larger read power than a small-capacity SRAM is 5, and the read power of 1-bit value 1 from thenon-volatile memory 10 is 15. Assume. When these assumptions are applied, the read power assumed when a certain original program P1 is recorded in thenonvolatile memory 10 is calculated as shown in FIG. 8A. Then, the read power assumed when the replaced program P2 is recorded in thenonvolatile memory 10 is calculated as shown in FIG. 8B. That is, when the original program P1 is read from thenonvolatile memory 10 and executed without adopting the present embodiment, the power of 54,880 is consumed. On the other hand, when this embodiment is adopted, the power of 1084 corresponding to the total number of instructions is consumed as the operating power of thereverse replacement unit 11 and theLUT 121, but the power of reading from thenonvolatile memory 10 is 31. , 840. For this reason, when this embodiment is adopted and the replaced program P2 is read from thenonvolatile memory 10 and executed, the power consumption of 32,924 is sufficient.
なお、図4~8を用いて説明した具体例では、8ビット固定長命令の場合について説明したが、本実施の形態が対象とする元プログラムP1に含まれる命令は、他の任意の長さの固定長命令であってもよいし、可変長命令であってもよい。また、本実施の形態の説明では、8ビット命令の上位4ビットと下位4ビットのように単純な区分を用いたが、命令を演算子(オペコード)と非演算子(オペランド)のような役割によって区分してもよい。さらに、これらの区分に応じて別々に出現頻度を計測し、別々の置換テーブル及び逆置換テーブルを用いてもよい。また、命令の一部(例えばオペコード)についてのみビットパターンの置換・逆置換処理の対象とし、他の一部は置換・逆置換処理の対象外としてもよい。これらの変形については、後述する本発明の実施の形態2及び3において説明する。In the specific examples described with reference to FIGS. 4 to 8, the case of an 8-bit fixed-length instruction has been described. However, the instruction included in the original program P1 targeted by the present embodiment has another arbitrary length. May be a fixed length instruction or a variable length instruction. In the description of the present embodiment, simple divisions such as the upper 4 bits and the lower 4 bits of an 8-bit instruction are used. However, the instruction has a role like an operator (opcode) and a non-operator (operand). You may sort by. Furthermore, the appearance frequency may be measured separately according to these sections, and separate replacement tables and reverse replacement tables may be used. Further, only a part of the instruction (for example, the operation code) may be subjected to the bit pattern replacement / reverse replacement process, and the other part may be excluded from the replacement / reverse replacement process. These modifications will be described in the second and third embodiments of the present invention described later.
また、本実施の形態によって得られる消費電力の低減効果は、元プログラムP1に含まれるビット値の偏り具合に依存する。例えば、元プログラムP1に含まれるビット値1とビット0の割合が同じであれば、本実施の形態で述べたビットパターン置換による消費電力の低減効果を得ることは困難である。従って、元プログラムP1中でのビットパターンの出現頻度の偏り具合に基づいて、ビットパターンの逆置換処理を行うことによるコンピュータ1の省電力効果が得られないと判定される場合には、不揮発性メモリ10に置換されたプログラムP2ではなく元プログラムP1を記録し、逆置換部11及び逆置換テーブル12の動作を停止してもよい。具体的には、コンピュータ1に外部から制御可能な制御端子を設け、この制御端子を介して逆置換部11及び逆置換テーブル12の動作を停止できるようにしてもよい。例えば、逆置換部11及び逆置換テーブル12(LUT121として用いるSRAM)への電源供給を遮断する遮断回路と、逆置換部11を迂回する信号経路とセレクタを設け、遮断回路及びセレクタの動作をコンピュータ1の外部から制御できるようにコンピュータ1を構成すればよい。In addition, the power consumption reduction effect obtained by this embodiment depends on the degree of bias of the bit values included in the original program P1. For example, if the ratio between thebit value 1 and the bit 0 included in the original program P1 is the same, it is difficult to obtain the power consumption reduction effect by the bit pattern replacement described in the present embodiment. Therefore, if it is determined that the power saving effect of thecomputer 1 cannot be obtained by performing the reverse replacement processing of the bit pattern based on the deviation of the appearance frequency of the bit pattern in the original program P1, the nonvolatile memory The original program P1 may be recorded instead of the replaced program P2 in thememory 10, and the operations of thereverse replacement unit 11 and the reverse replacement table 12 may be stopped. Specifically, thecomputer 1 may be provided with a control terminal that can be controlled from the outside, and the operations of thereverse replacement unit 11 and the reverse replacement table 12 may be stopped via this control terminal. For example, a blocking circuit that cuts off power supply to thereverse replacement unit 11 and the reverse replacement table 12 (SRAM used as the LUT 121), a signal path that bypasses thereverse replacement unit 11, and a selector are provided, and the operation of the blocking circuit and the selector is controlled by a computer. What is necessary is just to comprise thecomputer 1 so that control from the exterior of 1 is possible.
また、既に述べた通り、本実施の形態に係るライタ5が有する計測部50、テーブル生成部51、及び置換部53の機能は、PC等のコンピュータシステムに1又は複数のプログラムを実行させることによって実現してもよい。具体的には、元プログラムP1におけるビットパターン出現頻度の計測するための第1の命令群と、置換前後のビットパターンの対応関係を生成するための第2の命令群と、ビットパターン置換処理を行うための第3の命令群とをプロセッサがアクセス可能なメモリに記憶しておけばよい。これら第1~第3の命令群は、1のプログラムとして提供されてもよいし、複数のプログラムに分割されて提供されてもよい。コンピュータシステムは、第1~第3の命令群を実行することによって、計測部50、テーブル生成部51、及び置換部53として動作する。As described above, the functions of themeasurement unit 50, thetable generation unit 51, and thereplacement unit 53 included in thewriter 5 according to the present embodiment are performed by causing a computer system such as a PC to execute one or a plurality of programs. It may be realized. Specifically, the first instruction group for measuring the bit pattern appearance frequency in the original program P1, the second instruction group for generating the correspondence relationship between the bit patterns before and after the replacement, and the bit pattern replacement process The third instruction group to be executed may be stored in a memory accessible by the processor. These first to third instruction groups may be provided as one program, or may be provided by being divided into a plurality of programs. The computer system operates as themeasurement unit 50, thetable generation unit 51, and thereplacement unit 53 by executing the first to third instruction groups.
これらのプログラムは、様々なタイプの非一時的なコンピュータ可読媒体(non-transitory computer readable medium)を用いて格納され、コンピュータに供給することができる。非一時的なコンピュータ可読媒体は、様々なタイプの実体のある記録媒体(tangible storage medium)を含む。非一時的なコンピュータ可読媒体の例は、磁気記録媒体(例えばフレキシブルディスク、磁気テープ、ハードディスクドライブ)、光磁気記録媒体(例えば光磁気ディスク)、CD-ROM(Read Only Memory)、CD-R、CD-R/W、半導体メモリ(例えば、マスクROM、PROM(Programmable ROM)、EPROM(Erasable PROM)、フラッシュROM、RAM(random access memory))を含む。また、プログラムは、様々なタイプの一時的なコンピュータ可読媒体(transitory computer readable medium)によってコンピュータに供給されてもよい。一時的なコンピュータ可読媒体の例は、電気信号、光信号、及び電磁波を含む。一時的なコンピュータ可読媒体は、電線及び光ファイバ等の有線通信路、又は無線通信路を介して、プログラムをコンピュータに供給できる。These programs can be stored using various types of non-transitory computer readable media and supplied to a computer. Non-transitory computer readable media include various types of tangible storage media (tangible storage medium). Examples of non-transitory computer-readable media include magnetic recording media (eg flexible disks, magnetic tapes, hard disk drives), magneto-optical recording media (eg magneto-optical discs), CD-ROMs (Read Only Memory), CD-Rs, CD-R / W, semiconductor memory (for example, mask ROM, PROM (Programmable ROM), EPROM (Erasable ROM), flash ROM, RAM (random access memory)) are included. The program may also be supplied to the computer by various types of temporary computer-readable media. Examples of transitory computer readable media include electrical signals, optical signals, and electromagnetic waves. The temporary computer-readable medium can supply the program to the computer via a wired communication path such as an electric wire and an optical fiber, or a wireless communication path.
<発明の実施の形態2>
上述した発明の実施の形態1では、元プログラムP1の全体を対象としてビットパターン毎の出現頻度を計測し、プログラムP1の全体に対して1つのビットパターン対応関係(1組の置換テーブル及び逆置換テーブル)を生成する例を示した。本実施の形態では、元プログラムP1を複数の領域に区分し、ビットパターン毎の出現頻度を各領域について別々に計測し、各領域に対して個別にビットパターン対応関係を生成する例について説明する。<Embodiment 2 of the Invention>
In the first embodiment of the present invention described above, the appearance frequency for each bit pattern is measured for the entire original program P1, and one bit pattern correspondence relationship (one set of replacement table and reverse replacement is used for the entire program P1. Table) was generated. In the present embodiment, an example will be described in which the original program P1 is divided into a plurality of regions, the appearance frequency for each bit pattern is measured separately for each region, and the bit pattern correspondence relationship is individually generated for each region. .
本実施の形態に係るコンピュータ2及びライタ6の構成例を図9に示す。ライタ6が有する計測部60は、元プログラムP1を2つの領域に分割し、2つの領域について別々にビットパターンの出現頻度を計測する。例えば、元プログラムP1が(m+n)ビット命令を含む場合、上位のmビットを第1の領域とし、下位のnビットを第2の領域としてもよい。この場合、計測部60は、第1の領域(上位mビット)におけるビットパターンの出現頻度と、第2の領域(下位nビット)におけるビットパターン出現頻度を別々に計測する。また、命令中のオペコードを第1の領域とし、オペランドを第2の領域としてもよい。FIG. 9 shows a configuration example of thecomputer 2 and thewriter 6 according to the present embodiment. The measuringunit 60 included in thewriter 6 divides the original program P1 into two regions and measures the appearance frequency of bit patterns separately for the two regions. For example, when the original program P1 includes an (m + n) bit instruction, the upper m bits may be the first area and the lower n bits may be the second area. In this case, themeasurement unit 60 separately measures the appearance frequency of the bit pattern in the first area (upper m bits) and the appearance frequency of the bit pattern in the second area (lower n bits). Also, the opcode in the instruction may be the first area and the operand may be the second area.
テーブル生成部61は、2つの領域に関するビットパターンの出現頻度の計測結果に基づいて、2つのビットパターン対応関係(2組の置換テーブル及び逆置換テーブル)を生成する。テーブル生成部61による対応関係の決定手法は、上述した実施の形態1のテーブル生成部51と同様とすればよい。Thetable generation unit 61 generates two bit pattern correspondences (two sets of replacement tables and reverse replacement tables) based on the measurement result of the appearance frequency of bit patterns related to the two areas. The correspondence determination method by thetable generation unit 61 may be the same as thetable generation unit 51 of the first embodiment described above.
置換部63は、テーブル生成部61によって生成された2つの置換テーブル621及び622を適用して、ビットパターン置換されたプログラムP2を生成する。Thereplacement unit 63 applies the two replacement tables 621 and 622 generated by thetable generation unit 61 to generate the program P2 with the bit pattern replaced.
図9に示されたコンピュータ2は、SRAMを用いた2つのLUT121及び122を有する。LUT121及び122は、テーブル生成部61によって生成された2つの逆置換テーブルを保持する。図9の例では、LUT121は、8ビット命令の上位4ビットに対する逆置換テーブルを保持する。また、LUT122は、8ビット固定長命令の下位4ビットに対する逆置換テーブルを保持する。Thecomputer 2 shown in FIG. 9 has twoLUTs 121 and 122 using SRAM. TheLUTs 121 and 122 hold the two reverse replacement tables generated by thetable generation unit 61. In the example of FIG. 9, theLUT 121 holds a reverse replacement table for the upper 4 bits of an 8-bit instruction. TheLUT 122 holds an inverse replacement table for the lower 4 bits of the 8-bit fixed length instruction.
逆置換部11に配置されたマルチプレクサ111は、LUT121と結合され、不揮発性メモリ10から読み出された置換されたプログラムP2に含まれる8ビット命令の上位4ビットに対する逆置換を行う。また、マルチプレクサ112は、LUT122と結合され、置換されたプログラムP2に含まれる8ビット命令の下位4ビットに対する逆置換を行う。これにより、元プログラムP1の8ビット命令が復元される。Themultiplexer 111 arranged in thereverse replacement unit 11 is coupled to theLUT 121 and performs reverse replacement on the upper 4 bits of the 8-bit instruction included in the replaced program P2 read from thenonvolatile memory 10. Themultiplexer 112 is coupled to theLUT 122 and performs reverse replacement on the lower 4 bits of the 8-bit instruction included in the replaced program P2. As a result, the 8-bit instruction of the original program P1 is restored.
元プログラムP1に含まれる複数の領域(例えば8ビット命令の上位4ビットと下位4ビット)の間でビットパターンの出現頻度の偏り方に大きな違いが存在する場合が考えられる。本実施の形態は、このような場合に特に有効である。すなわち、本実施の形態は、元プログラムに含まれる各領域に対して適切なビットパターン置換を行うことができるため、不揮発性メモリ10からのプログラムP2の読み出しに要する電力をより一層低減できる。There may be a case where there is a great difference in the bias of appearance frequency of bit patterns between a plurality of areas (for example, upper 4 bits and lower 4 bits of an 8-bit instruction) included in the original program P1. The present embodiment is particularly effective in such a case. That is, according to the present embodiment, appropriate bit pattern replacement can be performed for each area included in the original program, so that the power required for reading the program P2 from thenonvolatile memory 10 can be further reduced.
<発明の実施の形態3>
本実施の形態では、元プログラムP1を複数の領域に区分し、このうち一部の領域に対してビットパターン置換処理を行い、他の領域に対してビットパターン置換処理を行わない例を説明する。<Third Embodiment of the Invention>
In the present embodiment, an example will be described in which the original program P1 is divided into a plurality of areas, a bit pattern replacement process is performed for some of these areas, and a bit pattern replacement process is not performed for other areas. .
本実施の形態に係るコンピュータ3及びライタ7の構成例を図10に示す。図10の例では、元プログラムP1及び置換されたプログラムP2に含まれる8ビット命令の上位4ビットがビットパターン置換・逆置換の対象とされる。これに対して、8ビット命令の下位4ビットに対しては、ビットパターン置換・逆置換が行われない。FIG. 10 shows a configuration example of thecomputer 3 and thewriter 7 according to the present embodiment. In the example of FIG. 10, the upper 4 bits of the 8-bit instruction included in the original program P1 and the replaced program P2 are subjected to bit pattern replacement / reverse replacement. On the other hand, bit pattern replacement / reverse replacement is not performed for the lower 4 bits of the 8-bit instruction.
計測部70は、発明の実施の形態2で述べた計測部60と同様に、元プログラムP1を2つの領域に分割し、2つの領域について別々にビットパターンの出現頻度を計測する。ここでは、元プログラムP1に含まれる8ビット命令の上位4ビットを第1の領域とし、下位4ビットを第2の領域とする場合を考える。Themeasurement unit 70 divides the original program P1 into two regions, and measures the appearance frequency of bit patterns separately for the two regions, as in themeasurement unit 60 described in the second embodiment of the invention. Here, a case is considered where the upper 4 bits of the 8-bit instruction included in the original program P1 are set as the first area and the lower 4 bits are set as the second area.
ここで、ビットパターンの出現頻度の計測を行った結果、第1の領域(上位4ビット)におけるビットパターンの出現頻度は図5の具体例に示したようなビットパターンによる顕著な偏りがあるが、第2の領域(下位4ビット)におけるビットパターンの出現頻度は各ビットパターンの出現数がほぼ同数であったと仮定する。この場合、第2の領域(下位4ビット)についてはビットパターンの置換・逆置換を行うことによる不揮発性メモリ10の読み出し電力の低減効果を得ることができない。このため、テーブル生成部71は、第1の領域(上位4ビット)に対してのみ置換テーブル及び逆置換テーブルを生成する。置換部73は、置換テーブル72を適用して第1の領域(上位4ビット)に対してのみビットパターン置換を行うとともに、第2の領域(下位4ビット)に対しては元プログラムP1のビット列をそのまま用いて、置換されたプログラムP2を生成する。Here, as a result of measuring the appearance frequency of the bit pattern, the appearance frequency of the bit pattern in the first region (upper 4 bits) is significantly biased by the bit pattern as shown in the specific example of FIG. Assume that the appearance frequency of the bit patterns in the second area (lower 4 bits) is almost the same as the appearance number of each bit pattern. In this case, for the second region (lower 4 bits), it is not possible to obtain an effect of reducing the read power of thenonvolatile memory 10 by performing bit pattern substitution / reverse substitution. For this reason, thetable generation unit 71 generates a replacement table and a reverse replacement table only for the first area (upper 4 bits). Thereplacement unit 73 applies the replacement table 72 to perform bit pattern replacement only for the first area (upper 4 bits), and for the second area (lower 4 bits), the bit string of the original program P1 Is used as it is to generate the replaced program P2.
図10に示されたコンピュータ3は、SRAMを用いた1つのLUT121を有する。UT121は、テーブル生成部61によって生成された第1の領域(上位4ビット)に対する逆置換テーブルを保持する。逆置換部31に配置されたマルチプレクサ111は、LUT121と結合され、不揮発性メモリ10から読み出された置換されたプログラムP2に含まれる8ビット命令の上位4ビットに対する逆置換を行う。一方、プログラムP2に含まれる8ビット命令の下位4ビットは、逆置換部31においてビットパターン逆置換処理を施されることなくそのまま命令処理部13に供給される。これにより、元プログラムP1の8ビット命令が復元される。Thecomputer 3 shown in FIG. 10 has oneLUT 121 using SRAM. TheUT 121 holds a reverse replacement table for the first area (upper 4 bits) generated by thetable generation unit 61. Themultiplexer 111 disposed in thereverse replacement unit 31 is coupled to theLUT 121 and performs reverse replacement on the upper 4 bits of the 8-bit instruction included in the replaced program P2 read from thenonvolatile memory 10. On the other hand, the lower 4 bits of the 8-bit instruction included in the program P2 are directly supplied to theinstruction processing unit 13 without being subjected to the bit pattern reverse replacement processing in thereverse replacement unit 31. As a result, the 8-bit instruction of the original program P1 is restored.
上述したように、元プログラムP1に含まれる複数の領域(例えば8ビット命令の上位4ビットと下位4ビット)の間でビットパターンの出現頻度の偏り方に大きな違いが存在する場合が考えられる。本実施の形態は、一部の領域に関してビットパターンの出現頻度の偏りが小さいためにビットパターン置換・逆置換による消費電力の低減効果が得られない場合に、この一部の領域をビットパターン置換・逆置換を除外できる。これにより、逆置換部31の消費電力を抑制でき、コンピュータ3の消費電力をより一層低減することができる。As described above, there may be a case where there is a great difference in the bias of appearance frequency of bit patterns between a plurality of areas (for example, upper 4 bits and lower 4 bits of an 8-bit instruction) included in the original program P1. In this embodiment, since the bias in the appearance frequency of the bit pattern is small with respect to a part of the area, the effect of reducing the power consumption by the bit pattern replacement / reverse replacement cannot be obtained. -Reverse substitution can be excluded. Thereby, the power consumption of thereverse substitution part 31 can be suppressed and the power consumption of thecomputer 3 can be reduced further.
なお、図10に示したコンピュータ3は、図4に示したコンピュータ1からマルチプレクサ112を取り除いた構成、又は図9に示したコンピュータ2からマルチプレクサ112及びLUT122を取り除いた構成となっている。しかしながら、コンピュータ3は、プログラムP2の一部の領域に対するビットパターン逆置換を選択的に停止できる構成を有してもよい。具体的には、コンピュータ3に外部から制御可能な制御端子を設け、この制御端子を介して逆置換部31に含まれる少なくとも一部のマルチプレクサ、及び少なくとも一部の逆置換テーブルの動作を停止できるようにしてもよい。例えば、少なくとも一部のマルチプレクサ及びLUT(SRAM)への電源供給を遮断する遮断回路と、少なくとも一部のマルチプレクサを迂回する信号経路とセレクタを設け、遮断回路及びセレクタの動作をコンピュータ3の外部から制御できるようにすればよい。Thecomputer 3 shown in FIG. 10 has a configuration in which themultiplexer 112 is removed from thecomputer 1 shown in FIG. 4, or a configuration in which themultiplexer 112 and theLUT 122 are removed from thecomputer 2 shown in FIG. However, thecomputer 3 may have a configuration that can selectively stop bit pattern reverse replacement for a partial region of the program P2. Specifically, thecomputer 3 is provided with a control terminal that can be controlled from the outside, and the operation of at least some of the multiplexers and at least some of the reverse substitution tables included in thereverse substitution unit 31 can be stopped via this control terminal. You may do it. For example, a cutoff circuit that cuts off power supply to at least some of the multiplexers and the LUT (SRAM), a signal path that bypasses at least some of the multiplexers, and a selector are provided. What is necessary is just to be able to control.
<その他の実施の形態>
上述した発明の実施の形態1~3では、元プログラムP1が圧縮されていないプログラムであるとして説明した。このような元プログラムP1は、プログラマにより直接生成されるか、プログラマが生成したソースプログラムをコンパイラで変換することによって生成される。元プログラムP1は、CD-ROM又はUSBメモリ等の外部記憶媒体を介してライタ5(6又は7)に入力されてもよいし、通信ネットワークを介してライタ5(6又は7)に入力されてもよい。また、ライタ5(6又は7)としてPCを用いる場合、このPC上でコンパイラを実行することによって、ソースプログラムから元プログラムP1を生成してもよい。<Other embodiments>
In the first to third embodiments of the present invention described above, the original program P1 has been described as an uncompressed program. Such an original program P1 is generated directly by a programmer or by converting a source program generated by the programmer with a compiler. The original program P1 may be input to the writer 5 (6 or 7) via an external storage medium such as a CD-ROM or USB memory, or may be input to the writer 5 (6 or 7) via a communication network. Also good. When a PC is used as the writer 5 (6 or 7), the original program P1 may be generated from the source program by executing a compiler on the PC.
しかしながら、元プログラムP1は、圧縮されたプログラムであってもよい。この場合、ライタ5(6又は7)は、圧縮されたプログラムP1に対するビットパターン置換を行ってプログラムP2を生成すればよい。また、コンピュータ1(2又は3)には、圧縮プログラムから元プログラムを復元するための伸張回路を設ければよい。伸張回路は、逆置換部11(31)によって逆置換を施された後の1又は複数のビット列(第1のビット列)を単位として伸張処理を実行し、元の命令を復元する。復元された命令は、命令処理部13に供給される。圧縮プログラムに対してビットパターン置換を行って得られるプログラムP2を不揮発性メモリ10に格納することによって、圧縮プログラム自体を不揮発性メモリ10に格納する場合に比べて、不揮発性メモリ10からのプログラム読み出しに要する消費電力の低減が期待できる。つまり、上述した本発明の実施の形態1~3は、特許文献1~3に記載されているようなプログラム圧縮の手法と組み合わせることができる。However, the original program P1 may be a compressed program. In this case, the writer 5 (6 or 7) may generate the program P2 by performing bit pattern replacement on the compressed program P1. The computer 1 (2 or 3) may be provided with a decompression circuit for restoring the original program from the compressed program. The decompression circuit performs decompression processing in units of one or a plurality of bit strings (first bit strings) after being subjected to reverse substitution by the reverse substitution unit 11 (31), and restores the original instruction. The restored instruction is supplied to theinstruction processing unit 13. By storing the program P2 obtained by performing bit pattern replacement on the compressed program in thenonvolatile memory 10, the program is read from thenonvolatile memory 10 as compared with the case where the compressed program itself is stored in thenonvolatile memory 10. Reduction of power consumption required for this can be expected. That is,Embodiments 1 to 3 of the present invention described above can be combined with a program compression method as described inPatent Documents 1 to 3.
発明の実施の形態2及び3では、元プログラムP1を2つの領域に分ける場合について説明した。しかしながら、元プログラムP1を3つ以上の領域に分割し、置換テーブル及び逆置換テーブルの組合せを3組以上生成してもよい。Embodiments 2 and 3 of the invention have described the case where the original program P1 is divided into two areas. However, the original program P1 may be divided into three or more areas, and three or more combinations of replacement tables and reverse replacement tables may be generated.
発明の実施の形態1~3では、不揮発性メモリ10にプログラムを格納する場合、言い換えると不揮発性メモリ10をマイクロコントローラ等のコンピュータと結合されるプログラムメモリとして使用する場合について説明した。コンピュータ装置の動作中はプログラム(又は圧縮プログラム)の書き換えは行われない。また、命令の使用頻度の偏りに起因して、プログラムにはビットパターンの出現頻度に偏り(一様からのずれ)が生じやすいことが想定される。したがって、不揮発性メモリ10をプログラムメモリとして利用する場合は、ビットパターンの置換・逆置換処理を行うことによって消費電力を大きく低減することが期待できる。しかしながら、発明の実施の形態1~3で述べたビットパターンの置換・逆置換処理は、不揮発性メモリ10を他の用途で利用するシステムに適用してもよい。In the first to third embodiments of the present invention, the case where a program is stored in thenonvolatile memory 10, in other words, the case where thenonvolatile memory 10 is used as a program memory coupled to a computer such as a microcontroller has been described. During the operation of the computer device, the program (or the compressed program) is not rewritten. In addition, it is assumed that due to the uneven usage frequency of instructions, the program tends to be biased (deviation from uniform) in the appearance frequency of bit patterns. Therefore, when thenonvolatile memory 10 is used as a program memory, it can be expected that the power consumption is greatly reduced by performing bit pattern replacement / reverse replacement processing. However, the bit pattern replacement / inverse replacement processing described in the first to third embodiments of the invention may be applied to a system that uses thenonvolatile memory 10 for other purposes.
さらに、本発明は上述した実施の形態のみに限定されるものではなく、既に述べた本発明の要旨を逸脱しない範囲において種々の変更が可能であることは勿論である。Furthermore, the present invention is not limited to the above-described embodiments, and various modifications can be made without departing from the gist of the present invention already described.
この出願は、2011年3月8日に出願された日本出願特願2011-050113を基礎とする優先権を主張し、その開示の全てをここに取り込む。This application claims priority based on Japanese Patent Application No. 2011-050113 filed on March 8, 2011, the entire disclosure of which is incorporated herein.