JPH0969046A - Controller for loop - Google Patents

Controller for loop

Info

Publication number
JPH0969046A
JPH0969046A JP22386095A JP22386095A JPH0969046A JP H0969046 A JPH0969046 A JP H0969046A JP 22386095 A JP22386095 A JP 22386095A JP 22386095 A JP22386095 A JP 22386095A JP H0969046 A JPH0969046 A JP H0969046A
Authority
JP
Japan
Prior art keywords
loop
stack
end address
program
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP22386095A
Other languages
Japanese (ja)
Inventor
Masaichiro Maeda
雅一郎 前田
Hideki Miyasato
秀樹 宮里
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.)
Toshiba Corp
Toshiba AVE Co Ltd
Original Assignee
Toshiba Corp
Toshiba AVE Co 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 Toshiba Corp, Toshiba AVE Co Ltd filed Critical Toshiba Corp
Priority to JP22386095A priority Critical patent/JPH0969046A/en
Publication of JPH0969046A publication Critical patent/JPH0969046A/en
Pending legal-status Critical Current

Links

Landscapes

  • Executing Machine-Instructions (AREA)

Abstract

PROBLEM TO BE SOLVED: To eliminate an unnecessary time due to a program which performs no process, etc., while eliminating the program. SOLUTION: This controller has 1st, 2nd, and 3rd stacks 101, 102, and 103 and a control means for a program counter 104 which counts the frequency of execution of a loop with a matching between the address value of the counter 104 and an end address pointed by a stack pointer(SP) in the 2nd stack 102, makes a comparison to check whether the end address pointed by the SP is the same as the end address of a one-stage higher loop instructed with a one-less value of the SP in the 2nd stack 102 when the counted frequency reaches the frequency instructed by the SP in the 3rd stack 103, and executes a program by decreasing the value of the SP to 1 or a high-order loop and sending out the start address of a loop indicated by a new SP as the output of the program 104 when the comparison result indicates that the addresses are the same and the frequency is equal to a one-stage higher frequency or a frequency higher than it.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、CPUやDSPな
どの集積回路において、プログラムカウンタで指示され
たプログラムの実行を制御するのにあたり、ループを有
するプログラムの実行を制御するための技術に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a technique for controlling the execution of a program having a loop in controlling the execution of a program designated by a program counter in an integrated circuit such as a CPU and a DSP.

【0002】[0002]

【従来の技術】同じ内容のプログラムが繰り返される場
合、プログラムカウンタ(以下PC)が示すアドレスを
変更させて、プログラムをループにして繰り返し同一の
プログラムを実行させることが通常行われる。このルー
プの実行の態様の一つとして、ループの始まりを示す所
定の命令(マシン語)があるアドレスから命令を実行
し、上記所定の命令で設定されたループのエンドアドレ
ス(以下エンドアドレスとする)にアドレスを変更し、
エンドアドレスまでの間の内容を上記所定の命令で指定
された回数、n回(nは正の整数)処理を繰り返す、と
いうものがある。この方法は、例えば、C言語にあるよ
うなfor文、while文などに対応して用いること
が可能であり、ソフトウェア等のプログラムの容量(実
際にここではアッセンブラまたはコンパイラ等によって
生成されたマシン語)を減らそうとするものである。
2. Description of the Related Art When a program having the same content is repeated, it is usual to change the address indicated by a program counter (hereinafter referred to as a PC) and loop the program to repeatedly execute the same program. As one of the modes of executing this loop, an instruction is executed from an address having a predetermined instruction (machine language) indicating the beginning of the loop, and the end address of the loop set by the predetermined instruction (hereinafter referred to as end address). ) Change the address to
There is a method in which the contents up to the end address are repeatedly processed n times (n is a positive integer) the number of times specified by the predetermined instruction. This method can be used, for example, in correspondence with a for statement, a while statement, etc. in C language, and the capacity of a program such as software (in this case, a machine language generated by an assembler or a compiler is actually used). ) Is intended to be reduced.

【0003】図4は、上記従来のループの始まりの命令
について、CPUやDSPなどのハードウェアの動作を
フローチャートにして示したものである。
FIG. 4 is a flowchart showing the operation of hardware such as a CPU and a DSP for the above-mentioned conventional loop start instruction.

【0004】まず、ハードウェアは、PCによって示さ
れるプログラムの内容をフェッチし(図4符号40
1)、PCを更新(例えばPCの値を1加算する)する
(同図符号402)。そして、そのプログラムがループ
中であれば、PCがエンドアドレスかを判断する(同図
符号403)。エンドアドレスである場合、記憶されて
いるループの回数を更新し(同図符号404)、指定さ
れた回数分の処理を行ったか等を判断する(同図符号4
05)。指定された回数分の処理を行っていない場合、
ループを繰り返すようにループのスタートアドレスにP
Cの値を更新する。そして、同図符号401の部分に戻
ってPCの値に更新し次ステップのプログラムをフェッ
チする動作を繰り返す。
First, the hardware fetches the contents of the program indicated by the PC (reference numeral 40 in FIG. 4).
1), the PC is updated (for example, the value of the PC is incremented by 1) (reference numeral 402 in the figure). Then, if the program is in a loop, it is determined whether the PC is the end address (reference numeral 403 in the figure). If it is the end address, the stored number of loops is updated (reference numeral 404 in the figure), and it is determined whether or not the processing has been performed the designated number of times (reference numeral 4 in the figure).
05). If processing has not been performed the specified number of times,
P to the start address of the loop to repeat the loop
Update the value of C. Then, returning to the portion indicated by reference numeral 401 in the figure, the operation of updating to the value of the PC and fetching the program of the next step is repeated.

【0005】また、プログラムのループが入れ子状態に
なっている場合、ループのネストと呼ばれ、ループ処理
(以下、親のループ)の中でさらに別のループ(以下、
子のループ)処理が1または複数段多重になっている。
次には、ネストを1段とした最も簡明化したものを説明
する。このようなループのネストの場合、親のループが
始まり、親のループの実行中に子のループが始まる。子
のループが終了するとき、PCが示している子のエンド
アドレスのプログラムをフェッチし、このフェッチした
エンドアドレスをPCは更新する。更新したPCの値は
子のエンドアドレスに1を加えた値を示している。そし
て、子のエンドアドレスで指定回数分ループを終了した
ときに、子のループを終了し、PCが示しているアドレ
ス「子のエンドアドレス+1」のプログラムの内容をフ
ェッチして、親のループに戻る。
Further, when a loop of a program is in a nested state, it is called a loop nest, and another loop (hereinafter, referred to as a parent loop) in a loop process (hereinafter, referred to as a parent loop).
Child loop) processing is multiplexed in one or more stages.
Next, the most simplified one with one nest will be described. With such loop nesting, the parent loop begins and the child loop begins during the execution of the parent loop. When the child loop ends, the PC fetches the program of the child end address indicated by the PC, and the PC updates the fetched end address. The updated PC value indicates the value obtained by adding 1 to the child end address. Then, when the loop ends for the specified number of times at the child end address, the child loop is ended, the contents of the program at the address "child end address + 1" indicated by the PC are fetched, and the parent loop is executed. Return.

【0006】しかしながら、このとき、親と子のエンド
アドレスが同じである場合、子のループが正常に終了し
た後、PCは子のエンドアドレスに1を加えた値つまり
親のエンドアドレスに1を加えた値を示していて親のル
ープに戻ることなしに親のループから抜け出てしまう。
そのため、ループのネストとして矛盾が生じる。
However, at this time, if the parent and child end addresses are the same, the PC adds 1 to the child end address, that is, 1 to the parent end address, after the child loop ends normally. It shows the added value and exits the parent loop without returning to the parent loop.
Therefore, a contradiction occurs as a loop nest.

【0007】そこで、従来、親と子のエンドアドレスは
同じにしない規制が設けられており、子のエンドアドレ
スに1を加えた値すなわち親のエンドアドレスに無処理
のプログラム(例えばNOP命令)等を配置することに
よって親のループに戻ることなしに親のループから抜け
出てしまうことを回避している。
Therefore, conventionally, there is a restriction that the end addresses of the parent and the child are not the same, and a value obtained by adding 1 to the end address of the child, that is, an unprocessed program (eg, NOP instruction) at the end address of the parent, etc. The placement of avoids getting out of the parent loop without returning to the parent loop.

【0008】[0008]

【発明が解決しようとする課題】上述の如く、親のエン
ドアドレスに無処理のプログラム(例えばNOP命令)
等を使用することによって矛盾を回避できるが、新たに
2つの問題点が生じてくる。その1つは、無処理のプロ
グラムを置くために、その分の容量が無駄となる点、も
う1つは、実行ステップに余分な時間がかかってしまう
点である。この余分な時間は、「(NOP等のマシンサ
イクル時間)×(ループの指定回数n)」であらわさ
れ、親のループ回数nが大きい場合には余分な時間によ
る処理速度の低下は顕著となる。このことは特にDSP
等で高速に処理を要求される場合には重大な問題となっ
てくる。
As described above, the unprocessed program (for example, NOP instruction) is stored in the parent end address.
Although the contradiction can be avoided by using, etc., two new problems arise. One is that the unprocessed program is placed, so that the capacity is wasted, and the other is that the execution step takes extra time. This extra time is represented by “(machine cycle time of NOP etc.) × (specified number of loops n)”, and when the parent's number of loops n is large, the decrease in processing speed due to the extra time becomes significant. . This is especially true for DSP
It becomes a serious problem when high-speed processing is required.

【0009】そこで、本発明は、このような問題に対
し、無処理等のプログラムを無くしつつ、それによって
生じていた余分な時間をなくす手段を提供することを目
的とする。
In view of the above, an object of the present invention is to provide means for eliminating the extra time generated by eliminating a program for no processing or the like in response to such a problem.

【0010】[0010]

【課題を解決するための手段】本願請求項1の発明にか
かるループの制御装置は、順次実行すべきプログラムの
アドレスを指示するためのプログラムカウンタを制御す
ることによってプログラムのループの制御を行うループ
の制御装置であって、プログラムのループのスタートア
ドレスを格納するための第1のスタックと、ループのエ
ンドアドレスを格納するための第2のスタックと、ルー
プの回数を格納するための第3のスタックと、カウンタ
によるアドレス値と第2のスタックのうちスタックポイ
ンタで指示されたエンドアドレスとの一致により前記ル
ープの実行回数を計数し、計数して得たループの実行回
数が第3のスタックのうちスタックポインタで指示され
たループの回数になっている場合、スタックポインタで
指示されたエンドアドレスが第2のスタックのうちスタ
ックポインタの1少ない値で指示された一段上位のルー
プのエンドアドレスと同じであるかを比較し、比較の結
果同じである場合、ループの実行回数が、一段上位のル
ープの実行回数、またはこれより上位のループの回数と
等しくなっているときに、前記スタックポインタの値を
1または上位のループまで減少させるとともに、新たな
スタックポインタで示されるループのスタートアドレス
を前記プログラムカウンタの出力として前記プログラム
の実行を行うプログラムカウンタの制御手段とを有す
る。
A loop control apparatus according to the invention of claim 1 controls a loop of a program by controlling a program counter for instructing addresses of programs to be sequentially executed. A first stack for storing the start address of the loop of the program, a second stack for storing the end address of the loop, and a third stack for storing the number of times of the loop. The number of executions of the loop is counted by matching the stack, the address value by the counter, and the end address designated by the stack pointer of the second stack, and the number of executions of the loop obtained by the counting is the number of executions of the third stack. If the number of loops indicated by the stack pointer is reached, the end indicated by the stack pointer If the address is the same as the end address of the one-step higher loop indicated by the stack pointer minus one in the second stack, and if the result of the comparison is the same, the loop execution count is one step higher. When the number of executions of the loop is equal to or higher than the number of executions of the loop, the value of the stack pointer is decreased to 1 or the upper loop, and the start address of the loop indicated by the new stack pointer is changed. And a program counter control means for executing the program as an output of the program counter.

【0011】本願請求項2の発明にかかるループの制御
装置は、請求項1の構成に加えて、プログラムカウンタ
の制御手段は、計数することによって順次実行すべきプ
ログラムのアドレスを与えるためのカウンタと、カウン
タの計数値と、第1のスタックでスタックポインタで指
示された位置に格納されたスタートアドレスとを切り替
えてプログラムカウンタの出力とするスイッチと、第1
のスタックでスタックポインタにより指示された位置に
格納されたエンドアドレスとカウンタの計数値とからル
ープの最後のアドレスに等しいかどうかを判定するため
のエンドアドレス比較回路と、ループの実行回数を計数
し、計数して得たループの実行回数が、第1のスタック
でスタックポインタにより指示された位置に格納された
ループの回数に等しいかどうかを判定するためのループ
回数判定回路と、スタックポインタで指示されたエンド
アドレスが第2のスタックのうちスタックポインタが示
す値より1少ない値で指示された一段上位のループのエ
ンドアドレスに等しいかを判定するための親エンドアド
レス比較回路と、ループの実行回数が、一段上位のルー
プの実行回数と等しいかを判定するための親ループ回数
判定回路と、エンドアドレス比較回路、ループ回数判定
回路、親エンドアドレス比較回路及び親ループ回数判定
回路の判定の結果等しいとされた場合に、スタックポイ
ンタの値を1減少させるスタックポインタのコントロー
ラと、を含んで構成され、コントローラによって1減少
させた新たなスタックポインタで示されるループのスタ
ートアドレスをスイッチからプログラムカウンタの出力
としてプログラムの実行を行う。
According to a second aspect of the present invention, in addition to the configuration of the first aspect, the control means of the program counter has a counter for giving an address of a program to be sequentially executed by counting. A switch for switching the count value of the counter and the start address stored at the position designated by the stack pointer in the first stack to be the output of the program counter;
In the stack of, the end address comparison circuit for determining whether it is equal to the last address of the loop from the end address stored at the position indicated by the stack pointer and the count value of the counter, and the number of times the loop is executed is counted. , A loop number determination circuit for determining whether or not the counted number of loop executions is equal to the number of loops stored in the position designated by the stack pointer in the first stack, and the stack pointer Parent end address comparison circuit for determining whether the generated end address is equal to the end address of the loop one step higher than the value indicated by the stack pointer in the second stack, and the number of times the loop is executed Is a parent loop count determination circuit for determining whether it is equal to the execution count of the loop one step higher, An address comparison circuit, a loop count determination circuit, a parent end address comparison circuit, and a stack pointer controller that decrements the stack pointer value by 1 when the results of the determinations of the parent loop address determination circuit are equal. , The program is executed by using the start address of the loop indicated by the new stack pointer reduced by 1 by the controller as the output of the program counter from the switch.

【0012】本願請求項3の発明にかかるループの制御
装置は、請求項1の構成に加えて、プログラムカウンタ
の制御手段は、計数することによって順次実行すべきプ
ログラムのアドレスを与えるためのカウンタと、カウン
タの計数値と、第1のスタックでスタックポインタで指
示された位置に格納されたスタートアドレスとを切り替
えてプログラムカウンタの出力とするスイッチと、第1
のスタックでスタックポインタにより指示された位置に
格納されたエンドアドレスとカウンタの計数値とからル
ープの最後のアドレスに等しいかどうかを判定するため
のエンドアドレス比較回路と、ループの実行回数を計数
し、計数して得たループの実行回数が、第1のスタック
でスタックポインタにより指示された位置に格納された
ループの回数に等しいかどうかを判定するためのループ
回数判定回路と、スタックポインタで指示されたエンド
アドレスが第2のスタックのうちスタックポインタが示
す値より少ない値で指示された上位のループのエンドア
ドレスに等しいかを判定するための親エンドアドレス比
較回路と、ループの実行回数が、上位のループの実行回
数と等しいかを判定するための親ループ回数判定回路
と、エンドアドレス比較回路、ループ回数判定回路及び
親エンドアドレス比較回路が等しいとされた場合に、前
記親ループ回数判定回路の判定の結果が等しいとされる
上位のループまで、前記スタックポインタの値を1減少
させるスタックポインタのコントローラと、を含んで構
成され、コントローラによって減少させた新たなスタッ
クポインタで示されるループのスタートアドレスをスイ
ッチからプログラムカウンタの出力として前記プログラ
ムの実行を行う。
In the loop control device according to the invention of claim 3 of the present application, in addition to the configuration of claim 1, the control means of the program counter includes a counter for giving an address of a program to be sequentially executed by counting. A switch for switching the count value of the counter and the start address stored at the position designated by the stack pointer in the first stack to be the output of the program counter;
In the stack of, the end address comparison circuit for determining whether it is equal to the last address of the loop from the end address stored at the position indicated by the stack pointer and the count value of the counter, and the number of times the loop is executed is counted. , A loop number determination circuit for determining whether or not the counted number of loop executions is equal to the number of loops stored in the position designated by the stack pointer in the first stack, and the stack pointer The parent end address comparison circuit for determining whether the generated end address is equal to the end address of the upper loop indicated by a value smaller than the value indicated by the stack pointer in the second stack, and the number of times the loop is executed, Parent loop count judgment circuit for judging whether it is equal to the execution count of the upper loop, and end address When the comparison circuit, the loop number determination circuit, and the parent end address comparison circuit are equal, the value of the stack pointer is decremented by 1 until a higher loop where the determination results of the parent loop number determination circuit are equal. A stack pointer controller is included, and the program is executed by using the start address of the loop indicated by the new stack pointer reduced by the controller as the output of the program counter from the switch.

【0013】本願請求項4の発明にかかるループの制御
装置は、請求項1の構成に加えて、プログラムのループ
のスタートを示す命令は、当該ループのネストの段数を
示す情報ビットを有し、プログラムカウンタの制御手段
は、ループのスタートを示す命令があったときに情報ビ
ットからループのネストの判定をすることを特徴とす
る。
According to a fourth aspect of the present invention, in addition to the configuration of the first aspect, the instruction indicating the start of the loop of the program has an information bit indicating the number of nest stages of the loop, The control means of the program counter is characterized in that the nest of the loop is judged from the information bit when there is an instruction indicating the start of the loop.

【0014】本願請求項5の発明にかかるループの制御
装置は、請求項1の構成に加えて、プログラムのループ
のスタートを示す命令は、当該ループのエンドアドレス
と該ループの一段上位のエンドアドレスとが同じか否か
を示す情報ビットを有し、前記プログラムカウンタの制
御手段は、前記ループのスタートを示す命令があったと
きに前記情報ビットから前記ループのネストの判定をす
ることを特徴とする請求項1記載のループの制御装置。
In the loop control device according to the invention of claim 5 of the application, in addition to the structure of claim 1, the instruction indicating the start of the loop of the program is the end address of the loop and the end address of the loop one step higher. And an information bit indicating whether or not is the same, and the control means of the program counter determines the nest of the loop from the information bit when an instruction indicating the start of the loop is given. The control device for the loop according to claim 1.

【0015】本願請求項1ないし3の発明にかかるルー
プの制御装置によれば、上述したように、新たなスタッ
クポインタで示されるループのスタートアドレスを前記
プログラムカウンタの出力として前記プログラムの実行
を行うことにより、プログラムのループがネストしてい
る状態において、そのループの終了アドレスを同じもの
にすることができる。
According to the loop control device of the present invention, the program is executed by using the loop start address indicated by the new stack pointer as the output of the program counter, as described above. This allows the end address of the loop to be the same when the loops of the program are nested.

【0016】とくに、本願請求項3の発明にかかるルー
プの制御装置によれば、2以上の複数のループがネスト
している状態においても、そのループの終了アドレスを
同じものにすることができる。
In particular, according to the loop control device of the third aspect of the present invention, even when two or more loops are nested, the end address of the loop can be the same.

【0017】本願請求項4の発明にかかるループの制御
装置は、情報ビットによりネストの段数を示すことによ
り、プログラムカウンタの制御手段は、ループのスター
トを示す命令があったときに情報ビットからループのネ
ストの判定をすることができる。
In the loop control device according to the fourth aspect of the present invention, the number of nest stages is indicated by the information bit, so that the control means of the program counter loops from the information bit when there is an instruction indicating the start of the loop. You can judge the nesting of.

【0018】本願請求項5の発明にかかるループの制御
装置によれば、情報ビットにより一段上位のエンドアド
レスとが同じか否かを示すことにより、ループのスター
トを示す命令があったときに情報ビットからループのネ
ストの判定をすることができる。
According to the loop control device of the present invention, the information bit indicates whether or not the end address one step higher is the same, so that when the instruction to start the loop is issued, the information is sent. It is possible to judge the nest of a loop from bits.

【0019】[0019]

【発明の実施の形態】以下、この発明の実施の形態を図
面を参照して説明する。図1は、本発明の第1の実施の
態様のブロック図であり、CPUやDSPなどの集積回
路において実行すべきプログラムのアドレスを制御する
プログラムカウンタ(以下PC)の出力を得るための部
分を示したものであり、PCの出力はハードウェアで制
御されるようになっている。
BEST MODE FOR CARRYING OUT THE INVENTION Embodiments of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram of a first embodiment of the present invention, showing a portion for obtaining an output of a program counter (hereinafter referred to as a PC) that controls an address of a program to be executed in an integrated circuit such as a CPU or a DSP. The output of the PC is controlled by hardware.

【0020】図1の装置には、レジスタファイルで構成
されたスタックエリアがあり、ここでは、各スタック1
01,102,103は、0,1,…,nのn段積み得
るものとして説明する。スタックエリア101は、ルー
プ0〜nについてそれらのスタートアドレスを格納し、
スタックエリア102は各ループ0〜nのループのエン
ドアドレスA0〜Anを格納し、スタックエリア103
は各ループ0〜nのループの回数C0〜Cnを格納す
る。これらスタックには、あるループの実行中に、ルー
プの始まりを示す所定の命令(マシン語)が実行される
ごとに値が順に格納されるようになっている。なお、こ
の所定の命令は、アセンブラやコンパイラ等といったソ
フトウェア等によって記述された内容(プログラム)を
マシン語に変換する課程においてマシン語内にネストの
段数の情報ビットを持つようになっており、これによっ
てネストの判定ができるようになっている。これ以外の
部分がプログラムカウンタの制御手段をなす。
The apparatus shown in FIG. 1 has a stack area composed of register files. Here, each stack 1
It is assumed that 01, 102, 103 can be stacked in n stages of 0, 1, ..., N. The stack area 101 stores the start addresses of loops 0 to n,
The stack area 102 stores the end addresses A0 to An of the loops of the loops 0 to n, and the stack area 103
Stores the number of times C0 to Cn of each loop 0 to n. During execution of a certain loop, these stacks sequentially store a value each time a predetermined instruction (machine language) indicating the beginning of the loop is executed. Note that this predetermined instruction has an information bit of the number of nest levels in the machine word in the process of converting the content (program) described by software such as assembler and compiler into the machine word. You can judge the nest by. The other parts form the control means of the program counter.

【0021】そして、これらスタック101,102,
103は、ループスタックポインタ(以下LSとする)
で指示された位置(0〜n)にあるものの値が取り出さ
れるようになっている。これらのスタック以外の部分が
プログラムカウンタの制御手段をなす。
Then, these stacks 101, 102,
103 is a loop stack pointer (hereinafter referred to as LS)
The value of the item at the position (0 to n) designated by is extracted. The parts other than these stacks form the control means of the program counter.

【0022】ループスタックポインタのコントローラ1
06は、LSの値mを制御するためのものである。
Loop stack pointer controller 1
06 is for controlling the value m of LS.

【0023】ループのネスト判定回路124は、その入
力にコントローラ106の出力であるLSが与えられ、
ループのネスト状態を判定するものである。このLSの
値m(0〜n)は、その時点でのループのスタック10
1,102,103の段数を示すが、これは現在実行さ
れているループのネストの状態と等価なものである。例
えば、LSの値mが0のときはループ状態でなく且つネ
ストがなく、LSの値mが1のときループ状態であるが
ネストがなく、LSの値mが2以上のときはループ状態
であり且つネストを成しており、そのときLSの値mだ
けネストの深さがある。このループのネストの判定結果
は、ネスト判定回路124からスイッチ切り替え判定回
路107に与えられるようになっている。
The loop nest decision circuit 124 receives the output LS of the controller 106 at its input,
This is to determine the nesting state of the loop. The value m (0 to n) of this LS is the stack 10 of the loop at that time.
The number of stages 1, 102, 103 is shown, which is equivalent to the state of the nest of the loop currently being executed. For example, when the value m of LS is 0, there is no loop and there is no nesting. When the value m of LS is 1, there is a loop but there is no nesting, and when the value m of LS is 2 or more, it is a looping state. Yes and there is nesting, then there is a nesting depth of LS value m. The nest determination result of this loop is given from the nest determination circuit 124 to the switch switching determination circuit 107.

【0024】PC用のカウンタ104は、実行すべきプ
ログラムのアドレスを生成するためのものであり、スイ
ッチ108を介してPCの値として出力されるようにな
っている。PC用カウンタ104の値は1ずつ増加する
ようになっているが、ループの実行の初めに、スタック
101に格納されたスタートアドレスのうち、LSの値
mが指し示すループのスタートアドレスが取り込まれる
ようになっている。
The PC counter 104 is for generating the address of the program to be executed, and is output as the PC value via the switch 108. Although the value of the PC counter 104 is incremented by 1, the start address of the loop indicated by the value m of LS among the start addresses stored in the stack 101 is taken in at the beginning of execution of the loop. It has become.

【0025】エンドアドレス比較回路105は、PC用
カウンタ104が生成したアドレスと、ループ・エンド
・アドレスを格納したスタックエリア102のうちLS
の値mが指し示す値A即ち現在のネストされているル
ープ・エンド・アドレスAとを比較するためのもので
ある。これによって、実行中のプログラムがそのループ
の最後であるかどうかが判定され、その結果はLSのコ
ントローラ106、スイッチ切り替え判定回路107及
びループ回数判定・更新回路123に与えられるように
なっている。
The end address comparison circuit 105 is the LS of the stack area 102 storing the address generated by the PC counter 104 and the loop end address.
That value m is indicated the value A m is for comparing the loop end address A m that is currently nested. As a result, it is determined whether the program being executed is the end of the loop, and the result is given to the LS controller 106, the switch switching determination circuit 107, and the loop number determination / update circuit 123.

【0026】エンドアドレス比較回路105において、
PC用カウンタ104が生成したアドレスとLSの値m
が指し示すループ・エンド・アドレスとを比較した結
果、これらが違えば、PC用カウンタ104の値がPC
の値として出力され、次ステップの命令がフェッチされ
る。これは図4でいえば符号403に対応し「NO」の
場合の分岐になる。比較した結果、これらが同じであ
る、即ち、PC用カウンタ104の値がループエンドア
ドレスを示し、そのループの終了を示している事にな
る。このときの結果は、LSのコントローラ106、ス
イッチ切り替え判定回路107及びループ回数判定・更
新回路123に与えられ、ループの終了の処理が行われ
る。
In the end address comparison circuit 105,
Address generated by PC counter 104 and LS value m
If they are different as a result of comparison with the loop end address pointed to by the
Is output as the value of and the instruction of the next step is fetched. This corresponds to reference numeral 403 in FIG. 4, and is a branch in the case of “NO”. As a result of comparison, these are the same, that is, the value of the PC counter 104 indicates the loop end address and indicates the end of the loop. The result at this time is given to the LS controller 106, the switch switching determination circuit 107, and the loop number determination / update circuit 123, and the process of ending the loop is performed.

【0027】親エンドアドレス比較回路121は、ルー
プが入れ子状態の場合に、ループのエンドアドレスがル
ープに対して一段上位のループのエンドアドレスと同じ
であるかを判定するものである。親エンドアドレス比較
回路121は、スタックエリア102のうちLSの値m
が指し示す現在のループ・エンド・アドレスAと、L
Sの値mよりも1小さいもの即ち親のループ・エンド・
アドレスAm−1とから、現在のループとその一段上位
である親のループとがともにループの最後であるかどう
かが判定され、その結果はLSのコントローラ106、
スイッチ切り替え判定回路107及びループ回数判定・
更新回路123に与えられるようになっている。
The parent end address comparison circuit 121 determines whether the end address of the loop is the same as the end address of the loop one step higher than the loop when the loop is in the nested state. The parent end address comparison circuit 121 uses the LS value m of the stack area 102.
And A m current loop-end address pointed, L
One less than the value m of S, that is, the loop end of the parent
It is determined from the address Am-1 whether the current loop and the parent loop, which is one step higher than the current loop, are the last of the loop, and the result is the controller 106 of the LS.
The switch switching determination circuit 107 and the loop count determination
It is provided to the update circuit 123.

【0028】ループ回数判定・更新回路123は、エン
ドアドレス比較回路105の比較結果からPC用カウン
タ104の値がループ・エンド・アドレスになった回数
をカウントして求め、この求めた回数とLSの値mが指
し示すスタックエリア103の内容である現在のループ
の回数(Cm)とを比較する。そして、現在実行されて
いるプログラムのループの回数が最後であるかを判定し
て、その結果をLSのコントローラ106及びスイッチ
切り替え判定回路107に与える。ループの回数が最後
である場合、LSの値mを減少させてスタックの位置を
更新し、あらたなスタック101の位置のループスター
トアドレスをPCの値を出力させる。
The loop number judging / updating circuit 123 counts and obtains the number of times the value of the PC counter 104 becomes the loop end address from the comparison result of the end address comparing circuit 105. The current loop count (Cm), which is the contents of the stack area 103 indicated by the value m, is compared. Then, it is determined whether or not the number of loops of the program currently being executed is the last, and the result is given to the LS controller 106 and the switch switching determination circuit 107. When the number of loops is the last, the value m of LS is decreased to update the position of the stack, and the value of PC is output as the loop start address at the position of the new stack 101.

【0029】親ループ回数判定回路122は、ループの
始まりを示す所定の命令があるとループ回数判定・更新
回路123でカウントしたループ回数を親のループ回数
として保存する。そして、その保存した値がLSの値m
より1小さい値で指し示すスタックエリア103の親の
ループ回数Cm−1と比較し、親のループが最後である
かどうかを判定する。その結果は、LSのコントローラ
106及びスイッチ切り替え判定回路107に与えら
れ、ループ回数判定・更新回路123の結果と共に用い
られるようになっている。
The parent loop number judging circuit 122 stores the loop number counted by the loop number judging / updating circuit 123 as the parent loop number when there is a predetermined instruction indicating the start of the loop. The stored value is the LS value m
It is determined whether or not the parent loop is the last by comparing with the parent loop count C m−1 of the stack area 103 indicated by a smaller value. The result is given to the LS controller 106 and the switch switching determination circuit 107, and is used together with the result of the loop number determination / update circuit 123.

【0030】スイッチ切り替え判定回路107は、ネス
ト判定回路124、エンドアドレス比較回路105、エ
ンドアドレス比較回路105、親エンドアドレス比較回
路121、ループ回数判定・更新回路123、親ループ
回数判定回路122の判定結果からスイッチ(SW)1
08の切り替えを制御するものであり、SW108を介
して、PC用カウンタ104からのアドレスか、スタッ
ク101に格納されたスタートアドレスのうち、LSの
値mが指し示すループのスタートアドレスかのいずれか
PCとして出力されるようになっている。このPCの値
が実行すべきプログラムのアドレスを示し、それに従っ
た制御がそのCPUやDSPなどの集積回路において行
われるようになっている。
The switch changeover judging circuit 107 judges by the nest judging circuit 124, the end address comparing circuit 105, the end address comparing circuit 105, the parent end address comparing circuit 121, the loop number judging / updating circuit 123, and the parent loop number judging circuit 122. Switch (SW) 1 from the result
08 switching control, and is either the address from the PC counter 104 via the SW 108 or the start address of the loop indicated by the LS value m among the start addresses stored in the stack 101. Is output as. The value of the PC indicates the address of the program to be executed, and the control according to the value is performed in the integrated circuit such as the CPU or DSP.

【0031】つぎに、この回路の動作を説明する。Next, the operation of this circuit will be described.

【0032】プログラムがループ中でない場合、LSの
値mが0であり、PC用カウンタ104からのアドレス
がPCとして出力され、アドレスをインクリメントしな
がら順にプログラムが実行されて行く。これは、図4で
いえば符号401及び符号402の動作になり、符号4
03の「NO」の場合の分岐になる。
When the program is not in a loop, the value m of LS is 0, the address from the PC counter 104 is output as the PC, and the program is sequentially executed while incrementing the address. This is the operation of reference numerals 401 and 402 in FIG.
In the case of “NO” in 03, the process is branched.

【0033】プログラム実行中に、ループの始まりを示
す所定の命令があると、LSの値mをインクリメント
し、そのループのスタートアドレス、エンドアドレス、
ループの回数C0〜Cnがスタック101,102,1
03のLSの値mが示す位置に格納される。そして、P
Cの値がそのループのエンドアドレスになるまで、アド
レスをインクリメントし次ステップの命令をフェッチし
ながら順にプログラムが実行されて行く。
During execution of the program, if there is a predetermined instruction indicating the beginning of the loop, the value m of LS is incremented, and the start address, end address,
The number of loops C0 to Cn is the stack 101, 102, 1
It is stored at the position indicated by the value m of the LS of 03. And P
The program is sequentially executed while incrementing the address and fetching the instruction of the next step until the value of C becomes the end address of the loop.

【0034】PCの値がそのループのエンドアドレスに
なると、これが現在のループのエンド・アドレスA
一致するためエンドアドレス比較回路105で検出され
る。そして、ループ回数判定・更新回路123で、現在
実行されているプログラムのループの回数を判定する。
これは、図4でいえば符号403から符号404への分
岐と等価である。
When the value of PC becomes the end address of the loop, it coincides with the end address A m of the current loop and is detected by the end address comparison circuit 105. Then, the loop number determination / update circuit 123 determines the number of loops of the program currently being executed.
This is equivalent to the branch from reference numeral 403 to reference numeral 404 in FIG.

【0035】現在実行中のプログラムのループの回数が
ループの回数Cmよりも小さい、すなわちループの回数
が最後でない場合、LSの値mの値はそのままであり、
LSの値mが指し示すスタックエリア101にあるその
ループのスタートアドレスをPCとして出力するととも
に、これをPC用カウンタ104に格納してそのループ
のスタートから次ステップの命令をフェッチしながら順
にプログラムの実行が繰り返される。こうしてPCをL
Sの値mが指し示すスタックエリア101にある現在の
ループスタートアドレスで更新させて実行される。これ
は、図4でいえば符号405の「NO」の場合の分岐と
等価である。
When the number of loops of the program currently being executed is smaller than the number of loops Cm, that is, when the number of loops is not the last, the value of LS, m, remains unchanged,
The start address of the loop in the stack area 101 indicated by the value m of LS is output as a PC, stored in the PC counter 104, and the program is executed sequentially while fetching the instruction of the next step from the start of the loop. Is repeated. In this way PC
It is updated and executed with the current loop start address in the stack area 101 indicated by the value m of S. This is equivalent to the branch in the case of “NO” of reference numeral 405 in FIG.

【0036】現在実行中のプログラムのループの回数が
ループの回数Cmと同じ、すなわちループの回数が最後
である場合、これは、図4でいえば符号405の「YE
S」の場合の分岐と等価である。しかし、この実施の態
様では、親エンドアドレス比較回路121及び親ループ
回数判定回路122で、そのときのPCの値が親ループ
のエンドアドレスAm−1及び親のループ回数Cm−1
の値の両方が最後であるかどうかが判定される。この点
が実施の態様の特徴である。
When the number of loops of the program currently being executed is the same as the number of loops Cm, that is, when the number of loops is the last, this is indicated by reference numeral 405 "YE" in FIG.
It is equivalent to the branch in the case of "S". However, in this embodiment, in the parent end address comparison circuit 121 and the parent loop number determination circuit 122, the PC value at that time is the parent loop end address A m−1 and the parent loop number C m−1.
It is determined if both of the values of are last. This point is a feature of the embodiment.

【0037】現在実行中のプログラムのループの回数が
ループの回数Cmと同じである場合、ループの回数が最
後であるので、ループ回数判定・更新回路123で最後
であると判定され、LSのコントローラ106はLSの
値mを1減少させる。そして、親エンドアドレス比較回
路121でPCの値が、そのループの親ループのエンド
アドレスかが判定される。
When the number of loops of the program currently being executed is the same as the number of loops Cm, the number of loops is the last, so the loop number determining / updating circuit 123 determines that the number is the last, and the LS controller 106 reduces the value m of LS by 1. Then, the parent end address comparison circuit 121 determines whether the value of PC is the end address of the parent loop of the loop.

【0038】PCの値がそのループの親ループのエンド
アドレスでなかった場合、SW108によりPC用カウ
ンタ104の値がPCの値として出力される。そして、
PC用カウンタ104の値即ちPCの値が1増加しアド
レスがインクリメントすることによって、そのループを
抜け出し親ループにもどる。そして、この親ループにつ
いて引き続き次ステップの命令をフェッチしながら順に
プログラムを実行する。
When the PC value is not the end address of the parent loop of the loop, the SW 108 outputs the value of the PC counter 104 as the PC value. And
When the value of the PC counter 104, that is, the value of PC is incremented by 1 and the address is incremented, the loop is exited and the process returns to the parent loop. The program is sequentially executed while fetching the next step instruction for this parent loop.

【0039】PCの値がそのループの親ループのエンド
アドレスであった場合、実行していたループは最後であ
り、PCの値が示すそのアドレスが実行していたループ
の親のループの終了のアドレスであるが、親のループは
終了しているものとは限らない。そのため、LSの値m
が2以上すなわちネスト状態が2以上であれば、親ルー
プ回数判定回路122で、親のループ回数Cm−1が最
後になっているかどうか判定される。
If the value of PC is the end address of the parent loop of the loop, the loop being executed is the last one, and the end of the loop of the parent of the loop having the address indicated by PC is the end of the loop. Although it is an address, the parent loop is not always finished. Therefore, the value of LS m
Is 2 or more, that is, the nesting state is 2 or more, the parent loop number determination circuit 122 determines whether or not the parent loop number C m−1 is the last.

【0040】親のループ回数Cm−1が最後になってい
ない場合、LSの値mが1、即ちネスト状態が1の場合
と同じであり、当該プロセスは実行中であり、親のルー
プは終了していないため、スタック101のうち、LS
の値mを1減少させた値(m−1)で指示される位置に
格納された親のループのスタートアドレスが選択され、
SW108によりPCの値として出力される。そして、
このスタートアドレスはPC用カウンタ104の初期値
として取り込まれ、SW108によりPC用カウンタ1
04の値がPCの値として出力される。そして、PC用
カウンタ104の値即ちPCの値が1増加しアドレスが
インクリメントすることによって、親ループの初めから
動作が繰り返される。
When the parent loop count C m-1 is not the last, the same as when the LS value m is 1, that is, the nesting state is 1, the process is running, and the parent loop is Since it is not finished, LS in the stack 101
The start address of the parent loop stored in the position indicated by the value (m-1) obtained by decrementing the value m of 1 by 1 is selected,
It is output as the value of PC by SW108. And
This start address is fetched as the initial value of the PC counter 104, and the PC counter 1 is set by the SW 108.
The value of 04 is output as the value of PC. Then, the value of the PC counter 104, that is, the value of PC is incremented by 1 and the address is incremented, whereby the operation is repeated from the beginning of the parent loop.

【0041】親のループ回数Cm−1が最後になってい
る場合、親のループは終了であるため、スタック101
のうち、LSの値mを2減少させた値(m−2)で指示
される位置に格納された親のループのさらに親のループ
のスタートアドレスが選択され、SW108によりPC
の値として出力される。そして、同様に、このスタート
アドレスはPC用カウンタ104の初期値として取り込
まれ、SW108によりPC用カウンタ104の値がP
Cの値として出力される。PC用カウンタ104の値即
ちPCの値が1増加しアドレスがインクリメントするこ
とによって、親のループのさらに親ループの初めから動
作が繰り返される。
When the parent loop count C m-1 is the last, the parent loop is finished, so the stack 101
Of these, the start address of the parent loop stored in the position indicated by the value (m−2) obtained by reducing the value m of LS by 2 is selected, and the start address of the parent loop is selected by the SW 108.
Is output as the value of. Then, similarly, this start address is fetched as the initial value of the PC counter 104, and the value of the PC counter 104 is set to P by the SW 108.
It is output as the value of C. By increasing the value of the PC counter 104, that is, the value of PC by 1 and incrementing the address, the operation is repeated from the beginning of the parent loop of the parent loop.

【0042】この実施の態様の場合は、ループが終了し
たアドレスにおいて、更新されるPCの値が3種類であ
り3分岐であることになるが、ループおよびその親ルー
プが終了したアドレスが同じであっても、ループの実行
の状態を判定してPCの値セットし、それぞれの分岐に
応じた正しい処理を実行することができる。
In the case of this embodiment, there are three types of PC values to be updated at the address where the loop ends, and there are three branches, but the address where the loop and its parent loop end are the same. Even if there is, it is possible to judge the execution state of the loop, set the value of the PC, and execute the correct processing according to each branch.

【0043】このように、連続してネスト状態になって
いるループのエンドアドレスが同じになっていても、ル
ープが終了したアドレスから正しい分岐先のアドレスに
することができる。
As described above, even if the end addresses of the loops which are continuously nested are the same, the correct branch destination address can be set from the address where the loop ends.

【0044】なお、この実施の態様では、ネスト状態に
なっているループのエンドアドレスが連続して同じにな
っているものが2つの場合に利用可能になっているが、
同じになっているものが2つよりも大きい場合には、コ
ンパイル時に何等かの使用上の制限をつけるか、また
は、エンドアドレス比較回路と親ループ回数判定回路と
をさらに複数設けるようにして利用可能になる。
In this embodiment, it is possible to use the case where the end addresses of the loops in the nest state are the same in succession in two cases.
If the same number is greater than two, some usage restrictions are applied at the time of compilation, or a plurality of end address comparison circuits and parent loop count determination circuits are provided for use. It will be possible.

【0045】図2は、第2の実施の態様のブロック図を
示したものである。
FIG. 2 shows a block diagram of the second embodiment.

【0046】上記第1の実施の態様では、ループのエン
ドアドレスが連続して2つまでであったが、本実施の態
様では、ネストの状態を総括的に判断して多分岐するよ
うに改良した一例である。なお、上記第1の実施の態様
と同一もしくは同等の構成要素については同一の符号を
用いると共にその説明を省略するものとする。
In the first embodiment, the end address of the loop is up to two in succession, but in the present embodiment, the nest state is comprehensively judged and improved so as to make multiple branches. This is one example. It should be noted that the same reference numerals will be used for the same or equivalent constituent elements as those of the first embodiment, and the description thereof will be omitted.

【0047】この第2の実施の態様においても、ループ
のスタートアドレス,エンドアドレス,回数を格納する
スタックエリア101,102,103があり、これら
はループスタックポインタ(LS)のコントローラ10
6にて制御されている。これらのスタックには、上記第
1の実施の態様同様、0,1,…,nの順に積まれ、ル
ープスタックポインタ(以下LSとする)で指示された
位置(0〜n)にあるものの値が取り出されるようにな
っている。これらの値は、上記第1の実施の態様同様、
エンドアドレス比較回路105と、ループ回数・更新回
路131とに与えられるようになっている。そして、ス
タック102,103に格納されたループのエンドアド
レス及びループの回数は、すべてLSのベクトル判定回
路132に与えられるようになっている。
Also in this second embodiment, there are stack areas 101, 102 and 103 for storing the start address, end address and number of times of the loop, which are the controller 10 of the loop stack pointer (LS).
It is controlled by 6. As in the case of the first embodiment, the value of the stack is stacked in the order of 0, 1, ..., N and is located at the position (0 to n) pointed to by the loop stack pointer (hereinafter referred to as LS). Are taken out. These values are the same as in the first embodiment described above.
It is provided to the end address comparison circuit 105 and the loop count / update circuit 131. The end addresses of the loops and the number of loops stored in the stacks 102 and 103 are all provided to the LS vector determination circuit 132.

【0048】ループ回数・更新回路131は、上記第1
の実施の態様同様、エンドアドレス比較回路105の比
較結果からPC用カウンタ104の値がループ・エンド
・アドレスになった回数をカウントして求め、この求め
た回数とLSの値mが指し示すスタックエリア103の
内容である現在のループの回数(Cm)とを比較する。
そして、現在実行されているプログラムのループの回数
が最後であるかを判定して、その結果をLSのコントロ
ーラ106及びスイッチ切り替え判定回路107に与え
る。ループの回数が最後である場合、LSのベクトル判
定回路132に対し、LSの値mを減少させてスタック
の位置を更新し、新たなスタック101の位置のループ
スタートアドレスをPCの値を出力させる。
The loop count / update circuit 131 is the first
The number of times the value of the PC counter 104 becomes the loop end address is counted and obtained from the comparison result of the end address comparison circuit 105, and the stack area indicated by the obtained number and the value m of LS The content of 103 is compared with the current loop count (Cm).
Then, it is determined whether or not the number of loops of the program currently being executed is the last, and the result is given to the LS controller 106 and the switch switching determination circuit 107. When the number of loops is the last, the LS vector determination circuit 132 decreases the value m of LS to update the position of the stack, and outputs the value of PC as the loop start address of the position of the new stack 101. .

【0049】LSのベクトル判定回路132は、スタッ
ク102,103に格納されたループのエンドアドレス
及びループの回数と、エンドアドレス比較回路105の
比較結果及びループ回数・更新回路131の結果とか
ら、スイッチ(SW)108の切り替えを制御するもの
であり、また、ループスタックポインタをどれだけ変化
させるかをLSのコントローラ106に与える。この様
に、LSのベクトル判定回路には、現在のループでのエ
ンドアドレス比較結果と指定回数終了判定結果とループ
のスタックに積まれているエンドアドレス,回数の全て
のデータが入力されるようになっていて、後述するよう
なスイッチ108の切り替え制御が行われる。
The LS vector determination circuit 132 switches based on the loop end address and the loop count stored in the stacks 102 and 103, the comparison result of the end address comparison circuit 105, and the loop count / update circuit 131. It controls switching of the (SW) 108, and gives the LS controller 106 how much to change the loop stack pointer. In this way, the LS vector determination circuit is made to input all the data of the end address comparison result in the current loop, the specified number of times end determination result, the end address accumulated in the stack of the loop, and the number of times. Therefore, switching control of the switch 108 as described later is performed.

【0050】つぎに、この回路の動作を説明する。Next, the operation of this circuit will be described.

【0051】プログラムがループ中でない場合、LSの
値mが0であり、PC用カウンタ104からのアドレス
がPCとして出力され、アドレスをインクリメントしな
がら順にプログラムが実行されて行く。そして、プログ
ラム実行中に、ループの始まりを示す所定の命令がある
と、LSの値mをインクリメントし、そのループのスタ
ートアドレス、エンドアドレス、ループの回数C0〜C
nがスタック101,102,103のLSの値mが示
す位置に格納される。図4でいえば符号401及び符号
403までの動作になる。
When the program is not in the loop, the value m of LS is 0, the address from the PC counter 104 is output as PC, and the program is sequentially executed while incrementing the address. Then, during execution of the program, if there is a predetermined instruction that indicates the beginning of a loop, the value m of LS is incremented, and the start address, end address, and loop count C0 to C of that loop are obtained.
n is stored in the position indicated by the LS value m of the stack 101, 102, 103. In FIG. 4, operations up to reference numerals 401 and 403 are performed.

【0052】PCの値がそのループのエンドアドレスに
なると、現在のループのエンド・アドレスAとの一致
がエンドアドレス比較回路105で検出される。そし
て、ループ回数・更新回路131で、現在実行されてい
るプログラムのループの回数を判定する。図4でいえば
符号403から符号404への分岐と等価である。
[0052] The value of the PC becomes the end address of the loop, coincident with the end address A m of the current loop is detected by the end address comparator circuit 105. Then, the loop count / update circuit 131 determines the number of loops of the program currently being executed. In FIG. 4, this is equivalent to the branch from reference numeral 403 to reference numeral 404.

【0053】現在実行中のプログラムのループの回数が
ループの回数Cmよりも小さい、すなわちループの回数
が最後でない場合、LSの値mの値はそのままであり、
LSの値mが指し示すスタックエリア101にあるその
ループのスタートアドレスをPCとして出力するととも
に、これをPC用カウンタ104に格納してそのループ
のスタートから次ステップの命令をフェッチしながら順
にプログラムの実行が繰り返される。こうしてPCをL
Sの値mが指し示すスタックエリア101にある現在の
ループスタートアドレスで更新させて実行される。これ
は、図4でいえば符号405の「NO」の場合の分岐と
等価である。ここまでは、第1の実施の態様と同じであ
る。
When the number of loops of the program currently being executed is smaller than the number of loops Cm, that is, when the number of loops is not the last, the value of the value LS of m remains unchanged,
The start address of the loop in the stack area 101 indicated by the value LS of the LS is output as a PC, stored in the PC counter 104, and the program is executed sequentially while fetching the instruction of the next step from the start of the loop. Is repeated. In this way PC
It is updated and executed with the current loop start address in the stack area 101 indicated by the value m of S. This is equivalent to the branch in the case of “NO” of reference numeral 405 in FIG. The process up to this point is the same as in the first embodiment.

【0054】現在実行中のプログラムのループの回数が
ループの回数Cmと同じ、すなわちループの回数が最後
である場合、この点に付いては、図4でいえば符号40
5の「YES」の場合の分岐と等価である。しかし、こ
の実施の態様では、LSのベクトル判定回路132での
判定が異なっている。
When the number of loops of the program currently being executed is the same as the number of loops Cm, that is, when the number of loops is the last, this point is indicated by reference numeral 40 in FIG.
This is equivalent to the branch in the case of “YES” of 5. However, in this embodiment, the determination by the LS vector determination circuit 132 is different.

【0055】まず、LSのベクトル判定回路132で、
そのときのPCの値が親ループのエンドアドレスA
m−1及び親のループ回数Cm−1の値の両方が最後で
あるかどうかが判定される。
First, in the LS vector determination circuit 132,
The PC value at that time is the end address A of the parent loop.
Both the number of loops C m-1 of the value of the m-1 and the parent whether the last is determined.

【0056】そして、現在実行中のプログラムのループ
の回数がループの回数Cmと同じである場合、ループの
回数が最後であるので、LSのベクトル判定回路132
で最後であると判定され、LSのコントローラ106は
LSの値mを1減少させる。PCの値がそのループの親
ループのエンドアドレスAm−1でなかった場合、SW
108によりPC用カウンタ104の値がPCの値とし
て出力される。そして、PC用カウンタ104の値即ち
PCの値が1増加しアドレスがインクリメントすること
によって、そのループを抜け出し親ループにもどる。そ
して、この親ループについて引き続き次ステップの命令
をフェッチしながら順にプログラムを実行する。
When the number of loops of the program currently being executed is the same as the number of loops Cm, the number of loops is the last, so the LS vector determination circuit 132
Then, the LS controller 106 decrements the LS value m by 1. If the value of PC is not the end address Am-1 of the parent loop of the loop, SW
The value of the PC counter 104 is output by 108 as the value of the PC. Then, when the value of the PC counter 104, that is, the value of PC is incremented by 1 and the address is incremented, the loop is exited to return to the parent loop. The program is sequentially executed while fetching the next step instruction for this parent loop.

【0057】PCの値がそのループの親ループのエンド
アドレスAm−1であった場合、実行していたループは
最後であり、PCの値が示すそのアドレスが実行してい
たループの親のループの終了のアドレスである。この場
合、LSの値mよりも2小さいさらに親のループについ
て同様の判定が行われる。即ち、LSのベクトル判定回
路132で、さらに親のループ回数Cm−2が最後にな
っているかどうか判定され、PCの値がさらに親のルー
プのエンドアドレスAm−2になっているかどうか判定
される。
When the value of PC is the end address Am-1 of the parent loop of the loop, the loop being executed is the last one, and the address indicated by the value of PC is the parent of the loop being executed. This is the address of the end of the loop. In this case, the same determination is made for the parent loop that is 2 smaller than the value m of LS. That is, the LS vector determination circuit 132 further determines whether or not the parent loop count C m-2 is the last, and determines whether the PC value is further equal to the parent loop end address A m-2. To be done.

【0058】ループ回数Cm−2が最後でない、或いは
エンドアドレスAm−2になっていない場合、LSの値
mを2小さく即ちm−2にして、さらに親のループの処
理が実行される。そうでない場合は、LSの値mよりも
3小さいさらに親のループについて同様の判定が行われ
る。
When the loop count C m-2 is not the last or the end address A m-2 is not reached, the value m of LS is reduced by 2, that is, m-2, and the processing of the parent loop is further executed. . Otherwise, a similar determination is made for the parent loop that is 3 less than the LS value m.

【0059】このようにループ回数が最後でかつエンド
アドレスであれば、ループ回数が最後でない或いはエン
ドアドレスではなくなるまでLSの値を小さくし、その
LSの値で示されるスタックに格納されたループのスタ
ートアドレスで或いはPCの値をインクリメントしたア
ドレスで処理が行なわれる。
As described above, when the loop count is the last and the end address, the value of LS is reduced until the loop count is not the last or the end address, and the loop stored in the stack indicated by the value of LS Processing is performed at the start address or at the address obtained by incrementing the PC value.

【0060】図3は、このベクトル判定回路132の一
動作例を示す図である。図の左側に示すようにアドレス
データA0,A1,…,Am−1,Amはループエンド
アドレスのスタック102に積まれ(スタックはA0→
Anの順に積まれる)、図の中央付近に示すようにルー
プ回数のデータをC0,C1,…,Cm−1,Cm,
…,Cnはループ回数のスタックに積まれ、現在のルー
プの基準を示しているポインタLSの値mを示している
ようすである。
FIG. 3 is a diagram showing an operation example of the vector determination circuit 132. As shown on the left side of the figure, the address data A0, A1, ..., Am-1, Am are stacked on the stack 102 of the loop end address (the stack is A0 →
An are stacked in the order of An), and as shown near the center of the figure, the data of the number of loops is C0, C1, ..., Cm-1, Cm,
, Cn are stacked on the stack corresponding to the number of loops and indicate the value m of the pointer LS indicating the current loop reference.

【0061】まず、ベクトル判定回路132は、エンド
アドレス比較回路105の比較結果とループ回数・更新
回路131の指定回数終了の判定結果とから、現在のル
ープが終了したときにおいて、エンドアドレスに対して
のベクトル量(Va)とループ回数に対してのベクトル
量(Vc)を求める。
First, based on the comparison result of the end address comparison circuit 105 and the judgment result of the loop count / update circuit 131 that the designated number of times has ended, the vector judgment circuit 132 determines that the end address is reached when the current loop ends. Vector amount (Va) and vector amount (Vc) for the number of loops.

【0062】ベクトル量Vaは、現在のループのエンド
アドレスAmを基準としてネストの浅い方向(Am−
1,Am−2,…,A0の順)にエンドアドレスAmと
異なるエンドアドレスまでのネストの段数を示したもの
である。これは、エンドアドレスAmが親のループのエ
ンドアドレスと同じ場合におけるネストの段数となって
いる。
The vector amount Va is determined in the shallow direction of the nest (Am- with reference to the end address Am of the current loop).
1, Am-2, ..., A0), the number of nest stages up to an end address different from the end address Am is shown. This is the number of nest stages when the end address Am is the same as the end address of the parent loop.

【0063】ベクトル量Vcは、ループの指定回数Cm
が最後を示す値となっている場合にLSの値mを基準と
してネストの浅い方向(Cm−1,Cm−2,…,C0
の順)にループの指定回数が最後を示す値が連続してい
るネストの段数で示す。
The vector amount Vc is the designated number of times Cm of the loop.
Is a value indicating the end, the shallow direction (Cm-1, Cm-2, ..., C0) of the nest with reference to the value m of LS.
In the order of), the number of times the loop is specified is the end of the loop.

【0064】ネストの段数(ベクトル量)が2の場合に
おいて、ループのエンドアドレスAmにおいてLSの値
mを変化させるベクトル量は、図の右側に示すように、
次の通りである。
When the number of nest stages (vector amount) is 2, the vector amount for changing the LS value m at the loop end address Am is as shown on the right side of the figure.
It is as follows.

【0065】Va>Vcのとき Vc Va=Vcのとき Va又はVc Va<Vcのとき Va その他の状態についても、エンドアドレスの比較結果と
指定回数終了の判定結果から、上記と同様にしてLSの
値mを変化させて更新する。
When Va> Vc When Vc Va = Vc When Va or Vc When Va <Vc Va For other states as well, from the end address comparison result and the determination result of the specified number of times, LS The value m is changed and updated.

【0066】その後、ベクトル判定回路132から出力
されるSW制御信号にてPC用カウンタ104またはL
Sコントローラ106からのLSの値mで示されている
ループスタートアドレスとを切り替えPCの値になって
いる。この実施の態様の場合はPCに更新される種類が
多種類であり、多分岐であることになる。
Thereafter, the SW counter signal output from the vector determination circuit 132 is used for the PC counter 104 or L.
The loop start address indicated by the value m of LS from the S controller 106 is switched to the value of PC. In the case of this embodiment, there are many types to be updated in the PC, which means multi-branching.

【0067】この実施の態様の場合でも、ループが終了
したアドレスにおいて、そのループおよびその親ループ
やさらにその親のループのエンドアドレスが同じであっ
ても、ループの実行の状態を判定してPCの値をセット
し、それぞれの分岐に応じた正しい処理を実行すること
ができる。
Even in the case of this embodiment, even if the end address of the loop, its parent loop and its parent loop are the same at the address where the loop ends, the execution state of the loop is judged and PC You can set the value of and execute the correct processing according to each branch.

【0068】このように、連続してネスト状態になって
いるループのエンドアドレスが同じになっていても、ル
ープが終了したアドレスから正しい分岐先のアドレスに
することができる。
As described above, even if the end addresses of the loops that are continuously nested are the same, the correct branch destination address can be set from the address where the loop ends.

【0069】以上、述べてきたように本発明によれば、
ハードウェアを用いたループの制御においてPCに設定
するアドレスを複数設定することで処理の状態に合わせ
て多分岐することが可能となる。このため従来の技術に
て使用されていたようなNOP命令などの無処理のプロ
グラム等をなくしつつ余分な時間をなくすことが可能と
なる。
As described above, according to the present invention,
By setting a plurality of addresses to be set in the PC in the control of the loop using hardware, it is possible to perform multi-branching in accordance with the processing state. Therefore, it is possible to eliminate extra time while eliminating unprocessed programs such as NOP instructions used in the conventional technique.

【0070】[0070]

【発明の効果】以上の通り、本願請求項1乃至3の発明
にかかるループの制御装置によれば、上述したように、
新たなスタックポインタで示されるループのスタートア
ドレスを前記プログラムカウンタの出力として前記プロ
グラムの実行を行うことにより、プログラムのループが
ネストしている状態において、そのループの終了アドレ
スを同じものにすることができる。
As described above, according to the loop control device of the inventions of claims 1 to 3, as described above,
By executing the program by using the start address of the loop indicated by the new stack pointer as the output of the program counter, the end address of the loop can be made the same when the loop of the program is nested. it can.

【0071】とくに、本願請求項3の発明にかかるルー
プの制御装置によれば、2以上の複数のループがネスト
している状態においても、そのループの終了アドレスを
同じものにすることができる。
Particularly, according to the loop control device of the third aspect of the present invention, even when two or more loops are nested, the end address of the loop can be the same.

【0072】本願請求項4の発明にかかるループの制御
装置は、情報ビットによりネストの段数を示すことによ
り、プログラムカウンタの制御手段は、ループのスター
トを示す命令があったときに情報ビットからループのネ
ストの判定をすることができる。
In the loop control device according to the invention of claim 4, the number of nest stages is indicated by the information bit, so that the control means of the program counter loops from the information bit when there is an instruction indicating the start of the loop. You can judge the nesting of.

【0073】本願請求項5の発明にかかるループの制御
装置によれば、情報ビットにより一段上位のエンドアド
レスとが同じか否かを示すことにより、ループのスター
トを示す命令があったときに情報ビットからループのネ
ストの判定をすることができる。
According to the loop control device of the fifth aspect of the present invention, the information bit indicates whether or not the end address of the next higher stage is the same. It is possible to judge the nest of a loop from bits.

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

【図1】本発明の第1の実施の態様のブロック図。FIG. 1 is a block diagram of a first embodiment of the present invention.

【図2】本発明の第2の実施の態様のブロック図。FIG. 2 is a block diagram of a second embodiment of the present invention.

【図3】ベクトル判定回路132の一動作例を示す図。FIG. 3 is a diagram showing an operation example of a vector determination circuit 132.

【図4】CPUやDSPなどのハードウェアの動作をフ
ローチャートにして示した図。
FIG. 4 is a diagram showing an operation of hardware such as a CPU and a DSP in a flowchart.

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

101,102,103 スタック、 104 カウン
タ、105 エンドアドレス比較回路、106 ループ
スタックポインタのコントローラ、107 スイッチ切
り替え判定回路、121 親エンドアドレス比較回路、
122 親ループ回数判定回路、 123 ループ回数
判定・更新回路、124 ネスト判定回路
101, 102, 103 stacks, 104 counter, 105 end address comparison circuit, 106 loop stack pointer controller, 107 switch switching determination circuit, 121 parent end address comparison circuit,
122 parent loop number determination circuit, 123 loop number determination / update circuit, 124 nest determination circuit

Claims (5)

【特許請求の範囲】[Claims] 【請求項1】 順次実行すべきプログラムのアドレスを
指示するためのプログラムカウンタを制御することによ
って前記プログラムのループの制御を行うループの制御
装置であって、 前記プログラムのループのスタートアドレスを格納する
ための第1のスタックと、 前記ループのエンドアドレスを格納するための第2のス
タックと、 前記ループの回数を格納するための第3のスタックと、 前記カウンタによるアドレス値と前記第2のスタックの
うちスタックポインタで指示されたエンドアドレスとの
一致により前記ループの実行回数を計数し、 計数して得た前記ループの実行回数が前記第3のスタッ
クのうちスタックポインタで指示された前記ループの回
数になっている場合、前記スタックポインタで指示され
たエンドアドレスが前記第2のスタックのうち前記スタ
ックポインタの1少ない値で指示された一段上位のルー
プのエンドアドレスと同じであるかを比較し、 比較の結果同じである場合、前記ループの実行回数が、
前記一段上位のループの実行回数、またはこれより上位
のループの回数と等しくなっているときに、前記スタッ
クポインタの値を1または上位のループまで減少させる
とともに、新たなスタックポインタで示されるループの
スタートアドレスを前記プログラムカウンタの出力とし
て前記プログラムの実行を行うプログラムカウンタの制
御手段とを有するループの制御装置。
1. A loop control device for controlling a loop of the program by controlling a program counter for designating an address of a program to be sequentially executed, which stores a start address of the loop of the program. A second stack for storing the end address of the loop, a third stack for storing the number of times of the loop, an address value by the counter and the second stack The number of executions of the loop is counted according to the match with the end address indicated by the stack pointer, and the number of executions of the loop obtained by the counting is the number of executions of the loop indicated by the stack pointer of the third stack. If the number is the number of times, the end address designated by the stack pointer is the second It compares the same as the end address of a loop of one stage higher instructed by one less of the stack pointer of the stack, when the same result of the comparison, the number of executions of the loop,
When the number of executions of the loop one level higher or equal to the number of executions of the loop higher than this, is equal to the value of the stack pointer, the value of the stack pointer is decreased to 1 or the upper loop, and the loop indicated by the new stack pointer A control device for a loop having a program counter control means for executing the program by using a start address as an output of the program counter.
【請求項2】 プログラムカウンタの制御手段は、 計数することによって順次実行すべきプログラムのアド
レスを与えるためのカウンタと、 前記カウンタの計数値と、前記第1のスタックで前記ス
タックポインタで指示された位置に格納されたスタート
アドレスとを切り替えて前記プログラムカウンタの出力
とするスイッチと、 前記第1のスタックで前記スタックポインタにより指示
された位置に格納されたエンドアドレスと前記カウンタ
の計数値とから前記ループの最後のアドレスに等しいか
どうかを判定するためのエンドアドレス比較回路と、 前記ループの実行回数を計数し、計数して得た前記ルー
プの実行回数が、前記第1のスタックで前記スタックポ
インタにより指示された位置に格納されたループの回数
に等しいかどうかを判定するためのループ回数判定回路
と、 前記スタックポインタで指示されたエンドアドレスが前
記第2のスタックのうち前記スタックポインタが示す値
より1少ない値で指示された一段上位のループのエンド
アドレスに等しいかを判定するための親エンドアドレス
比較回路と、 前記ループの実行回数が、前記一段上位のループの実行
回数と等しいかを判定するための親ループ回数判定回路
と、 前記エンドアドレス比較回路、前記ループ回数判定回
路、前記親エンドアドレス比較回路及び前記親ループ回
数判定回路の判定の結果等しいとされた場合に、前記ス
タックポインタの値を1減少させるスタックポインタの
コントローラと、 を含んで構成され、 前記コントローラによって1減少させた新たなスタック
ポインタで示されるループのスタートアドレスを前記ス
イッチから前記プログラムカウンタの出力として前記プ
ログラムの実行を行う請求項1記載のループの制御装
置。
2. The control means of the program counter, a counter for giving an address of a program to be sequentially executed by counting, a count value of the counter, and an instruction of the stack pointer in the first stack. A switch for switching the start address stored in the position to the output of the program counter, the end address stored in the position designated by the stack pointer in the first stack, and the count value of the counter An end address comparison circuit for determining whether it is equal to the last address of the loop, counting the number of executions of the loop, and the number of executions of the loop obtained by counting is the stack pointer in the first stack. Determines if it is equal to the number of loops stored in the position pointed to by And a loop number determination circuit for determining whether the end address indicated by the stack pointer is equal to the end address of the loop one step higher than the value indicated by the stack pointer in the second stack by one. Parent end address comparison circuit for determining, the execution count of the loop, the parent loop number determination circuit for determining whether the execution count of the loop one step higher than the loop, the end address comparison circuit, the loop A stack pointer controller that decrements the value of the stack pointer by 1 when the results of the determinations of the number of times determination circuit, the parent end address comparison circuit, and the parent loop number determination circuit are equal, Start of loop indicated by new stack pointer decremented by controller Controller of the loop of claim 1, wherein the dress from the switch the execution of the program as an output of the program counter.
【請求項3】 プログラムカウンタの制御手段は、 計数することによって順次実行すべきプログラムのアド
レスを与えるためのカウンタと、 前記カウンタの計数値と、前記第1のスタックで前記ス
タックポインタで指示された位置に格納されたスタート
アドレスとを切り替えて前記プログラムカウンタの出力
とするスイッチと、 前記第1のスタックで前記スタックポインタにより指示
された位置に格納されたエンドアドレスと前記カウンタ
の計数値とから前記ループの最後のアドレスに等しいか
どうかを判定するためのエンドアドレス比較回路と、 前記ループの実行回数を計数し、計数して得た前記ルー
プの実行回数が、前記第1のスタックで前記スタックポ
インタにより指示された位置に格納されたループの回数
に等しいかどうかを判定するためのループ回数判定回路
と、 前記スタックポインタで指示されたエンドアドレスが前
記第2のスタックのうち前記スタックポインタが示す値
より少ない値で指示された上位のループのエンドアドレ
スに等しいかを判定するための親エンドアドレス比較回
路と、 前記ループの実行回数が、前記上位のループの実行回数
と等しいかを判定するための親ループ回数判定回路と、 前記エンドアドレス比較回路、前記ループ回数判定回路
及び前記親エンドアドレス比較回路が等しいとされた場
合に、前記親ループ回数判定回路の判定の結果が等しい
とされる前記上位のループまで、前記スタックポインタ
の値を1減少させるスタックポインタのコントローラ
と、 を含んで構成され、 前記コントローラによって減少させた新たなスタックポ
インタで示されるループのスタートアドレスを前記スイ
ッチから前記プログラムカウンタの出力として前記プロ
グラムの実行を行う請求項1記載のループの制御装置。
3. The control means of the program counter, a counter for giving an address of a program to be sequentially executed by counting, a count value of the counter, and an instruction of the stack pointer in the first stack. A switch for switching the start address stored in the position to the output of the program counter, the end address stored in the position designated by the stack pointer in the first stack, and the count value of the counter An end address comparison circuit for determining whether it is equal to the last address of the loop, counting the number of executions of the loop, and the number of executions of the loop obtained by counting is the stack pointer in the first stack. Determines if it is equal to the number of loops stored in the position pointed to by And a loop number determination circuit for determining whether the end address indicated by the stack pointer is equal to the end address of the upper loop indicated by a value smaller than the value indicated by the stack pointer in the second stack. A parent end address comparison circuit for performing, the number of times the loop is executed, a parent loop number determination circuit for determining whether it is equal to the number of times the upper loop is executed, the end address comparison circuit, the loop number determination circuit And a controller of a stack pointer that decrements the value of the stack pointer by 1 up to the upper loop where the determination result of the parent loop number determination circuit is equal when the parent end address comparison circuit is equal. , A new stack pointer reduced by the controller Controller of the loop of which the start address of the loop from the switching program counter of claim 1, wherein the execution of the program as an output represented.
【請求項4】 前記プログラムのループのスタートを示
す命令は、当該ループのネストの段数を示す情報ビット
を有し、 前記プログラムカウンタの制御手段は、前記ループのス
タートを示す命令があったときに前記情報ビットから前
記ループのネストの判定をすることを特徴とする請求項
1記載のループの制御装置。
4. The instruction indicating the start of the loop of the program has an information bit indicating the number of nest stages of the loop, and the control means of the program counter controls when the instruction indicating the start of the loop is received. 2. The loop control device according to claim 1, wherein the loop nest is determined from the information bit.
【請求項5】 前記プログラムのループのスタートを示
す命令は、当該ループのエンドアドレスと該ループの一
段上位のエンドアドレスとが同じか否かを示す情報ビッ
トを有し、 前記プログラムカウンタの制御手段は、前記ループのス
タートを示す命令があったときに前記情報ビットから前
記ループのネストの判定をすることを特徴とする請求項
1記載のループの制御装置。
5. The instruction indicating the start of the loop of the program has an information bit indicating whether or not the end address of the loop is equal to the end address of the next higher stage of the loop, and the control means of the program counter. 2. The loop control device according to claim 1, wherein said loop bit is judged from said information bit when there is an instruction indicating the start of said loop.
JP22386095A 1995-08-31 1995-08-31 Controller for loop Pending JPH0969046A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP22386095A JPH0969046A (en) 1995-08-31 1995-08-31 Controller for loop

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP22386095A JPH0969046A (en) 1995-08-31 1995-08-31 Controller for loop

Publications (1)

Publication Number Publication Date
JPH0969046A true JPH0969046A (en) 1997-03-11

Family

ID=16804846

Family Applications (1)

Application Number Title Priority Date Filing Date
JP22386095A Pending JPH0969046A (en) 1995-08-31 1995-08-31 Controller for loop

Country Status (1)

Country Link
JP (1) JPH0969046A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7080239B2 (en) 2002-06-26 2006-07-18 Oki Electric Industry, Co., Ltd. Loop control circuit and loop control method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7080239B2 (en) 2002-06-26 2006-07-18 Oki Electric Industry, Co., Ltd. Loop control circuit and loop control method

Similar Documents

Publication Publication Date Title
US5507027A (en) Pipeline processor with hardware loop function using instruction address stack for holding content of program counter and returning the content back to program counter
KR0138468B1 (en) Microcomputer
JP2002516425A (en) Controller for digital processor
JP3237693B2 (en) Language processing apparatus and language processing method
JPH0969046A (en) Controller for loop
EP0270125B1 (en) Pipeline controlling system
JPH01269131A (en) Instruction precedence control system
US6718459B1 (en) Device and method for arithmetic processing
JP2526703B2 (en) Programmable controller
JP2921259B2 (en) Processing method of multi-branch instruction
JPH0256636A (en) Branching controller
JP2002297378A (en) Signal processor
JP2002041310A (en) Class dynamic bind system and its method
JP3638505B2 (en) Simulation apparatus and software simulation method for microprocessor
JP2504974B2 (en) Sequencer high-speed processing method
JPH0679271B2 (en) Loop control circuit
JPH05165640A (en) Microprocessor
JPH08272411A (en) Ladder instruction processor
JP3164690B2 (en) Address control device
JP3541498B2 (en) Data processing device
JPH07264784A (en) Power distribution system monitor
JPH05100720A (en) Managing device for program
JPH08129487A (en) Program sequence control circuit
JP2000222010A (en) Microcontroller for sequence control
JP2573391B2 (en) Programmable controller