JP3414579B2 - Programmable controller - Google Patents

Programmable controller

Info

Publication number
JP3414579B2
JP3414579B2 JP09128396A JP9128396A JP3414579B2 JP 3414579 B2 JP3414579 B2 JP 3414579B2 JP 09128396 A JP09128396 A JP 09128396A JP 9128396 A JP9128396 A JP 9128396A JP 3414579 B2 JP3414579 B2 JP 3414579B2
Authority
JP
Japan
Prior art keywords
instruction
stop
stage
executed
state
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 - Fee Related
Application number
JP09128396A
Other languages
Japanese (ja)
Other versions
JPH09282164A (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 JP09128396A priority Critical patent/JP3414579B2/en
Priority to US08/721,181 priority patent/US5933651A/en
Priority to CNB961211032A priority patent/CN1137421C/en
Priority to EP96115647A priority patent/EP0766155B1/en
Priority to DE69621091T priority patent/DE69621091T2/en
Priority to KR1019960042852A priority patent/KR100260012B1/en
Publication of JPH09282164A publication Critical patent/JPH09282164A/en
Application granted granted Critical
Publication of JP3414579B2 publication Critical patent/JP3414579B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Advance Control (AREA)

Description

【発明の詳細な説明】 【0001】 【発明の属する技術分野】本発明はビット処理を主とす
る基本命令と、複数ビットの応用命令処理を行うプログ
ラマブルコントローラに関し、特に基本命令と応用命令
を両方処理することのできる命令処理部を有するプログ
ラマブルコントローラに関するものである。 【0002】 【従来の技術】プログラマブルコントローラは産業用装
置、機械、FA機器の制御に広く用いられており、対象
となる装置の複雑化、高速化に応じて、より多数の入出
力信号を高速に処理することが求められている。このた
め、ビット処理を主とする基本命令と、複数ビットの応
用命令処理を行うことのできる専用ハードウェア(プロ
セッサ)で高速化を実現し、通信処理・周辺処理などを
行う汎用マイクロプロセッサと組み合わせてプログラマ
ブルコントローラを構成している。この専用ハードウェ
ア(プロセッサ)の構造として、従来は、以下のような
3段パイプライン構造で命令を実行していた。 【0003】第1ステージ:命令フェッチ 第2ステージ:命令デコード、レジスタフェッチ、算術
論理演算、データアドレス計算、分岐先計算、 第3ステージ:メモリアクセス(リード/ライト)、分
岐、ビット演算、レジスタ書き込み 【0004】 【発明が解決しようとする課題】上記の3段パイプライ
ン構造では、各ステージのうち一番遅い実行ステージの
処理速度で、全体の命令実行速度が決まってしまう。こ
のようなパイプライン処理の高速化のためには、各ステ
ージの処理速度を均等にする必要があるが、この例では
命令メモリとデータメモリに同じアクセス時間のメモリ
を使用すると、第1ステージに対して第3ステージの方
がビット演算を行う分、処理時間が必要になるというア
ンバランスがある。実行速度向上のためには、パイプラ
インステージをさらに分割して多段にすれば良い。そこ
で、本発明者らは、専用ハードウェア(プロセッサ)の
命令実行サイクルを以下のような5段に要素分割した、
5段パイプライン構造を持ったプログラマブルコントロ
ーラを開発した。 【0005】第1ステージ:命令フェッチ 第2ステージ:命令デコード、レジスタフェッチ 第3ステージ:算術論理演算、データアドレス計算、分
岐先計算 第4ステージ:メモリアクセス(リード/ライト) 第5ステージ:分岐、ビット演算、レジスタ書き込み この5段パイプライン構造を採用すると、従来の3段パ
イプライン構造のプログラマブルコントローラに比べて
パイプラインステージ間のアンバランスが改善され、パ
イプラインステージ1段あたりの所要時間も短縮される
ため、全体の命令実行速度を向上させることができる。
この5段パイプライン構造のプログラマブルコントロー
ラの概略構成図を、図3に示す。 【0006】図で、IF(Instruction F
etch)で示される第1ステージは、命令メモリIM
から命令レジスタIRヘ次に実行する命令を読み込む命
令フェッチ処理を行うステージで、命令を格納する命令
メモリIMと、プログラムカウンタ制御のためのアドレ
ス計算回路ADDRCALCからの信号を受けて、次に
実行する命令が格納された命令メモリIMのアドレスを
計数するプログラムカウンタPCとで構成されている。
プログラムカウンタPCのアドレス指定に従って命令メ
モリIMから読み出された命令が格納される命令レジス
タIRは、第1ステージIFの実行結果を保存して、次
の第2ステージであるIDにその結果を伝える、パイプ
ラインレジスタIF/IDを兼ねている。 【0007】ID(Instruction Deco
de)で示される第2ステージは、命令デコーダDCに
よる命令デコード、及び、レジスタファイルRFを構成
する複数の汎用レジスタのいずれかより値を取り出すレ
ジスタフェッチ処理を行うステージで、命令のオペレー
ションコード部を解読するデコーダDCと、複数の汎用
レジスタで構成された汎用レジスタファイルRFとで構
成されている。汎用レジスタファイルRFには、2つの
出力が設けられており、一方の出力はパイプラインレジ
スタID/EXのS1に接続され、他方の出力はパイプ
ラインレジスタID/EXのS2に接続されている。ま
た、命令デコーダDCで解読された値もパイプラインレ
ジスタID/EXの所定の箇所に格納される。 【0008】次に、EX(EXecute)で示される
第3ステージは、算術論理演算ユニットALUによっ
て、算術論理演算またはデータアドレス計算または分岐
先の実効アドレスを計算する分岐先計算を行うステージ
で、算術論理演算ユニットALUの一方の入力は、パイ
プラインレジスタID/EXのS1の出力に接続され、
他方の入力は、パイプラインレジスタID/EXのS2
の出力に接続されている。また、算術論理演算ユニット
ALUは、パイプラインレジスタID/EXの所定の箇
所に格納された、デコードされた命令の値によって制御
され、算術論理演算ユニットALUの出力は、パイプラ
インレジスタEX/MEMのDの箇所に格納される。 【0009】次に、MEM(MEMory acces
s)で示される第4ステージは、データメモリDMヘの
メモリアクセス処理を行うステージで、パイプラインレ
ジスタEX/MEMのDの箇所に格納されていた値は、
データメモリDMの所定アドレスのメモリに格納される
と共に、パイプラインレジスタMEM/WBの所定箇所
に出力される。または、データメモリDMの所定アドレ
スに格納されていた値がパイプラインレジスタMEM/
WBの所定箇所に格納される。 【0010】最後に、WB(Write Back)で
示される第5ステージは、ビット演算または汎用レジス
タへの書き込み処理または分岐処理を行うステージで、
汎用レジスタへの書き込み処理の場合は、パイプライン
レジスタMEM/WBの所定箇所に格納されていた値
が、レジスタファイルRFの所定の汎用レジスタに格納
される。但し、図3では本発明に関する部分のみ図示し
ており、他の構成は図示を省略している。 【0011】以上のように、5段パイプライン構造を持
つプログラマブルコントローラでは、IF:命令フェッ
チ、ID:命令デコード、レジスタフェッチ、EX:算
術論理演算、データアドレス計算、分岐先計算、ME
M:メモリアクセス(リード/ライト)、WB:分岐、
レジスタ書き込みのように、1つの命令を5つのパイプ
ラインステージに分けて実行する。このような命令に加
えて、プログラマブルコントローラに必要とされる命令
として、データメモリ1ワード中のある1ビットの値を
参照したり更新したりする“ビット処理命令”というも
のが存在する。ビット処理命令と呼ばれる命令には様々
なものがあり、読み込んだデータメモリ1ワードのある
ビットの状態によりプログラマブルコントローラ内部の
レジスタ:BITACC(ビットアキュムレータ)を更
新したり、このレジスタBITACCの更新に加えてデ
ータメモリ中のある1ビットの値も更新する命令が存在
する。 【0012】ところでプログラマブルコントローラが停
止する条件には、停止命令実行や割り込み発生、演算エ
ラー発生など、様々なものがある。そして停止条件によ
って、例えばプログラムカウンタPCの値などのプログ
ラマブルコントローラの停止後の状態なども違ってく
る。5段パイプライン構造を持ったプログラマブルコン
トローラで例えば停止命令を実行して停止する場合、
止命令を実行した時点で停止するものとし、割り込み要
求発生時には、割り込み要求発生後に、最初に現れる
「停止マーク」がついた命令を実行した後に停止するも
のとすると、停止条件によって停止動作が異なり、プロ
グラマブルコントローラの停止後の状態なども違ってく
る。 【0013】本発明はこのような点に鑑みてなされたも
のであり、その目的とするところは、様々な停止条件に
基づく停止動作を仕様上求められた通りに矛盾なく実行
させることが可能な5段パイプライン構造を持つプログ
ラマブルコントローラを提供することにある。 【0014】 【課題を解決するための手段】本発明のプログラマブル
コントローラにあっては、上記の課題を解決するため
に、図1に示すように、命令メモリIMから命令を取り
出す命令フェッチ処理を行う第1ステージIFと、命令
デコード処理及び汎用レジスタから値を取り出すレジス
タフェッチ処理を行う第2ステージIDと、算術論理演
算処理またはデータアドレス演算処理または分岐先の実
効アドレス計算処理または分岐条件の判定処理を行う第
3ステージEXと、データメモリDMへのメモリアクセ
ス処理または分岐処理を行う第4ステージMEMと、ビ
ット演算処理または前記汎用レジスタへの書き込み処理
または分岐処理を行う第5ステージWBの、5つのステ
ージをパイプライン実行する5段パイプライン構造のプ
ログラマブルコントローラにおいて、全命令の特定位置
のビットを停止マークとして用いるビットとし、命令実
行状態で割り込み要求信号が入力されると、命令を実行
しつつ停止マークのついた命令が実行されるのを待つ状
態になり、この状態で停止マークのついた命令が実行さ
れると停止の制御を行うステートマシンSTMを有し、
このステートマシンSTMは、通常の命令実行状態で停
止命令が実行されたとき、あるいは停止マークのついた
命令が実行されるのを待つ状態になっているときに停止
命令が実行されたとき、あるいは命令実行状態において
停止命令の実行と割り込み要求が同時に発生したときに
は、必要な停止動作を実行するように構成されている。 【0015】 【発明の実施の形態】図1及び図2は本発明の実施の形
態を示す5段パイプライン構造のプログラマブルコント
ローラの全体構成を示すブロック図であり、図中のa〜
hはそれぞれ接続されている。図3の従来例の構造と比
較すれば明らかなように、本発明では、プログラマブル
コントローラの起動/停止を制御するためのステートマ
シンSTMと、不正な命令実行を阻止するためのハザー
ド検出ユニットHDUを追加した構造となっている。 【0016】このプログラマブルコントローラでは、以
下の場合に停止するものとする。 (a)停止命令実行時 停止命令を実行した時点で停止する。停止後のプログラ
ムカウンタPCの値は、停止命令自身のアドレス。 (b)割り込み要求発生時 割り込み要求発生後に、最初に現れる「停止マーク」が
ついた命令を実行した後に停止する。停止後のプログラ
ムカウンタPCの値は、停止する原因になった「停止マ
ークがついた命令」の次の命令のアドレスとなる。本実
施例のプログラマブルコントローラでは、全命令の特定
位置のビットを「停止マーク」として用いるものとし、
このビットが「1」に設定されている命令だけが、割り
込み要求発生時に停止する命令になるものとする。 【0017】上記の停止の仕様を満足するプログラマブ
ルコントローラの実施例のブロック図を、図1及び図2
に示す。図では実施例の中の、本発明に関連する部分だ
けを図示している。図中のSTMが、プログラマブルコ
ントローラの起動/停止を制御するステートマシンであ
る(請求項1)。ステートマシンSTMには、起動要求
や割り込み要求が入力されると共に、停止命令や停止マ
ークがついた命令が実行されたことを知るために制御信
号STOPとENDが入力されている。これらの制御信
号について説明すると、IFステージで命令メモリIM
から取り込んだ命令語はパイプラインレジスタIF/I
D上のインストラクションレジスタIRに格納される。
それをIDステージのデコーダブロックDCで解読し、
解読した結果をパイプラインレジスタID/EXに書き
込む。ここで解読した命令が停止命令であった場合、パ
イプラインレジスタID/EX上に設けた制御信号ST
OPに「1」を書き込むことにする。また、停止マーク
のついた命令を実行する際は、命令を解読してパイプラ
インレジスタID/EX上の該当命令に停止マークが設
定されていることを示す制御信号ENDに「1」を書き
込む。これらの制御信号STOPやENDに基づいて、
ステートマシンSTMは停止命令や停止マークのついた
命令が実行されたことを知ることができる。 【0018】また、命令メモリIMのアドレスを示すプ
ログラムカウンタPCの値をパイプラインレジスタIF
/IDに入力し、その値をID/EX、EX/MEMと
順次転送し、停止時のプログラムカウンタPCの値を求
める際に用いることができるようにしている(請求項
2)。そして、パイプラインレジスタID/EXまたは
EX/MEM上に存在するプログラムカウンタPCの
値、命令解読の結果であるパイプラインレジスタID/
EXの値、停止条件になる割り込み要求信号などをもと
に、請求項1で述べたステートマシンSTMは、停止時
のプログラムカウンタPCの値を計算し、停止前にその
値をプログラムカウンタPCに書き込む(請求項3)。
ここで、プログラムカウンタの値を保存する方法として
は、命令をフェッチしたときのプログラムカウンタの値
をスタックに格納し、停止時にスタックから値を取り出
すなどの構成も考えられるが、制御が複雑になること
と、分岐命令用などにパイプラインレジスタ上にプログ
ラムカウンタPCの値を伝達させていることから、ここ
ではパイプラインレジスタID/EXまたはEX/ME
M上のプログラムカウンタの値をステートマシンSTM
に転送し、停止の仕様に合わせてプログラムカウンタP
Cに書き戻す際に用いるという構成を採用している。 【0019】また、ステートマシンSTMは必要に応じ
てハザード発生要求をハザード検出ユニットHDUに送
ってハザード信号を発生させ、これにより命令の実行を
無効にすることにより、停止動作中に不正な命令を実行
することを防ぐ(請求項4)。ハザード検出ブロックH
DUはハザード信号HZD_PC、HZD_IF、HZ
D_ID、HZD_EXを生成し、これらの信号はそれ
ぞれHZD_PCによりプログラムカウンタPCのイン
クリメント停止、HZD_IFによりIFステージでの
命令フェッチを無効にする、HZD_IDによりIDス
テージでデコードした結果のうち、メモリアクセス、レ
ジスタ書き込みを無効にする、そして、HZD_EXに
よりEXステージでデコードした結果のうち、メモリア
クセス、レジスタ書き込みを無効にする、という働きを
する。 【0020】請求項1で述べた起動/停止制御用ステー
トマシンの状態遷移図を、図4に示す。プログラマブル
コントローラのリセット時や電源投入時には、ステート
マシンの状態はIDLEになる。そして、プログラマブ
ルコントローラの起動要求信号が入力されると、状態は
IDLEからS0に変化し、プログラマブルコントロー
ラは命令の実行を開始する。状態がS0の時はそのまま
プログラマブルコントローラは命令の実行を続けるが、
停止命令を実行したときには、状態はS0からS11に
変化し、S11からはS12、S13と順に状態が変化
し、そのあいだに必要な停止動作を実行した後プログラ
マブルコントローラは停止し、ステートマシンの状態も
IDLEに変化する。 【0021】また、命令実行中の状態がS0の時に割り
込み要求が発生すると、ステートマシンの状態はS0か
らS21に変化して、プログラマブルコントローラは命
令を実行しつつ、停止マークのついた命令が実行される
のを待つ状態になる。そして、ステートマシンの状態が
S21の時に停止マークのついた命令が実行されると、
状態はS21からS22へ、さらにS23、S24、S
25へと変化し、この間に必要な停止動作を実行し、そ
して状態がIDLEになってプログラマブルコントロー
ラは停止する。状態がS21で停止マークのついた命令
を待っているときに停止命令が実行されると、状態はS
21からS11ヘと変化し、停止命令実行時の停止動作
に移る。S0とS21のように複数の状態に遷移できる
状態の時は、図4中に付記した順位(1)や(2)に示
すように、次の状態に移る際の優先順位を定めておく。
状態S0で命令を実行しているとき、停止命令の実行と
割り込み要求が同時に発生したときは、状態はS11に
変化して、停止命令実行時の停止動作に移る。 【0022】次に、実施例のプログラマブルコントロー
ラの停止動作の様子を、図5と図6のタイミングチャー
トに示す。図5は、停止命令を実行したときの停止動作
の様子を示したものであり、命令メモリIMの3番地に
停止命令が格納されているものとする。図5のSTAT
Eは起動/停止制御用ステートマシンの状態で、PCK
EEPはステートマシン内部に存在する停止時のプログ
ラムカウンタPCを一時的に保存するためのレジスタ
で、PCWTRQはステートマシンがプログラムカウン
タPCに値を書き込むための制御信号である。またIF
_ID_IRは、パイプラインレジスタIF/ID上に
存在する、命令をフェッチするための命令レジスタで、
HZD_PCはプログラムカウンタPCのインクリメン
トを停止させるためのハザード信号で、HZD_IFは
命令メモリIMから読み込んだ命令をさらにNOP命令
(ノーオペレーション命令)で上書きするためのハザー
ド信号である。 【0023】停止命令を実行する際は、命令を解読して
パイプラインレジスタID/EX上の該当命令が停止命
令であることを示す制御信号STOPに、「1」を書き
込む。起動/停止制御用ステートマシンは、このパイプ
ラインレジスタID/EX上の制御信号STOPの値が
「1」の時に状態をS0からS11に更新し、その後は
無条件にS12、S13、IDLEと状態を変化させ
る。また、状態がS11の時にパイプラインレジスタI
D/EX上のプログラムカウンタPCの値をPCKEE
Pに書き込み、状態がS12の時にPCKEEPの値を
プログラムカウンタPCに書き込む。書き込んだ値は、
停止命令のアドレスを示している。 【0024】図6は、割り込み要求により停止する場合
の停止動作の様子を示したもので、命令メモリIMの3
番地に停止マークを設定した命令が格納され、この命令
を実行する前に割り込み要求INT_RQが与えられる
ものとする。図6の各信号は、図5のものと同じであ
る。割り込み要求INT_RQが与えられると、起動/
停止制御用ステートマシンは状態をS0からS21に更
新し、停止マークのついた命令が実行されるのを待つ状
態になる。停止マークが設定された命令を実行する際
は、命令を解読してパイプラインレジスタID/EX上
の該当命令に停止マークが設定されていることを示す制
御信号ENDに「1」を書き込む。起動/停止制御用ス
テートマシンはこのパイプラインレジスタID/EX上
の制御信号ENDの値が「1」の時に状態をS21から
S22に更新し、その後は無条件にS23、S24、S
25、IDLEと状態を変化させる。また、状態がS2
3の時にパイプラインレジスタEX/MEM上のプログ
ラムカウンタPCの値に1を加えた値をPCKEEPに
書き込み、状態がS24の時にPCKEEPの値をプロ
グラムカウンタPCに書き込む。書き込んだ値は、停止
マークが設定された命令の次の命令のアドレスを示して
いる。 【0025】 【発明の効果】発明によれば、5段パイプライン型の
構造を持つプログラマブルコントローラにおいて、全命
令の特定位置のビットを停止マークとして用いるビット
とし、命令実行状態で割り込み要求信号が入力される
と、命令を実行しつつ停止マークのついた命令が実行さ
れるのを待つ状態になり、この状態で停止マークのつい
た命令が実行されると停止の制御を行うステートマシン
を有するので、割り込み要求発生時には、割り込み要求
発生後に最初に現れる停止マークがついた命令を実行し
た後に停止するように制御することができ、また、通常
の命令実行状態で停止命令が実行されたときや、停止マ
ークのついた命令が実行されるのを待つ状態になってい
るときに停止命令が実行されたとき、あるいは命令実行
状態において停止命令の実行と割り込み要求が同時に発
生したときには、必要な停止動作を実行するように構成
したので、割り込み要求発生時の停止動作よりも停止命
令の実行による停止動作の方を優先させることができ
る。
Description: BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a basic controller mainly for bit processing and a programmable controller for processing a plurality of bits of an application instruction. The present invention relates to a programmable controller having an instruction processing unit capable of processing. 2. Description of the Related Art Programmable controllers are widely used for controlling industrial equipment, machines, and FA equipment. Is required to be processed. For this reason, a basic instruction mainly for bit processing is combined with a general-purpose microprocessor that performs high-speed processing using dedicated hardware (processor) capable of processing multi-bit applied instructions and performs communication processing and peripheral processing. To form a programmable controller. Conventionally, as the structure of this dedicated hardware (processor), instructions have been executed in the following three-stage pipeline structure. First stage: instruction fetch Second stage: instruction decode, register fetch, arithmetic logic operation, data address calculation, branch destination calculation, third stage: memory access (read / write), branch, bit operation, register write In the above-described three-stage pipeline structure, the overall instruction execution speed is determined by the processing speed of the slowest execution stage among the stages. In order to speed up such pipeline processing, it is necessary to equalize the processing speed of each stage. However, in this example, if a memory having the same access time is used for the instruction memory and the data memory, the first stage can be used. On the other hand, there is an imbalance that the processing time is required as much as the third stage performs the bit operation. In order to improve the execution speed, the pipeline stage may be further divided into multiple stages. Therefore, the present inventors divided the instruction execution cycle of the dedicated hardware (processor) into five stages as follows.
A programmable controller with a five-stage pipeline structure has been developed. First stage: instruction fetch Second stage: instruction decode, register fetch Third stage: arithmetic logic operation, data address calculation, branch destination calculation Fourth stage: memory access (read / write) Fifth stage: branch, Bit operation and register writing By using this five-stage pipeline structure, the imbalance between pipeline stages is improved compared to the conventional three-stage pipeline structure programmable controller, and the time required per pipeline stage is also reduced. Therefore, the overall instruction execution speed can be improved.
FIG. 3 shows a schematic configuration diagram of the programmable controller having the five-stage pipeline structure. In the figure, an IF (Instruction F)
The first stage, denoted by (etch), is the instruction memory IM
In the stage for performing an instruction fetch process of reading an instruction to be executed next from the instruction register IR, an instruction memory IM for storing the instruction and a signal from an address calculation circuit ADDRCALC for controlling a program counter are executed next. And a program counter PC for counting the address of the instruction memory IM where the instruction is stored.
An instruction register IR storing an instruction read from the instruction memory IM in accordance with the address designation of the program counter PC stores an execution result of the first stage IF and transmits the result to the next second stage ID. , Pipeline register IF / ID. ID (Instruction Deco)
The second stage indicated by de) is a stage for performing instruction decoding by the instruction decoder DC and register fetch processing for extracting a value from one of a plurality of general-purpose registers constituting the register file RF. It comprises a decoder DC for decoding and a general-purpose register file RF composed of a plurality of general-purpose registers. The general register file RF is provided with two outputs, one output is connected to S1 of the pipeline register ID / EX, and the other output is connected to S2 of the pipeline register ID / EX. The value decoded by the instruction decoder DC is also stored in a predetermined location of the pipeline register ID / EX. Next, a third stage indicated by EX (Execute) is a stage in which the arithmetic and logic unit ALU performs an arithmetic and logic operation or a data address calculation or a branch destination calculation for calculating an effective address of a branch destination. One input of the logical operation unit ALU is connected to the output of S1 of the pipeline register ID / EX,
The other input is S2 of the pipeline register ID / EX.
Connected to the output. The arithmetic and logic unit ALU is controlled by the value of the decoded instruction stored at a predetermined location of the pipeline register ID / EX, and the output of the arithmetic and logic unit ALU is output from the pipeline register EX / MEM. D is stored. Next, MEM (MEMory acces)
The fourth stage shown in s) is a stage for performing a memory access process to the data memory DM, and the value stored at the location D of the pipeline register EX / MEM is
The data is stored in a memory at a predetermined address of the data memory DM and output to a predetermined location of the pipeline register MEM / WB. Alternatively, the value stored at a predetermined address of the data memory DM is stored in the pipeline register MEM /
It is stored at a predetermined location in the WB. Finally, a fifth stage represented by WB (Write Back) is a stage for performing a bit operation, a write process to a general-purpose register, or a branch process.
In the case of a write process to a general-purpose register, a value stored in a predetermined location of the pipeline register MEM / WB is stored in a predetermined general-purpose register of the register file RF. However, FIG. 3 shows only a portion related to the present invention, and other components are not shown. As described above, in a programmable controller having a five-stage pipeline structure, IF: instruction fetch, ID: instruction decode, register fetch, EX: arithmetic logic operation, data address calculation, branch destination calculation, ME
M: memory access (read / write), WB: branch,
Like a register write, one instruction is divided into five pipeline stages and executed. In addition to such an instruction, there is an instruction required by the programmable controller called a “bit processing instruction” for referring to or updating a certain 1-bit value in one word of the data memory. There are various types of instructions called bit processing instructions. In addition to updating a register: BITACC (bit accumulator) inside the programmable controller according to the state of a certain bit in one word of the read data memory, in addition to updating this register BITACC, There is an instruction that also updates a certain 1-bit value in the data memory. There are various conditions for stopping the programmable controller, such as execution of a stop instruction, occurrence of an interrupt, occurrence of an arithmetic error, and the like. The state after the stop of the programmable controller, such as the value of the program counter PC, also differs depending on the stop condition. A programmable controller having a five-stage pipeline structure example when stopping running stop instruction, stops
Stop when the stop instruction is executed.
Request first appears after an interrupt request occurs
Stop after executing the instruction with "stop mark"
In this case, the stop operation differs depending on the stop conditions,
The state after the stop of the grammar controller is also different
You. SUMMARY OF THE INVENTION The present invention has been made in view of such a point, and an object of the present invention is to enable a stop operation based on various stop conditions to be executed without contradiction as required by specifications. An object of the present invention is to provide a programmable controller having a five-stage pipeline structure. In order to solve the above-mentioned problems, the programmable controller of the present invention performs an instruction fetch process for fetching an instruction from an instruction memory IM as shown in FIG. A first stage IF, a second stage ID for performing an instruction decoding process and a register fetch process for extracting a value from a general-purpose register, and an arithmetic logic operation process, a data address operation process, a branch destination effective address calculation process, or a branch condition determination process , A fourth stage MEM performing a memory access process or a branch process to the data memory DM, and a fifth stage WB performing a bit operation process or a write process or a branch process to the general-purpose register. A five-stage pipeline structure program that executes two stages in a pipeline In the mable controller, a bit at a specific position of all instructions is used as a stop mark bit, and when an interrupt request signal is input in the instruction execution state, the instruction with the stop mark is executed while executing the instruction. ready to wait, have a state machine STM for controlling the stop and instruction with a stop mark in this state is executed,
This state machine STM stops in a normal instruction execution state.
When a stop command is executed or when a stop mark is marked
Stop when waiting for an instruction to be executed
When an instruction is executed or in the instruction execution state
When execution of a stop instruction and an interrupt request occur simultaneously
Is configured to perform a necessary stop operation. FIG. 1 and FIG. 2 are block diagrams showing an overall configuration of a programmable controller having a five-stage pipeline structure showing an embodiment of the present invention.
h are connected. As is apparent from comparison with the structure of the conventional example shown in FIG. 3, in the present invention, a state machine STM for controlling start / stop of the programmable controller and a hazard detection unit HDU for preventing execution of an illegal instruction are provided. It has an added structure. This programmable controller stops in the following cases. (A) Stop instruction execution When the stop instruction is executed, the operation is stopped. The value of the program counter PC after the stop is the address of the stop instruction itself. (B) When an interrupt request is generated After an interrupt request is generated, an instruction with a “stop mark” that appears first is executed and then stopped. The value of the program counter PC after the stop is the address of the instruction next to the “instruction with a stop mark” that caused the stop. In the programmable controller of the present embodiment, bits at specific positions of all instructions are used as “stop marks”.
Only instructions for which this bit is set to "1" are instructions that stop when an interrupt request occurs. FIGS. 1 and 2 are block diagrams showing an embodiment of a programmable controller satisfying the above stop specification.
Shown in In the figure, only the part related to the present invention in the embodiment is shown. The STM in the figure is a state machine that controls start / stop of the programmable controller (claim 1). A start request and an interrupt request are input to the state machine STM, and control signals STOP and END are input to know that a stop instruction or an instruction with a stop mark has been executed. To explain these control signals, the instruction memory IM
Instruction fetched from the pipeline register IF / I
It is stored in the instruction register IR on D.
It is decoded by the decoder block DC of the ID stage,
The decrypted result is written to the pipeline register ID / EX. If the decoded instruction is a stop instruction, the control signal ST provided on the pipeline register ID / EX is used.
"1" is written in the OP. When an instruction with a stop mark is executed, the instruction is decoded and "1" is written to the control signal END indicating that the corresponding instruction on the pipeline register ID / EX is set to the stop mark. Based on these control signals STOP and END,
The state machine STM can know that a stop instruction or an instruction with a stop mark has been executed. The value of the program counter PC indicating the address of the instruction memory IM is stored in the pipeline register IF
/ ID, and the value is sequentially transferred to ID / EX and EX / MEM so that the value can be used for obtaining the value of the program counter PC at the time of stop (Claim 2). Then, the value of the program counter PC existing on the pipeline register ID / EX or EX / MEM, and the value of the pipeline register ID /
The state machine STM described in claim 1 calculates the value of the program counter PC at the time of the stop based on the value of EX, an interrupt request signal serving as a stop condition, and the like, and stores the value in the program counter PC before the stop. Write (claim 3).
Here, as a method of storing the value of the program counter, a configuration in which the value of the program counter at the time of fetching an instruction is stored in the stack and the value is taken out of the stack when the instruction is stopped can be considered. In addition, since the value of the program counter PC is transmitted to the pipeline register for a branch instruction, the pipeline register ID / EX or EX / ME
The value of the program counter on M is used as the state machine STM
To the program counter P according to the stop specification.
The configuration used when writing back to C is adopted. Further, the state machine STM sends a hazard generation request to the hazard detection unit HDU as necessary to generate a hazard signal, thereby invalidating the execution of the instruction. Execution is prevented (claim 4). Hazard detection block H
DU is a hazard signal HZD_PC, HZD_IF, HZ
D_ID and HZD_EX are generated, and these signals are used to stop the increment of the program counter PC by HZD_PC, disable the instruction fetch in the IF stage by HZD_IF, and to access the memory access and register write among the decoding results in the ID stage by HZD_ID. Is invalidated, and memory access and register writing are invalidated among the results decoded in the EX stage by HZD_EX. FIG. 4 shows a state transition diagram of the start / stop control state machine described in claim 1. When the programmable controller is reset or powered on, the state of the state machine becomes IDLE. Then, when the activation request signal of the programmable controller is input, the state changes from IDLE to S0, and the programmable controller starts executing the instruction. When the state is S0, the programmable controller continues executing the instruction as it is,
When the stop command is executed, the state changes from S0 to S11, and from S11, the state changes in the order of S12 and S13. During this time, after performing a necessary stop operation, the programmable controller stops and the state of the state machine is changed. Also changes to IDLE. When an interrupt request is issued while the state of executing an instruction is S0, the state of the state machine changes from S0 to S21, and the programmable controller executes the instruction while executing the instruction with the stop mark. It will be in the state of waiting for it. When an instruction with a stop mark is executed when the state of the state machine is S21,
The state changes from S21 to S22, and further to S23, S24, S
25, during which the necessary stop operation is performed, and the state becomes IDLE and the programmable controller stops. If a stop instruction is executed while the state is waiting for an instruction with a stop mark in S21, the state becomes S
The state changes from 21 to S11, and the operation shifts to the stop operation at the time of executing the stop instruction. When the state can transition to a plurality of states such as S0 and S21, the priority order when moving to the next state is determined as shown in the order (1) or (2) added in FIG.
When the instruction is being executed in the state S0 and the execution of the stop instruction and the interrupt request are simultaneously generated, the state changes to S11 and the operation shifts to the stop operation at the time of executing the stop instruction. Next, the state of the stopping operation of the programmable controller of the embodiment is shown in timing charts of FIGS. FIG. 5 shows a state of the stop operation when the stop instruction is executed, and it is assumed that the stop instruction is stored at address 3 of the instruction memory IM. STAT of FIG.
E is the state of the start / stop control state machine.
EEP is a register in the state machine for temporarily storing the program counter PC at the time of stop, and PCWTRQ is a control signal for the state machine to write a value to the program counter PC. Also IF
_ID_IR is an instruction register existing on the pipeline register IF / ID for fetching an instruction.
HZD_PC is a hazard signal for stopping the increment of the program counter PC, and HZD_IF is a hazard signal for overwriting the instruction read from the instruction memory IM with a NOP instruction (no operation instruction). When executing the stop instruction, the instruction is decoded and "1" is written to the control signal STOP indicating that the corresponding instruction on the pipeline register ID / EX is the stop instruction. The start / stop control state machine updates the state from S0 to S11 when the value of the control signal STOP on the pipeline register ID / EX is "1", and thereafter unconditionally changes the state to S12, S13, IDLE. To change. When the state is S11, the pipeline register I
PCKEE the value of the program counter PC on D / EX
P is written, and when the state is S12, the value of PCKEEP is written to the program counter PC. The written value is
This shows the address of the stop instruction. FIG. 6 shows a state of a stop operation when stopping by an interrupt request.
An instruction with a stop mark set at an address is stored, and an interrupt request INT_RQ is given before executing this instruction. Each signal in FIG. 6 is the same as that in FIG. When an interrupt request INT_RQ is given, activation /
The stop control state machine updates the state from S0 to S21, and enters a state of waiting for the execution of the instruction with the stop mark. When executing an instruction with a stop mark set, the instruction is decoded and "1" is written to the control signal END indicating that the corresponding instruction on the pipeline register ID / EX has a stop mark set. The start / stop control state machine updates the state from S21 to S22 when the value of the control signal END on the pipeline register ID / EX is "1", and thereafter unconditionally updates S23, S24, S
25, change the state to IDLE. If the state is S2
At 3, the value obtained by adding 1 to the value of the program counter PC on the pipeline register EX / MEM is written to PCKEEP, and when the state is S24, the value of PCKEEP is written to the program counter PC. The written value indicates the address of the instruction next to the instruction for which the stop mark has been set. According to the present invention, in a programmable controller having a five-stage pipeline structure, a bit at a specific position of all instructions is used as a stop mark, and an interrupt request signal is generated in an instruction execution state. When a command is input, a state machine that waits for an instruction with a stop mark to be executed while executing the instruction, and has a state machine that controls the stop when the instruction with the stop mark is executed in this state. since, when an interrupt request occurs, can be controlled to stop after executing the instruction the stop mark appears first after the interrupt request occurs with, and usually
When a stop instruction is executed while the
Waiting for the marked instruction to be executed.
When a stop instruction is executed or when an instruction is executed
Execution of a stop instruction and an interrupt request at the same time
Configured to perform necessary stop operation when generated
Command, the stop command is issued instead of the stop operation when an interrupt request occurs.
Command to give priority to the stop operation.
You.

【図面の簡単な説明】 【図1】本発明の5段パイプライン構造のプログラマブ
ルコントローラの第1及び第2ステージの構成を示すブ
ロック図である。 【図2】本発明の5段パイプライン構造のプログラマブ
ルコントローラの第3乃至第5ステージの構成を示すブ
ロック図である。 【図3】従来のプログラマブルコントローラのブロック
図である。 【図4】請求項1のステートマシンの状態遷移図であ
る。 【図5】停止命令実行時の動作を示すタイムチャートで
ある。 【図6】割り込みで停止する場合の動作を示すタイムチ
ャートである。 【符号の説明】 IM 命令メモリ DM データメモリ PC プログラムカウンタ ALU 算術論理演算ユニット DC 命令デコーダ RF レジスタファイル HDU ハザード検出ユニット STM ステートマシン
BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a block diagram showing a configuration of first and second stages of a programmable controller having a five-stage pipeline structure of the present invention. FIG. 2 is a block diagram showing configurations of third to fifth stages of a programmable controller having a five-stage pipeline structure according to the present invention. FIG. 3 is a block diagram of a conventional programmable controller. FIG. 4 is a state transition diagram of the state machine of claim 1; FIG. 5 is a time chart showing an operation when a stop instruction is executed. FIG. 6 is a time chart illustrating an operation when the operation is stopped by an interrupt; [Description of Signs] IM Instruction Memory DM Data Memory PC Program Counter ALU Arithmetic Logic Operation Unit DC Instruction Decoder RF Register File HDU Hazard Detection Unit STM State Machine

Claims (1)

(57)【特許請求の範囲】 【請求項1】 命令メモリから命令を取り出す命令フ
ェッチ処理を行う第1ステージと、命令デコード処理及
び汎用レジスタから値を取り出すレジスタフェッチ処理
を行う第2ステージと、算術論理演算処理またはデータ
アドレス演算処理または分岐先の実効アドレス計算処理
または分岐条件の判定処理を行う第3ステージと、デー
タメモリへのメモリアクセス処理または分岐処理を行う
第4ステージと、ビット演算処理または前記汎用レジス
タへの書き込み処理または分岐処理を行う第5ステージ
の、5つのステージをパイプライン実行する5段パイプ
ライン構造のプログラマブルコントローラにおいて、全
命令の特定位置のビットを停止マークとして用いるビッ
トとし、命令実行状態で割り込み要求信号が入力される
と、命令を実行しつつ停止マークのついた命令が実行さ
れるのを待つ状態になり、この状態で停止マークのつい
た命令が実行されると停止の制御を行うステートマシン
を有し、 前記ステートマシンは、プログラマブルコントローラの
リセット時または電源投入時には起動要求信号が入力さ
れるまで命令の実行を待機するIDLE状態となり、 IDLE状態で起動要求信号が入力されると命令実行状
態となり、 命令実行状態でIDLE状態に変化させるための命令で
ある停止命令を実行したとき、または、前記停止マーク
のついた命令が実行されるのを待つ状態になっていると
きに停止命令を実行したとき、または、命令実行状態に
おいて停止命令の実行と割り込み要求が同時に発生した
ときは、必要な停止動作を実行した後にIDLE状態と
なる ことを特徴とするプログラマブルコントローラ。
(57) [Claim 1] A first stage for performing an instruction fetch process for fetching an instruction from an instruction memory, a second stage for performing an instruction decode process and a register fetch process for fetching a value from a general-purpose register, A third stage for performing arithmetic logic operation processing, data address operation processing, effective address calculation processing for branch destinations, or processing for determining branch conditions, a fourth stage for performing memory access processing or branch processing for data memory, and bit operation processing Alternatively, in a programmable controller having a five-stage pipeline structure in which five stages are pipeline-executed in a fifth stage for performing a write process or a branch process to the general-purpose register, a bit at a specific position of all instructions is used as a stop mark. The interrupt request signal is input while the instruction is being executed. If, while executing the instruction is ready to wait for with a stop mark instruction is executed, possess and instruction with a stop mark is executed a state machine for controlling the stop in this state, the The state machine is a programmable controller
A start request signal is input at reset or when power is turned on.
When the activation request signal is input in the IDLE state, the instruction execution state is set.
Command to change to the IDLE state in the command execution state.
When a certain stop command is executed, or the stop mark
Is waiting for an instruction with
When a stop command is executed or when the
Execution of a stop instruction and an interrupt request occurred simultaneously
In some cases, after performing the necessary stop operation,
Programmable controller characterized by comprising.
JP09128396A 1995-09-29 1996-04-12 Programmable controller Expired - Fee Related JP3414579B2 (en)

Priority Applications (6)

Application Number Priority Date Filing Date Title
JP09128396A JP3414579B2 (en) 1996-04-12 1996-04-12 Programmable controller
US08/721,181 US5933651A (en) 1995-09-29 1996-09-27 Programmable controller
CNB961211032A CN1137421C (en) 1995-09-29 1996-09-29 Programmable controller
EP96115647A EP0766155B1 (en) 1995-09-29 1996-09-30 Programmable controller
DE69621091T DE69621091T2 (en) 1995-09-29 1996-09-30 Programmable control
KR1019960042852A KR100260012B1 (en) 1995-09-29 1996-09-30 Programmable controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP09128396A JP3414579B2 (en) 1996-04-12 1996-04-12 Programmable controller

Publications (2)

Publication Number Publication Date
JPH09282164A JPH09282164A (en) 1997-10-31
JP3414579B2 true JP3414579B2 (en) 2003-06-09

Family

ID=14022141

Family Applications (1)

Application Number Title Priority Date Filing Date
JP09128396A Expired - Fee Related JP3414579B2 (en) 1995-09-29 1996-04-12 Programmable controller

Country Status (1)

Country Link
JP (1) JP3414579B2 (en)

Also Published As

Publication number Publication date
JPH09282164A (en) 1997-10-31

Similar Documents

Publication Publication Date Title
EP1241567B1 (en) Method and apparatus for executing coprocessor instructions
EP0240606B1 (en) Pipe-line processing system and microprocessor using the system
JP3414579B2 (en) Programmable controller
JPH06295243A (en) Data processor
EP1177499B1 (en) Processor and method of executing instructions from several instruction sources
JPH10124312A (en) Central processor
JPH05241827A (en) Command buffer controller
JP2001014161A (en) Programmable controller
JP4564025B2 (en) Interrupt processing method in information processing apparatus
JP2504191B2 (en) Microprocessor
JP2510691B2 (en) Arithmetic processing method
JP3063593B2 (en) Programmable controller
JP3405106B2 (en) Programmable controller
JPH0248733A (en) Information processor
JP2004062427A (en) Microprocessor
JP3481039B2 (en) Programmable controller
JP2522564B2 (en) Programmable controller
JP3206394B2 (en) Programmable controller with 5-stage pipeline structure
JPS6221130B2 (en)
JPH09231074A (en) Programmable controller
JPH052485A (en) Pipeline control system
JPH0752402B2 (en) Data processing device
JPH03154929A (en) Central processing unit
JPH02206836A (en) Data processor
JPH08314720A (en) Branch control system

Legal Events

Date Code Title Description
FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20080404

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20090404

Year of fee payment: 6

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: 20090404

Year of fee payment: 6

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: 20100404

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20100404

Year of fee payment: 7

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

Free format text: PAYMENT UNTIL: 20110404

Year of fee payment: 8

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

Free format text: PAYMENT UNTIL: 20120404

Year of fee payment: 9

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: 20120404

Year of fee payment: 9

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: 20120404

Year of fee payment: 9

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

Free format text: PAYMENT UNTIL: 20130404

Year of fee payment: 10

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

Free format text: PAYMENT UNTIL: 20130404

Year of fee payment: 10

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: 20130404

Year of fee payment: 10

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: 20130404

Year of fee payment: 10

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

Free format text: PAYMENT UNTIL: 20140404

Year of fee payment: 11

LAPS Cancellation because of no payment of annual fees