JPH04364533A - Stack controller - Google Patents

Stack controller

Info

Publication number
JPH04364533A
JPH04364533A JP16637791A JP16637791A JPH04364533A JP H04364533 A JPH04364533 A JP H04364533A JP 16637791 A JP16637791 A JP 16637791A JP 16637791 A JP16637791 A JP 16637791A JP H04364533 A JPH04364533 A JP H04364533A
Authority
JP
Japan
Prior art keywords
data
stack
bidirectional buffer
stored
memory
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
JP16637791A
Other languages
Japanese (ja)
Inventor
Tsukasa Kobayashi
司 小林
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.)
Oki Electric Industry Co Ltd
Original Assignee
Oki Electric Industry 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 Oki Electric Industry Co Ltd filed Critical Oki Electric Industry Co Ltd
Priority to JP16637791A priority Critical patent/JPH04364533A/en
Publication of JPH04364533A publication Critical patent/JPH04364533A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To speed up access by decreasing the frequency of access to stack data through a data bus. CONSTITUTION:This stack controller is equipped with a two-way buffer 22 which can perform first-in, last-out operation and first-in, first-out operation. Stack data are stored in this two-way buffer 22 and not stored in a data memory 14 as long as its capacity allows. The data bus 16 is dedicated to data access. When the stack data are generated exceeding the capacity of the two- way buffer 22, a stack pointer 21 operates and stack data expelled from the two-way buffer 22 are stored in the data memory 14. When the stack data stored in the two-way buffer 22 decreases, the stack data are read out of the data memory 14 again and put back to the two-way buffer 22.

Description

【発明の詳細な説明】[Detailed description of the invention]

【0001】0001

【産業上の利用分野】本発明は、マイクロプロセッサが
演算処理を行う場合に、データの一時的な保持を目的と
して行うスタック動作を、効率的に実行できるスタック
制御装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a stack control device that can efficiently execute a stack operation for the purpose of temporarily holding data when a microprocessor performs arithmetic processing.

【0002】0002

【従来の技術】マイクロプロセッサが演算処理を行う場
合には、通常、外部メモリに格納された命令を読み出し
、更に外部メモリに格納されたデータを読み出して所定
の演算処理を施し、外部メモリに格納するといった動作
を行う。このような動作を行う場合には、その都度外部
メモリに対するアクセスを行うためのアドレス信号が発
生される。
[Background Art] When a microprocessor performs arithmetic processing, it usually reads instructions stored in external memory, then reads data stored in external memory, performs predetermined arithmetic processing, and stores the data in external memory. perform an action such as When performing such an operation, an address signal for accessing the external memory is generated each time.

【0003】図2に、このような処理を行う従来装置の
ブロック図を示す。図の装置は、マイクロプロセッサ1
−1 が外部メモリ2とアドレスバス3及びデータバス
4を介して接続された構成とされている。マイクロプロ
セッサ1−1 には、論理演算部5、プログラムカウン
タ6、スタックポインタ7、汎用レジスタ8及び外部バ
ス制御部9が設けられている。外部バス制御部9は、内
部バス10とアドレスバス3やデータバス4との間の入
出力を制御する回路である。ここで、論理演算部5が外
部メモリ2に対してアクセスを行う場合には、そのアド
レスがプログラムカウンタ6、スタックポインタ7ある
いは汎用レジスタ8から出力される。プログラムカウン
タ6により示されるアドレスによってアクセスする場合
を命令フェッチ、汎用レジスタ8により示されるアドレ
スによってアクセスする場合を、データリード/ライト
、スタックポインタ7により示されるアドレスによって
アクセスする場合をスタックプッシュ/ポップと呼んで
いる。図3に、このような形でアクセスされる図2に示
す外部メモリ2のメモリアドレス空間説明図を示す。
FIG. 2 shows a block diagram of a conventional device that performs such processing. The device shown is a microprocessor 1
-1 is connected to an external memory 2 via an address bus 3 and a data bus 4. The microprocessor 1-1 is provided with a logic operation section 5, a program counter 6, a stack pointer 7, a general-purpose register 8, and an external bus control section 9. The external bus control unit 9 is a circuit that controls input/output between the internal bus 10 and the address bus 3 and data bus 4. Here, when the logical operation unit 5 accesses the external memory 2, the address is output from the program counter 6, stack pointer 7, or general-purpose register 8. Accessing by the address indicated by the program counter 6 is called an instruction fetch, accessing by the address indicated by the general register 8 is called a data read/write, and accessing by the address indicated by the stack pointer 7 is called a stack push/pop. I'm calling. FIG. 3 shows an explanatory diagram of the memory address space of the external memory 2 shown in FIG. 2, which is accessed in this manner.

【0004】図に示すように、メモリアドレス空間を0
000〜FFFFの広さに設定したとする。この場合、
プログラムは例えば2000番地〜3000番地のアド
レスに格納され、データは8000番地〜9000番地
に格納される。またスタックデータは更に別の6000
〜6500番地に格納される。従って、マイクロプロセ
ッサ1がこのようなアドレス空間18をアクセスする場
合には、まずプログラムを呼び出し、所定の演算処理を
行い、その結果をデータとして格納し、演算途中で一時
的に保持が必要となったスタックデータをメモリに書き
込むといった処理が行われる。このように、プログラム
とスタックデータ及びデータは、それぞれ全く異なった
アドレス空間に格納されるため、一組のアドレスバス3
及びデータバス4を使用してアクセスを行うと、アドレ
スの局所性及び連続性が小さくなってしまう。
As shown in the figure, the memory address space is set to 0.
Assume that the width is set to 000 to FFFF. in this case,
Programs are stored, for example, at addresses 2000 to 3000, and data are stored at addresses 8000 to 9000. Also, the stack data is another 6000
It is stored at addresses ~6500. Therefore, when the microprocessor 1 accesses such an address space 18, it must first call a program, perform a predetermined calculation process, store the result as data, and temporarily hold it during the calculation. Processing such as writing the stack data to memory is performed. In this way, the program, stack data, and data are stored in completely different address spaces, so a set of address buses 3
If access is performed using the data bus 4 and the data bus 4, the locality and continuity of addresses will be reduced.

【0005】アドレスの局所性というのは、アドレス空
間の一部を連続的にアクセスするような性質をいう。集
中した領域を連続的にアクセスすれば、通常、アドレス
信号の生成が高速になり、高速アクセスが可能となる。 例えば16ビットのアドレス信号のうち、下位数ビット
のみが変化するようなアクセスは、極めて高速に行うこ
とができる。更にそのアドレスが単純にインクリメント
され、或はデクリメントされるような連続性がある場合
には、より一層の高速アクセスが可能となる。
[0005] Address locality refers to the property that a part of the address space is accessed continuously. If a concentrated area is accessed continuously, address signals can normally be generated at high speed and high-speed access is possible. For example, an access in which only the lower several bits of a 16-bit address signal change can be performed at extremely high speed. Furthermore, if there is continuity such that the address is simply incremented or decremented, even faster access becomes possible.

【0006】ところが、上記のような演算処理実行の際
、プログラムとデータを交互にアクセスするような処理
を行えば、このような高速処理を妨げることになる。 図4には、上記のような問題を解決するために、命令の
アクセスとデータのアクセスをそれぞれ別々のバスを介
して行うようにした、従来の別の装置のブロック図を示
した。図のマイクロプロセッサ1−2 は、図2に示し
たマイクロプロセッサ1−1 と同様に、論理演算部5
、プログラムカウンタ6、スタックポインタ7及び汎用
レジスタ8を備えている。そして、これらと内部バス1
0を介して、命令用バス制御部11とデータ用バス制御
部12が接続されている。命令用バス制御部11は命令
用メモリ13に対し、命令用バス15を介して接続され
ている。 またデータ用バス制御部12はデータ用メモリ14に対
しデータ用バス16を介して接続されている。
However, when performing the above-mentioned arithmetic processing, if the program and data are accessed alternately, such high-speed processing will be hindered. FIG. 4 shows a block diagram of another conventional device in which instruction access and data access are performed via separate buses in order to solve the above problems. The microprocessor 1-2 shown in the figure has a logic operation unit 5 similar to the microprocessor 1-1 shown in FIG.
, a program counter 6, a stack pointer 7, and a general-purpose register 8. And these and internal bus 1
The instruction bus control section 11 and the data bus control section 12 are connected through the bus control section 0. The instruction bus control section 11 is connected to the instruction memory 13 via an instruction bus 15. Further, the data bus control unit 12 is connected to the data memory 14 via a data bus 16.

【0007】上記の構成のマイクロプロセッサ1−2 
は、プログラムカウンタ6を用いてアクセスする命令フ
ェッチについては、専ら命令用バス15を介して命令用
メモリ13をアクセスする。また汎用レジスタ8による
データリード/ライト及びスタックポインタ7によるス
タックプッシュ/ポップについては、データ用バス制御
部12とデータ用バス16を介してデータ用メモリ14
に対しアクセスする。その結果、プログラムに対するア
クセスとデータに対するアクセスが別々の命令用バス1
5及びデータ用バスに16を介して行われるため、先に
説明したアドレスの局所性や連続性を改善できる。
Microprocessor 1-2 having the above configuration
For instruction fetch accessed using the program counter 6, the instruction memory 13 is accessed exclusively via the instruction bus 15. Data read/write by the general-purpose register 8 and stack push/pop by the stack pointer 7 are performed by the data memory 14 via the data bus control unit 12 and the data bus 16.
access to. As a result, access to programs and access to data are performed using separate instruction buses.
5 and the data bus 16, it is possible to improve the locality and continuity of addresses as described above.

【0008】図5に、図2に示す装置と図4に示す装置
を比較したメモリアクセス動作説明図を示す。図5(a
)には、図2に示すアドレスバス3に現れるアドレス信
号及びその動作を図示した。図のように、図2の装置の
場合、例えば2000番地のプログラムをリードし80
00番地にデータをライトし、更に2001番地のプロ
グラムをリードし8005番地にデータをライトすると
いったように、頻繁にアドレス信号が切り替えられる処
理が実行される。これに対し図4に示す装置では、図5
(b)及び(c)に示すように、命令用バスは2000
番地の命令をリードし、次に2001,2002,20
03というよう順に連続したアドレスの命令を読み込む
。一方、データ用バスについては、8000番地にライ
トし、8005番地,8003番地というように、比較
的狭い領域に対してデータ書き込みのアクセスが行われ
る。従来はこのようにして、マイクロプロセッサによる
外部メモリのアクセス速度の向上を図っていた。
FIG. 5 shows a memory access operation diagram comparing the device shown in FIG. 2 and the device shown in FIG. 4. Figure 5 (a
) illustrates the address signals appearing on the address bus 3 shown in FIG. 2 and their operations. As shown in the figure, in the case of the device in FIG. 2, for example, the program at address 2000 is read and
Processing in which the address signal is frequently switched is executed, such as writing data to address 00, then reading the program at address 2001, and writing data to address 8005. On the other hand, in the device shown in FIG.
As shown in (b) and (c), the instruction bus is 2000
Read the address command, then 2001, 2002, 20
Instructions at consecutive addresses such as 03 are read in order. On the other hand, regarding the data bus, data write access is performed to relatively narrow areas such as writing to address 8000, addresses 8005 and 8003, and so on. Conventionally, this has been done to improve the access speed of the external memory by the microprocessor.

【0009】[0009]

【発明が解決しようとする課題】ところで、図4に示す
ような構成にしたとしても、データ用メモリに格納され
たデータとスタックデータとは、それぞれアドレス空間
上、比較的離れた領域に格納される。従って、データの
リードライトとスタックデータのプッシュ/ホップが頻
繁に交互に行われるような場合には、すでに図2におい
て説明したと同様のアクセス速度低下という問題を引き
起こす。
By the way, even with the configuration shown in FIG. 4, the data stored in the data memory and the stack data are stored in relatively separate areas in the address space. Ru. Therefore, if reading/writing data and pushing/hopping stack data are frequently performed alternately, the same problem of reduced access speed as already explained with reference to FIG. 2 occurs.

【0010】その解決のためには、更にデータ用バス制
御部を二分割し、スタックデータ用と通常のデータ用と
に分離して、それぞれ専用のバスを設けることが考えら
れる。しかしながらそのような構成にした場合、バスの
信号線の数が図2に示した例の場合の3倍にも増加し、
マイクロプロセッサの小型化の障害となり、またその配
線や実装方法などに新たな問題が生じてしまう。本発明
は以上の点に着目してなされたもので、バスの複雑化、
高価格化を防止しつつ、アクセスアドレスの連続性と局
所性を改善し、マイクロプロセッサの動作高速化を図っ
たスタック制御装置を提供することを目的とするもので
ある。
In order to solve this problem, it is conceivable to further divide the data bus control section into two, one for stack data and one for normal data, and provide dedicated buses for each. However, in such a configuration, the number of bus signal lines increases three times as much as in the example shown in FIG.
This becomes an obstacle to the miniaturization of microprocessors, and new problems arise in wiring and mounting methods. The present invention has been made by focusing on the above-mentioned points.
The object of the present invention is to provide a stack control device that improves the continuity and locality of access addresses and speeds up the operation of a microprocessor while preventing an increase in price.

【0011】[0011]

【課題を解決するための手段】本発明のスタック制御装
置は、演算処理を実行するプロセッサと、このプロセッ
サとバスラインを介して接続され、プロセッサの演算処
理実行の際アクセスされる外部メモリと、前記プロセッ
サのスタック処理実行の際スタックデータを格納する双
方向バッファと、この双方向バッファを動作させるため
に、前記スタックデータを前記双方向バッファに対し、
先入れ後出し方式で格納するとともに、前記双方向バッ
ファの容量を越えるスタックデータがその双方向バッフ
ァに格納されようとする場合、スタックデータを先入れ
先出し方式で取り出すよう制御するバッファメモリ制御
部と、前記双方向バッファから前記スタックデータが先
入れ先出し方式で取り出された場合、そのスタックデー
タを、前記バスラインを介して前記外部メモリに書き込
み、前記双方向バッファからスタックデータが読み出さ
れて当該双方向バッファに格納されたスタックデータが
その容量以下になろうとする場合、前記外部メモリから
前記スタックデータを読み出して双方向バッファに戻す
スタックポインタとを備えたことを特徴とするものであ
る。
[Means for Solving the Problems] A stack control device of the present invention includes a processor that executes arithmetic processing, an external memory that is connected to the processor via a bus line and that is accessed when the processor executes the arithmetic processing. a bidirectional buffer that stores stack data when the processor executes stack processing; and a bidirectional buffer that stores the stack data in order to operate the bidirectional buffer;
a buffer memory control unit that stores the stack data in a first-in, last-out manner, and controls the stack data to be retrieved in a first-in, first-out manner when stack data exceeding the capacity of the bidirectional buffer is to be stored in the bidirectional buffer; When the stack data is retrieved from the bidirectional buffer in a first-in, first-out manner, the stack data is written to the external memory via the bus line, and the stack data is read from the bidirectional buffer and stored in the bidirectional buffer. The device is characterized by comprising a stack pointer that reads the stack data from the external memory and returns it to the bidirectional buffer when the stored stack data is about to become less than its capacity.

【0012】0012

【作用】この装置は、先入れ後出し動作と先入れ先出し
動作の可能な双方向バッファを備えている。そしてスタ
ックデータは、この双方向バッファに格納され、双方向
バッファの容量が許す限り、データ用メモリへのスタッ
クデータ格納は行わない。従って、データ用バスは専ら
データアクセスに使用される。一方、双方向バッファの
容量を越えるスタックデータが発生した場合、始めてス
タックポインタが動作し、データ用メモリに双方向バッ
ファから押し出されたスタックデータの格納を行う。双
方向バッファに格納されたスタックデータが減少すれば
、データ用メモリから再びスタックデータが読み出され
双方向バッファに戻される。これによりデータ用バスを
介してスタックデータをアクセスする度合が減少しアク
セスの高速化が図れる。
[Operation] This device is equipped with a bidirectional buffer capable of first-in, last-out operation and first-in, first-out operation. The stack data is stored in this bidirectional buffer, and as long as the capacity of the bidirectional buffer allows, stack data is not stored in the data memory. Therefore, the data bus is used exclusively for data access. On the other hand, when stack data exceeding the capacity of the bidirectional buffer is generated, the stack pointer operates for the first time, and the stack data pushed out from the bidirectional buffer is stored in the data memory. When the stack data stored in the bidirectional buffer decreases, the stack data is read out from the data memory again and returned to the bidirectional buffer. This reduces the degree to which stack data is accessed via the data bus and speeds up access.

【0013】[0013]

【実施例】以下、本発明を図の実施例を用いて詳細に説
明する。図1は本発明のスタック制御装置実施例を示す
ブロック図である。この装置は、マイクロプロセッサ2
0が命令用バス15を介して命令用メモリ13に接続さ
れ、データ用バス16を介してデータ用メモリ14に接
続される構成となっている。マイクロプロセッサ20に
は、論理演算部5、プログラムカウンタ6、汎用レジス
タ8、スタックポインタ21、双方向バッファ22、バ
ッファメモリ制御部23、命令用バス制御部11及びデ
ータ用バス制御部12が設けられている。また、これら
は内部バス10を介して相互に接続されている。マイク
ロプロセッサ20に含まれる論理演算部5、プログラム
カウンタ6、汎用レジスタ8、命令用バス制御部11及
びデータ用バス制御部12の構成は、すでに図2や図4
によって説明した、従来装置の回路ブロックと変わると
ころがない。また、制御用メモリ13、データ用メモリ
14及び命令用バス15、データ用バス16の構成も従
来装置と変わるところはない。
DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention will be explained in detail below using examples shown in the drawings. FIG. 1 is a block diagram showing an embodiment of the stack control device of the present invention. This device consists of a microprocessor 2
0 is connected to the instruction memory 13 via the instruction bus 15 and connected to the data memory 14 via the data bus 16. The microprocessor 20 is provided with a logic operation section 5, a program counter 6, a general-purpose register 8, a stack pointer 21, a bidirectional buffer 22, a buffer memory control section 23, an instruction bus control section 11, and a data bus control section 12. ing. Further, these are interconnected via an internal bus 10. The configurations of the logic operation unit 5, program counter 6, general-purpose register 8, instruction bus control unit 11, and data bus control unit 12 included in the microprocessor 20 are already shown in FIGS. 2 and 4.
There is no difference from the circuit block of the conventional device explained by. Furthermore, the configurations of the control memory 13, data memory 14, command bus 15, and data bus 16 are also the same as in the conventional device.

【0014】ここで、本発明のマイクロプロセッサ20
は、双方向バッファ22及びバッファメモリ制御部23
が追加された点に特徴がある。この双方向バッファ22
は、通常のバッファメモリに対し、バッファメモリ制御
部23によって先入れ後出し方式で格納する機能と、先
入れ先出し方式でデータを格納する機能の二つの機能を
持たせている。即ち、双方向バッファ22をスタックデ
ータ格納用として使用する場合、スタックデータは先入
れ後出し方式で使用される。しかしながら、格納された
スタックデータが双方向バッファ22の容量を越える場
合には、最も古く格納されたスタックデータが双方向バ
ッファ22から押し出され、これがデータ用メモリ14
に退避させられるといった動作を行う。従ってこの場合
には双方向バッファ22は先入れ先出しメモリとして機
能する構成とされている。
Here, the microprocessor 20 of the present invention
The bidirectional buffer 22 and the buffer memory control unit 23
It is distinctive in that it has been added. This bidirectional buffer 22
The buffer memory controller 23 provides two functions to a normal buffer memory: a function to store data in a first-in, last-out manner, and a function to store data in a first-in, first-out manner. That is, when the bidirectional buffer 22 is used to store stack data, the stack data is used on a first-in, last-out basis. However, if the stored stack data exceeds the capacity of the bidirectional buffer 22, the oldest stored stack data is pushed out of the bidirectional buffer 22, and this is transferred to the data memory 14.
Perform actions such as being evacuated. Therefore, in this case, the bidirectional buffer 22 is configured to function as a first-in, first-out memory.

【0015】バッファメモリ制御部23は、このような
動作を行うための、各種の制御信号を出力するカウンタ
やゲート回路から構成される。スタックポインタ21の
構成自体は、従来のスタックポインタと変わるところが
ないが、従来のスタックポインタは、論理演算部5のプ
ッシュ命令とポップ命令を受け入れて、直ちに書き込み
アドレスや読み出しアドレスを、データ用メモリ14に
出力していた。これに対し、本発明に使用されるスタッ
クポインタ21は、バッファメモリ制御部23の制御に
より、双方向バッファ22に格納されたスタックデータ
がオーバーフローした場合のみ動作する構成とされてい
る。
The buffer memory control unit 23 is composed of a counter and a gate circuit that output various control signals for performing the above operations. The configuration of the stack pointer 21 itself is the same as that of a conventional stack pointer, but the conventional stack pointer accepts push and pop instructions from the logic operation unit 5 and immediately transfers the write address and read address to the data memory 14. It was outputting to. In contrast, the stack pointer 21 used in the present invention is configured to operate under the control of the buffer memory control section 23 only when the stack data stored in the bidirectional buffer 22 overflows.

【0016】図6に、本発明の装置の具体的な動作説明
図を示す。図6の(a)〜(e)は、スタックデータが
双方向バッファの容量以下で動作している場合を示して
いる。図の左側が論理演算部のアクセス内容を示し、中
央が双方向バッファの状態を示す。また右側は、データ
用メモリ14へのアクセス内容を示し、更にその右側に
はスタックポインタ21の内容を示している。例えば図
1の論理演算部5から始めにスタックデータd1 のプ
ッシュ命令があると、双方向バッファ22にはそのデー
タが格納される[図6(a)]。そして次に、論理演算
部5がスタックデータd2 のプッシュ命令を行うと、
このデータも双方向バッファ22に格納される[図6(
b)]。同様に、更にスタックデータd3のプッシュ命
令があると、これも双方向バッファ22に格納される[
図6(c)]。次に、論理演算部5からポップ命令があ
ると、双方向バッファ22から最も後で格納されたスタ
ックデータd3 が読み出される[図6(d)]。同様
にして、再度ポップ命令が入力すると、双方向バッファ
22に格納された最も後で格納されたスタックデータd
2 が読み出される[図6(e)]。この間、図1に示
したデータ用メモリ14へのアクセスはなく、スタック
ポインタ21もその内容をP0 としたまま動作しない
FIG. 6 shows a detailed operational diagram of the apparatus of the present invention. (a) to (e) in FIG. 6 show the case where the stack data is operating at less than the capacity of the bidirectional buffer. The left side of the figure shows the access contents of the logic operation unit, and the center shows the state of the bidirectional buffer. The right side shows the contents of access to the data memory 14, and the right side shows the contents of the stack pointer 21. For example, when there is a push command for stack data d1 from the logic operation unit 5 in FIG. 1, the data is stored in the bidirectional buffer 22 [FIG. 6(a)]. Then, when the logic operation unit 5 issues a push command for the stack data d2,
This data is also stored in the bidirectional buffer 22 [Fig.
b)]. Similarly, if there is another push command for stack data d3, this is also stored in the bidirectional buffer 22 [
Figure 6(c)]. Next, when a pop instruction is issued from the logic operation unit 5, the stack data d3 stored most recently is read out from the bidirectional buffer 22 [FIG. 6(d)]. Similarly, when a pop instruction is input again, the stack data d stored in the bidirectional buffer 22 most recently
2 is read out [FIG. 6(e)]. During this time, there is no access to the data memory 14 shown in FIG. 1, and the stack pointer 21 does not operate, with its contents set to P0.

【0017】図6(f)〜(j)には、双方向バッファ
22が、その容量を越えてスタックデータを格納した場
合の例を示す。図6(f),(g)において、スタック
データdn−1 及びdn のプッシュ命令が連続して
入力したとする。そして双方向バッファ22の容量がス
タックデータn個分であったとする。この場合、図6(
g)に示した状態で双方向バッファ22は満杯となる。
FIGS. 6(f) to 6(j) show an example in which the bidirectional buffer 22 stores stack data exceeding its capacity. In FIGS. 6F and 6G, it is assumed that push commands for stack data dn-1 and dn are input successively. Assume that the capacity of the bidirectional buffer 22 is equivalent to n pieces of stack data. In this case, in Figure 6 (
In the state shown in g), the bidirectional buffer 22 becomes full.

【0018】従って、図6(h)に示すように、再度ス
タックデータdn+1のプッシュ命令があった場合に、
そのままではスタックデータ全てを収容しきれない。こ
の時、双方向バッファ22は、まず、最も後で入力する
スタックデータdn+1 を格納する一方、最先に格納
されたスタックデータd1 を先入れ先出し方式で押し
出す。この時スタックポインタ21が動作し、図1に示
す内部バス10とデータ用バス制御部12を通じて、デ
ータ用バス16のアドレスバスに、スタックデータを格
納するためのアドレスPx−1 を出力する。これによ
り、データ用メモリ14はスタックデータd1 を受け
入れ、該当するアドレスにスタックデータを格納する。 図6(i)においては更に、スタックデータdn+2 
のプッシュ命令があった場合を示し、この場合、更にス
タックデータd2 が押し出され、スタックポインタの
発生するアドレスPx−2 に従って、データ用メモリ
14の該当する場所に、スタックデータd2 が格納さ
れる。
Therefore, as shown in FIG. 6(h), when there is a push command for stack data dn+1 again,
As it is, it cannot accommodate all the stack data. At this time, the bidirectional buffer 22 first stores stack data dn+1 that is input last, while pushing out stack data d1 that is stored first in a first-in, first-out manner. At this time, the stack pointer 21 operates and outputs the address Px-1 for storing the stack data to the address bus of the data bus 16 through the internal bus 10 and data bus control unit 12 shown in FIG. As a result, the data memory 14 accepts the stack data d1 and stores the stack data at the corresponding address. In FIG. 6(i), furthermore, stack data dn+2
In this case, the stack data d2 is further pushed out, and the stack data d2 is stored in the corresponding location of the data memory 14 according to the address Px-2 generated by the stack pointer.

【0019】続いて図6(j)において、論理演算部5
からポップ命令があった場合には、最も後で格納された
スタックデータdn+2 が双方向バッファ22から読
み出される。一方、双方向バッファ22には、その読み
出しによって一つ空きが生じる。そこでスタックポイン
タ21は、アドレスPx−1 を発生し、データ用メモ
リ14に格納されたスタックデータd2 を読み出す。 そしてこのスタックデータを双方向バッファ22に格納
する。以上のような構成の装置は、図6(a)〜(e)
に示すような動作が大部分であるように双方向バッファ
22の容量を設定すれば、データ用バス16は専らデー
タのアクセスに使用され、高速アクセスが可能となる。
Next, in FIG. 6(j), the logic operation section 5
If there is a pop instruction from , the stack data dn+2 stored most recently is read from the bidirectional buffer 22. On the other hand, in the bidirectional buffer 22, one space becomes available due to the reading. Therefore, the stack pointer 21 generates the address Px-1 and reads the stack data d2 stored in the data memory 14. This stack data is then stored in the bidirectional buffer 22. The device configured as above is shown in FIGS. 6(a) to (e).
If the capacity of the bidirectional buffer 22 is set so that most of the operations are as shown in FIG.

【0020】もし、演算処理で発生するスタックデータ
の量があらかじめ分かっていれば、その量が適切である
限り、双方向バッファ22の容量を、その発生するスタ
ックデータ量以上に設定して於けば、全くデータ用バス
16をスタックデータアクセスに使用する必要がなくな
る。しかしながら、論理演算部5が実行する演算処理の
内容は未知であり、またその演算の自由度を制限するよ
うであってはならない。従って、双方向バッファ22を
現実的な容量に選定し、その容量を越えるスタックデー
タがあっても、その分をデータ用メモリ14に押し出す
ことを可能にしておけば、論理演算部5は双方向バッフ
ァ22の存在を全く意識することなく従来通りの動作を
行うことができる。
If the amount of stack data generated in arithmetic processing is known in advance, the capacity of the bidirectional buffer 22 can be set to be greater than the amount of stack data generated as long as the amount is appropriate. In other words, there is no need to use the data bus 16 for stack data access at all. However, the contents of the arithmetic processing executed by the logic operation unit 5 are unknown, and the degree of freedom of the calculation must not be restricted. Therefore, if the bidirectional buffer 22 is selected to have a realistic capacity, and even if there is stack data exceeding that capacity, it is possible to push that amount to the data memory 14, the logic operation section 5 can be Conventional operations can be performed without being aware of the existence of the buffer 22 at all.

【0021】上記のような動作を実行するためには、バ
ッファメモリ制御部23は、次の図7から図10に示す
ような信号を生成する処理を行うことになる。図7は、
双方向バッファ容量以下のプッシュ命令時の動作説明図
である。図のように、双方向バッファ22に対し、スタ
ックデータの格納を行うプッシュ命令が論理演算部から
出力された場合、そのプッシュ命令に従って双方向バッ
ファ22には書込みイネーブル信号が入力し、スタック
データの書込みが行われる。
In order to perform the above operations, the buffer memory control unit 23 performs processing to generate signals as shown in FIGS. 7 to 10. Figure 7 shows
FIG. 7 is an explanatory diagram of an operation when a push command is performed below the bidirectional buffer capacity. As shown in the figure, when a push instruction for storing stack data is output from the logic operation unit to the bidirectional buffer 22, a write enable signal is input to the bidirectional buffer 22 according to the push instruction, and the stack data is stored in the bidirectional buffer 22. Writing is performed.

【0022】図8に、双方向バッファの容量以下のポッ
プ命令に於ける動作説明図を示す。図のように、ポップ
命令が論理演算部5から出力されると、双方向バッファ
22に対し読み出しイネーブル信号が入力し、スタック
データが読み出される。以上のような図7及び図8に示
す動作は、双方向バッファが先入れ先出し方式で動作し
ている状態を示している。一方、図9に、双方向バッフ
ァの容量以上のプッシュ命令時に於ける動作説明図を示
す。この状態は、双方向バッファ22からスタックデー
タが先入れ先出し方式で押し出されて来る状態である。 この場合、論理演算部5からプッシュ命令が出力される
と、双方向バッファ22には書き込みイネーブル信号が
入力し、スタックデータが書き込まれる。その一方で、
バッファメモリ制御部23からは、双方向バッファ22
に対し読み出しイネーブル信号が出力され、双方向バッ
ファ22からは、先入れ先出し方式でスタックデータが
読み出される。更にバッファメモリ制御部23からスタ
ックポインタ21に対しプッシュ命令が出力され、スタ
ックポインタ21は書き込みアドレスを発生する。この
書き込みアドレスがデータ用メモリ14に入力し、その
アドレスにスタックデータが書き込まれる。
FIG. 8 is an explanatory diagram of the operation in a pop instruction whose capacity is less than the capacity of the bidirectional buffer. As shown in the figure, when a pop instruction is output from the logic operation unit 5, a read enable signal is input to the bidirectional buffer 22, and the stack data is read out. The operations shown in FIGS. 7 and 8 as described above show a state in which the bidirectional buffer operates on a first-in, first-out basis. On the other hand, FIG. 9 is an explanatory diagram of the operation when a push command exceeds the capacity of the bidirectional buffer. In this state, stack data is pushed out from the bidirectional buffer 22 in a first-in, first-out manner. In this case, when a push command is output from the logic operation unit 5, a write enable signal is input to the bidirectional buffer 22, and stack data is written. On the other hand,
From the buffer memory control unit 23, the bidirectional buffer 22
A read enable signal is output to the bidirectional buffer 22, and stack data is read out from the bidirectional buffer 22 in a first-in, first-out manner. Further, a push command is output from the buffer memory control unit 23 to the stack pointer 21, and the stack pointer 21 generates a write address. This write address is input to the data memory 14, and stack data is written to that address.

【0023】図10に、双方向バッファの容量以上のポ
ップ命令時動作説明図を示す。図のように、論理演算部
5からポップ命令が出力されると、双方向バッファ22
に読み出しイネーブル信号が入力し、双方向バッファ2
2からスタックデータが読み出される。この時バッファ
メモリ制御部23からポップ命令がスタックポインタ2
1に入力し、スタックポインタ21は読み出しアドレス
をデータ用メモリ14に出力する。これによってデータ
用メモリ14からスタックデータが読み出され、同時に
バッファメモリ制御部23から書き込みイネーブル信号
が双方向バッファ22に入力する。これによって、双方
向バッファ22にはデータ用メモリ14から読み出され
たスタックデータが書き込まれる。
FIG. 10 is a diagram illustrating the operation when a pop instruction exceeds the capacity of the bidirectional buffer. As shown in the figure, when a pop instruction is output from the logic operation unit 5, the bidirectional buffer 22
A read enable signal is input to the bidirectional buffer 2.
Stack data is read from 2. At this time, a pop instruction is sent from the buffer memory control unit 23 to the stack pointer 2.
1, and the stack pointer 21 outputs the read address to the data memory 14. As a result, the stack data is read from the data memory 14, and at the same time, a write enable signal is input from the buffer memory control section 23 to the bidirectional buffer 22. As a result, the stack data read from the data memory 14 is written into the bidirectional buffer 22.

【0024】バッファメモリ制御部23は、図7から図
10に示したような書き込みイネーブル信号、読み出し
イネーブル信号、プッシュ命令、ポップ命令などを生成
し各部へ出力するよう動作する。この動作はよく知られ
たカウンタやゲート回路によって容易に実現が可能であ
る。通常、スタックプッシュは、サブルーチンコール時
の戻り番地やサブルーチンに渡すデータの保持などに使
用され、プッシュされたデータは比較的短時間にポップ
される可能性が高く、大量のデータが連続してプッシュ
される可能性は小さい。従って、上記のような双方向バ
ッファのサイズを適当に選定すると、スタックプッシュ
/ポップによるデータ用メモリのアクセス頻度を非常に
小さくすることが可能になる。
The buffer memory control section 23 operates to generate write enable signals, read enable signals, push commands, pop commands, etc. as shown in FIGS. 7 to 10, and output them to each section. This operation can be easily realized using well-known counters and gate circuits. Stack push is usually used to hold the return address when a subroutine is called or data to be passed to a subroutine, etc. Pushed data is likely to be popped in a relatively short time, and a large amount of data is pushed continuously. The possibility of it happening is small. Therefore, by appropriately selecting the size of the bidirectional buffer as described above, it is possible to significantly reduce the frequency of accessing the data memory by stack push/pop.

【0025】[0025]

【発明の効果】以上説明した本発明のスタック制御装置
によれば、双方向バッファにスタックデータが格納され
、双方向バッファの容量の範囲以内でスタックデータが
発生する場合には、スタックプッシュ/ポップによる外
部メモリアクセスを行わない。このために外部メモリア
クセスの局所性や連続性を高め、処理の高速化を図るこ
とができる。なお上記実施例においては、マイクロプロ
セッサと外部メモリとの間が命令用バスとデータ用バス
を介して接続された例を示したが、このようにバスが別
れていないものについても、また、バスが3種類以上存
在するようなものについても、本発明を同様に実施する
ことが可能である。またスタックプッシュ/ポップが双
方向バッファのみに対して行われる場合、外部メモリに
対してアクセスする場合に比べ、より高速アクセスが可
能になる。この点からも、本発明のスタック制御装置に
よるマイクロプロセッサの処理高速化の効果は高いとい
える。
According to the stack control device of the present invention described above, stack data is stored in a bidirectional buffer, and when stack data is generated within the capacity of the bidirectional buffer, stack push/pop is performed. External memory access is not performed. For this reason, locality and continuity of external memory access can be improved, and processing speed can be increased. In the above embodiment, an example was shown in which the microprocessor and external memory were connected via an instruction bus and a data bus. It is possible to implement the present invention in the same way even for those in which there are three or more types. Furthermore, when stack push/pop is performed only on bidirectional buffers, faster access is possible than when accessing external memory. From this point of view as well, it can be said that the effect of increasing the processing speed of a microprocessor by the stack control device of the present invention is high.

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

【図1】本発明のスタック制御装置実施例を示すブロッ
ク図である。
FIG. 1 is a block diagram showing an embodiment of a stack control device of the present invention.

【図2】従来装置のブロック図である。FIG. 2 is a block diagram of a conventional device.

【図3】外部メモリのメモリアドレス空間説明図である
FIG. 3 is an explanatory diagram of a memory address space of an external memory.

【図4】従来の別の装置のブロック図である。FIG. 4 is a block diagram of another conventional device.

【図5】メモリアクセス動作説明図である。FIG. 5 is an explanatory diagram of memory access operation.

【図6】本発明の装置の動作説明図である。FIG. 6 is an explanatory diagram of the operation of the apparatus of the present invention.

【図7】双方向バッファ容量以下のプッシュ命令動作説
明図である。
FIG. 7 is an explanatory diagram of push command operation below the bidirectional buffer capacity.

【図8】双方向バッファ容量以下のポップ命令動作説明
図である。
FIG. 8 is an explanatory diagram of pop instruction operation below the bidirectional buffer capacity.

【図9】双方向バッファ容量以上のプッシュ命令動作説
明図である。
FIG. 9 is an explanatory diagram of push command operation exceeding the bidirectional buffer capacity.

【図10】双方向バッファ容量以上のポップ命令動作説
明図である。
FIG. 10 is an explanatory diagram of the operation of a pop instruction that exceeds the bidirectional buffer capacity.

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

5  論理演算部 6  プログラムカウンタ 8  汎用レジスタ 11  命令用バス制御部 12  データ用バス制御部 13  命令用メモリ 14  データ用メモリ 15  命令用バス 16  データ用バス 20  マイクロプロセッサ 21  スタックポインタ 22  双方向バッファ 23  バッファメモリ制御部 5 Logic operation section 6 Program counter 8 General purpose register 11 Instruction bus control unit 12 Data bus control section 13 Instruction memory 14 Data memory 15 Instruction bus 16 Data bus 20 Microprocessor 21 Stack pointer 22 Bidirectional buffer 23 Buffer memory control unit

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】  演算処理を実行するプロセッサと、こ
のプロセッサとバスラインを介して接続され、プロセッ
サの演算処理実行の際アクセスされる外部メモリと、前
記プロセッサのスタック処理実行の際スタックデータを
格納する双方向バッファと、この双方向バッファを動作
させるために、前記スタックデータを前記双方向バッフ
ァに対し、先入れ後出し方式で格納するとともに、前記
双方向バッファの容量を越えるスタックデータがその双
方向バッファに格納されようとする場合、スタックデー
タを先入れ先出し方式で取り出すよう制御するバッファ
メモリ制御部と、前記双方向バッファから前記スタック
データが先入れ先出し方式で取り出された場合、そのス
タックデータを、前記バスラインを介して前記外部メモ
リに書き込み、前記双方向バッファからスタックデータ
が読み出されて当該双方向バッファに格納されたスタッ
クデータがその容量以下になろうとする場合、前記外部
メモリから前記スタックデータを読み出して双方向バッ
ファに戻すスタックポインタとを備えたことを特徴とす
るスタック制御装置。
1. A processor that executes arithmetic processing, an external memory that is connected to the processor via a bus line and is accessed when the processor executes the arithmetic processing, and stores stack data when the processor executes the stack processing. In order to operate this bidirectional buffer, the stack data is stored in the bidirectional buffer in a first-in, last-out manner, and stack data exceeding the capacity of the bidirectional buffer is stored in both of the bidirectional buffers. When the stack data is to be stored in the bidirectional buffer, the stack data is extracted from the bidirectional buffer in a first-in, first-out manner; When the stack data is read from the bidirectional buffer and the stack data stored in the bidirectional buffer is about to become less than its capacity, the stack data is read from the external memory via the external memory. A stack control device comprising: a stack pointer that reads data and returns it to a bidirectional buffer.
JP16637791A 1991-06-11 1991-06-11 Stack controller Pending JPH04364533A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP16637791A JPH04364533A (en) 1991-06-11 1991-06-11 Stack controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP16637791A JPH04364533A (en) 1991-06-11 1991-06-11 Stack controller

Publications (1)

Publication Number Publication Date
JPH04364533A true JPH04364533A (en) 1992-12-16

Family

ID=15830288

Family Applications (1)

Application Number Title Priority Date Filing Date
JP16637791A Pending JPH04364533A (en) 1991-06-11 1991-06-11 Stack controller

Country Status (1)

Country Link
JP (1) JPH04364533A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013219715A (en) * 2012-04-12 2013-10-24 Panasonic Corp Load controller, load control system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2013219715A (en) * 2012-04-12 2013-10-24 Panasonic Corp Load controller, load control system

Similar Documents

Publication Publication Date Title
US4188662A (en) Address converter in a data processing apparatus
JPH0248747A (en) Microprocessor
US4314332A (en) Memory control system
JPH04364533A (en) Stack controller
JP3165598B2 (en) Bus interface device for first-in first-out memory
JP3307325B2 (en) Data buffer circuit
JP2645477B2 (en) Microprocessor and its cache memory
JPS607529A (en) Buffer memory device
JPH04181454A (en) Data access controller
JPS60134956A (en) Information processing system
JPS61153770A (en) Image processor
JPS6391756A (en) Partial write instruction processing system for storage device
JPS6350995A (en) Stack memory device
JPH0333934A (en) Register saving/recovering system
JPH04363760A (en) Digital signal processor
JPH0573423A (en) Microprocessor
JPS6034147B2 (en) Multi-stage advance control method in data transfer
JPS6269321A (en) Process switching system
JPH11283362A (en) Fifo memory control circuit and microprocessor using the same
JPH0154729B2 (en)
JPH087663B2 (en) Computer system and storage device access method thereof
JPH02307123A (en) Computer
JPS61161560A (en) Memory device
JPH02227753A (en) Computer containing mulit-port cache memory
JPH02232895A (en) Semiconductor memory device