JP2721609B2 - Programmable controller - Google Patents

Programmable controller

Info

Publication number
JP2721609B2
JP2721609B2 JP602192A JP602192A JP2721609B2 JP 2721609 B2 JP2721609 B2 JP 2721609B2 JP 602192 A JP602192 A JP 602192A JP 602192 A JP602192 A JP 602192A JP 2721609 B2 JP2721609 B2 JP 2721609B2
Authority
JP
Japan
Prior art keywords
instruction
flag
error
block
register
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.)
Expired - Lifetime
Application number
JP602192A
Other languages
Japanese (ja)
Other versions
JPH05189013A (en
Inventor
明 薮田
稔 黒田
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.)
Panasonic Electric Works Co Ltd
Original Assignee
Matsushita Electric Works Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Matsushita Electric Works Ltd filed Critical Matsushita Electric Works Ltd
Priority to JP602192A priority Critical patent/JP2721609B2/en
Publication of JPH05189013A publication Critical patent/JPH05189013A/en
Application granted granted Critical
Publication of JP2721609B2 publication Critical patent/JP2721609B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Multi Processors (AREA)
  • Programmable Controllers (AREA)
  • Advance Control (AREA)

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【産業上の利用分野】本発明は、メインプロセッサとは
別に命令実行専用のコプロセッサを設けたプログラマブ
ルコントローラに関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a programmable controller provided with a coprocessor dedicated to instruction execution separately from a main processor.

【0002】[0002]

【従来の技術】従来より、プログラマブルコントローラ
の処理速度を向上させることなどを目的として、図4に
示すように、従来から用いられている汎用のメインプロ
セッサ11と並行動作する命令実行専用のコプロセッサ
21を設けることが提案されている。コプロセッサ21
としては、処理の高速化を図るために、縮小命令セット
プロセッサ(RISCプロセッサ)が用いられる。この
場合、ユーザ等により設計されてソースプログラムメモ
リ12に格納されたシーケンスプログラムのソースコー
ドは、コンパイルされて縮小命令のオブジェクトコード
に変換された後にオブジェクトプログラムメモリ22に
格納され、基本命令や応用命令はオブジェクトプログラ
ムメモリ22に格納されたオブジェクトコードに基づい
てコプロセッサ21で実行される。ソースコードのコン
パイルは、システムメモリ13に格納されたコンパイラ
を用いてメインプロセッサ11によって行われる。ま
た、メインプロセッサ11は、シーケンスプログラムの
命令の実行には用いられず、ソースコードのコンパイル
のほか、インタフェース14を通して行われる周辺装置
の制御や通信の制御に用いられる。メインプロセッサ1
1とコプロセッサ21との間の通信はバスコントローラ
15を介して行われる。ここに、メインプロセッサ11
のデータバスは16ビットであり、コプロセッサ21の
データバスは、オブジェクトプログラムメモリ22との
間では32ビット、データメモリ23との間では16ビ
ットになっている。バスコントローラ15は、メインプ
ロセッサ11の16ビットのデータバスとコプロセッサ
21の32ビットのデータバスとを結合する機能を有し
ている。コプロセッサ21の内部処理は32ビットで行
われるから、RISCプロセッサであることとあいまっ
て命令をメインプロセッサ11よりも高速に実行できる
のである。
2. Description of the Related Art Conventionally, as shown in FIG. 4, for the purpose of improving the processing speed of a programmable controller, as shown in FIG. It has been proposed to provide 21. Coprocessor 21
In order to increase the processing speed, a reduced instruction set processor (RISC processor) is used. In this case, the source code of the sequence program designed by the user or the like and stored in the source program memory 12 is compiled and converted into the object code of the reduced instruction, stored in the object program memory 22, and stored in the object program memory 22. Is executed by the coprocessor 21 based on the object code stored in the object program memory 22. Compilation of the source code is performed by the main processor 11 using a compiler stored in the system memory 13. The main processor 11 is not used for executing the instructions of the sequence program, but is used for compiling the source code and for controlling peripheral devices and communication performed through the interface 14. Main processor 1
1 and the coprocessor 21 are communicated via the bus controller 15. Here, the main processor 11
Is 16 bits, and the data bus of the coprocessor 21 is 32 bits with the object program memory 22 and 16 bits with the data memory 23. The bus controller 15 has a function of connecting a 16-bit data bus of the main processor 11 and a 32-bit data bus of the coprocessor 21. Since the internal processing of the coprocessor 21 is performed in 32 bits, the instruction can be executed faster than the main processor 11 in combination with the RISC processor.

【0003】ソースコードとオブジェクトコードとの関
係は、図5のようになる。たとえば、ソースコードでは
3命令であって、各命令のワード数が2、4、4である
とき、縮小命令を用いたオブジェクトコードのワード数
は、ソースコードの各命令に対して、たとえば、3、
7、5などとなる。オブジェクトコードでは、1ワード
が1命令に対応するのであって、上述した例では、ソー
スコードで2ワードを用いる1命令が、オブジェクトコ
ードでは3命令になる。
[0003] The relationship between the source code and the object code is as shown in FIG. For example, when the source code has three instructions and the number of words in each instruction is 2, 4, and 4, the number of words in the object code using the reduced instruction is, for example, 3 for each instruction in the source code. ,
7, 5, etc. In the object code, one word corresponds to one instruction. In the example described above, one instruction using two words in the source code becomes three instructions in the object code.

【0004】ところで、命令を実行する際には、桁上が
りを示すキャリーフラグ、0での除算などの実行できな
い演算を示すエラーフラグ、電源の異常を示す電源異常
フラグ等の各種フラグによって動作状態を監視すること
が必要である。このようなフラグは、メインプロセッサ
11とコプロセッサ21とで共用できるように、データ
メモリ23に設けることが考えられている。たとえば、
データメモリ23の一つのアドレスに、図6のように各
ビットを割り付けたフラグ設定領域を設けるのである。
ここに、図6に示したフラグは、上位から2つの値の大
小関係に関する3種のフラグ(より小(smt) 、等しい(e
q)、より大(grt) )、キャリーフラグ(crry)、演算エラ
ーに関する2種のフラグ(最新のもの(lerr)、前のもの
(perr))、電池異常に関する2種のフラグ(前のもの(p
berr) 、最新のもの(berr))、インタフェース照合異常
(ioerr) 、特殊ユニットの異常(spuerr)、ヒューズの異
常(fuse)、瞬時停電の検出(mmstp) 、自己診断エラー(s
elf)の13種類である。
When an instruction is executed, the operation state is determined by various flags such as a carry flag indicating a carry, an error flag indicating an unexecutable operation such as division by 0, and a power supply abnormality flag indicating a power supply abnormality. It is necessary to monitor. It is considered that such a flag is provided in the data memory 23 so that the flag can be shared by the main processor 11 and the coprocessor 21. For example,
At one address of the data memory 23, a flag setting area to which each bit is allocated is provided as shown in FIG.
Here, the flags shown in FIG. 6 are three kinds of flags (smaller (smt), equal (e
q), greater (grt)), carry flag (crry), two kinds of flags related to operation errors (latest (lerr), previous one)
(perr)), two flags related to battery abnormality (previous (p
berr), latest one (berr)), interface collation error
(ioerr), special unit error (spuerr), fuse error (fuse), momentary power failure detection (mmstp), self-diagnosis error (s
elf).

【0005】ところで、上述したように演算エラーのフ
ラグには最新のもの(lerr)と前のもの(perr)とがあり、
たとえば、下のような除算命令を実行する際に除数が0
であれば最新の演算エラーフラグ(lerr)が「1」に設定
される。下の除算命令はソースコードにおける除算命令
を縮小命令であるオブジェクトコードに展開したもので
ある。
By the way, as described above, the operation error flag includes the latest one (lerr) and the previous one (perr).
For example, when executing a division instruction such as
If so, the latest calculation error flag (lerr) is set to “1”. The lower division instruction is obtained by expanding the division instruction in the source code into an object code which is a reduction instruction.

【0006】 LOAD R1 LOAD R2 DIV R1,R2,R3,R4 STORE R3 STORE R4 ここで、R1,R2,R3,R4 は、それぞれコプロセッサ21の
内部のレジスタを示し、LOADはレジスタへの数値の取り
込み、STORE はレジスタ内の数値の取り出し、DIV R1,R
2,R3,R4 はレジスタR1の値をレジスタR2の値で除算し、
商をレジスタR3、剰余をレジスタR4にそれぞれ格納する
ことを示す。ここにおいて、レジスタR2にセットされた
数値が0であると、命令DIV の実行時に最新の演算エラ
ーフラグ(lerr)を「1」にセットする。また、最新の演
算エラーフラグ(lerr)が「1」にセットされると、ソー
スコードの1命令を展開したオブジェクトコードの1つ
のブロックが終了するまでの以後の命令(すなわち、続
く2つの命令STORE )を無動作命令(NOP) に置き換え
る。このようにして最新の演算エラーフラグ(lerr)が
「1」になれば、ソースコードの1命令を展開したオブ
ジェクトコードの1つのブロックが終了した時点で実行
が中断される。
LOAD R1 LOAD R2 DIV R1, R2, R3, R4 STORE R3 STORE R4 Here, R1, R2, R3, and R4 indicate registers inside the coprocessor 21, respectively, and LOAD indicates a value taken into the register. , STORE retrieves the value in the register, DIV R1, R
2, R3, R4 divide the value of register R1 by the value of register R2,
This indicates that the quotient is stored in the register R3 and the remainder is stored in the register R4. Here, if the value set in the register R2 is 0, the latest operation error flag (lerr) is set to "1" when the instruction DIV is executed. When the latest operation error flag (lerr) is set to “1”, the subsequent instructions (that is, the following two instructions STORE) until one block of the object code obtained by expanding one instruction of the source code ends. ) Is replaced with a non-operation instruction (NOP). When the latest operation error flag (lerr) becomes "1" in this way, the execution is interrupted when one block of the object code obtained by expanding one instruction of the source code is completed.

【0007】一方、演算エラーによる実行の中断後に実
行を再開させたとすると、最新の演算エラーフラグ(ler
r)が「1」に保たれているから、コプロセッサ21では
引き続くオブジェクトコードのブロックの全体を無動作
命令(NOP) とし、そのブロックには問題がない場合で
も、何の処理もしないことになる。このような動作は不
都合であるから、演算エラーが発生し最新の演算エラー
フラグ(lerr)が「1」になると、演算エラーが生じたオ
ブジェクトコードのブロックの終了後にメインプロセッ
サ11で処理を引継ぎ、ソースコードの次命令をメイン
プロセッサ11で実行した後、エラーの発生がなければ
最新の演算エラーフラグ(lerr)を「0」にリセットし
て、コプロセッサ21に実行を引き渡すようにしている
のが現状である。
On the other hand, if execution is resumed after execution is interrupted due to an arithmetic error, the latest arithmetic error flag (ler
Since r) is kept at "1", the coprocessor 21 sets the entire subsequent object code block as a non-operation instruction (NOP), and performs no processing even if the block has no problem. Become. Since such an operation is inconvenient, if an arithmetic error occurs and the latest arithmetic error flag (lerr) becomes "1", the main processor 11 takes over the processing after the end of the block of the object code in which the arithmetic error has occurred. After the next instruction of the source code is executed by the main processor 11, if no error occurs, the latest operation error flag (lerr) is reset to "0" and the execution is passed to the coprocessor 21. It is the current situation.

【0008】ここにおいて、オブジェクトコードの次の
ブロックの命令が実行される前に最新の演算エラーフラ
グ(lerr)を「0」にリセットすることも考えられるが、
ソースコードで考えれば次命令まで演算エラーの情報が
保持されないことになって不都合である。たとえば、ソ
ースコードにおいて演算エラーが生じた命令の次の命令
に対応するオブジェクトコードのブロックを実行してい
る途中で割り込みが要求されたような場合に、演算エラ
ーフラグがすでにリセットされていることになり、ソー
スコードでは前命令で演算エラーが生じたはずであるの
に、演算エラーの情報が得られないことになるのであっ
て、ソースコードとオブジェクトコードとの情報が不一
致になってデバッグなどの際に不都合が生じるのであ
る。したがって、このような処理は採用することができ
ない。
Here, it is conceivable to reset the latest operation error flag (lerr) to "0" before the instruction of the next block of the object code is executed.
Considering the source code, the operation error information is not held until the next instruction, which is inconvenient. For example, if an interrupt is requested during execution of the object code block corresponding to the instruction following the instruction in which the operation error occurred in the source code, the operation error flag has already been reset. In the source code, an operation error must have occurred in the previous instruction, but information on the operation error cannot be obtained. In that case, inconvenience occurs. Therefore, such processing cannot be adopted.

【0009】[0009]

【発明が解決しようとする課題】上述したように、デー
タメモリ23に設定したフラグ設定領域の演算エラーフ
ラグのみを用いてメインプロセッサ11とコプロセッサ
21とで演算エラーの情報を共有している上記構成で
は、ソースコードとオブジェクトコードとで演算エラー
に関する情報の整合性を保とうとすれば、演算エラーの
発生後にはメインプロセッサ11に一時的に処理を引き
渡さなければならないのである。その結果、コプロセッ
サ21を設けて実行速度を向上させようとしているにも
かかわらず、演算エラーの処理が処理速度の向上の妨げ
になるという問題がある。
As described above, the main processor 11 and the coprocessor 21 share the information on the operation error using only the operation error flag in the flag setting area set in the data memory 23. In the configuration, if it is intended to maintain the consistency of the information relating to the operation error between the source code and the object code, it is necessary to temporarily hand over the processing to the main processor 11 after the occurrence of the operation error. As a result, there is a problem that, despite the provision of the coprocessor 21 to improve the execution speed, the processing of the arithmetic error hinders the improvement of the processing speed.

【0010】本発明は上記問題点の解決を目的とするも
のであり、ソースコードとオブジェクトコードとで演算
エラーに関する情報の整合性を保ちながらも、演算エラ
ーの発生時にメインプロセッサに処理を引き渡すことな
くコプロセッサのみで処理を継続することができるよう
にし、もって処理速度の向上を図ったプログラマブルコ
ントローラを提供しようとするものである。
SUMMARY OF THE INVENTION It is an object of the present invention to solve the above-mentioned problem, and to transfer processing to a main processor when an operation error occurs, while maintaining consistency of information on the operation error between a source code and an object code. It is an object of the present invention to provide a programmable controller in which the processing can be continued by only the coprocessor and the processing speed is improved.

【0011】[0011]

【課題を解決するための手段】本発明では、上記目的を
達成するために、シーケンスプログラムを実行する命令
実行専用のコプロセッサをメインプロセッサとは別に備
え、シーケンスプログラムのソースコードの命令をコン
パイルして得たオブジェクトコードの命令をコプロセッ
サによって実行するようにしたプログラマブルコントロ
ーラにおいて、コプロセッサで演算エラーが生じたとき
に発生する演算エラーフラグを格納するフラグレジスタ
およびエラー制御フラグレジスタを備え、コプロセッサ
は、ソースコードの1命令に対応するオブジェクトコー
ドの複数の命令よりなるブロック内で演算エラーが発生
するとフラグレジスタおよびエラー制御フラグレジスタ
に演算エラーフラグをセットし、フラグレジスタにセッ
トされたエラー情報をメインプロセッサと共有し、エラ
ー制御フラグレジスタに演算エラーフラグがセットされ
ると同一ブロック内の以後の命令を無視するとともに同
一ブロックの終了時に実行を停止し、次の実行開始時に
エラー制御フラグレジスタをリセットし、次ブロック以
後のブロックで演算エラーが発生しなかったときにフラ
グレジスタをリセットするのである。
According to the present invention, in order to achieve the above object, a dedicated coprocessor for executing an instruction for executing a sequence program is provided separately from a main processor, and an instruction of a source code of the sequence program is compiled. A program controller for executing an instruction of an object code obtained by a coprocessor, comprising: a flag register for storing an operation error flag generated when an operation error occurs in the coprocessor; and a coprocessor. Sets an operation error flag in a flag register and an error control flag register when an operation error occurs in a block including a plurality of instructions of an object code corresponding to one instruction of a source code, and sets the error information set in the flag register. When the operation error flag is set in the error control flag register, the subsequent instructions in the same block are ignored, execution is stopped at the end of the same block, and the error control flag register is Is reset, and the flag register is reset when an operation error does not occur in the blocks subsequent to the next block.

【0012】[0012]

【作用】上記構成によれば、演算エラーが生じたとき
に、演算エラーフラグをエラー制御フラグレジスタとフ
ラグレジスタとに二重に格納し、エラー制御フラグレジ
スタについては演算エラーが発生したオブジェクトコー
ドのブロックの終了で実行が停止した後の実行再開時に
リセットし、フラグレジスタについては演算エラーが発
生したブロックの次ブロック以後で演算エラーが生じな
かったときにリセットするようにしているので、コプロ
セッサの内部処理に関してはエラー制御フラグレジスタ
の設定値に基づいて命令の実行制御を行い、メインプロ
セッサ等のコプロセッサ以外に対してはフラグレジスタ
の設定値に基づいて演算エラーの情報を共有することが
できるのである。すなわち、エラー制御フラグは、演算
エラーの発生したブロックの終了時点で実行が停止し、
実行を再開したときにリセットされるから、次ブロック
の実行を継続することができて、実行制御をメインプロ
セッサに引き渡す必要がないのであって、高速な処理速
度を確保することができる。一方、演算エラーが生じた
ブロックの次のブロックの実行中に割り込みなどが生じ
たときには、エラーフラグの情報によって前ブロックで
の演算エラーの発生を知ることができるのであって、メ
インプロセッサとのエラー情報の整合性を確保できるの
である。
According to the above construction, when an operation error occurs, the operation error flag is stored in the error control flag register and the flag register in duplicate, and the error control flag register stores the object code of the object code in which the operation error has occurred. The reset is performed when execution is resumed after execution has stopped at the end of the block, and the flag register is reset when no operation error occurs after the block following the block where the operation error occurred. For internal processing, execution control of an instruction is performed based on the set value of the error control flag register, and information on operation errors can be shared with other than the coprocessor such as the main processor based on the set value of the flag register. It is. That is, the execution of the error control flag is stopped at the end of the block in which the arithmetic error has occurred,
Since reset is performed when execution is resumed, execution of the next block can be continued, and there is no need to transfer execution control to the main processor, so that a high processing speed can be secured. On the other hand, when an interrupt or the like occurs during the execution of the block next to the block in which the operation error has occurred, the occurrence of the operation error in the previous block can be known from the information of the error flag. Information consistency can be ensured.

【0013】[0013]

【実施例】本実施例では、基本的には従来構成と同様
に、データメモリ23にフラグの設定領域を備えている
ものであるが、これに加えて、図1に示すように、命令
の実行に伴って変化するフラグを格納するフラグレジス
タ31をコプロセッサ21の内部に設けるとともに、演
算エラーについてソースコードとオブジェクトコードと
の整合性を保つためのエラー制御フラグを格納するエラ
ー制御フラグレジスタ41を設けている。フラグレジス
タ31に設定されるフラグは、データメモリ23に設定
されているフラグの一部と同じ意味を持つ。フラグレジ
スタ31のフラグは、オブジェクトコードの特定の命令
の中の一部のビットによって設定されたフラグ用フィー
ルドにより操作される。この点については後述する。
In this embodiment, the data memory 23 basically has a flag setting area as in the conventional configuration. In addition to this, as shown in FIG. A flag register 31 for storing a flag that changes with execution is provided inside the coprocessor 21, and an error control flag register 41 for storing an error control flag for maintaining consistency between a source code and an object code with respect to an operation error. Is provided. The flags set in the flag register 31 have the same meaning as some of the flags set in the data memory 23. The flags of the flag register 31 are operated by a flag field set by some bits in a specific instruction of the object code. This will be described later.

【0014】以下に、動作の順に従って説明する。ま
ず、命令の実行に先立ってデータメモリ23に格納され
ているフラグのうちで、フラグレジスタ31に書き込む
ことができる一部のフラグがフラグレジスタ31に複写
される。フラグレジスタ31は、格納すべきフラグと同
数個のDフリップフロップFFa,FFbよりなる。命
令の実行前にフラグレジスタ31にフラグを書き込む処
理に関する構成は、図1には示されていないが、データ
メモリ23のフラグ設定領域のアドレスを指定してデー
タメモリ23からのフラグの読み出しを行い、たとえば
キャリーフラグ(crry)であれば、アンド回路32のクロ
ック信号clk ではないほうの入力をHレベルに設定する
とともに、DフリップフロップFFaのD端子にデータ
バスを通して読み込んだフラグの状態を入力すればよ
い。また、除算の際の演算エラーフラグ(diverr)や2進
化10進コードと2進コードとの相互変換の際の演算エ
ラーフラグ(bcderr)などはそれぞれ除算器やBCD−B
IN変換器から出力されるから、最新の演算エラーフラ
グ(lerr)であれば、除算器やBCD−BIN変換器から
の演算エラーフラグ(diverr,bcderr) をデータメモリ2
3のフラグ設定領域に書き込むと同時にDフリップロッ
プFFbのD端子に入力し、データメモリ23に書き込
んだ演算エラーフラグ(lerr)をクロック信号clk に同期
して読み込むことによって、フラグレジスタ31の設定
状態をデータメモリ23と一致させるようにする。こう
して、フラグレジスタ31に格納されるフラグが、デー
タメモリ23に格納された一部のフラグと一致する。次
に、コプロセッサ21によって、オブジェクトプログラ
ムメモリ22に格納されたオブジェクトコードによる命
令の実行が開始される。このとき、論理演算や算術演算
に伴うフラグへのアクセスが必要になると、フラグレジ
スタ31に対して書き込みや読み出しが行われる。
The operation will be described below in the order of operation. First, among the flags stored in the data memory 23 prior to the execution of the instruction, some of the flags that can be written to the flag register 31 are copied to the flag register 31. The flag register 31 includes the same number of D flip-flops FFa and FFb as the number of flags to be stored. Although a configuration relating to a process of writing a flag to the flag register 31 before execution of an instruction is not shown in FIG. 1, a flag is read from the data memory 23 by specifying an address of a flag setting area of the data memory 23. For example, in the case of a carry flag (crry), the input other than the clock signal clk of the AND circuit 32 is set to the H level, and the state of the flag read through the data bus is input to the D terminal of the D flip-flop FFa. I just need. An operation error flag (diverr) at the time of division and an operation error flag (bcderr) at the time of mutual conversion between a binary-coded decimal code and a binary code are respectively provided by a divider and a BCD-B.
Since the data is output from the IN converter, if it is the latest operation error flag (lerr), the operation error flag (diverr, bcderr) from the divider or the BCD-BIN converter is stored in the data memory 2.
3 is input to the D terminal of the D flip-flop FFb at the same time as writing to the flag setting area of 3, and the operation error flag (lerr) written to the data memory 23 is read in synchronization with the clock signal clk, thereby setting the flag register 31. Is matched with the data memory 23. Thus, the flags stored in the flag register 31 match some of the flags stored in the data memory 23. Next, the coprocessor 21 starts executing an instruction based on the object code stored in the object program memory 22. At this time, when it is necessary to access a flag associated with a logical operation or an arithmetic operation, writing or reading to or from the flag register 31 is performed.

【0015】ところで、コプロセッサ21で用いる命令
には、図2に示すような4種類の形式がある。ここに、
src1、src2、dst1は、コプロセッサ21の内部レジスタ
を指定するためのフィールドである。図2(a)は、オ
ブジェクトプログラムメモリ22やデータメモリ23と
内部レジスタとの間のデータの移動命令に対応するMタ
イプと称する形式の命令である。上位6ビットは命令コ
ードフィールド(op-code)、次の3ビットは移動元を指
定するソースレジスタ指定フィールド(src1)、次の3ビ
ットは移動先を指定するディスティネーションレジスタ
指定フィールド(dst1)、次の4ビットはソースコードと
オブジェクトコードとの対応関係を示すステータスタグ
コードを格納するステータスタグフィールド(St) 、下
位16ビットはメモリアドレスのオフセット値を格納す
るオフセットフィールド(offset) になっている。ここ
に、移動元や移動先が内部レジスタであれば指定された
内部レジスタが移動元や移動先になり、移動元や移動先
がオブジェクトプログラムメモリ22やデータメモリ2
3であれば指定された内部レジスタに格納されたデータ
が移動元や移動先のアドレスになる。
The instructions used in the coprocessor 21 have four types as shown in FIG. here,
src1, src2, and dst1 are fields for specifying internal registers of the coprocessor 21. FIG. 2A shows an instruction of a format called an M type corresponding to an instruction of moving data between the object program memory 22 or the data memory 23 and the internal register. The upper six bits are an instruction code field (op-code), the next three bits are a source register specification field (src1) that specifies a source, the next three bits are a destination register specification field (dst1) that specifies a destination, The next 4 bits are a status tag field (St) for storing a status tag code indicating the correspondence between the source code and the object code, and the lower 16 bits are an offset field (offset) for storing an offset value of a memory address. . If the source and destination are internal registers, the specified internal register is the source and destination, and the source and destination are the object program memory 22 and the data memory 2.
If it is 3, the data stored in the designated internal register becomes the source and destination addresses.

【0016】図2(b)は、2個の内部レジスタに格納
された値の間での論理演算や算術演算の結果を他の内部
レジスタに格納するRタイプと称する形式の命令であ
る。上位ビットから命令コードフィールド(op-code)に
6ビット、2個の被演算値がそれぞれ格納された2個の
内部レジスタを指定するソースレジスタ指定フィールド
(src1),(src2)に3ビットずつ、ステータスタグフィー
ルド(St) に4ビット、演算結果を格納する内部レジス
タを指定するディスティネーションレジスタ指定フィー
ルド(dst1)に3ビットを用いている。残りの下位13ビ
ットは後述するファンクションフィールド(function)と
して利用される。
FIG. 2B shows an instruction of the type called an R type for storing the result of a logical operation or an arithmetic operation between values stored in two internal registers in another internal register. A source register specification field that specifies two internal registers in which an instruction code field (op-code) is 6 bits and two operand values are stored, respectively, from the upper bits
(src1) and (src2) use 3 bits each, the status tag field (St) uses 4 bits, and the destination register specification field (dst1) specifies an internal register for storing the operation result. The remaining lower 13 bits are used as a function field (function) described later.

【0017】図2(c)は、内部レジスタに格納された
値と、設定された値との間での論理演算や算術演算の結
果を他の内部レジスタに格納するIタイプと称する形式
の命令である。この形式の命令では、Mタイプの形式の
命令のオフセットフィールドに代えて即値用フィールド
(immediate) を設けている点が形式上の相違点である。
この命令では、ソースレジスタ指定フィールド(src1)に
格納された値と即値用フィールド(immediate) に設定さ
れた値との間で、論理演算や算術演算が行われるのであ
る。したがって、演算すべき2つの値の一方が即値用フ
ィールド(immediate) に設定に格納される点を除けば、
Rタイプの命令と同様の処理を行うことになる。
FIG. 2C shows an instruction of a type called an I type for storing the result of a logical operation or an arithmetic operation between a value stored in an internal register and a set value in another internal register. It is. In this type of instruction, an immediate value field is used instead of the offset field of the M type instruction.
The difference is that (immediate) is provided.
In this instruction, a logical operation or an arithmetic operation is performed between the value stored in the source register specification field (src1) and the value set in the immediate field (immediate). Therefore, except that one of the two values to be computed is stored in the setting in the immediate field,
Processing similar to that of the R type instruction is performed.

【0018】図2(d)は、2個の内部レジスタに格納
された値の大小関係に応じてプログラムカウンタで設定
されたアドレスにジャンプしたり、1個の内部レジスタ
に格納されたアドレスにジャンプしたりするJタイプと
称する形式の命令である。形式的には、Mタイプの形式
の命令のディスティネーションレジスタ指定フィールド
(dst1)に代えて、ソースレジスタ指定フィールド(src2)
を設けた形式になっている。すなわち、2個の内部レジ
スタを指定するソースレジスタ指定フィールド(src1),
(src2)に格納された値の大小関係を比較してプログムカ
ウンタで指定されたアドレスにジャンプしたり、いずれ
か一方のソースレジスタ指定フィールド(src1),(src2)
に格納された値をジャンプ先のアドレスとしてジャンプ
したりするのである。また、この形式の命令には無動作
命令も含まれる。
FIG. 2D shows a jump to an address set by the program counter or a jump to an address stored in one internal register according to the magnitude relationship between the values stored in the two internal registers. This is an instruction in a form called J type. Formally, the destination register specification field of an M-type instruction
Source register specification field (src2) instead of (dst1)
It is in the form that has been provided. That is, a source register specification field (src1) for specifying two internal registers,
The value stored in (src2) is compared to compare the magnitude and jump to the address specified by the program counter, or one of the source register specification fields (src1), (src2)
Is performed using the value stored in the address as a jump destination address. In addition, this type of instruction includes a non-operation instruction.

【0019】上述したステータスタグフィールド(St)
は4ビットであって、図3に示すように、ソースコード
の1単位を構成するワード数を格納するための3ビット
のコード数フィールド(code)と、ソースコードの各単位
に対応したオブジェクトコードのブロックの最後の命令
コードの位置を示す1ビットの終了位置指定フィールド
(end) とを備えている。ソースコードの1単位が複数ワ
ードであって対応するオブジェクトコードのブロックが
複数ワードである場合に、コンパイラはソースコードの
1単位に対応するオブジェクトコードのブロックの先頭
の命令コードのコード数フィールド(code)に、ソースコ
ードの1単位のワード数を設定する。また、同一ブロッ
ク内の他の命令コードについてはコード数フィールド(c
ode)を0に設定する。ここに、コード数フィールド(cod
e)は、3ビットであるから最大数は7になるが、ソース
コードの1単位が8ワード以上である場合もある。この
場合には、ソースコードの1単位に対応したオブジェク
トコードのブロックの先頭の命令コードから順にコード
数フィールド(code)にワード数を設定し、同一ブロック
内の合計のワード数が、ソースコードの1単位のワード
数になるようにすればよい。たとえば、ソースコードの
1単位が15ワードであれば、オブジェクトコードの対
応するブロックの命令コードのコード数フィールド(cod
e)は、ブロックの先頭の命令コードから順に、7、7、
1となる。
The above status tag field (St)
Is 4 bits, as shown in FIG. 3, a 3-bit code number field (code) for storing the number of words constituting one unit of the source code, and an object code corresponding to each unit of the source code. 1-bit end position specification field indicating the position of the last instruction code of the block
(end). If one unit of the source code is a plurality of words and the corresponding block of the object code is a plurality of words, the compiler determines the code number field (code number) of the first instruction code of the block of the object code corresponding to one unit of the source code. ) Is set to the number of words per unit of the source code. For other instruction codes in the same block, the code number field (c
ode) is set to 0. Where the code number field (cod
Since e) is 3 bits, the maximum number is 7, but one unit of the source code may be 8 words or more. In this case, the number of words is set in the code number field (code) in order from the first instruction code of the object code block corresponding to one unit of the source code, and the total number of words in the same block is determined by the source code. What is necessary is just to make it the number of words of one unit. For example, if one unit of the source code is 15 words, the code number field (cod
e) is 7, 7,.
It becomes 1.

【0020】一方、ソースコードの1単位に対応するブ
ロックの終了位置は、終了位置指定フィールド(end) の
内容により指定される。すなわち、終了位置指定フィー
ルド(end) が、「0」のときにはブロックの途中の命令
コードを示し、「1」のときには最終位置の命令コード
を示すのである。以上をまとめて、ソースコードとオブ
ジェクトコードの命令コードのステータスタグフィール
ド(St)の設定内容との対応関係の一例を示すと、表1の
ようになる。
On the other hand, the end position of the block corresponding to one unit of the source code is specified by the contents of the end position specification field (end). That is, when the end position designation field (end) is "0", it indicates an instruction code in the middle of the block, and when it is "1", it indicates the instruction code at the last position. Summarizing the above, Table 1 shows an example of the correspondence between the source code and the setting contents of the status tag field (St) of the instruction code of the object code.

【0021】[0021]

【表1】 [Table 1]

【0022】ところで、図6に示した各種フラグのう
ち、第7ビットから第12ビットの6個のフラグは、命
令の実行の際に書き込みや読み出しが必要になるフラグ
であり、これらのフラグは、実際には、RタイプやIタ
イプの形式の命令を実行する際に書き込みや読み出しが
必要になるものである。ここに、Iタイプの形式の命令
では32ビットのすべてのビットが使用されるが、Rタ
イプの形式の命令では13ビットがファンクションフィ
ールド(function)として他の用途に利用できるように空
フールドになっている。そこで、図3に示すように、フ
ァンクションフィールド(function)の上位6ビットを、
フラグレジスタ31に各フラグを書き込むか否かを設定
するためのフラグ用フィールドとして使用する。すなわ
ち、フラグ用フィールドは、フラグレジスタ31の各D
フリップフロップFFa,FFbの個数と同じビット数
を有しており、各DフリップフロップFFa,FFbに
対して書込許可を与えるか否かを設定するための書込許
可ビットを設定する。ここに、書込許可ビットの種類と
しては、比較した2つの値の大小関係に関する3種の書
込許可ビット(より小(smt) 、等しい(eq)、より大(gr
t))と、キャリーフラグに対応する書込許可ビット(cr
ry)と、演算エラーに関する2種の書込許可ビット(最
新エラー(lerr)、前エラー(perr))とが設定される。フ
ァンクションフィールド(function)は13ビットである
が、図6における演算に必要なフラグと同じ位置に対応
するフラグを格納できるように、上位6ビットのみを使
用し、下位7ビットについては他の用途に使用できるよ
うにしてある。
By the way, among the various flags shown in FIG. 6, six flags from the seventh bit to the twelfth bit are flags that need to be written or read when executing the instruction. Actually, writing or reading is required when executing an instruction of the R type or I type format. Here, all 32 bits are used in the instruction of the I type, but in the instruction of the R type, 13 bits become an empty field so that they can be used for other purposes as a function field. ing. Therefore, as shown in FIG. 3, the upper 6 bits of the function field (function) are
It is used as a flag field for setting whether or not to write each flag in the flag register 31. That is, the flag field stores each D of the flag register 31.
It has the same number of bits as the number of flip-flops FFa and FFb, and sets a write enable bit for setting whether or not write permission is given to each of the D flip-flops FFa and FFb. Here, as the types of the write permission bits, three kinds of write permission bits (smaller (smt), equal (eq), and greater (gr)
t)) and the write enable bit (cr
ry) and two types of write permission bits relating to the operation error (latest error (lerr), previous error (perr)). Although the function field (function) is 13 bits, only the upper 6 bits are used, and the lower 7 bits are used for other purposes so that a flag corresponding to the same position as the flag required for the operation in FIG. 6 can be stored. Available for use.

【0023】しかるに、コプロセッサ21において除算
や2進化10進コードと2進コードとの相互変換のよう
な応用命令を実行しているときに演算エラーが生じる
と、フラグレジスタ31における演算エラーフラグ格納
用のDフリップフロップFFbのD端子にオア回路42
を介して除算器またはBCD−BIN変換器から演算エ
ラーフラグ(diverr,bcderr) が入力される。また、デー
タメモリ23のフラグ設定領域では最新の演算エラーフ
ラグが「1」(=Hレベル)にセットされる。一方、ソ
ースプログラムの応用命令(すなわち、基本命令に対応
するビット処理命令以外の命令)に対応する処理をコプ
ロセッサ21が実行する際には、命令のデコードの際に
デコーダ(図示せず)から出力される応用命令信号mpu
がHレベルになる。したがって、アンド回路43によっ
て、演算エラーフラグの書込許可ビット(lerr)と応用命
令信号mpu との論理積をとり、この論理積をクロック信
号clk に同期させた信号をオア回路45を介してDフリ
ップフロップFFbのクロック端子CKに入力すれば、
DフリップフロップFFbに演算エラーフラグ(diverr,
bcderr) がセットされることになる。また、オア回路4
5には、ソースコードの1命令に対応するオブジェクト
コードの1ブロックの最後の命令を実行する際に「1」
(=Hレベル)になるステータスタグフィールド(St)の
終了位置指定フィールド(end) の値と、応用命令信号mp
u との論理積をとり、この論理積をクロック信号clk に
同期させるアンド回路44からの信号も入力される。し
たがって、オブジェクトコードのブロックの最後の縮小
命令においてDフリップフロップFFbが書き換えられ
るのであり、このブロック内で演算エラーフラグ(diver
r,bcderr) が発生していないときには、Dフリップフロ
ップFFbはリセットされることになる。
However, if an operation error occurs during execution of an application instruction such as division or conversion between a binary code and a binary code in the coprocessor 21, an operation error flag is stored in the flag register 31. OR circuit 42 is connected to the D terminal of D flip-flop FFb for
, An operation error flag (diverr, bcderr) is input from the divider or the BCD-BIN converter. In the flag setting area of the data memory 23, the latest calculation error flag is set to "1" (= H level). On the other hand, when the coprocessor 21 executes a process corresponding to an application instruction of the source program (that is, an instruction other than the bit processing instruction corresponding to the basic instruction), a decoder (not shown) performs decoding of the instruction. Output application instruction signal mpu
Becomes H level. Therefore, the AND circuit 43 calculates the logical product of the write enable bit (lerr) of the operation error flag and the application instruction signal mpu, and outputs a signal obtained by synchronizing the logical product with the clock signal clk via the OR circuit 45 to the D circuit. When input to the clock terminal CK of the flip-flop FFb,
An operation error flag (diverr,
bcderr) will be set. Also, OR circuit 4
5 is “1” when the last instruction of one block of the object code corresponding to one instruction of the source code is executed.
(= H level), the value of the end position specification field (end) of the status tag field (St) and the application instruction signal mp
A signal from the AND circuit 44 which takes a logical product with u and synchronizes the logical product with the clock signal clk is also input. Therefore, the D flip-flop FFb is rewritten in the last reduction instruction of the block of the object code, and the operation error flag (diver) is set in this block.
When (r, bcderr) has not occurred, the D flip-flop FFb is reset.

【0024】一方、エラー制御フラグレジスタ41は、
Dフリップフロップによって構成されたものであって、
上述したアンド回路43の出力信号がクロック端子CK
に入力され、演算エラーフラグ(diverr,bcderr) がD端
子に入力されるようになっている。また、命令の実行を
開始する際にはコプロセッサ21の内部のコントローラ
からのリセット信号rst がリセット端子Rに入力されて
リセットされるようになっている。このリセット信号rs
t としては、メインプロセッサ11がコプロセッサ21
を起動する際に発生する起動信号を用いてもよい。エラ
ー制御フラグレジスタ41の出力が「1」であるときに
は、コプロセッサ21は入力された命令を無動作命令(N
OP) に置き換えて動作する。すなわち、従来は演算エラ
ーフラグが「1」であると命令を無動作命令に置き換え
て動作していたのに対して、本発明ではエラー制御フラ
グレジスタ41にセットされた演算エラーフラグが
「1」であると無動作命令に置き換えるのである。ま
た、エラー制御フラグレジスタ41は、命令の実行を開
始するとリセットされるから、命令の実行を一旦中断し
て再開する場合にもリセットされる。
On the other hand, the error control flag register 41
D flip-flops,
The output signal of the AND circuit 43 is connected to the clock terminal CK.
, And an operation error flag (diverr, bcderr) is input to the D terminal. When the execution of an instruction is started, a reset signal rst from a controller inside the coprocessor 21 is input to a reset terminal R and reset. This reset signal rs
As t, the main processor 11
May be used. When the output of the error control flag register 41 is “1”, the coprocessor 21 converts the input instruction into a non-operation instruction (N
OP). That is, in contrast to the conventional case where the operation error flag is "1" and the instruction is replaced with a non-operation instruction to operate, the present invention sets the operation error flag set in the error control flag register 41 to "1". Is replaced with a non-operation instruction. Further, since the error control flag register 41 is reset when the execution of the instruction is started, the error control flag register 41 is also reset when the execution of the instruction is temporarily interrupted and resumed.

【0025】上記構成によれば、コプロセッサ21にお
いて応用命令のオブジェクトコードのブロックを実行し
ている過程で演算エラーが生じたとすると、その時点で
エラー制御フラグレジスタ41およびフラグレジスタ3
1のDフリップフロップFFbに対してクロック信号cl
k に同期して演算エラーフラグがセットされ、同一ブロ
ック内の以後の命令は無視される(無動作命令として扱
われる)。このブロックの最後の命令の終了位置指定フ
ィールド(end) の値は「1」であるから、Dフリップフ
ロップFFbに演算エラーフラグ(diverr,bcderr) の値
が再度書き込まれ、この時点では演算エラーフラグ(div
err,bcderr) の値は「0」になっているが、非同期セッ
ト端子Sに入力されているエラー制御フラグレジスタ4
1の出力は「1」であるから、DフリップフロップFF
bがリセットされることはなく、DフリップフロップF
Fbの出力値は「1」に保たれる。オブジェクトコード
のブロックの最後の命令をコプロセッサ21の内部のコ
ントローラが検出すると、命令の実行が停止する。すな
わち、ソースコードの1つ命令において演算エラーが生
じたことによって、その命令に対応するオブジェクトコ
ードの1ブロックの終了時点で実行が停止するのであ
る。
According to the above configuration, if an operation error occurs during the execution of the object code block of the application instruction in the coprocessor 21, the error control flag register 41 and the flag register 3 at that point.
The clock signal cl for one D flip-flop FFb
An operation error flag is set in synchronization with k, and subsequent instructions in the same block are ignored (handled as a non-operation instruction). Since the value of the end position designation field (end) of the last instruction of this block is "1", the value of the operation error flag (diverr, bcderr) is written again to the D flip-flop FFb. (div
err, bcderr) is “0”, but the error control flag register 4
1 is "1", the D flip-flop FF
b is not reset and the D flip-flop F
The output value of Fb is kept at "1". When the controller inside the coprocessor 21 detects the last instruction of the block of the object code, the execution of the instruction is stopped. That is, when an operation error occurs in one instruction of the source code, the execution is stopped at the end of one block of the object code corresponding to the instruction.

【0026】その後、実行を再開すると、コントローラ
からはリセット信号rst が出力され、エラー制御フラグ
レジスタ41はリセットされるが、エラーフラグレジス
タ31のDフリップフロップFFbはリセットされな
い。したがって、コプロセッサ21の内部ではエラー制
御フラグレジスタ41の出力値が「0」であるから、命
令の実行を再開し、一方、フラグレジスタ31のDフリ
ップフロップFFbの出力値は「1」に保持されている
から、前ブロックで演算エラーが発生したという情報を
保持しておくことができるのである。このようにして、
コプロセッサ21では、次のブロックを実行することが
できるのである。次ブロックで除算命令のように演算エ
ラーのフラグの書込許可ビット(lerr)が「1」に設定さ
れる命令が含まれているときには、演算エラーフラグ(d
iverr,bcderr) がすでに「0」になっていることによっ
て、その命令の実行時点でDフリップフロップFFbが
リセットされる。また、次ブロックを構成する命令が加
算命令などのように書込許可ビット(lerr)が定義されて
いない命令ばかりであるときには、次ブロックの最後の
命令に同期してDフリップフロップFFbがリセットさ
れる。
Thereafter, when the execution is resumed, the reset signal rst is output from the controller and the error control flag register 41 is reset, but the D flip-flop FFb of the error flag register 31 is not reset. Therefore, since the output value of the error control flag register 41 is "0" inside the coprocessor 21, execution of the instruction is resumed, while the output value of the D flip-flop FFb of the flag register 31 is held at "1". Therefore, information that an operation error has occurred in the previous block can be held. In this way,
The coprocessor 21 can execute the next block. When the next block includes an instruction such as a division instruction in which the write enable bit (lerr) of the operation error flag is set to “1”, the operation error flag (d
iverr, bcderr) is already "0", so that the D flip-flop FFb is reset at the time of execution of the instruction. Also, when the instructions composing the next block are only instructions for which the write enable bit (lerr) is not defined, such as an addition instruction, the D flip-flop FFb is reset in synchronization with the last instruction of the next block. You.

【0027】次に、キャリーフラグについて説明する。
いま、Rタイプの命令コードによって加算等の演算を実
行したときに、キャリー信号がALU30から発生した
とする。キャリー信号は、キャリーフラグを保持するD
フリップフロップFFaのD端子に入力される。一方、
ALU30からキャリー信号が発生する場合であって
も、ソースコードの内容により、キャリーフラグを設定
する必要がある場合と必要がない場合とがある。キャリ
ーフラグの要否は、ソースコードからオブジェクトコー
ドにコンパイルしたときにわかっているから、オブジェ
クトコードのRタイプの命令コードに設定したフラグ用
フィールドうちキャリーフラグに対応する書込許可ビッ
ト(crry)を「1」とするか「0」とするかによって、キ
ャリーフラグの要否を設定しておく。このようにして、
キャリー信号がALU30から発生したときに命令コー
ドのキャリーフラグに対応する書込許可ビット(crry)が
「1」であると、アンド回路32の一方の入力端子はH
レベルになり、アンド回路32の他方の入力端子に入力
されているクロック信号clk の立ち上がりに同期してD
フリップフロップFFaのクロック入力端子CKへの入
力信号ckが立ち上がることになる。こうしてフラグレジ
スタ31のキャリーフラグが設定されるのである。命令
コードのキャリーフラグに対応する書込許可ビット(crr
y)が「0」であれば、フラグレジスタ31のキャリーフ
ラグは変更されず、前の状態に保持される。他のフラグ
に関しても同様であって、ALU30からフラグが発生
したときに、命令コードの対応する書込許可ビットが
「1」であるフラグのみがフラグレジスタ31に設定さ
れるのである。
Next, the carry flag will be described.
Now, it is assumed that a carry signal is generated from the ALU 30 when an operation such as addition is performed by an R type instruction code. The carry signal is D holding the carry flag.
The signal is input to the D terminal of the flip-flop FFa. on the other hand,
Even when the carry signal is generated from the ALU 30, there is a case where the carry flag needs to be set and a case where it is not necessary depending on the contents of the source code. The necessity of the carry flag is known when the source code is compiled into the object code. Therefore, the write enable bit (crry) corresponding to the carry flag in the flag field set in the R type instruction code of the object code is set. Whether the carry flag is required is set according to whether the carry flag is set to “1” or “0”. In this way,
If the write enable bit (crry) corresponding to the carry flag of the instruction code is "1" when the carry signal is generated from the ALU 30, one input terminal of the AND circuit 32 is at H level.
Level, and is synchronized with the rise of the clock signal clk input to the other input terminal of the AND circuit 32.
The input signal ck to the clock input terminal CK of the flip-flop FFa rises. Thus, the carry flag of the flag register 31 is set. Write enable bit (crr
If y) is "0", the carry flag of the flag register 31 is not changed and is held at the previous state. The same applies to the other flags. When a flag is generated from the ALU 30, only the flag whose corresponding write enable bit of the instruction code is "1" is set in the flag register 31.

【0028】一方、フラグをデータとして用いて演算を
行う場合には、内部のデータバッファ37にフラグを取
り込む必要がある。そこで、セレクタ33を介してフラ
グレジスタ31と、データメモリ23に接続されたデー
タバスとのデータを選択的にデータバッファ37に取り
込むことができるようにしてある。セレクタ33は、ア
ドレス発生部34(プログラムカウンタ等)より発生す
るアドレスデータと、アドレス記憶部35に設定された
アドレスデータとを比較部36で比較した結果に基づい
てデータバッファ37に取り込むデータを選択する。す
なわち、アドレス発生部35は、プログラムに応じてデ
ータメモリ23をアクセスするためのアドレスデータを
発生してアドレスバスに送出しており、アドレス記憶部
35にはデータメモリ23のフラグ設定領域のアドレス
データが格納されていて、データメモリ23のフラグ設
定領域が選択されるときには、セレクタ33を通してフ
ラグレジスタ31の内容がデータバッファ37に取り込
まれるようにしているのである。この構成によって、演
算の実行中に次々に更新されるフラグレジスタ31の内
容をデータバッファ37に取り込んで演算に用いること
ができるようになるのである。すなわち、演算中にはデ
ータメモリ23のフラグ設定領域の内容を更新しないか
ら、データメモリ23にアクセスしても演算の実行中に
更新されたフラグを得ることができないが、セレクタ3
3を介してフラグレジスタ31からフラグをデータバッ
ファ37に取り込むことによって、最新のフラグを演算
に用いることができるのである。演算の終了後には、フ
ラグレジスタ31の内容はデータメモリ23のフラグ設
定領域に転送される。これによって、メインプロセッサ
11がフラグを利用することが可能になる。
On the other hand, when performing an operation using a flag as data, it is necessary to take the flag into the internal data buffer 37. Therefore, the data of the flag register 31 and the data bus connected to the data memory 23 can be selectively taken into the data buffer 37 via the selector 33. The selector 33 selects the data to be taken into the data buffer 37 based on the result of the comparison unit 36 comparing the address data generated by the address generation unit 34 (a program counter or the like) with the address data set in the address storage unit 35. I do. That is, the address generator 35 generates address data for accessing the data memory 23 according to the program and sends it to the address bus. The address storage 35 stores the address data in the flag setting area of the data memory 23. Is stored, and when the flag setting area of the data memory 23 is selected, the contents of the flag register 31 are taken into the data buffer 37 through the selector 33. With this configuration, the contents of the flag register 31 updated one after another during execution of the operation can be taken into the data buffer 37 and used for the operation. That is, since the contents of the flag setting area of the data memory 23 are not updated during the operation, the updated flag cannot be obtained during the execution of the operation even if the data memory 23 is accessed.
By taking the flag from the flag register 31 into the data buffer 37 via the third register 3, the latest flag can be used for the calculation. After the operation is completed, the contents of the flag register 31 are transferred to the flag setting area of the data memory 23. This allows the main processor 11 to use the flag.

【0029】以上説明したように、コプロセッサ21で
は、演算エラーの発生時に以後の命令を無動作命令に置
き換えるかどうかを、エラーフラグレジスタ31とは別
に設けたエラー制御フラグレジスタ41の出力値によっ
て判定し、かつ、エラー制御フラグレジスタ41は実行
を再開したときにリセットされるようにしているのであ
って、エラーフラグレジスタ31については演算エラー
が発生したオブジェクトコードのブロック以後のブロッ
クで演算エラーが生じなかったときに初めてリセットさ
れるようにしているのである。したがって、コプロセッ
サ21で演算エラーが生じたときには、そのブロック内
ではエラー制御フラグレジスタ41を参照して命令を無
視し、次ブロックの命令をコプロセッサ21で継続する
ことができるのである。また、次ブロックの途中で割り
込みがかかったとしても、前ブロックで演算エラーが生
じたことを、エラーフラグレジスタ31に格納された情
報によって知ることができるから、メインプロセッサ1
1とコプロセッサ21とにおいて、演算エラーに関する
情報の整合性を保つことができるのである。
As described above, the coprocessor 21 determines whether or not to replace a subsequent instruction with an inoperative instruction when an operation error occurs, based on the output value of the error control flag register 41 provided separately from the error flag register 31. The judgment is made and the error control flag register 41 is reset when the execution is resumed. Therefore, the error flag register 31 indicates that an operation error has occurred in a block subsequent to the block of the object code in which the operation error has occurred. They are only reset when they do not occur. Therefore, when an operation error occurs in the coprocessor 21, the instruction is ignored in the block with reference to the error control flag register 41, and the instruction of the next block can be continued by the coprocessor 21. Further, even if an interrupt occurs in the middle of the next block, it is possible to know from the information stored in the error flag register 31 that an arithmetic error has occurred in the previous block.
1 and the coprocessor 21 can maintain the consistency of the information regarding the operation error.

【0030】[0030]

【発明の効果】本発明は上述のように、演算エラーが生
じたときに、演算エラーフラグをエラー制御フラグレジ
スタとフラグレジスタとに二重に格納し、エラー制御フ
ラグレジスタについては演算エラーが発生したオブジェ
クトコードのブロックの終了で実行が停止した後の実行
再開時にリセットし、フラグレジスタについては演算エ
ラーが発生したブロックの次ブロック以後で演算エラー
が生じなかったときにリセットするようにしているの
で、コプロセッサの内部処理に関してはエラー制御フラ
グレジスタの設定値に基づいて命令の実行制御を行い、
メインプロセッサ等のコプロセッサ以外に対してはフラ
グレジスタの設定値に基づいて演算エラーの情報を共有
することができるのである。すなわち、エラー制御フラ
グは、演算エラーの発生したブロックの終了時点で実行
が停止し、実行を再開したときにリセットされるから、
次ブロックの実行を継続することができて、実行制御を
メインプロセッサに引き渡す必要がないのであって、高
速な処理速度を確保することができるという利点があ
る。一方、演算エラーが生じたブロックの次のブロック
の実行中に割り込みなどが生じたときには、エラーフラ
グの情報によって前ブロックでの演算エラーの発生を知
ることができるのであって、メインプロセッサとのエラ
ー情報の整合性を確保できるという効果を奏する。
As described above, according to the present invention, when an operation error occurs, the operation error flag is stored in the error control flag register and the flag register doubly, and an operation error occurs in the error control flag register. Since the reset is performed when execution is resumed after the execution is stopped at the end of the object code block, and the flag register is reset when no operation error occurs after the block following the block where the operation error occurred, For the internal processing of the coprocessor, the execution of the instruction is controlled based on the set value of the error control flag register,
The information of the operation error can be shared with the non-coprocessor such as the main processor based on the set value of the flag register. That is, the error control flag stops execution at the end of the block in which the operation error has occurred, and is reset when execution is restarted.
Since the execution of the next block can be continued, there is no need to transfer execution control to the main processor, and there is an advantage that a high processing speed can be secured. On the other hand, when an interrupt or the like occurs during the execution of the block next to the block in which the operation error has occurred, the occurrence of the operation error in the previous block can be known from the information of the error flag. This has the effect of ensuring information consistency.

【図面の簡単な説明】[Brief description of the drawings]

【図1】実施例を示す要部ブロック図である。FIG. 1 is a main block diagram showing an embodiment.

【図2】実施例に用いる命令コードの形式を示す説明図
である。
FIG. 2 is an explanatory diagram showing a format of an instruction code used in the embodiment.

【図3】実施例に用いる命令コード中のフラグ用フィー
ルドの構成例を示す説明図である。
FIG. 3 is an explanatory diagram showing a configuration example of a flag field in an instruction code used in the embodiment.

【図4】本発明に係るプログラマブルコントローラのブ
ロック図である。
FIG. 4 is a block diagram of a programmable controller according to the present invention.

【図5】本発明に係るプログラマブルコントローラでの
ソースコードとオブジェクトコードとの関係の例を示す
説明図である。
FIG. 5 is an explanatory diagram showing an example of a relationship between a source code and an object code in the programmable controller according to the present invention.

【図6】本発明に係るプログラマブルコントローラのデ
ータメモリでのフラグ設定領域の構成の例を示す説明図
である。
FIG. 6 is an explanatory diagram showing an example of the configuration of a flag setting area in the data memory of the programmable controller according to the present invention.

【符号の説明】[Explanation of symbols]

30 ALU 31 フラグレジスタ 41 エラー制御フラグレジスタ FFa Dフリップフロップ FFb Dフリップフロップ 30 ALU 31 Flag register 41 Error control flag register FFa D flip-flop FFb D flip-flop

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 シーケンスプログラムを実行する命令実
行専用のコプロセッサをメインプロセッサとは別に備
え、シーケンスプログラムのソースコードの命令をコン
パイルして得たオブジェクトコードの命令をコプロセッ
サによって実行するようにしたプログラマブルコントロ
ーラにおいて、コプロセッサで演算エラーが生じたとき
に発生する演算エラーフラグを格納するフラグレジスタ
およびエラー制御フラグレジスタを備え、コプロセッサ
は、ソースコードの1命令に対応するオブジェクトコー
ドの複数の命令よりなるブロック内で演算エラーが発生
するとフラグレジスタおよびエラー制御フラグレジスタ
に演算エラーフラグをセットし、フラグレジスタにセッ
トされたエラー情報をメインプロセッサと共有し、エラ
ー制御フラグレジスタに演算エラーフラグがセットされ
ると同一ブロック内の以後の命令を無視するとともに同
一ブロックの終了時に実行を停止し、次の実行開始時に
エラー制御フラグレジスタをリセットし、次ブロック以
後のブロックで演算エラーが発生しなかったときにフラ
グレジスタをリセットすることを特徴とするプログラマ
ブルコントローラ。
An instruction execution coprocessor for executing a sequence program is provided separately from a main processor, and an instruction of an object code obtained by compiling an instruction of a source code of the sequence program is executed by the coprocessor. A programmable controller, comprising: a flag register for storing an operation error flag generated when an operation error occurs in the coprocessor; and an error control flag register. The coprocessor includes a plurality of instructions of an object code corresponding to one instruction of a source code. When an operation error occurs in a block consisting of a block, an operation error flag is set in the flag register and the error control flag register, and the error information set in the flag register is shared with the main processor, and the error control flag register is set. When the operation error flag is set to, the subsequent instructions in the same block are ignored, execution is stopped at the end of the same block, the error control flag register is reset at the start of the next execution, and the operation is performed in the block after the next block. A programmable controller, which resets a flag register when no error occurs.
JP602192A 1992-01-16 1992-01-16 Programmable controller Expired - Lifetime JP2721609B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP602192A JP2721609B2 (en) 1992-01-16 1992-01-16 Programmable controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP602192A JP2721609B2 (en) 1992-01-16 1992-01-16 Programmable controller

Publications (2)

Publication Number Publication Date
JPH05189013A JPH05189013A (en) 1993-07-30
JP2721609B2 true JP2721609B2 (en) 1998-03-04

Family

ID=11627039

Family Applications (1)

Application Number Title Priority Date Filing Date
JP602192A Expired - Lifetime JP2721609B2 (en) 1992-01-16 1992-01-16 Programmable controller

Country Status (1)

Country Link
JP (1) JP2721609B2 (en)

Also Published As

Publication number Publication date
JPH05189013A (en) 1993-07-30

Similar Documents

Publication Publication Date Title
JPS5855528B2 (en) address generator
JPH04260930A (en) Data processor
KR970003321B1 (en) System using microprocessor address lines coprocessor selection within a multi-coprocessor apparatus
JPH10207717A (en) Microcomputer
JPH04260927A (en) Data processor
JPS6224831B2 (en)
US4771376A (en) Processor
JP3556252B2 (en) Data processing system and method for calculating offset total
JP2721609B2 (en) Programmable controller
WO2023142524A1 (en) Instruction processing method and apparatus, chip, electronic device, and storage medium
JP2004030224A (en) Processor, method for retracting register and method for designating register
JP2607319B2 (en) Programmable controller
JP3172214B2 (en) Status mode setting method
JPH04260926A (en) Bit retrieving circuit and data processor provided with the same
US4866608A (en) Microprocessor with improved execution of instructions
JP2559929B2 (en) Programmable controller
US10817288B2 (en) Combined instruction for addition and checking of terminals
US20050216708A1 (en) Processor for performing context switching, a method for performing context switching, a computer program for perform context switching
JPH04260928A (en) Data processor
JP3539914B2 (en) Microcomputer
JP2755646B2 (en) Data driven data processor
JP2022033968A (en) Processing speed matching circuit and microprocessor
JP2559924B2 (en) Programmable controller
JPS61267133A (en) Microprogram storage system
JPS6012656B2 (en) Retry control method

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19971104

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20081121

Year of fee payment: 11

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20081121

Year of fee payment: 11

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20091121

Year of fee payment: 12

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20091121

Year of fee payment: 12

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20101121

Year of fee payment: 13

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111121

Year of fee payment: 14

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111121

Year of fee payment: 14

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313111

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20111121

Year of fee payment: 14

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121121

Year of fee payment: 15

EXPY Cancellation because of completion of term
FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20121121

Year of fee payment: 15