JPH09167117A - Microcomputer and real time system using the microcomputer - Google Patents

Microcomputer and real time system using the microcomputer

Info

Publication number
JPH09167117A
JPH09167117A JP7326635A JP32663595A JPH09167117A JP H09167117 A JPH09167117 A JP H09167117A JP 7326635 A JP7326635 A JP 7326635A JP 32663595 A JP32663595 A JP 32663595A JP H09167117 A JPH09167117 A JP H09167117A
Authority
JP
Japan
Prior art keywords
register
microcomputer
stack area
overflow
stack
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
JP7326635A
Other languages
Japanese (ja)
Inventor
Masahiko Takei
正彦 武井
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.)
Hitachi Ltd
Renesas Semiconductor Package and Test Solutions Co Ltd
Original Assignee
Hitachi Ltd
Hitachi Yonezawa Electronics 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 Hitachi Ltd, Hitachi Yonezawa Electronics Co Ltd filed Critical Hitachi Ltd
Priority to JP7326635A priority Critical patent/JPH09167117A/en
Publication of JPH09167117A publication Critical patent/JPH09167117A/en
Pending legal-status Critical Current

Links

Landscapes

  • Storage Device Security (AREA)
  • Debugging And Monitoring (AREA)
  • Microcomputers (AREA)

Abstract

PROBLEM TO BE SOLVED: To immediately detect the destruction of a stack area, to prevent secondary and ternary faults, to improve debugging efficiency and to reduce man-hour in the debugging of a real time system. SOLUTION: In the system being a single chip microcomputer, a central processing unit is provided with an instruction prefetch/decoding unit 1, a control unit 2, an arithmetic unit 3, a stack area abnormality detection unit having a stack area abnormality detection function and an input/output control unit 5. An address register for setting the highest address of an area becoming an object for destruction detection and a status register for reflecting the presence or absence of the occurrence of overflow from the setting address to an upper part are provided in the stack abnormality detection unit 4. When a stack pointer shows a value upper than the value of the address register, the status register is automatically set and the destruction of the stack area owing to overflow is detected.

Description

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

【0001】[0001]

【発明の属する技術分野】本発明は、マイクロコンピュ
ータ技術に関し、ソフトウェアの開発、特にリアルタイ
ムマルチタスクシステムのデバッグにおいて、スタック
破壊による二次、三次障害を未然に防止する場合に好適
なマイクロコンピュータおよびこれを用いたリアルタイ
ムシステムに適用して有効な技術に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a microcomputer technology, and a microcomputer suitable for preventing secondary and tertiary failures due to stack destruction in software development, especially debugging of a real-time multitasking system, and a microcomputer thereof. The present invention relates to a technique effectively applied to a real-time system using.

【0002】[0002]

【従来の技術】たとえば、発明者が検討したところによ
れば、メモリマネジメントユニットを持たない計算機を
用いたリアルタイムマルチタスクOS(オペレーティン
グシステム)においては、ソフトウェアまたはハードウ
ェア割り込みを併用して、スタック領域のオーバーフロ
ーによるスタック領域破壊の検出を可能とする技術など
が考えられる。
2. Description of the Related Art For example, according to a study by the inventor, in a real-time multitasking OS (operating system) using a computer without a memory management unit, a stack area is used together with software or hardware interrupts. A technology that enables detection of stack area destruction due to the overflow of

【0003】なお、このようなスタック領域破壊などに
関する技術としては、たとえば昭和62年1月20日、
株式会社オーム社発行の「情報処理受験講座 ハードウ
ェアの知識」P65〜P110の計算機の制御方式など
の文献に記載されている。
A technique relating to such stack area destruction is, for example, January 20, 1987,
It is described in "Information Processing Examination Course Hardware Knowledge" published by Ohmsha Co., Ltd., such as the computer control methods of P65 to P110.

【0004】[0004]

【発明が解決しようとする課題】ところで、前記のよう
なリアルタイムマルチタスクOS技術においては、スタ
ック領域破壊の検出は不可能ではないが、不連続なメモ
リ配置が不可欠であったり、対象目的とは関係のない不
要な手続きが必要であったり、また検出できても直接の
障害の検出につながらない場合がほとんどであり、現実
的ではないと考えられる。
By the way, in the above-mentioned real-time multitasking OS technology, detection of stack area destruction is not impossible, but discontinuous memory allocation is indispensable, and the target purpose is In most cases, unnecessary unrelated procedures are required, or even if they can be detected, they do not lead to the detection of a direct failure, which is considered unrealistic.

【0005】また、リアルタイムマルチタスクシステム
において、あるタスクあるいは割り込みハンドラのスタ
ック領域の破壊、オーバーフローによって他のタスク、
割り込みハンドラなどのスタック領域が破壊されたり、
OS、アプリケーションのワークエリアが破壊された場
合に、この破壊されたスタックを持つタスク、割り込み
ハンドラがすぐに動作するとは限らず、スタック破壊に
よる障害が即時に発見できるわけではない。
In the real-time multi-task system, destruction or overflow of a stack area of a task or an interrupt handler causes another task,
The stack area such as the interrupt handler is destroyed,
When the work area of the OS or the application is destroyed, the task or interrupt handler having the destroyed stack does not always operate immediately, and the failure due to the stack destruction cannot be found immediately.

【0006】このため、スタック領域破壊の早期発見は
難しく、またこの障害により、二次、三次障害が発生
し、プログラムの誤動作につながる。また、デバッグに
おいても、二次、三次障害が発生すると、根本的な原因
究明に多大な時間を費やしてしまうということが考えら
れる。
Therefore, early detection of stack area destruction is difficult, and secondary and tertiary failures occur due to this failure, which leads to malfunction of the program. In addition, even in debugging, if a secondary or tertiary failure occurs, it may take a great deal of time to investigate the root cause.

【0007】すなわち、ソフトウェアの開発、特にリア
ルタイムマルチタスクシステムのデバッグにおいて、ス
タック領域の破壊やスタック領域のオーバーフローによ
り、二次、三次障害につながり、障害の原因究明に多大
な労力、費用を費やすことが考えられる。
That is, in software development, especially in debugging of a real-time multitasking system, destruction of the stack area or overflow of the stack area leads to secondary and tertiary failures, and a great deal of labor and cost are spent for investigating the cause of the failure. Can be considered.

【0008】そこで、本発明の目的は、以上の問題を簡
単に解決し、リアルタイムシステムのデバッグにおい
て、スタック領域の破壊を即時に発見し、これによる二
次、三次障害を未然に防止することができ、またリアル
タイムシステムのデバッグ効率を向上し、工数低減を図
ることができるマイクロコンピュータおよびこれを用い
たリアルタイムシステムを提供することにある。
Therefore, an object of the present invention is to easily solve the above problems, to immediately detect the destruction of the stack area in the debugging of a real-time system, and to prevent the secondary and tertiary failures caused thereby. Another object of the present invention is to provide a microcomputer capable of improving the debugging efficiency of the real-time system and reducing the number of steps, and a real-time system using the same.

【0009】本発明の前記ならびにその他の目的と新規
な特徴は、本明細書の記述および添付図面から明らかに
なるであろう。
The above and other objects and novel features of the present invention will become apparent from the description of the present specification and the accompanying drawings.

【0010】[0010]

【課題を解決するための手段】本願において開示される
発明のうち、代表的なものの概要を簡単に説明すれば、
以下のとおりである。
SUMMARY OF THE INVENTION Among the inventions disclosed in the present application, the outline of a representative one will be briefly described.
It is as follows.

【0011】すなわち、本発明のマイクロコンピュータ
は、中央処理装置およびその周辺装置を有するマイクロ
コンピュータに適用されるものであり、中央処理装置
に、スタックポインタの値と所定のアドレス値との比較
結果によりスタック領域のオーバーフローを検出するス
タック領域異常検出手段を内蔵するものである。
That is, the microcomputer of the present invention is applied to a microcomputer having a central processing unit and its peripheral devices, and the central processing unit determines whether the value of the stack pointer is compared with a predetermined address value. The stack area abnormality detecting means for detecting the overflow of the stack area is incorporated.

【0012】具体的には、前記スタック領域異常検出手
段の制御レジスタとして、破壊検出の対象となる領域の
最上部アドレスを設定する第1のレジスタ、設定アドレ
スから上部へのオーバーフロー発生の有無を反映する第
2のレジスタを設け、さらにオーバーフローを検出後、
割り込みを発生するかどうかを設定する第3のレジスタ
を設けるようにしたものである。
Specifically, as the control register of the stack area abnormality detecting means, a first register for setting the uppermost address of the area to be detected for destruction, and the presence / absence of overflow from the set address to the upper side are reflected. A second register is provided, and after detecting an overflow,
A third register for setting whether or not to generate an interrupt is provided.

【0013】これにより、たとえば第3のレジスタの値
を“1”に設定し、スタック領域のオーバーフローの検
出を可能にし、このときスタックポインタが第1のレジ
スタの内容より上部を示したとき、第2のレジスタの値
を“1”に自動設定し、またこれと同時に割り込みを発
生することができる。
Thus, for example, the value of the third register is set to "1" to enable the detection of the overflow of the stack area. At this time, when the stack pointer indicates the upper part of the content of the first register, The value of the register 2 can be automatically set to "1", and at the same time, an interrupt can be generated.

【0014】また、本発明のリアルタイムシステムは、
前記マイクロコンピュータを用い、このマイクロコンピ
ュータを、リアルタイムOSなどの処理時間が重要とな
るシステムやアプリケーションプログラムを用いて動作
させるものである。
Further, the real-time system of the present invention is
The microcomputer is used, and the microcomputer is operated by using a system or application program, such as a real-time OS, in which processing time is important.

【0015】よって、マイクロコンピュータ、リアルタ
イムシステムのデバッグにおいて、スタック領域のオー
バーフローの検出が可能となり、スタック領域破壊によ
る二次、三次障害を防止できる。また、二次、三次障害
の防止によりリアルタイムシステムのデバッグ効率の向
上を図ることができる。
Therefore, in the debugging of the microcomputer and the real time system, the overflow of the stack area can be detected, and the secondary and tertiary failures due to the stack area destruction can be prevented. In addition, it is possible to improve the debugging efficiency of the real-time system by preventing the secondary and tertiary failures.

【0016】[0016]

【発明の実施の形態】以下、本発明の実施の形態を図面
に基づいて詳細に説明する。
Embodiments of the present invention will be described below in detail with reference to the drawings.

【0017】(実施の形態1)図1は本発明の実施の形
態1であるマイクロコンピュータを示すブロック図、図
2は本実施の形態1における中央処理装置を示すブロッ
ク図、図3はスタック異常検出ユニット内の制御レジス
タを示す説明図、図4はタスクスタック領域のメモリ配
置を示す説明図、図5はオーバーフロー発生の有無を反
映するレジスタによる判断処理モデルを示すフローチャ
ートである。
(First Embodiment) FIG. 1 is a block diagram showing a microcomputer according to the first embodiment of the present invention, FIG. 2 is a block diagram showing a central processing unit in the first embodiment, and FIG. 3 is a stack abnormality. FIG. 4 is an explanatory view showing a control register in the detection unit, FIG. 4 is an explanatory view showing a memory arrangement of a task stack area, and FIG. 5 is a flowchart showing a judgment processing model by a register that reflects the presence or absence of overflow.

【0018】まず、図1により本実施の形態1のマイク
ロコンピュータの構成を説明する。
First, the configuration of the microcomputer according to the first embodiment will be described with reference to FIG.

【0019】本実施の形態1のマイクロコンピュータ
は、たとえば周知の半導体製造技術によってシリコン基
板などの1つの半導体基板上に形成されているシングル
チップマイクロコンピュータとされ、中央処理装置CP
U、リードオンリメモリROM、ランダムアクセスメモ
リRAM、発振器CPG、割り込みコントローラIR
C、バスステートコントローラBSC、シリアルコミュ
ニケーションインタフェースSCI、タイマパルスユニ
ットTPU、アナログ/デジタル変換器A/D、入出力
ポートI/Oなどから構成されている。
The microcomputer of the first embodiment is a single chip microcomputer formed on one semiconductor substrate such as a silicon substrate by a well-known semiconductor manufacturing technique, for example, and is a central processing unit CP.
U, read only memory ROM, random access memory RAM, oscillator CPG, interrupt controller IR
C, bus state controller BSC, serial communication interface SCI, timer pulse unit TPU, analog / digital converter A / D, input / output port I / O and the like.

【0020】中央処理装置CPUは、スタック領域異常
検出機能を有し、命令デコード部、命令実行部およびア
ドレス生成部などからなるマイクロコンピュータの中枢
部分であり、メモリに対するデータの読み出し/書き込
み、コントローラに対する制御の指示、入出力ポートに
対するデータの入力/出力など、これらの周辺回路が中
央処理装置CPUにより制御、管理されている。
The central processing unit CPU has a stack area abnormality detection function and is a central part of a microcomputer including an instruction decoding section, an instruction executing section, an address generating section, etc. These peripheral circuits such as control instructions and input / output of data to the input / output ports are controlled and managed by the central processing unit CPU.

【0021】たとえば、中央処理装置CPUは図2のよ
うな構成とされ、命令のプリフェッチ、デコードを行う
命令プリフェッチ・デコードユニット1、他のユニット
を制御する制御ユニット2、データの演算を行う演算ユ
ニット3、スタック領域異常検出機能を持つスタック異
常検出ユニット4(スタック領域異常検出手段)、命令
やオペランドの入出力を制御する入出力制御ユニット5
などから構成されている。
For example, the central processing unit CPU is configured as shown in FIG. 2, and has an instruction prefetch / decode unit 1 for prefetching and decoding instructions, a control unit 2 for controlling other units, and an arithmetic unit for arithmetic operation of data. 3, a stack error detection unit 4 having a stack area error detection function (stack area error detection means), an input / output control unit 5 for controlling input / output of instructions and operands
It is composed of

【0022】スタック異常検出ユニット4には、特に制
御レジスタとして、図3(a) のような破壊検出の対象と
なる領域の最上部アドレスを設定するアドレスレジスタ
ADR(第1のレジスタ)、図3(b) のような設定アド
レスから上部へのオーバーフロー発生の有無を反映する
ステータスレジスタSTS(第2のレジスタ)が設けら
れている。
In the stack abnormality detecting unit 4, particularly as a control register, an address register ADR (first register) for setting an uppermost address of an area to be detected for destruction as shown in FIG. A status register STS (second register) that reflects the occurrence of overflow from the set address as shown in (b) is provided.

【0023】リードオンリメモリROMは、メモリセル
とアドレスデコーダなどからなる読み出し専用メモリで
あり、たとえば製品完成後に記憶内容を自由に決めるこ
とができるプログラマブルリードオンリメモリPROM
や、製品製造途中で使用されるマスクにより記憶内容が
決められてしまうマスクROMなどが用いられ、システ
ムやアプリケーションのプログラムなどが記憶されてい
る。
The read-only memory ROM is a read-only memory including memory cells and address decoders, and is a programmable read-only memory PROM whose stored contents can be freely determined after the product is completed.
Alternatively, a mask ROM whose storage content is determined by a mask used during product manufacturing is used, and a system or application program is stored.

【0024】ランダムアクセスメモリRAMは、メモリ
セルとアドレスデコーダなどからなる随時読み出し書き
込み可能メモリであり、データの書き込みと読み出しが
任意のアドレスのメモリセルに対してほぼ同じアクセス
時間で行うことができるようになっている。
The random access memory RAM is a memory that can be read from and written to at any time and is composed of a memory cell, an address decoder, etc., so that writing and reading of data can be performed to a memory cell of an arbitrary address at substantially the same access time. It has become.

【0025】発振器CPGは、クロックパルスを発生す
る部分であり、たとえばフリップフロップ、カウンタ、
ゲートからなる分周回路、ドライバ回路などから構成さ
れ、この発振器CPGで発生されたクロックパルスがマ
イクロコンピュータの内部、外部のデバイスに対して供
給される。
The oscillator CPG is a part for generating a clock pulse, for example, a flip-flop, a counter,
It is composed of a frequency dividing circuit including a gate, a driver circuit, and the like, and clock pulses generated by the oscillator CPG are supplied to devices inside and outside the microcomputer.

【0026】割り込みコントローラIRCは、割り込み
要因の優先順位を判定し、中央処理装置CPUへの割り
込み要求を制御する部分であり、たとえばマイクロコン
ピュータの外部、内部のバスステートコントローラBS
C、タイマパルスユニットTPUなどからの処理要求に
対して、中央処理装置CPUにより現在実行しているプ
ログラムが一時中断され、その要求が出力されている装
置の処理が優先的に行われる。
The interrupt controller IRC is a part which determines the priority of interrupt factors and controls an interrupt request to the central processing unit CPU. For example, the bus state controller BS outside or inside the microcomputer.
In response to a processing request from C, the timer pulse unit TPU, etc., the program currently being executed by the central processing unit CPU is temporarily suspended, and the processing of the device to which the request is output is preferentially performed.

【0027】バスステートコントローラBSCは、アド
レス空間の分割、各種メモリ、周辺回路に応じた制御信
号の出力を行う部分であり、たとえばこのバスステート
コントローラBSCによってマイクロコンピュータの内
部バスであるアドレスバス、データバスなどの使用権が
制御されている。
The bus state controller BSC is a part that divides the address space and outputs control signals according to various memories and peripheral circuits. For example, the bus state controller BSC is an internal bus of the microcomputer, that is, data. The right to use the bus is controlled.

【0028】シリアルコミュニケーションインタフェー
スSCIは、シリアルデータの通信を行う部分であり、
たとえば周辺デバイスとデータを送受信する場合に、バ
スラインの専用を防止したり、入出力のピン数を削減す
るなどの理由により8ビットなどのビット長のデータが
直列に転送される。
The serial communication interface SCI is a part for communicating serial data.
For example, when transmitting / receiving data to / from a peripheral device, data having a bit length of 8 bits or the like is serially transferred for reasons such as preventing exclusive use of a bus line and reducing the number of input / output pins.

【0029】タイマパルスユニットTPUは、タイマ出
力、パルス出力を制御する部分であり、たとえば初期設
定のできるレジスタとインクリメンタ(またはデクリメ
ンタ)などを備え、キャリー(またはボロー)の発生な
どにより内部割り込みを発生させることができるように
なっている。
The timer pulse unit TPU is a part for controlling timer output and pulse output. For example, the timer pulse unit TPU is provided with a register that can be initialized and an incrementer (or decrementer), and an internal interrupt is generated when a carry (or borrow) occurs. It can be generated.

【0030】アナログ/デジタル変換器A/Dは、アナ
ログデータをデジタルデータに変換する部分であり、た
とえば周辺デバイスから入力されるアナログデータが抵
抗回路網に接続されるスイッチ回路のON/OFFなど
によりデジタルデータに変換され、マイクロコンピュー
タの内部においてデジタル的な制御が行われるようにな
っている。
The analog / digital converter A / D is a part for converting analog data into digital data. For example, analog data input from a peripheral device is turned on / off by a switch circuit connected to a resistor network. It is converted into digital data, and digital control is performed inside the microcomputer.

【0031】入出力ポートI/Oは、データの入出力を
行う部分であり、たとえばデータをラッチする機能を持
ったものが多く、命令により一度データの入出力が行わ
れると、次の命令までそのデータが保持されるようにな
っている。
The input / output port I / O is a part for inputting / outputting data, and for example, many have a function of latching data, and once data is input / output by an instruction, the next instruction is executed. The data is retained.

【0032】以上のように構成されるマイクロコンピュ
ータにおいて、中央処理装置CPUは、リードオンリメ
モリROMに記憶されているシステムやアプリケーショ
ンプログラムに基づいて、マイクロコンピュータを構成
するそれぞれの構成要素の動作を制御することができる
ようになっている。
In the microcomputer configured as described above, the central processing unit CPU controls the operation of each constituent element of the microcomputer based on the system and application programs stored in the read-only memory ROM. You can do it.

【0033】次に、本実施の形態1の作用について、ス
タック領域のオーバーフローによるスタック領域破壊の
判断処理モデルを図5に基づいて説明する。本実施の形
態1においては、図3(b) に示すステータスレジスタS
TSをアクセスすることにより、スタック領域破壊の早
期発見を実現することができる。
Next, the operation of the first embodiment will be described with reference to FIG. 5, which shows a determination processing model of stack area destruction due to stack area overflow. In the first embodiment, the status register S shown in FIG.
By accessing the TS, early detection of stack area destruction can be realized.

【0034】具体的には、図4に示すようにOSのデー
タ管理領域の下部にタスクスタック領域が配置されてい
るものとすると、図1に示すアドレスレジスタADR
に、予めタスクスタック領域の最上部アドレスを設置す
る(ステップ501)。
Specifically, assuming that the task stack area is located below the data management area of the OS as shown in FIG. 4, the address register ADR shown in FIG.
In advance, the uppermost address of the task stack area is set (step 501).

【0035】また、オーバーフロー発生の有無を反映す
るステータスレジスタSTSには、スタックポインタS
PがアドレスレジスタADRの内容より上部を示したと
きに、オーバーフローの発生を示す“1”が中央処理装
置CPUの制御により自動的に設定されている。
Further, the stack pointer S is stored in the status register STS that reflects the presence or absence of overflow.
When P indicates the upper part of the contents of the address register ADR, "1" indicating the occurrence of overflow is automatically set by the control of the central processing unit CPU.

【0036】このとき、タスクからOSへ制御が渡った
とき、OSがデータ管理領域をアクセスする前に、オー
バーフロー発生の有無を反映するステータスレジスタS
TSをアクセスし、ONか否か、すなわちオーバーフロ
ーが発生したかどうかを判定する(ステップ502)。
At this time, when control is passed from the task to the OS, the status register S that reflects the presence or absence of overflow before the OS accesses the data management area.
The TS is accessed to determine whether it is ON, that is, whether an overflow has occurred (step 502).

【0037】この判定の結果、ステータスレジスタST
Sに、オーバーフローが発生したことを示す“1”が設
定されていてONの場合には、タスクスタック領域にオ
ーバーフローが発生していると判断して異常ルーチンな
どに制御を渡す(ステップ503)。
As a result of this judgment, the status register ST
If "1" indicating that an overflow has occurred is set in S and is ON, it is determined that an overflow has occurred in the task stack area and control is passed to an abnormal routine or the like (step 503).

【0038】一方、ステータスレジスタSTSに、
“0”が設定されていてOFFの場合には、タスクスタ
ック領域にオーバーフローが発生していないものと判断
することができるので、通常の処理を継続して行う(ス
テップ504)。
On the other hand, in the status register STS,
If "0" is set and OFF, it can be determined that no overflow has occurred in the task stack area, and therefore normal processing is continued (step 504).

【0039】これにより、図3(b) に示すステータスレ
ジスタSTSの値をデータ管理領域をアクセスする前に
監視することにより、オーバーフローの発生によるスタ
ック領域の破壊を検出することができる。
Accordingly, by monitoring the value of the status register STS shown in FIG. 3B before accessing the data management area, it is possible to detect the destruction of the stack area due to the occurrence of overflow.

【0040】従って、本実施の形態1のマイクロコンピ
ュータによれば、スタック異常検出ユニット4内の制御
レジスタとして、アドレスレジスタADR、ステータス
レジスタSTSが設けられることにより、スタックポイ
ンタSPがアドレスレジスタADRの値より上部を示し
てオーバーフローが発生したときにステータスレジスタ
STSの値を“1”に自動設定することで、スタック領
域の破壊を即時に発見し、これによる二次、三次障害を
未然に防止することができる。
Therefore, according to the microcomputer of the first embodiment, by providing the address register ADR and the status register STS as the control registers in the stack abnormality detection unit 4, the stack pointer SP is set to the value of the address register ADR. By indicating the upper part and automatically setting the value of the status register STS to "1" when an overflow occurs, the destruction of the stack area can be found immediately and the secondary and tertiary failures due to this can be prevented. You can

【0041】また、スタック領域の破壊を即時に発見で
き、従来のような二次、三次障害につながることによる
障害の原因究明に多大な労力、費用を費やす必要がない
ので、マイクロコンピュータのデバッグ効率を向上させ
ることができ、工数の低減を図ることができる。
Further, since the destruction of the stack area can be found immediately and it is not necessary to spend a great deal of labor and cost for investigating the cause of the failure due to the secondary and tertiary failures as in the conventional case, the debugging efficiency of the microcomputer can be improved. Can be improved and the number of steps can be reduced.

【0042】(実施の形態2)図6は本発明の実施の形
態2であるマイクロコンピュータにおいて、スタック異
常検出ユニット内の制御レジスタを示す説明図、図7は
割り込みによる判断処理モデルを示すフローチャートで
ある。
(Second Embodiment) FIG. 6 is an explanatory view showing a control register in a stack abnormality detecting unit in a microcomputer according to a second embodiment of the present invention, and FIG. 7 is a flow chart showing a judgment processing model by interruption. is there.

【0043】本実施の形態2のマイクロコンピュータ
は、前記実施の形態1と同様に周知の半導体製造技術に
よってシリコン基板などの1つの半導体基板上に形成さ
れているシングルチップマイクロコンピュータとされ、
前記実施の形態1との相違点は、スタック領域のオーバ
ーフローによるスタック領域破壊の判断処理方法が異な
り、オーバーフロー検出後の割り込み許可/禁止の設定
を可能にし、ステータスレジスタSTSをアクセスする
か、割り込み異常終了ルーチンなどに制御を渡すことに
より、スタック領域のオーバーフローによるスタック領
域破壊の早期発見を実現できるようにした点である。
The microcomputer of the second embodiment is a single-chip microcomputer formed on one semiconductor substrate such as a silicon substrate by the well-known semiconductor manufacturing technique as in the first embodiment.
The difference from the first embodiment is that the method of determining the stack area destruction due to the overflow of the stack area is different, it is possible to set the interrupt enable / disable after the overflow is detected, and the status register STS is accessed or an interrupt error occurs. By passing control to a termination routine, etc., it is possible to realize early detection of stack area destruction due to stack area overflow.

【0044】すなわち、本実施の形態2においては、ス
タック異常検出ユニット4に、破壊検出の対象となる領
域の最上部アドレスを設定するアドレスレジスタADR
(第1のレジスタ)、設定アドレスから上部へのオーバ
ーフロー発生の有無を反映するステータスレジスタST
S(第2のレジスタ)に加えて、図6のようなオーバー
フローを検出後、割り込みを発生するかどうかを設定す
るフラグレジスタFLG(第3のレジスタ)が設けられ
ている。
That is, in the second embodiment, the address register ADR for setting the uppermost address of the area to be the destruction detection target is set in the stack abnormality detection unit 4.
(First register), status register ST that reflects the occurrence of overflow from the set address to the upper part
In addition to S (second register), a flag register FLG (third register) for setting whether to generate an interrupt after detecting an overflow as shown in FIG. 6 is provided.

【0045】よって、本実施の形態2においては、前記
実施の形態1と同様なメモリ配置のとき、図7に示すよ
うに、アドレスレジスタADRにタスクスタック領域の
最上部アドレスを設置し(ステップ701)、かつフラ
グレジスタFLGに、スタック領域のオーバーフロー発
生時、割り込み許可を示す“1”によるON状態に設定
する(ステップ702)。
Therefore, in the second embodiment, when the memory arrangement is similar to that of the first embodiment, as shown in FIG. 7, the uppermost address of the task stack area is set in the address register ADR (step 701). ), And when the stack area overflows, the flag register FLG is set to the ON state by "1" indicating the interrupt permission (step 702).

【0046】このとき、通常の処理を継続するが(ステ
ップ703)、スタック領域のオーバーフローが発生す
ると、ステータスレジスタSTSに反映させるばかりで
なく、スタック異常割り込みを発生する(ステップ70
4)。この割り込みベクタにスタック異常ルーチンを埋
め込んでおけば、スタック異常ルーチンに自動的に制御
が渡り、スタック異常時の処理を行うことができる(ス
テップ705)。
At this time, normal processing is continued (step 703), but when an overflow of the stack area occurs, not only is it reflected in the status register STS, but a stack abnormal interrupt is generated (step 70).
4). If the stack abnormality routine is embedded in this interrupt vector, the control is automatically passed to the stack abnormality routine, and the processing at the time of the stack abnormality can be performed (step 705).

【0047】これにより、ステータスレジスタSTSの
値、あるいは割り込み発生により、オーバーフローの発
生によるスタック領域の破壊を検出することができる。
Thus, it is possible to detect the destruction of the stack area due to the overflow due to the value of the status register STS or the occurrence of the interrupt.

【0048】従って、本実施の形態2のマイクロコンピ
ュータによれば、スタック異常検出ユニット4内の制御
レジスタとして、フラグレジスタFLGが追加されるこ
とにより、スタックポインタSPがアドレスレジスタA
DRの値より上部を示してオーバーフローが発生したと
きに、ステータスレジスタSTSの値を“1”に自動設
定するとともにスタック異常割り込みを発生すること
で、前記実施の形態1と同様にスタック領域の破壊を即
時に発見し、これによる二次、三次障害を未然に防止し
てマイクロコンピュータのデバッグ効率を向上させ、工
数の低減を図ることができる。
Therefore, according to the microcomputer of the second embodiment, the flag register FLG is added as a control register in the stack abnormality detection unit 4, so that the stack pointer SP is moved to the address register A.
When an overflow occurs above the value of DR and the overflow occurs, the value of the status register STS is automatically set to "1" and a stack abnormal interrupt is generated, so that the stack area is destroyed as in the first embodiment. Can be immediately detected, and secondary and tertiary failures due to this can be prevented, the debugging efficiency of the microcomputer can be improved, and the number of steps can be reduced.

【0049】以上、本発明者によってなされた発明を発
明の実施の形態に基づき具体的に説明したが、本発明は
前記実施の形態に限定されるものではなく、その要旨を
逸脱しない範囲で種々変更可能であることはいうまでも
ない。
Although the invention made by the inventor has been specifically described based on the embodiments of the present invention, the present invention is not limited to the above embodiments, and various modifications may be made without departing from the gist of the invention. Needless to say, it can be changed.

【0050】たとえば、前記実施の形態においては、破
壊検出の対象となる領域の最上部アドレスを設定する場
合について説明したが、本発明は前記実施の形態に限定
されるものではなく、スタック領域の最下部を異なるア
ドレスレジスタに設定して監視することも可能であり、
この場合にはスタック領域の上部、下部を管理すること
ができる。
For example, in the above-mentioned embodiment, the case of setting the uppermost address of the area to be detected for destruction is described, but the present invention is not limited to the above-mentioned embodiment, and the stack area It is also possible to set the bottom part to a different address register for monitoring,
In this case, the upper and lower parts of the stack area can be managed.

【0051】また、ステータスレジスタとフラグレジス
タのビットno.と、アドレスレジスタを対応させて、
アドレスレジスタを複数設置することで、複数のタスク
スタック領域の破壊を監視することも可能である。
In addition, the bit no. Of the status register and the flag register. And the address register,
It is also possible to monitor the destruction of multiple task stack areas by installing multiple address registers.

【0052】さらに、前記実施の形態においては、マイ
クロコンピュータ単体に適用した場合について説明した
が、マイクロコンピュータを用いたリアルタイムシステ
ム、すなわちリアルタイムOSなどの処理時間が重要と
なるシステムやアプリケーションプログラムを用いて動
作させる複写機、ファクシミリ、電話機などの各種シス
テムに適用され、一例として図8によりファクシミリシ
ステムについて説明する。
Further, in the above-described embodiment, the case where the present invention is applied to a microcomputer alone has been described, but a real-time system using a microcomputer, that is, a system or application program in which processing time is important such as a real-time OS is used. The present invention is applied to various systems such as copiers, facsimiles, and telephones to be operated. As an example, a facsimile system will be described with reference to FIG.

【0053】このファクシミリシステムにおいて、たと
えばマイクロコンピュータには符号化または復号化後の
画像データを入出力するポートと、符号を入出力する2
つのポートが備えられている。各ポートは画像データバ
スとシステムバスと接続されており、画像データバスに
はイメージスキャナやプリンタなどが接続され、システ
ムバスにはマイクロコンピュータを制御するホストCP
Uやモデムなどの伝送路インタフェースなどが接続され
ている。また、画像データバスには画像メモリが接続さ
れ、これは画像データまたは符号をバッファリングする
ためのメモリである。
In this facsimile system, for example, a microcomputer has a port for inputting / outputting encoded or decoded image data and a port for inputting / outputting a code.
There are two ports. Each port is connected to an image data bus and a system bus, an image scanner and a printer are connected to the image data bus, and a host CP for controlling a microcomputer is connected to the system bus.
A transmission line interface such as a U or a modem is connected. An image memory is connected to the image data bus, and this is a memory for buffering image data or codes.

【0054】次に、このファクシミリシステムの概略動
作を説明する。まず、画像データをイメージスキャナで
読み取り、符号化データを伝送回線に送信する場合、前
記イメージスキャナから読み込んだ2値画像データは、
DMAコントローラにより、一時画像メモリに蓄積され
る。そして、マイクロコンピュータにより、前記画像メ
モリからのデータが読み込まれ、符号化処理が行われ
る。
Next, the general operation of this facsimile system will be described. First, when the image data is read by the image scanner and the encoded data is transmitted to the transmission line, the binary image data read by the image scanner is
It is stored in the temporary image memory by the DMA controller. Then, the microcomputer reads the data from the image memory and performs an encoding process.

【0055】さらに、マイクロコンピュータによる処理
後の符号化データは、マイクロコンピュータの内部レジ
スタに蓄積される。そして、マイクロコンピュータによ
りホストCPUに対して、割り込み信号を発生させ、内
部レジスタから符号化データを読み出させる要求が行わ
れる。
Further, the coded data processed by the microcomputer is stored in the internal register of the microcomputer. Then, the microcomputer requests the host CPU to generate an interrupt signal and read the encoded data from the internal register.

【0056】続いて、前記ホストCPUにより、I/O
リードまたはシステムバスのDMAコントローラによる
DMA転送により符号化データが読み出される。この読
み出されたデータは、一時システムメモリでバッファリ
ングしてから、伝送回線としてのモデムに出力される。
Then, by the host CPU, I / O
The coded data is read by read or DMA transfer by the DMA controller of the system bus. The read data is temporarily buffered in the system memory and then output to the modem as a transmission line.

【0057】また、伝送回線から受信した符号化データ
をプリント出力する場合は、前記した画像データをイメ
ージスキャナで読み取り、符号化データを伝送回線に送
信する場合と逆の方法で行う。これにより、送信側から
送られた符号化データは、受信側において復号化され、
この復号化データがプリント出力されるようになってい
る。
When the encoded data received from the transmission line is printed out, the above-mentioned image data is read by the image scanner and the encoded data is transmitted to the transmission line in the reverse manner. As a result, the encoded data sent from the transmitting side is decoded on the receiving side,
This decrypted data is printed out.

【0058】以上のように、本発明においては、リアル
タイムOSなどの処理時間が重要となるシステムやアプ
リケーションプログラムを用いて動作させるシステムな
どについても良好に適用可能である。
As described above, the present invention can be favorably applied to a system in which the processing time is important such as a real-time OS or a system operated by using an application program.

【0059】[0059]

【発明の効果】本願において開示される発明のうち、代
表的なものによって得られる効果を簡単に説明すれば、
以下のとおりである。
Advantageous effects obtained by typical ones of the inventions disclosed in the present application will be briefly described.
It is as follows.

【0060】(1).スタック領域のオーバーフローを検出
するスタック領域異常検出手段に、破壊検出の対象とな
る領域の最上部アドレスを設定する第1のレジスタと、
設定アドレスから上部へのオーバーフロー発生の有無を
反映する第2のレジスタを設けることで、スタックポイ
ンタが第1のレジスタの内容より上部を示したときに第
2のレジスタを自動設定することができるので、この第
2のレジスタを監視することによってスタック領域のオ
ーバーフローの検出が可能となる。
(1). A stack area abnormality detecting means for detecting an overflow of the stack area, and a first register for setting an uppermost address of an area to be detected for destruction,
By providing the second register that reflects the occurrence of overflow from the set address to the upper part, the second register can be automatically set when the stack pointer indicates the upper part of the contents of the first register. By monitoring this second register, the stack area overflow can be detected.

【0061】(2).スタック領域のオーバーフローを検出
するスタック領域異常検出手段に、最上部アドレスを設
定する第1のレジスタ、オーバーフロー発生の有無を反
映する第2のレジスタに加えて、オーバーフローを検出
した後に割り込みを発生するか否かを設定する第3のレ
ジスタを設けることで、第3のレジスタを設定し、スタ
ックポインタが第1のレジスタの内容より上部を示した
ときに第2のレジスタを自動設定すると同時に割り込み
を発生することができるので、この割り込みによってス
タック領域のオーバーフローの検出が可能となる。
(2). In addition to the first register for setting the uppermost address and the second register for reflecting the occurrence of overflow, the stack area abnormality detecting means for detecting overflow of the stack area detects overflow. By setting a third register for setting whether or not to generate an interrupt after that, the second register is set when the third pointer is set and the stack pointer indicates the upper part of the contents of the first register. Since an interrupt can be generated at the same time as the automatic setting, the overflow of the stack area can be detected by this interrupt.

【0062】(3).前記(1),(2) により、スタック領域の
オーバーフロー検出によってスタック領域破壊の早期発
見を実現することができるので、このスタック領域破壊
による二次、三次障害を未然に防止することが可能とな
る。
(3) Because of the above (1) and (2), it is possible to realize early detection of stack area destruction by detecting overflow of the stack area, so that secondary and tertiary failures due to this stack area destruction can be prevented. It becomes possible to prevent it.

【0063】(4).前記(3) により、スタック領域破壊に
よる二次、三次障害を未然に防止することができるの
で、デバッグ効率の向上が可能となる。
(4) By the above (3), secondary and tertiary failures due to stack area destruction can be prevented in advance, so that debugging efficiency can be improved.

【0064】(5).前記(1) 〜(4) により、マイクロコン
ピュータ、およびこれを用いたリアルタイムシステムの
デバッグにおいて、マルチタスクリアルタイムシステム
の性能向上と、この開発工数の低減が可能となる。
(5) According to the above (1) to (4), in the debugging of the microcomputer and the real-time system using the microcomputer, it is possible to improve the performance of the multi-task real-time system and reduce the development man-hours.

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

【図1】本発明の実施の形態1であるマイクロコンピュ
ータを示すブロック図である。
FIG. 1 is a block diagram showing a microcomputer that is Embodiment 1 of the present invention.

【図2】実施の形態1における中央処理装置を示すブロ
ック図である。
FIG. 2 is a block diagram showing a central processing unit in the first embodiment.

【図3】実施の形態1におけるスタック異常検出ユニッ
ト内の制御レジスタを示す説明図である。
FIG. 3 is an explanatory diagram showing a control register in the stack abnormality detection unit according to the first embodiment.

【図4】実施の形態1におけるタスクスタック領域のメ
モリ配置を示す説明図である。
FIG. 4 is an explanatory diagram showing a memory layout of a task stack area according to the first embodiment.

【図5】実施の形態1において、オーバーフロー発生の
有無を反映するレジスタによる判断処理モデルを示すフ
ローチャートである。
FIG. 5 is a flowchart showing a judgment processing model by a register that reflects the presence or absence of overflow in the first embodiment.

【図6】本発明の実施の形態2であるマイクロコンピュ
ータにおいて、スタック異常検出ユニット内の制御レジ
スタを示す説明図である。
FIG. 6 is an explanatory diagram showing a control register in a stack abnormality detection unit in the microcomputer that is Embodiment 2 of the present invention.

【図7】実施の形態2において、割り込みによる判断処
理モデルを示すフローチャートである。
FIG. 7 is a flowchart showing a judgment processing model by interruption in the second embodiment.

【図8】実施の形態におけるマイクロコンピュータを用
いたファクシミリシステムを示すブロック図である。
FIG. 8 is a block diagram showing a facsimile system using the microcomputer according to the embodiment.

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

1 命令プリフェッチ・デコードユニット 2 制御ユニット 3 演算ユニット 4 スタック異常検出ユニット(スタック領域異常検出
手段) 5 入出力制御ユニット CPU 中央処理装置 ROM リードオンリメモリ RAM ランダムアクセスメモリ CPG 発振器 IRC 割り込みコントローラ BSC バスステートコントローラ SCI シリアルコミュニケーションインタフェース TPU タイマパルスユニット A/D アナログ/デジタル変換器 I/O 入出力ポート ADR アドレスレジスタ(第1のレジスタ) STS ステータスレジスタ(第2のレジスタ) FLG フラグレジスタ(第3のレジスタ)
1 instruction prefetch / decode unit 2 control unit 3 arithmetic unit 4 stack abnormality detection unit (stack area abnormality detection means) 5 input / output control unit CPU central processing unit ROM read only memory RAM random access memory CPG oscillator IRC interrupt controller BSC bus state controller SCI serial communication interface TPU timer pulse unit A / D analog / digital converter I / O I / O port ADR address register (first register) STS status register (second register) FLG flag register (third register)

Claims (4)

【特許請求の範囲】[Claims] 【請求項1】 少なくとも中央処理装置およびその周辺
装置を有するマイクロコンピュータであって、前記中央
処理装置に、スタックポインタの値と所定のアドレス値
との比較結果によりスタック領域のオーバーフローを検
出するスタック領域異常検出手段を内蔵することを特徴
とするマイクロコンピュータ。
1. A microcomputer having at least a central processing unit and its peripherals, wherein the central processing unit detects a stack area overflow based on a result of comparison between a stack pointer value and a predetermined address value. A microcomputer having a built-in abnormality detecting means.
【請求項2】 請求項1記載のマイクロコンピュータで
あって、前記スタック領域異常検出手段の制御レジスタ
として、破壊検出の対象となる領域の最上部アドレスを
設定する第1のレジスタと、この設定されたアドレスか
らのオーバーフロー検出の有無を反映する第2のレジス
タとを設けることを特徴とするマイクロコンピュータ。
2. The microcomputer according to claim 1, wherein a first register for setting an uppermost address of an area to be destroyed and detected is set as a control register of the stack area abnormality detecting means. A second register that reflects the presence or absence of overflow detection from the address.
【請求項3】 請求項2記載のマイクロコンピュータで
あって、前記オーバーフローを検出した後に割り込みを
発生するか否かを設定する第3のレジスタを設け、この
第3のレジスタを設定してオーバーフロー検出可能状態
にし、前記スタックポインタの値が前記第1のレジスタ
の値よりも上部を示したときに、前記第2のレジスタの
値を自動設定し、同時に割り込みを発生することを特徴
とするマイクロコンピュータ。
3. The microcomputer according to claim 2, further comprising a third register for setting whether or not to generate an interrupt after detecting the overflow, and setting the third register to detect overflow. A microcomputer which is enabled and automatically sets the value of the second register and simultaneously generates an interrupt when the value of the stack pointer is higher than the value of the first register. .
【請求項4】 請求項1、2または3記載のマイクロコ
ンピュータを用いたリアルタイムシステムであって、前
記マイクロコンピュータを、リアルタイムオペレーショ
ンシステムなどの処理時間が重要となるシステムやアプ
リケーションプログラムを用いて動作させることを特徴
とするリアルタイムシステム。
4. A real-time system using the microcomputer according to claim 1, 2 or 3, wherein the microcomputer is operated using a system or application program such as a real-time operation system in which processing time is important. A real-time system characterized by that.
JP7326635A 1995-12-15 1995-12-15 Microcomputer and real time system using the microcomputer Pending JPH09167117A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7326635A JPH09167117A (en) 1995-12-15 1995-12-15 Microcomputer and real time system using the microcomputer

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7326635A JPH09167117A (en) 1995-12-15 1995-12-15 Microcomputer and real time system using the microcomputer

Publications (1)

Publication Number Publication Date
JPH09167117A true JPH09167117A (en) 1997-06-24

Family

ID=18189998

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7326635A Pending JPH09167117A (en) 1995-12-15 1995-12-15 Microcomputer and real time system using the microcomputer

Country Status (1)

Country Link
JP (1) JPH09167117A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11203166A (en) * 1998-01-19 1999-07-30 Nec Corp Stack pointer tracing device and its method, and recording medium
JP2002073418A (en) * 2000-08-25 2002-03-12 Fujitsu Ltd Micro processor
KR100350484B1 (en) * 1998-11-23 2002-08-28 삼성전자 주식회사 Apparatus and method for detecting corruption associated with a stack in a storage device
JP2018092486A (en) * 2016-12-06 2018-06-14 日立オートモティブシステムズ株式会社 Automobile electronic controller and abnormality detection method of dma controller

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11203166A (en) * 1998-01-19 1999-07-30 Nec Corp Stack pointer tracing device and its method, and recording medium
KR100350484B1 (en) * 1998-11-23 2002-08-28 삼성전자 주식회사 Apparatus and method for detecting corruption associated with a stack in a storage device
JP2002073418A (en) * 2000-08-25 2002-03-12 Fujitsu Ltd Micro processor
JP2018092486A (en) * 2016-12-06 2018-06-14 日立オートモティブシステムズ株式会社 Automobile electronic controller and abnormality detection method of dma controller

Similar Documents

Publication Publication Date Title
US4112490A (en) Data transfer control apparatus and method
US4949241A (en) Microcomputer system including a master processor and a slave processor synchronized by three control lines
KR20010052423A (en) System, device, and method for communicating with and initializing a computer peripheral
JPH0430053B2 (en)
US6968410B2 (en) Multi-threaded processing of system management interrupts
US5664198A (en) High speed access to PC card memory using interrupts
JPH09167117A (en) Microcomputer and real time system using the microcomputer
US5586336A (en) Microcomputer capable of monitoring internal resources from external
JP4334026B2 (en) Computer system and method for generating and handling system management interrupts therein
US7237099B2 (en) Multiprocessor system having a plurality of control programs stored in a continuous range of addresses of a common memory and having identification registers each corresponding to a processor and containing data used in deriving a starting address of a CPU-linked interrupt handler program to be executed by the corresponding processor
JPH08171504A (en) Emulation device
JPH06274462A (en) Asynchronous writing system for shared memory
JP2990800B2 (en) Interrupt processing device
JP3547012B2 (en) Microcomputer
EP0138045A2 (en) Apparatus and method for synchronization of peripheral devices via bus cycle alteration in a microprocessor implemented data processing system
KR100331027B1 (en) Interrupt acknowledge controller and control method for a single signal interrupted processor
KR100238175B1 (en) Bus control logic apparatus
JP2003296130A (en) Microcomputer
KR100331028B1 (en) Interrupt request controller and control method for a single signal interrupted processor
JP2560312B2 (en) Information processing system
JPH10333920A (en) Interruption processing circuit
JPH0659921A (en) Microcomputer
JPH05120155A (en) Microprogram controller
JPH02297650A (en) Receiver
JPH05158872A (en) Data processor