JP2010198183A - Program execution device - Google Patents

Program execution device Download PDF

Info

Publication number
JP2010198183A
JP2010198183A JP2009040718A JP2009040718A JP2010198183A JP 2010198183 A JP2010198183 A JP 2010198183A JP 2009040718 A JP2009040718 A JP 2009040718A JP 2009040718 A JP2009040718 A JP 2009040718A JP 2010198183 A JP2010198183 A JP 2010198183A
Authority
JP
Japan
Prior art keywords
instruction
error
program
error detection
execution
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
JP2009040718A
Other languages
Japanese (ja)
Inventor
Teruaki Tanaka
輝明 田中
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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric Corp
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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP2009040718A priority Critical patent/JP2010198183A/en
Publication of JP2010198183A publication Critical patent/JP2010198183A/en
Pending legal-status Critical Current

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a program execution device for continuing the whole operation even when any error is occurred during execution of a program. <P>SOLUTION: In the program execution device, an error detection corresponding call instruction/return instruction execution function part 5 executes an ECALL instruction corresponding to a function call invalidating function due to error occurrence, and an error detection instruction execution function part 6 detects an error during program execution by the ECALL instruction according to an error detection instruction. When the error is detected by the error detection instruction execution function part 6, the error detection corresponding call instruction/return instruction execution function part 5 invalidates the ECALL instruction. <P>COPYRIGHT: (C)2010,JPO&INPIT

Description

本発明は、分岐命令によるプログラムの実行中にエラーを検出した場合に、プログラム動作全体を停止することなく、エラーを検出した分岐命令部分のプログラム実行を停止することにより、プログラム動作自体は継続する機能を有するプログラム実行装置に関する。   According to the present invention, when an error is detected during execution of a program by a branch instruction, the program operation itself is continued by stopping the program execution of the branch instruction portion in which the error is detected without stopping the entire program operation. The present invention relates to a program execution device having a function.

従来、プログラムを実行するシステムにおいて、システムの動作中に異常が発生した場合に、システムを停止するモードと、異常が発生した装置をシステムから切り離して動作を継続するモードのいずれを選択すべきかを決定する装置があった。
例えば、特許文献1に記載された装置では、エラー検出機構により、システム動作中に装置の異常を検出した場合、誤動作を防止するためにシステムを緊急停止するシステムダウンモードと、異常が発生した装置(部品)をシステムから切り離して動作を継続する動的縮退モードのいずれを選択すべきかを決定するよう構成されていた。
ここでいう動的縮退モードでは、切り離される装置を制御するドライバ等の装置制御部が、装置を切り離された場合の動作をサポートしており、かつ、その装置を切り離してもシステムの運用を継続できるようになっている。
Conventionally, in a system that executes a program, when an abnormality occurs during system operation, it should be selected between a mode in which the system is stopped and a mode in which the apparatus in which the abnormality has occurred is disconnected from the system and the operation is continued. There was a device to decide.
For example, in the apparatus described in Patent Document 1, when an error of the apparatus is detected during system operation by the error detection mechanism, a system down mode in which the system is urgently stopped to prevent malfunction, and an apparatus in which an abnormality has occurred The system is configured to determine which of the dynamic degeneration modes in which the (part) is disconnected from the system and continues to operate is selected.
In this dynamic degeneration mode, the device control unit such as a driver that controls the device to be disconnected supports the operation when the device is disconnected, and the system continues to operate even if the device is disconnected. It can be done.

特開2001−175489号公報Japanese Patent Application Laid-Open No. 2001-175489

例えば、モータ制御を行うような処理をプロセッサもしくはコントローラ上にソフトウェアで実装する場合、基本的な制御処理となる演算処理内容は、PID(比例・積分・微分)制御方法といった定型的な処理であり、その定型処理が生成もしくは使用する制御量もしくは目的値に対し、補正量を加算もしくは減算する形で実現することが多い。
そのようなコントローラ製品におけるソフトウェア処理内容の更新を行う場合、基本的な制御処理内容の正当性はその時点で既に製品として使用されているソフトウェアで既に検証されている事が多く、また、製品におけるソフトウェアで実現している機能の不具合も、基本的な制御処理内容に対し、ソフトウェアとして追加した差分機能の部分で発生することが多い。
For example, when processing such as motor control is implemented by software on a processor or controller, the contents of arithmetic processing as basic control processing are routine processing such as a PID (proportional / integral / derivative) control method. In many cases, the fixed amount processing is realized by adding or subtracting a correction amount to a control amount or target value generated or used.
When updating the software processing content in such a controller product, the validity of the basic control processing content is often already verified by the software that is already used as the product at that time. A malfunction of a function realized by software often occurs in a difference function part added as software with respect to basic control processing contents.

追加実装した差分機能は製品出荷前に検証作業は実施しているが、製品の実使用環境下で発生する想定外の状況により、処理の実行が継続困難な致命的なエラーを発生させることがある。例えば、処理の継続実行が困難な致命的なエラーとしては、
・差分機能により計算された補正量は正の値となるはずなのに負の値となっている
・差分機能により計算された補正量が、ある値の範囲内に入っているはずなのに範囲をオーバーする
等が存在する。
Although the added differential function has been verified before shipping the product, a fatal error that makes it difficult to continue processing may occur due to an unexpected situation that occurs in the actual use environment of the product. is there. For example, as a fatal error that makes it difficult to continue processing,
・ The correction amount calculated by the difference function is a negative value although it should be a positive value. ・ The correction amount calculated by the difference function should be within the range of a certain value, but the range is exceeded. Etc. exist.

そのようなエラーが発生した場合、適切な制御量が計算出来ないため、コントローラの継続実行が困難となり、コントローラの動作そのものを停止しなければならず、当該コントローラ製品を使用しているユーザの作業を止めてしまうという問題点があった。
また、そのような不具合が発生しないようコントローラ開発時、十分に検証を行おうとしても、検証すべき状態の組合せが多いため、出荷前に全ての不具合を検出および対応することが作業工数として困難であるという問題点があった。
When such an error occurs, it is difficult to calculate an appropriate control amount, which makes it difficult to continue execution of the controller, and the operation of the controller itself must be stopped. There was a problem of stopping.
Also, even when trying to fully verify when developing a controller so that such defects do not occur, it is difficult to detect and respond to all defects before shipping because there are many combinations of states to be verified. There was a problem that.

この発明は上記のような課題を解決するためになされたもので、プログラムの実行中にエラーが発生しても、全体の動作を継続することのできるプログラム実行装置を得ることを目的とする。   The present invention has been made to solve the above problems, and an object of the present invention is to provide a program execution device capable of continuing the entire operation even if an error occurs during the execution of the program.

この発明に係るプログラム実行装置は、分岐命令によるプログラム実行中のエラーを検出するエラー検出部と、エラー検出部でエラーを検出した場合に、分岐命令を無効とする命令実行部とを備えたものである。
なお、ここで、“分岐命令によるプログラム実行中”とは、分岐命令を発行後、分岐先の命令をフェッチ・実行している状態を示している。
A program execution device according to the present invention includes an error detection unit that detects an error during program execution by a branch instruction, and an instruction execution unit that invalidates the branch instruction when an error is detected by the error detection unit It is.
Here, “program execution by branch instruction” indicates a state in which a branch destination instruction is fetched and executed after a branch instruction is issued.

この発明のプログラム実行装置は、分岐命令によるプログラム実行中にエラーを検出した場合は、その分岐命令を無効としたので、プログラム全体の動作を停止させることなく、プログラム実行を継続することができる。   When an error is detected during program execution by a branch instruction, the program execution apparatus according to the present invention invalidates the branch instruction, so that the program execution can be continued without stopping the operation of the entire program.

この発明の実施の形態1によるプログラム実行装置を示す構成図である。It is a block diagram which shows the program execution apparatus by Embodiment 1 of this invention. この発明の実施の形態1によるプログラム実行装置におけるプログラム実行動作を示す説明図である。It is explanatory drawing which shows the program execution operation | movement in the program execution apparatus by Embodiment 1 of this invention. この発明の実施の形態1によるプログラム実行装置における処理パターンを示す説明図である。It is explanatory drawing which shows the process pattern in the program execution apparatus by Embodiment 1 of this invention.

実施の形態1.
図1は、この発明の実施の形態1によるプログラム実行装置を示す構成図である。
図1に示すプログラム実行装置1は、命令実行機能部2、命令フェッチ機能部3、NOP命令切替機能部4を備えている。命令実行機能部2は、エラー検出対応コール命令・リターン命令実行機能部(命令実行部)5とエラー検出命令実行機能部(エラー検出部)6を有している。エラー検出対応コール命令・リターン命令実行機能部5は、予め定められたエラー発生無効化分岐命令を実行中、エラー検出命令実行機能部6において分岐命令実行中にエラーを検出すると、実行中の分岐命令を無効化する機能を有するものである。また、エラー検出命令実行機能部6は、エラー発生無効化分岐命令によるプログラム実行中にエラーが発生したか否かを検出する機能部である。
Embodiment 1 FIG.
FIG. 1 is a block diagram showing a program execution device according to Embodiment 1 of the present invention.
A program execution device 1 shown in FIG. 1 includes an instruction execution function unit 2, an instruction fetch function unit 3, and a NOP instruction switching function unit 4. The instruction execution function section 2 includes an error detection corresponding call instruction / return instruction execution function section (instruction execution section) 5 and an error detection instruction execution function section (error detection section) 6. When the error detection corresponding call instruction / return instruction execution function unit 5 is executing a predetermined error generation invalidation branch instruction and the error detection instruction execution function unit 6 detects an error during execution of the branch instruction, the branch being executed is executed. It has a function of invalidating an instruction. The error detection instruction execution function unit 6 is a function unit that detects whether an error has occurred during program execution by an error generation invalidation branch instruction.

エラー検出対応コール命令・リターン命令実行機能部5は、エラー検出対応リターン処理実行機能部7、エラーフラグ設定機能部8、戻りアドレス設定機能部9、エラー検出対応コール命令無効化機能部10を備えている。また、エラーフラグ設定機能部8は、ERRSTレジスタ(エラー発生状態保持部)81とECALLFLGレジスタ82を有している。更に、戻りアドレス設定機能部9はERETADRレジスタ91を、エラー検出対応コール命令無効化機能部10はEADRレジスタ(アドレス保持部)101を有している。   The error detection support call instruction / return instruction execution function section 5 includes an error detection support return process execution function section 7, an error flag setting function section 8, a return address setting function section 9, and an error detection support call instruction invalidation function section 10. ing. The error flag setting function unit 8 includes an ERRST register (error occurrence state holding unit) 81 and an ECALLFLG register 82. Further, the return address setting function unit 9 has an ERETADR register 91, and the error detection corresponding call instruction invalidation function unit 10 has an EADR register (address holding unit) 101.

エラー検出命令実行機能部6は、エラー状態識別機能部11とエラー発生コール命令アドレス識別機能部12を有し、エラー状態識別機能部11はERRSIGレジスタ111を有している。また、命令フェッチ機能部3は、プログラムカウンタ31を有している。   The error detection instruction execution function unit 6 includes an error state identification function unit 11 and an error occurrence call instruction address identification function unit 12, and the error state identification function unit 11 includes an ERRSIG register 111. The instruction fetch function unit 3 has a program counter 31.

エラー検出対応リターン処理実行機能部7は、通常のリターン処理を行うと共に、エラーが検出された場合(エラーフラグ設定機能部8のECALLFLGレジスタ82が1で、かつ、ERRSTレジスタ81が1であった場合)は戻りアドレス設定機能部9のERETADRレジスタ91のアドレスに基づいてリターン処理を行う機能部である。エラーフラグ設定機能部8は、エラー発生無効化分岐命令を実行する場合にECALLFLGレジスタ82のフラグを1にセットし、また、エラー検出命令実行機能部6のエラー状態識別機能部11からエラー検出が通知された場合はERRSTレジスタ81のフラグを1にセットするよう構成されている。戻りアドレス設定機能部9は、ERETADRレジスタ91にリターンアドレス(関数コールから戻る際の復帰先プログラムアドレス)を設定する機能部である。エラー検出対応コール命令無効化機能部10は、エラー発生コール命令アドレス識別機能部12から、エラー発生コール命令アドレスが通知された場合は、このアドレスをEADRレジスタ101に設定すると共に、エラー発生無効化分岐命令実行時に、ERRSTレジスタ81の値が1であれば、EADRレジスタ101上の値と現在のプログラムアドレスを比較し、もし同じであればエラー発生無効化分岐命令を無効とし、分岐処理は行わない旨の通知を行うよう構成されている。   The error detection corresponding return process execution function unit 7 performs normal return processing, and if an error is detected (the ECALLFLG register 82 of the error flag setting function unit 8 is 1 and the ERRST register 81 is 1) ) Is a functional unit that performs return processing based on the address of the ERETADR register 91 of the return address setting function unit 9. The error flag setting function unit 8 sets the flag of the ECALLFLG register 82 to 1 when executing an error generation invalidation branch instruction, and error detection is performed from the error state identification function unit 11 of the error detection instruction execution function unit 6. When notified, the flag of the ERRRST register 81 is set to 1. The return address setting function unit 9 is a function unit that sets a return address (return destination program address when returning from a function call) in the ERETADR register 91. When an error occurrence call instruction address is notified from the error occurrence call instruction address identification function section 12, the error detection corresponding call instruction invalidation function section 10 sets this address in the EADR register 101 and invalidates the error occurrence. When the branch instruction is executed, if the value in the ERRST register 81 is 1, the value in the EADR register 101 is compared with the current program address, and if they are the same, the error generation invalidation branch instruction is invalidated and the branch process is performed. It is configured to notify that there is no.

エラー検出命令実行機能部6におけるエラー状態識別機能部11は、エラー検出命令実行時にエラーを検出する機能を有するもので、エラーを検出した場合は、ERRSIGレジスタ111に1をセットするよう構成されている。尚、エラー検出命令については後述する。エラー発生コール命令アドレス識別機能部12は、エラー状態識別機能部11がエラーを検出した場合は戻りアドレス設定機能部9のERETADRレジスタ91の値に基づいて、エラー発生時における関数コールを発行したプログラムアドレスを演算し、このアドレスをエラー検出対応コール命令無効化機能部10に通知するよう構成されている。   The error state identification function unit 11 in the error detection command execution function unit 6 has a function of detecting an error when executing an error detection command. When an error is detected, the error state identification function unit 11 is configured to set 1 in the ERRRSIG register 111. Yes. The error detection command will be described later. The error occurrence call instruction address identification function unit 12 is a program that has issued a function call when an error occurs based on the value of the ERETADR register 91 of the return address setting function unit 9 when the error state identification function unit 11 detects an error. An address is calculated, and this address is notified to the error detection handling call instruction invalidation function unit 10.

また、命令フェッチ機能部3は、プログラムカウンタ31の値に基づき、命令メモリ13から命令をフェッチする機能部である。NOP命令切替機能部4は、エラー検出対応コール命令無効化機能部10から、エラー発生無効化分岐命令を無効とする通知があった場合は、その分岐命令を無効化し、NOP命令(No Operation命令)とする機能部である。また、命令メモリ13は、プログラム実行装置1が実行するプログラムを格納するメモリである。   The instruction fetch function unit 3 is a function unit that fetches an instruction from the instruction memory 13 based on the value of the program counter 31. The NOP instruction switching function unit 4 invalidates the error instruction invalidation branch instruction from the error detection corresponding call instruction invalidation function unit 10 and invalidates the branch instruction, and the NOP instruction (No Operation instruction) ). The instruction memory 13 is a memory that stores a program executed by the program execution device 1.

プログラム実行装置1は、通常の、例えば一般的にプロセッサやコントローラと称されるプログラム実行装置における、命令フェッチ機能、命令デコード機能、命令実行機能は備わっているとする。尚、図1において、命令デコード機能部は記載していないが、命令デコード結果により、命令実行機能部2で命令実行がなされているとする。命令フェッチ機能部3は、プログラムカウンタ31に基づき、命令メモリ13から命令をフェッチしているとする。   The program execution apparatus 1 is assumed to have an instruction fetch function, an instruction decode function, and an instruction execution function in a normal program execution apparatus, for example, generally called a processor or a controller. In FIG. 1, although the instruction decode function unit is not described, it is assumed that the instruction execution function unit 2 executes an instruction based on the instruction decode result. It is assumed that the instruction fetch function unit 3 fetches an instruction from the instruction memory 13 based on the program counter 31.

通常の、例えば一般的にプロセッサやコントローラと称されるプログラム実行装置における構成に対し、本実施の形態におけるプログラム実行装置1に、どのような機能が備わっているかを説明するために、本発明におけるプログラム実行装置1が保有する命令および、その動作について以下説明する。
本実施の形態におけるプログラム実行装置1は、通常のプログラム実行装置が保有する算術演算命令、論理演算命令、データのロードストア命令、および分岐命令は保有している。通常の分岐命令としては、関数コールを実現するためのCALL命令(コール命令)や、関数コール後、関数コール元に復帰するためのRET命令(リターン命令)が存在している。
このような通常の分岐命令に対し、本発明の特徴となるエラー発生による関数コール無効化機能に対応したCALL命令(エラー発生無効化分岐命令:以下、説明のため本命令をECALL命令と呼称する)およびこの特殊なCALL命令に対応したRET命令(以下、説明のため本命令をERET命令と呼称する)が定義され、プログラム実行装置1上で、エラー検出対応コール命令・リターン命令実行機能部5に、その実行機能が備わっているとする。
In order to explain what functions the program execution device 1 according to the present embodiment has with respect to a normal configuration in a program execution device generally called a processor or a controller, for example, in the present invention, The instructions held by the program execution device 1 and their operations will be described below.
The program execution apparatus 1 according to the present embodiment has arithmetic operation instructions, logical operation instructions, data load / store instructions, and branch instructions that are held by a normal program execution apparatus. As a normal branch instruction, there are a CALL instruction (call instruction) for realizing a function call and a RET instruction (return instruction) for returning to the function call source after the function call.
For such a normal branch instruction, a CALL instruction (error generation invalidation branch instruction: hereinafter referred to as an ECALL instruction for explanation) corresponding to a function call invalidation function upon occurrence of an error, which is a feature of the present invention. ) And a RET instruction corresponding to this special CALL instruction (hereinafter, this instruction is referred to as an ERET instruction for the sake of explanation), and an error detection corresponding call instruction / return instruction execution function unit 5 on the program execution device 1 Are provided with the execution function.

ECALL命令は、関数コール先アドレス(関数コールにより変更されるプログラム実行アドレス)を引数(オペランド)として取り、エラー検出対応コール命令・リターン命令実行機能部5により実行される。即ち、戻りアドレス設定機能部9により、ECALL命令実行時、リターンアドレス(関数コールから戻る際の復帰先プログラムアドレス)を、本プログラム実行装置1が保有する専用レジスタ(ERETADRレジスタ91)に保持すると共に、エラーフラグ設定機能部8により、ECALL命令による関数コールが実行中であることを示すフラグレジスタであるECALLFLGレジスタ82を値1にセットする。   The ECALL instruction takes the function call destination address (program execution address changed by the function call) as an argument (operand) and is executed by the error detection corresponding call instruction / return instruction execution function unit 5. That is, when the ECALL instruction is executed, the return address setting function unit 9 holds the return address (return destination program address when returning from the function call) in a dedicated register (ERETADR register 91) held by the program execution device 1. Then, the error flag setting function unit 8 sets the ECALLFLG register 82, which is a flag register indicating that a function call based on the ECALL instruction is being executed, to a value of 1.

ERET命令は、エラー検出対応コール命令・リターン命令実行機能部5により実行される。即ち、その命令実行時、エラーフラグ設定機能部8がECALLFLGレジスタ82の値をチェックし、値が1であれば値0に設定すると共に、エラー検出対応リターン処理実行機能部7により、先述のERETADRレジスタ91に保持されたプログラムアドレスに復帰し、継続実行する。   The ERET instruction is executed by the error detection corresponding call instruction / return instruction execution function unit 5. That is, when the instruction is executed, the error flag setting function unit 8 checks the value of the ECALLFLG register 82. If the value is 1, the error flag setting function unit 8 sets the value to 0, and the error detection corresponding return process execution function unit 7 performs the above-described ERETADR. Return to the program address held in the register 91 and continue execution.

尚、ECALL命令は、実行される毎に、どのプログラムアドレスで実行されたかの情報をプロセッサ内部に保持している。ERETADRレジスタ91に保持された復帰先プログラムアドレスからの単純な減算によりECALL命令の発行アドレスは通常識別可能であるため、その呼び出し元となるプログラムアドレスはERETADRレジスタ91から導出可能であり、本実施の形態では、エラー発生コール命令アドレス識別機能部12が導出する。
具体的には、コール命令発行後の遅延スロットが0ならばERETADRレジスタ91に保持されたアドレスの1つ前、遅延スロットが1ならばERETADRレジスタ91に保持されたアドレスの2つ前のアドレスが、関数コールを発行したプログラムアドレスである。尚、ここで遅延スロットとは一般的な用語であり、直前の命令が効力を発揮する前に実行される命令の位置を指すものである。
Each time the ECALL instruction is executed, information on which program address is executed is held in the processor. Since the issue address of the ECALL instruction can be normally identified by simple subtraction from the return destination program address held in the ERETADR register 91, the program address as the call source can be derived from the ERETADR register 91. In the embodiment, the error occurrence call instruction address identification function unit 12 derives.
Specifically, if the delay slot after the call instruction is issued is 0, the address immediately before the address held in the ERETADR register 91 is 1 and if the delay slot is 1, the address 2 before the address held in the ERETADR register 91 is The program address that issued the function call. Here, the delay slot is a general term and indicates the position of an instruction executed before the immediately preceding instruction takes effect.

また、プロセッサ内部のECALL命令発行機能(エラー検出対応コール命令・リターン命令実行機能部5)に関連する専用レジスタが二つ存在する。一つはエラーフラグ設定機能部8に存在するERRSTレジスタ81であり、もう一つは、エラー検出対応コール命令無効化機能部10に存在するEADRレジスタ101である。
ERRSTレジスタ81は、後述するエラー検出命令の実行によりエラーが検出された時、その情報を保持しているレジスタであり、エラーフラグ設定機能部8により、エラー発生時およびそれ以降は値1を、エラーが発生していない時には値0を保持する。
また、EADRレジスタ101はエラー発生時における関数コールを発行したプログラムアドレスを保持しているレジスタであり、エラー発生コール命令アドレス識別機能部12によって通知されたアドレスが保持される。
In addition, there are two dedicated registers related to the ECALL instruction issue function (error detection handling call instruction / return instruction execution function unit 5) in the processor. One is an ERRST register 81 existing in the error flag setting function unit 8, and the other is an EADR register 101 existing in the error detection handling call instruction invalidation function unit 10.
The ERRST register 81 holds information when an error is detected by execution of an error detection instruction to be described later. The error flag setting function unit 8 sets a value of 1 when an error occurs and thereafter. The value 0 is held when no error has occurred.
The EASR register 101 is a register that holds a program address that issued a function call when an error occurs, and holds an address notified by the error occurrence call instruction address identification function unit 12.

ECALL命令発行機能は、命令発行時にERRSTレジスタ81をチェックし、もし値が0であればECALL命令をそのまま発行し、もし値が1であれば、エラー検出対応コール命令無効化機能部10により、EADRレジスタ101上の値と現在のプログラムアドレスを比較し、もし同じであればECALL命令を無効とし、分岐処理は行わない。この場合は、NOP命令切替機能部4により、ECALL命令を、いわゆるNOP命令として扱う。   The ECALL instruction issue function checks the ERRST register 81 when issuing an instruction. If the value is 0, the ECALL instruction is issued as it is. If the value is 1, the error detection corresponding call instruction invalidation function unit 10 The value on the EADR register 101 is compared with the current program address. If they are the same, the ECALL instruction is invalidated and the branch process is not performed. In this case, the ECP instruction is handled as a so-called NOP instruction by the NOP instruction switching function unit 4.

また、先述の通り、本プログラム実行装置1では、演算結果のエラーチェックを行うためのエラー検出命令を装備する。エラー検出命令とは、演算結果が保持されている汎用レジスタ上の値に対して範囲チェックを行う命令であり、例えば、レジスタ上の値が、指定した値以上もしくは値以下か否か、または値の符号が正か負か、または値の絶対値が指定した範囲内であるか否かといった範囲チェックの命令である。具体的には、
「その値の絶対値がある正値よりも小さいかをテストする命令(以下、ERANGE命令と呼称する)」
「正値であるかをテストする命令(以下、EPOS命令と呼称する)」
「負値であるかをテストする命令(以下、ENEG命令と呼称する)」
等である。また、これら命令はエラー検出命令実行機能部6により実行される。
Further, as described above, the program execution apparatus 1 is equipped with an error detection instruction for performing an error check on the operation result. An error detection instruction is an instruction that performs a range check on a value on a general-purpose register that holds an operation result. For example, whether or not a value on a register is greater than or less than a specified value, or a value Is a range check command such as whether the sign of is positive or negative, or whether the absolute value is within a specified range. In particular,
“Instruction to test whether the absolute value of the value is smaller than a certain positive value (hereinafter referred to as ERANGE instruction)”
“Instruction for testing whether it is positive (hereinafter referred to as EPOS instruction)”
“Instruction to test for negative value (hereinafter referred to as ENEG instruction)”
Etc. These instructions are executed by the error detection instruction execution function unit 6.

ERANGE命令では、演算結果が保持されている図示しない汎用レジスタを指し示す番号と、その汎用レジスタ上の演算結果と比較する値が保持されている汎用レジスタ番号もしくはデータメモリ上のアドレスをオペランドとして指定する。EPOS命令、ENEG命令は、演算結果が保持されている汎用レジスタ番号をオペランドとして指定する。   In the ERANGE instruction, a number indicating a general register (not shown) in which the operation result is held and a general register number holding a value to be compared with the operation result in the general register or an address in the data memory are designated as operands. . The EPOS instruction and the ENEG instruction specify a general-purpose register number that holds the operation result as an operand.

これらのエラー検出命令の発行機能(エラー検出命令実行機能部6)は、エラー状態識別機能部11により、命令毎に規定した値のチェックを行い、エラーと判断された場合には、プロセッサ内部のエラー発生信号を示すERRSIGレジスタ111の値を1とする。エラーと判断されない場合には本レジスタは値0のままである。
ERRSIGレジスタ111の値が1となった場合に、エラーフラグ設定機能部8は、ECALLFLGレジスタ82の値が1であれば、ERRSTレジスタ81を値1にセットする。また、エラー発生コール命令アドレス識別機能部12は、関数コールを発行したプログラムアドレスを、ERETADRレジスタ91にセットされた値から求めてエラー検出対応コール命令無効化機能部10に通知する。エラー検出対応コール命令無効化機能部10は、エラー発生コール命令アドレス識別機能部12から通知されたアドレスをEADRレジスタ101に保持すると共に、ECALL命令が無効であることを示す情報を命令フェッチ機能部3と戻りアドレス設定機能部9に通知する。これにより、エラー検出対応リターン処理実行機能部7は、ERETADRレジスタ91にセットされたリターンアドレスに即座に復帰する。
The error detection instruction issue function (error detection instruction execution function unit 6) checks the value defined for each instruction by the error state identification function unit 11, and if an error is determined, The value of the ERRRSIG register 111 indicating an error occurrence signal is set to 1. If no error is determined, this register remains at the value 0.
When the value of the ERRSIG register 111 becomes 1, the error flag setting function unit 8 sets the ERRST register 81 to the value 1 if the value of the ECALLFLG register 82 is 1. The error occurrence call instruction address identification function unit 12 obtains the program address that issued the function call from the value set in the ERETADR register 91 and notifies the error detection corresponding call instruction invalidation function unit 10. The error detection corresponding call instruction invalidation function unit 10 holds an address notified from the error occurrence call instruction address identification function unit 12 in the EADR register 101 and also indicates information indicating that the ECALL instruction is invalid as an instruction fetch function unit 3 and the return address setting function unit 9 are notified. As a result, the error detection return process execution function unit 7 immediately returns to the return address set in the ERETADR register 91.

以下、プログラムコードを元に、どのような動作となるかを説明する。具体例として、基盤として考えるプログラムコードをBASEとする(図2参照)。
そのプログラムBASEが導出する指令値に対し、追加プログラムにより差分量を計算し、それを加算する事により、新たな指令値が導出されるという処理を考える。具体的には、指令値が汎用レジスタR1に保持されており、補正量が汎用レジスタR2に保持されるとし、常に指令値R1に対する補正量R2の加算:
R1+R2→R1
により指令値R1が更新されるとする。
The operation will be described below based on the program code. As a specific example, a program code considered as a base is BASE (see FIG. 2).
A process is considered in which a new command value is derived by calculating a difference amount by an additional program and adding the command value derived by the program BASE. Specifically, assuming that the command value is held in the general-purpose register R1, and the correction amount is held in the general-purpose register R2, the correction amount R2 is always added to the command value R1:
R1 + R2 → R1
The command value R1 is updated by

プログラム処理記述上の差分コードとして補正処理プログラムAを追加機能として関数で実装するとし、そのプログラムアドレスを判りやすさのため同じくAとする。
ECALL命令は遅延スロットを一般的なRISCプロセッサと同様に一つ持つとする。この場合のプログラム記述は図2のようになる。
ECALL命令は発行時に、プロセッサ内部のERETADRレジスタ91に戻りアドレスを保持しているとする(図2中のADD R1,R2→R1を指すアドレス)。また、戻りアドレスからECALL命令を発行した命令アドレスも識別可能であるとする(遅延スロットが1で、ADD R1,R2→R1を指すアドレスから2を引いたものがECALL命令を発行したアドレス)。このアドレス識別はエラー発生コール命令アドレス識別機能部12によって行われる。
Assuming that the correction processing program A is implemented as a function as an additional function as a difference code in the program processing description, the program address is also A for ease of understanding.
It is assumed that the ECALL instruction has one delay slot like a general RISC processor. The program description in this case is as shown in FIG.
When the ECALL instruction is issued, it is assumed that the return address is held in the ERETADR register 91 in the processor (the address indicating ADD R1, R2 → R1 in FIG. 2). Also, it is assumed that the instruction address that issued the ECALL instruction can be identified from the return address (the delay slot is 1 and the address indicating ADD R1, R2 → R1 minus 2 is the address that issued the ECALL instruction). This address identification is performed by the error occurrence call instruction address identification function unit 12.

補正処理Aでは、処理全体が終わる時点までに汎用レジスタR3に補正量を計算しておく。また、補正量が満足すべき値の範囲を、図には記載していないデータメモリ上のアドレスaddrで指定されるデータメモリ上に保持しておくとする。
エラー状態識別機能部11におけるERANGE命令は、アドレスaddrからその値をロードし、汎用レジスタR3の値を比較し、もし、R3の絶対値がアドレスaddrからロードした値よりも小さい場合には、エラー無しと判断し、エラー検出対応リターン処理実行機能部7は、通常のERET命令による復帰を行う。
これにより、補正量R2の値の遷移は、
MOV 0→R2
MOV R3→R2 (R3:補正量)
ADD R1,R2→R1 (R1:制御量)
となり制御量R1に補正量R3が加算される。
In the correction process A, the correction amount is calculated in the general-purpose register R3 by the time when the entire process is completed. Further, it is assumed that a range of values that the correction amount should satisfy is held in a data memory specified by an address addr on the data memory not shown in the figure.
The ERANGE instruction in the error state identification function unit 11 loads the value from the address addr, compares the value of the general-purpose register R3, and if the absolute value of R3 is smaller than the value loaded from the address addr, an error occurs. It is determined that there is no error, and the error detection corresponding return process execution function unit 7 performs a return by a normal ERET instruction.
Thereby, the transition of the value of the correction amount R2 is
MOV 0 → R2
MOV R3 → R2 (R3: Correction amount)
ADD R1, R2 → R1 (R1: Control amount)
The correction amount R3 is added to the control amount R1.

一方、ERANGE命令でエラーだと判断した場合(値が範囲外である事を示す)、エラー検出対応リターン処理実行機能部7によって即座に戻りアドレスに復帰すると共に、ECALL A命令を発行したアドレスは無効だという事をプロセッサ内部のERRSTレジスタ81とEADRレジスタ101に保持する。
これにより、本処理以降、エラー検出対応コール命令無効化機能部10は、該当するECALL A命令を発行する命令は、無効なECALL命令だと識別し、ECALL命令を無視する(NOP命令切替機能部4がNOP命令とする)。
これにより、補正量のレジスタ遷移は
MOV 0→R2
ADD R1,R2→R1 (R1:制御量)
となり、制御量R1は追加機能による補正量が加算されない状態の結果として導出される。
On the other hand, if it is determined that an error is detected by the ERAANG instruction (indicating that the value is out of range), the error detection corresponding return processing execution function unit 7 immediately returns to the return address and the address that issued the ECALL A instruction is It is held in the ERRST register 81 and EADR register 101 inside the processor that it is invalid.
Thus, after this processing, the error detection corresponding call instruction invalidation function unit 10 identifies that the instruction issuing the corresponding ECALL A instruction is an invalid ECALL instruction, and ignores the ECALL instruction (NOP instruction switching function unit). 4 is a NOP instruction).
As a result, the register transition of the correction amount is MOV 0 → R2.
ADD R1, R2 → R1 (R1: Control amount)
Thus, the control amount R1 is derived as a result of the state in which the correction amount by the additional function is not added.

上記で説明した処理の動きをまとめると図3のようになる。通常は「処理パターン(1)」でプログラム実行が行われる。エラー検出対応コール命令・リターン命令実行機能部5によるECALL A命令の実行により処理Aに分岐し、処理本体を実行した後、エラー検出命令によりエラー検出命令実行機能部6にてエラー検出が行われる。エラーが検出されなければ、エラー検出対応コール命令・リターン命令実行機能部5は、そのままERET命令を実行し、元の処理部にリターンし、処理を継続する。   The movements of the processing described above are summarized as shown in FIG. Normally, the program is executed by “processing pattern (1)”. Execution of the ECALL A instruction by the error detection corresponding call instruction / return instruction execution function unit 5 branches to the process A, and after executing the processing body, the error detection instruction execution function unit 6 performs error detection by the error detection instruction. . If no error is detected, the error detection corresponding call instruction / return instruction execution function unit 5 executes the ERET instruction as it is, returns to the original processing unit, and continues the processing.

同様に処理を繰り返している際、「処理パターン(2)」のように、処理Aの処理本体を実行後、エラー検出命令によりエラー検出を行った際、エラーが検出された場合、エラー検出対応コール命令・リターン命令実行機能部5は、その後の命令実行をやめ(ERET命令は実行しない)、即時に元の処理部にリターンし、命令実行を継続するが、エラーが発生したという情報を保持しているため、次回の処理からは「処理パターン(3)」で実行されることとなる。
「処理パターン(3)」では、ECALL命令はNOP命令扱いとなるため、処理Aへのコール処理は行われず、常にECALL命令を無視した形での処理の実行が行われる。
Similarly, when processing is repeated, if an error is detected when an error is detected by an error detection command after executing the processing body of processing A as in “Processing pattern (2)”, error detection is supported. The call instruction / return instruction execution function unit 5 stops the subsequent instruction execution (does not execute the ERET instruction), immediately returns to the original processing unit, continues the instruction execution, but retains information that an error has occurred. Therefore, the processing is executed with “processing pattern (3)” from the next processing.
In the “processing pattern (3)”, since the ECALL instruction is handled as a NOP instruction, the call process to the process A is not performed, and the process is always executed while ignoring the ECALL instruction.

このようにプログラム実行装置1は実現されているため、差分として作成し、関数コールとして実行されるプログラムコード部位に処理の継続が困難なエラーが発生した場合に、そのコード部位を次回以降実行せずに処理本体の実行を継続することができ、プログラムの実行を停止せずにプログラム処理の継続が可能となる。
また、本機能はプログラム実行装置1上が保有する機能として実現しているため、その上で動作させるプログラムコードにおいては、わずかな命令の追加のみで機能実現が可能である。
更に、本実施の形態で記載したエラー検出による関数コール無効化機能は、プログラムコードで実現した機能ではなく、プログラム実行装置1上に実現した機能であるため、エラーが発生した場合にも、プログラムコードの実行時間を大きく延ばす事なく処理の実行が可能であり、ソフトウェア処理のリアルタイム性を確保する事が可能である。また、不具合検出用プログラムコードを検出する数だけ設定する必要もなく、従って、このプログラムを格納しておくメモリの使用量も少なくて済み、製品コストを抑えることができる。
As described above, since the program execution device 1 is realized, when an error that is difficult to continue processing occurs in a program code portion that is created as a difference and executed as a function call, the code portion is executed from the next time onward. Thus, the execution of the processing main body can be continued without stopping the program, and the program processing can be continued without stopping the execution of the program.
Further, since this function is realized as a function possessed by the program execution device 1, the program code to be operated on the function can be realized by adding a few instructions.
Furthermore, the function call invalidation function based on error detection described in the present embodiment is not a function realized by the program code but a function realized on the program execution device 1, so that even if an error occurs, the program The processing can be executed without greatly extending the execution time of the code, and the real time property of the software processing can be secured. Further, it is not necessary to set the number of defect detection program codes to be detected. Therefore, the amount of memory used to store this program can be reduced, and the product cost can be reduced.

尚、上記実施の形態では、通常の分岐命令以外にECALL命令が与えられた場合に、エラー検出命令実行機能部6がエラー検出命令によってエラー検出を行うようにしたが、通常の分岐命令が与えられた場合でも、この分岐命令に対してエラー検出を行うようにしてもよい。   In the above embodiment, when the ECALL instruction is given in addition to the normal branch instruction, the error detection instruction execution function unit 6 detects the error by the error detection instruction. However, the normal branch instruction is given. Even in such a case, error detection may be performed for this branch instruction.

また、プログラムコードの実行時間はある程度必要となるが、プログラム実行装置1におけるエラー検出対応コール命令・リターン命令実行機能部5やエラー検出命令実行機能部6の機能をソフトウェアで構成してもよい。   Although the execution time of the program code is required to some extent, the functions of the error detection support call instruction / return instruction execution function unit 5 and the error detection instruction execution function unit 6 in the program execution device 1 may be configured by software.

以上のように、実施の形態1のプログラム実行装置によれば、分岐命令によるプログラム実行中のエラーを検出するエラー検出部と、エラー検出部でエラーを検出した場合に、以後の命令実行で分岐命令を無効とする命令実行部とを備えたので、プログラム全体の動作を停止させることなく、プログラム実行を継続することができる。   As described above, according to the program execution device of the first embodiment, when an error is detected during execution of a program due to a branch instruction, and when the error is detected by the error detection section, branching is performed in subsequent instruction execution. Since the instruction execution unit for invalidating the instruction is provided, the program execution can be continued without stopping the operation of the entire program.

また、実施の形態1のプログラム実行装置によれば、エラー検出部は、分岐命令によるプログラム実行で得た値が、指定した値以上もしくは値以下か否か、または値の符号が正か負か、または値の絶対値が指定した範囲内であるか否かに基づいてエラーを検出するようにしたので、どのような状況ならばエラーとするかをプログラム作成者が任意に設定可能となり、きめ細かな判定処理を行うことができる。   Further, according to the program execution device of the first embodiment, the error detection unit determines whether the value obtained by executing the program with the branch instruction is greater than or less than the specified value, or whether the sign of the value is positive or negative. Because the error is detected based on whether or not the absolute value of the value is within the specified range, it is possible for the program creator to arbitrarily set what kind of situation the error will occur, and finely Determination processing can be performed.

また、実施の形態1のプログラム実行装置によれば、エラー検出部でエラーが検出された場合、エラー発生を示すエラー発生フラグがオン状態となるエラー発生状態保持部と、エラーが発生した分岐命令が置かれているプログラムメモリ上のアドレスを保持するアドレス保持部とを備え、エラー発生状態保持部でエラー発生フラグがオンであり、かつ、アドレス保持部で保持されているアドレスの分岐命令を実行する場合は、その分岐命令を無効命令に置き換えるようにしたので、プログラム実行装置上で実行するプログラムコードに対する修正を行わずに、関数コールされる処理の切り離しが可能となり、プログラムの保守性を高めることができる。   Further, according to the program execution device of the first embodiment, when an error is detected by the error detection unit, an error occurrence state holding unit in which an error occurrence flag indicating an error occurrence is turned on, and a branch instruction in which the error has occurred And an address holding unit that holds an address on the program memory where the error is stored, the error occurrence flag is turned on in the error occurrence state holding unit, and the branch instruction of the address held in the address holding unit is executed In this case, since the branch instruction is replaced with an invalid instruction, it is possible to separate the function called process without modifying the program code executed on the program execution device, thereby improving the maintainability of the program. be able to.

また、実施の形態1のプログラム実行装置によれば、エラー検出部は、通常の分岐命令とは異なるエラー発生無効化分岐命令が与えられた場合に、エラー発生無効化分岐命令により実行されるプログラムのエラーを検出するようにしたので、エラー検出対象とする関数と、エラー検出の対象としない通常関数とを、プログラム実装は同じのまま切り替える事が容易にでき、プログラムの保守性を高めることができる。   In addition, according to the program execution device of the first embodiment, the error detection unit is a program executed by an error generation invalidation branch instruction when an error generation invalidation branch instruction different from a normal branch instruction is given. Error can be detected, so it is easy to switch between functions that are subject to error detection and normal functions that are not subject to error detection, while maintaining the same program implementation, which improves program maintainability. it can.

1 プログラム実行装置、2 命令実行機能部、3 命令フェッチ機能部、4 NOP命令切替機能部、5 エラー検出対応コール命令・リターン命令実行機能部、6 エラー検出命令実行機能部、7 エラー検出対応リターン処理実行機能部、8 エラーフラグ設定機能部、9 戻りアドレス設定機能部、10 エラー検出対応コール命令無効化機能部、11 エラー状態識別機能部、12 エラー発生コール命令アドレス識別機能部、13 命令メモリ、31 プログラムカウンタ、81 ERRSTレジスタ、82 ECALLFLGレジスタ、91 ERETADRレジスタ、101 EADRレジスタ、111 ERRSIGレジスタ。   1 program execution device, 2 instruction execution function section, 3 instruction fetch function section, 4 NOP instruction switching function section, 5 error detection support call instruction / return instruction execution function section, 6 error detection instruction execution function section, 7 error detection support return Processing execution function section, 8 error flag setting function section, 9 return address setting function section, 10 error detection corresponding call instruction invalidation function section, 11 error status identification function section, 12 error occurrence call instruction address identification function section, and 13 instruction memory , 31 program counter, 81 ERRST register, 82 ECALLFLG register, 91 ERETADR register, 101 EADR register, 111 ERRSIG register.

Claims (4)

分岐命令によるプログラム実行中のエラーを検出するエラー検出部と、
前記エラー検出部でエラーを検出した場合に、以後の命令実行で当該分岐命令を無効とする命令実行部とを備えたプログラム実行装置。
An error detection unit for detecting an error during program execution by a branch instruction;
A program execution device comprising: an instruction execution unit that invalidates the branch instruction in subsequent instruction execution when an error is detected by the error detection unit.
エラー検出部は、分岐命令によるプログラム実行で得た値が、指定した値以上もしくは値以下か否か、または値の符号が正か負か、または値の絶対値が指定した範囲内であるか否かに基づいてエラーを検出することを特徴とする請求項1記載のプログラム実行装置。   The error detection unit checks whether the value obtained by executing the program using the branch instruction is greater than or less than the specified value, whether the sign of the value is positive or negative, or whether the absolute value of the value is within the specified range. 2. The program execution device according to claim 1, wherein an error is detected based on whether or not. エラー検出部でエラーが検出された場合、当該エラー発生を示すエラー発生フラグがオン状態となるエラー発生状態保持部と、
前記エラーが発生した分岐命令が置かれているプログラムメモリ上のアドレスを保持するアドレス保持部とを備え、
前記エラー発生状態保持部でエラー発生フラグがオンであり、かつ、前記アドレス保持部で保持されているアドレスの分岐命令を実行する場合は、当該分岐命令を無効命令に置き換えることを特徴とする請求項1または請求項2記載のプログラム実行装置。
When an error is detected by the error detection unit, an error occurrence state holding unit in which an error occurrence flag indicating the occurrence of the error is turned on; and
An address holding unit holding an address on a program memory in which the branch instruction in which the error has occurred is placed,
When the error occurrence flag is on in the error occurrence state holding unit and a branch instruction at an address held in the address holding unit is executed, the branch instruction is replaced with an invalid instruction. The program execution device according to claim 1 or 2.
エラー検出部は、通常の分岐命令とは異なるエラー発生無効化分岐命令が与えられた場合に、当該エラー発生無効化分岐命令により実行されるプログラムのエラーを検出することを特徴とする請求項1から請求項3のうちのいずれか1項記載のプログラム実行装置。   The error detection unit detects an error in a program executed by the error generation invalidation branch instruction when an error generation invalidation branch instruction different from a normal branch instruction is given. The program execution device according to claim 1.
JP2009040718A 2009-02-24 2009-02-24 Program execution device Pending JP2010198183A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2009040718A JP2010198183A (en) 2009-02-24 2009-02-24 Program execution device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009040718A JP2010198183A (en) 2009-02-24 2009-02-24 Program execution device

Publications (1)

Publication Number Publication Date
JP2010198183A true JP2010198183A (en) 2010-09-09

Family

ID=42822868

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009040718A Pending JP2010198183A (en) 2009-02-24 2009-02-24 Program execution device

Country Status (1)

Country Link
JP (1) JP2010198183A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015185152A (en) * 2014-03-26 2015-10-22 株式会社メガチップス SIMD processor
WO2016040071A1 (en) * 2014-09-12 2016-03-17 Intel Corporation Returning to a control transfer instruction

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015185152A (en) * 2014-03-26 2015-10-22 株式会社メガチップス SIMD processor
WO2016040071A1 (en) * 2014-09-12 2016-03-17 Intel Corporation Returning to a control transfer instruction
US9519773B2 (en) 2014-09-12 2016-12-13 Intel Corporation Returning to a control transfer instruction
CN106575335A (en) * 2014-09-12 2017-04-19 英特尔公司 Returning to a control transfer instruction
CN106575335B (en) * 2014-09-12 2019-08-09 英特尔公司 Return to control transfer instruction

Similar Documents

Publication Publication Date Title
US8959318B2 (en) Illegal mode change handling
TWI738744B (en) Apparatus, method, and computer program product for program loop control
US8266597B2 (en) Dynamically patching computer code using breakpoints
KR20180067583A (en) Move prefix command
US20070006158A1 (en) Instruction execution device, debugging method, debugging device, and debugging program
JP2003271400A (en) Method for performing critical task
JP2008530693A (en) Conditional instruction execution via an emissary instruction for condition evaluation
JP2010238228A (en) Method and device for dynamically analyzing program
TW201439904A (en) Managing potentially invalid results during runahead
US9003171B2 (en) Page fault prediction for processing vector instructions
TW201737060A (en) Program loop control
KR20180126003A (en) Branch instruction
KR102307581B1 (en) register recovery branch instruction
KR100303712B1 (en) Method and apparatus for an address pipeline in a pipelined machine
US6654877B1 (en) System and method for selectively executing computer code
CN107851012B (en) Accidental load suppression
JP2010198183A (en) Program execution device
US6643769B1 (en) System and method for enabling selective execution of computer code
US8683178B2 (en) Sharing a fault-status register when processing vector instructions
JP2008299729A (en) Processor
US20030084272A1 (en) Handling problematic events in a data processing apparatus
JP5822848B2 (en) Exception control method, system and program
KR20040058228A (en) Low overhead exception checking
JP3762608B2 (en) Computer and its control method
JP6221110B2 (en) Apparatus and method for determining and resolving errors in a processing apparatus