JP2919302B2 - CPU simulation method - Google Patents

CPU simulation method

Info

Publication number
JP2919302B2
JP2919302B2 JP7109421A JP10942195A JP2919302B2 JP 2919302 B2 JP2919302 B2 JP 2919302B2 JP 7109421 A JP7109421 A JP 7109421A JP 10942195 A JP10942195 A JP 10942195A JP 2919302 B2 JP2919302 B2 JP 2919302B2
Authority
JP
Japan
Prior art keywords
instruction
cpu
simulation
target
executed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP7109421A
Other languages
Japanese (ja)
Other versions
JPH08305583A (en
Inventor
直樹 佐藤
修 中越
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ENU II SHII JOHO SHISUTEMUZU KK
NEC Corp
Original Assignee
ENU II SHII JOHO SHISUTEMUZU KK
Nippon Electric 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 ENU II SHII JOHO SHISUTEMUZU KK, Nippon Electric Co Ltd filed Critical ENU II SHII JOHO SHISUTEMUZU KK
Priority to JP7109421A priority Critical patent/JP2919302B2/en
Publication of JPH08305583A publication Critical patent/JPH08305583A/en
Application granted granted Critical
Publication of JP2919302B2 publication Critical patent/JP2919302B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Debugging And Monitoring (AREA)
  • Test And Diagnosis Of Digital Computers (AREA)

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、ターゲットCPUの動
作をホストCPU上でシミュレートする方法に関し、特
に、高速なCPUシミュレーション方法に関する。
The present invention relates to a method for simulating the operation of a target CPU on a host CPU, and more particularly to a high-speed CPU simulation method.

【0002】[0002]

【従来の技術】ターゲットCPUを含むターゲットマシ
ンの完成前に、あるいはターゲットマシン上でのデバッ
グ、性能解析前に、ターゲットCPU用に開発されたプ
ログラム(ターゲットプログラムと称す)のデバッグを
行ったり、性能評価を行う方法として、ターゲットCP
Uとは別のCPUであるホストCPUを含むCPUシミ
ュレータ上でターゲットプログラムにかかるターゲット
CPUの動作をシミュレートする方法があり、その方法
は、ターゲットCPU用のソースプログラムを逐次解釈
実行するインタプリタ方式を使用したCPUシミュレー
ション方法と、ターゲットCPUのマシン語コードを逐
次解釈実行するオブジェクトシミュレーション方式を使
用したCPUシミュレーション方法とに大別される(例
えば、社団法人電子通信学会ハンドブック委員会編集、
株式会社オーム社昭和63年3 月30日発行、第1版「電子
情報通信ハンドブック第2分冊」1857頁、5 ・3 「シミ
ュレータ」参照)。
2. Description of the Related Art Before a target machine including a target CPU is completed, or before debugging or performance analysis on the target machine, a program developed for the target CPU (referred to as a target program) is debugged. The target CP is used as an evaluation method.
There is a method of simulating the operation of the target CPU according to the target program on a CPU simulator including a host CPU which is a CPU different from the U. The method includes an interpreter method for sequentially interpreting and executing a source program for the target CPU. The CPU simulation method used is broadly divided into a CPU simulation method using an object simulation method of sequentially interpreting and executing a machine language code of a target CPU (for example, edited by the IEICE Handbook Committee,
Published by Ohmsha Co., Ltd. on March 30, 1988, 1st edition, "Electronic Information and Communication Handbook Second Volume," p. 1857, 5.3 Simulator).

【0003】ここで、インタプリタ方式を使用したCP
Uシミュレーション方法は、ターゲットCPU用の原始
プログラム(ソースプログラム) を直接にインタプリト
しつつシミュレートするものであり、オブジェクトシミ
ュレーション方式を使用したCPUシミュレーション方
法は、シミュレートに先立ってターゲットプログラムの
原始プログラム(ソースプログラム)をコンパイルまた
はアセンブルしてターゲットCPUのマシン語レベル命
令コードに変換し、この命令コードをシミュレートする
ものである。
[0003] Here, a CP using an interpreter system is used.
The U simulation method simulates while directly interpreting a source program (source program) for the target CPU. The CPU simulation method using the object simulation method uses the source program (target program) of the target program prior to the simulation. The source program is compiled or assembled, converted into a machine language level instruction code of the target CPU, and the instruction code is simulated.

【0004】オブジェクトシミュレーション方式を使用
したCPUシミュレーション方法は、ターゲットCPU
のマシン語レベルの命令生成のための時間がかかるが、
シミュレートの実行時間はインタプリタ方式を使用した
CPUシミュレーション方法に比べて速くなるため、短
いシミュレーション時間を要求される場合には、オブジ
ェクトシミュレータ方式を使用したCPUシミュレーシ
ョン方法が用いられる。なお、ターゲットプログラムが
マシン語レベルで既に存在する場合には、コンパイルま
たはアセンブルが不要であることは勿論のことである。
[0004] The CPU simulation method using the object simulation method is based on a target CPU.
It takes time to generate machine language level instructions,
The simulation execution time is faster than the CPU simulation method using the interpreter method. Therefore, when a short simulation time is required, the CPU simulation method using the object simulator method is used. If the target program already exists at the machine language level, it goes without saying that compilation or assembling is unnecessary.

【0005】そして、オブジェクトシミュレーション方
式を使用したCPUシミュレーション方法においては、
例えば特開平2-250122号公報に見られるように、ターゲ
ットCPUの命令コードをホストCPU上で実行時に1
命令ずつ解釈しながらシミュレートを進めている。
[0005] In the CPU simulation method using the object simulation method,
For example, as described in Japanese Patent Application Laid-Open No. 2-250122, an instruction code of a target CPU is executed at the time of execution on a host CPU.
Simulating while interpreting each instruction.

【0006】このようにオブジェクトシミュレーション
方式を使用したCPUシミュレーション方法は、インタ
プリタ方式のものに比べてシミュレーション速度の点で
優れているが、従来のようにターゲットCPUの命令コ
ードをホストCPU上で実行時に1命令ずつ解釈実行す
る構成では、その解釈のために要する時間がシミュレー
ション実行時のオーバーヘッドとなる。
As described above, the CPU simulation method using the object simulation method is superior in terms of simulation speed as compared with the interpreter method. However, unlike the conventional method, the instruction code of the target CPU is executed at the time of execution on the host CPU. In a configuration in which the interpretation is executed one instruction at a time, the time required for the interpretation becomes an overhead during the execution of the simulation.

【0007】[0007]

【発明が解決しようとする課題】ターゲットCPUのタ
ーゲットプログラムをホストCPU上でシミュレートす
るための前記インタプリタ方式や前記オブジェクトシミ
ュレーション方式を使用したCPUシミュレーション方
法では、シミュレーション実行時に要する時間が大きく
なるという問題がある。
In the CPU simulation method using the interpreter system or the object simulation system for simulating a target program of a target CPU on a host CPU, the time required for executing the simulation is increased. There is.

【0008】そこで本発明は、ターゲットCPUと互
換、あるいは上位互換の命令セットをもつホストCPU
上、あるいはターゲットCPUと同種のアーキテクチャ
をもつホストCPU上でターゲットプログラムのシミュ
レーションを高速に行うことを目的とする。
Accordingly, the present invention provides a host CPU having an instruction set compatible with or upwardly compatible with a target CPU.
It is an object of the present invention to perform a target program simulation at high speed on a host CPU having the same architecture as that of the target CPU.

【0009】[0009]

【課題を解決するための手段】本発明は、ターゲットC
PUのマシン語レベルの命令をシミュレーションする命
令シミュレーション手段をホストCPUによって実行す
るCPUシミュレーション方法において、前記ホストC
PUが前記ターゲットCPUのマシン語レベルの命令セ
ットと互換もしくは上位互換のマシン語命令セットを持
つ場合、または前記ホストCPUが前記ターゲットCP
Uと同種のアーキテクチャを持つ場合、前記ターゲット
CPU用に開発されたターゲットプログラムのロード時
に前記ターゲットプログラムのマシン語レベルの命令の
うち、前記ホストCPUが直接実行できる命令はそのま
まメモリ上に配置し、前記ホストCPU上で動作してい
るオペレーテイングシステムの制限および前記ターゲッ
トCPUと前記ホストCPUの機能の相違により直接実
行できない命令は命令シミュレーション手段呼び出し命
令に置き換えてメモリ上に配置し、前記命令シミュレー
ション手段呼び出し命令に置換された命令とそのアドレ
スとを記憶し、前記ホストCPUが直接実行可能な命令
はホストCPUにより直接実行し、前記ホストCPUが
直接実行ができない命令は置換した前記命令シュミレー
ション手段呼び出し命令により前記記憶されている対応
する命令とアドレスとを参照して呼び出される命令シミ
ュレーション手段によってシミュレーションされること
を特徴とするものである。
According to the present invention, a target C is provided.
In a CPU simulation method in which instruction simulation means for simulating a machine language level instruction of a PU is executed by a host CPU, the host C
When the PU has a machine language instruction set compatible with or upwardly compatible with the machine language level instruction set of the target CPU, or when the host CPU has the target CP
When the target program developed for the target CPU is loaded, when the same type of architecture as U is used.
Among instructions at the machine language level of the target program, instructions that can be directly executed by the host CPU are arranged in memory as they are, and restrictions on the operating system operating on the host CPU and the restrictions on the target CPU and the host Instructions that cannot be directly executed due to differences in the functions of the CPU are replaced with instruction simulation means call instructions and arranged in memory, and the instruction simulation is executed.
Instruction replaced by the instruction
The instructions that can be directly executed by the host CPU are directly executed by the host CPU, and the instructions that cannot be directly executed by the host CPU are replaced by the instruction stored by the instruction simulation unit calling instruction .
The simulation is performed by instruction simulation means called with reference to the instruction and the address to be executed.

【0010】[0010]

【実施例】次に本発明の実施例について図面を参照して
詳細に説明する。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, embodiments of the present invention will be described in detail with reference to the drawings.

【0011】図1は本発明によるCPUシミュレーショ
ン方法を適用したCPUシミュレータの一実施例を示す
構成図である。このCPUシミュレータ1は、ホストC
PU12と、メモリ11とを具備する。メモリ11は、
ターゲットプログラム2に含まれる、ホストCPU12
で直接実行できない命令を、命令シミュレーション手段
15を呼び出す命令に置き換える処理、および置き換え
を行う以前の命令コードとそのアドレスを置き換え命令
位置記憶領域14に登録する命令置き換え手段10と、
置き換え後の命令コード領域13と、置き換え命令位置
記憶領域14と、命令シミュレーション手段15とを格
納する。
FIG. 1 is a block diagram showing an embodiment of a CPU simulator to which the CPU simulation method according to the present invention is applied. This CPU simulator 1 has a host C
A PU 12 and a memory 11 are provided. The memory 11
Host CPU 12 included in target program 2
A process that replaces an instruction that cannot be directly executed by the instruction with an instruction that calls the instruction simulation unit 15, and an instruction replacement unit 10 that registers an instruction code and its address before replacement in the replacement instruction position storage area 14;
The instruction code area 13 after replacement, the replacement instruction position storage area 14, and the instruction simulation means 15 are stored.

【0012】ターゲットプログラム2は、ターゲットC
PU (図示せず。以下同じ)用に開発されたプログラム
であり、ターゲットCPUのマシン語レベルの命令コー
ド2-1 〜2-n で構成されている。
The target program 2 includes a target C
This is a program developed for a PU (not shown; the same applies hereinafter), and includes instruction codes 2-1 to 2-n at the machine language level of the target CPU.

【0013】置き換え後の命令コード領域13は、ター
ゲットプログラム2中に含まれる命令コードのうちホス
トCPU12で直接実行できる命令と、CPU12で直
接実行できない命令を命令シミュレーション手段呼び出
し命令に置き換えたものの集合である。ターゲットプロ
グラム2中の命令コードのうち、命令コード2-2 がホス
トCPU12で直接実行できないものの場合には、命令
シミュレーション手段呼び出し命令13-2に変換されメモ
リ11上に配置される。命令コード2-1,2-n がホストC
PU12によって直接実行可能な命令の場合には、その
ままメモリ11上に命令コード13-1,13-n として配置さ
れる。
The instruction code area 13 after replacement is a set of instruction codes included in the target program 2 that can be directly executed by the host CPU 12 and instructions that cannot be directly executed by the CPU 12 are replaced with instruction simulation means calling instructions. is there. When the instruction code 2-2 among the instruction codes in the target program 2 cannot be directly executed by the host CPU 12, the instruction code 2-2 is converted into an instruction simulation means call instruction 13-2 and arranged on the memory 11. Instruction code 2-1 and 2-n is host C
In the case of an instruction that can be directly executed by the PU 12, the instruction code 13-1, 13-n is arranged on the memory 11 as it is.

【0014】命令シミュレーション手段15は、置き換
え後の命令コード領域13中に含まれる命令シミュレー
ション手段呼び出し命令によって呼び出される。呼び出
された命令シミュレーション手段15は、命令シミュレ
ーション手段呼び出し命令のアドレスをもとに、置き換
え命令位置記憶領域14中から置き換え前の命令コード
を取得し、その命令コードのシミュレーションを行う。
シミュレーション完了後、命令シミュレーション手段1
5は、置き換え後の命令コード領域13中の次に実行す
べき命令コード部分に復帰する処理を行う。
The instruction simulation means 15 is called by an instruction simulation means call instruction included in the instruction code area 13 after replacement. The called instruction simulation means 15 acquires the instruction code before replacement from the replacement instruction position storage area 14 based on the address of the instruction simulation means calling instruction, and simulates the instruction code.
After the simulation is completed, the instruction simulation means 1
5 performs processing for returning to the next instruction code portion to be executed in the instruction code area 13 after replacement.

【0015】CPUシミュレータ1は、ターゲットプロ
グラム2にかかるターゲットCPUの動作のシミュレー
ションを実行する場合、シミュレーションの実行に先立
って命令置き換え手段10を起動する。
When simulating the operation of the target CPU according to the target program 2, the CPU simulator 1 activates the instruction replacing means 10 before executing the simulation.

【0016】命令置き換え手段10は、ターゲットプロ
グラム2の各命令コード2-1 〜2-nを順次読み込んで解
釈し、ホストCPU12が直接実行可能な命令かどうか
の判断をおこなう。ホストCPU12が直接実行できな
い命令コードの場合には、命令シミュレーション手段呼
び出し命令に置き換える処理と、置き換えを行った命令
のアドレスと置き換え前の命令コードの組を置き換え命
令位置記憶領域14に登録する。読み込んだ命令コード
がホストCPU12によって直接実行可能な命令の場合
には置き換えを行わない。
The instruction replacing means 10 sequentially reads and interprets each of the instruction codes 2-1 to 2-n of the target program 2 and determines whether or not the instruction code can be directly executed by the host CPU 12. If the instruction code cannot be directly executed by the host CPU 12, the instruction code is replaced with an instruction simulation means calling instruction, and a set of the address of the replaced instruction and the instruction code before the replacement are registered in the replacement instruction position storage area 14. If the read instruction code is an instruction directly executable by the host CPU 12, no replacement is performed.

【0017】例えば、命令コード2-1,2-n がホストCP
U12によって直接実行可能な命令コードで、命令コー
ド2-2 がホストCPU12によって直接実行できない命
令の場合、命令置き換え手段10は命令コード2-2 を命
令シミュレーション手段呼び出し命令に置き換えを行う
が、命令コード2-1,2-n に対しては置き換えを行わな
い。この処理により、命令コード2-1 〜2-n は命令コー
ド13-1〜13-nとしてメモリ上に格納された場合、命令コ
ード13-1および命令コード13-nはもとの命令コード2-1
、命令コード2-n と同じ命令コードであり、命令コー
ド2-2 は置き換えが行われ命令シミュレーション手段呼
び出し手段13-2に置き換えられメモリ11上に格納され
る。命令置き換え手段10は、このとき置き換えを行っ
た命令コード2-2 のアドレスと置き換え前の命令コード
の組を置き換え命令位置記憶領域14に登録する。
For example, if the instruction code 2-1,2-n is the host CP
If the instruction code 2-2 is an instruction code that can be directly executed by the U12 and the instruction code 2-2 cannot be directly executed by the host CPU 12, the instruction replacement means 10 replaces the instruction code 2-2 with an instruction simulation means call instruction. 2-1,2-n is not replaced. By this processing, when the instruction codes 2-1 to 2-n are stored in the memory as the instruction codes 13-1 to 13-n, the instruction code 13-1 and the instruction code 13-n are restored to the original instruction code 2 -1
The instruction code 2-2 is the same instruction code as the instruction code 2-n. The instruction code 2-2 is replaced and replaced by the instruction simulation means calling means 13-2 and stored in the memory 11. The instruction replacement means 10 registers the set of the address of the replaced instruction code 2-2 and the instruction code before replacement in the replacement instruction position storage area 14 at this time.

【0018】図1中の命令置き換え手段10は、メモリ
11に結果を格納しているが、図示しない外部記憶装置
に置き換え後の命令コード領域13の内容と置き換え命
令位置記憶領域14の内容を一旦格納し、シミュレーシ
ョン実行時に外部記憶装置3から置き換え後の命令コー
ド領域13の内容と置き換え命令位置記憶領域14の内
容をメモリ11上に読み込む構成も可能である。
The instruction replacing means 10 in FIG. 1 stores the result in the memory 11, but temporarily stores the contents of the replaced instruction code area 13 and the contents of the replaced instruction position storage area 14 in an external storage device (not shown). It is also possible to store the contents of the instruction code area 13 after replacement and the contents of the replacement instruction position storage area 14 from the external storage device 3 into the memory 11 when executing the simulation.

【0019】CPUシミュレータ1は、命令置き換え手
段10によってメモリ11上に置き換え後の命令コード
領域13が生成されると、ホストCPU12にメモリ1
1上の置き換え後の命令コード領域13を実行させる。
When the replaced instruction code area 13 is generated in the memory 11 by the instruction replacing means 10, the CPU simulator 1
1 to execute the replaced instruction code area 13.

【0020】ホストCPU12は、まずターゲットプロ
グラムの実行開始番地に対応する置き換え後の命令コー
ド領域13中の命令コードを実行する。命令シミュレー
ション手段呼び出し命令以外の命令の場合には、命令コ
ードはそのままホストCPU12によって実行される。
実行した命令が命令シミュレーション手段呼び出し命令
であった場合には、命令シミュレーション手段15へ実
行が移る。
The host CPU 12 first executes the instruction code in the instruction code area 13 after replacement corresponding to the execution start address of the target program. In the case of an instruction other than the instruction simulation means call instruction, the instruction code is executed by the host CPU 12 as it is.
If the executed instruction is an instruction simulation means call instruction, the execution moves to the instruction simulation means 15.

【0021】命令シミュレーション手段15では、呼び
出される原因となった命令シミュレーション手段呼び出
し命令のアドレスをもとに、置き換え命令位置記憶領域
14中から置き換え前の命令コードを取得し、その命令
コードのシミュレーションを行う。シミュレーション終
了後は、置き換え後の命令コード領域13中の次に実行
すべき命令コードの位置へ処理を戻す。
The instruction simulation means 15 obtains the instruction code before replacement from the replacement instruction position storage area 14 based on the address of the instruction to call the instruction simulation means, and simulates the instruction code. Do. After the simulation, the process is returned to the position of the next instruction code to be executed in the replaced instruction code area 13.

【0022】以下、上記動作の繰り返しにより、置き換
え後の命令コード領域13中の命令が実行されることに
より、ターゲットプログラム2にかかるターゲットCP
Uの動作がホストCPU12上でシミュレートされる。
Thereafter, by repeating the above operation, the instruction in the instruction code area 13 after the replacement is executed, and the target CP according to the target program 2 is executed.
The operation of U is simulated on the host CPU 12.

【0023】図2は、命令置き換え手段10の処理を示
したフローチャートである。ステップ101 では、図示し
ないメモリやファイル等に格納されたターゲットプログ
ラムの1命令を読み込む処理を行う。
FIG. 2 is a flowchart showing the processing of the instruction replacing means 10. In step 101, a process of reading one instruction of the target program stored in a memory or a file (not shown) is performed.

【0024】次にステップ102 では、ステップ101 で読
み込んだ命令がホストCPUで直接実行可能な命令かど
うかを判別し、直接実行可能な命令ならばステップ103
へ、直接実行可能な命令ではない場合にはステップ104
へ進む。
Next, in step 102, it is determined whether or not the instruction read in step 101 is an instruction that can be directly executed by the host CPU.
To step 104 if the instruction is not directly executable
Proceed to.

【0025】ステップ103では、ステップ101で読
み込んだ命令コードを置き換え後の命令コード領域13
へ格納する処理を行う。その後、ターゲットプログラム
2の命令コードをすべて読み込んだかどうかを判別し、
全ての命令を読み込んでいない場合にはステップ101
へ進み、全ての命令を読み込んだ場合には処理を終了す
In step 103, the instruction code area 13 after replacing the instruction code read in step 101
Perform the process of storing in. Then the target program
Judge whether all the instruction codes of step 2 have been read,
If all instructions have not been read, step 101
Proceed to and terminate the process if all instructions have been read
You .

【0026】ステップ104では、命令シミュレーショ
ン手段呼び出し命令を置き換え後の命令コード領域13
へ格納する処理を行なう。その後、ステップ101で読
み込んだ命令コードとその命令コードがメモリ上で配置
されるアドレスを置き換え命令位置記憶手段14へ格納
する処理を行う。その後、ターゲットプログラム2の命
令コードをすべて読み込んだかどうかを判別し、全ての
命令を読み込んでいない場合にはステップ101へ進
み、全ての命令を読み込んだ場合には、処理を終了す
る。
In step 104, the instruction code area 13 after replacing the instruction simulation means calling instruction
The processing for storing in is performed. Then, in step 101,
Instruction code and its instruction code are allocated in memory
Replaced address is stored in instruction position storage means 14
Perform the following processing. After that, the life of target program 2
It is determined whether all the instruction codes have been read and all
If no instruction has been read, proceed to step 101.
When all instructions have been read, the process ends.
You.

【0027】[0027]

【0028】[0028]

【0029】以下に、ターゲットCPUがMIPS社の
R3000で、ホストCPUがR3000でオペレーティングシ
ステムとしてUNIXを搭載しCPUシミュレータがU
NIXのアプリケーションプログラムとして動作する場
合の命令置き換えの例をアセンブラ表記で示す。また、
命令の配置されるアドレスは説明のためAddr_1 〜Addr
_5 というラベル名を使用する。
In the following, the target CPU is M3000 R3000, the host CPU is R3000, UNIX is installed as an operating system, and the CPU simulator is U3000.
An example of instruction replacement when operating as a NIX application program is shown in assembler notation. Also,
The addresses where the instructions are located are Addr_1 to Addr for explanation.
Use the label name _5.

【0030】 ○ターゲットプログラム中の命令コード Addr_1: srl ra,ra,6 /* ホストCPU上で直接実行可能 */ Addr_2: sll ra,ra,6 /* ホストCPU上で直接実行可能 */ Addr_3: or gp,gp,ra /* ホストCPU上で直接実行可能 */ Addr_4: mtc0 gp,sr /* ホストCPU上で直接実行不可能 */ Addr_5: lw ra,0x50(sp) /* ホストCPU上で直接実行可能 */ ○置き換え後の命令コード Addr_1: srl ra,ra,6 /* 置き換え無し */ Addr_2: sll ra,ra,6 /* 置き換え無し */ Addr_3: or gp,gp,ra /* 置き換え無し */ Addr_4: .word 0xfffffffe /* 命令の置き換え */ Addr_5: lw ra,0x50(sp) /* 置き換え無し */ 上記srl,sll,or,lw命令は、UNIXのアプリケーショ
ンプログラムとして動作しているCPUシミュレータ上
でも直接ホストCPUが実行可能であるが、mtc0命令は
特権命令であるためUNIXのアプリケーションプログ
ラムとして動作しているCPUシミュレータは直接実行
することができない。そのため、mtc0命令は命令シミュ
レーション手段呼び出し手段(この例では、.word 0xff
fffffeを使用している)に置き換えている。
○ Instruction code in target program Addr_1: srl ra, ra, 6 / * Directly executable on host CPU * / Addr_2: sll ra, ra, 6 / * Directly executable on host CPU * / Addr_3: or gp, gp, ra / * Execute directly on host CPU * / Addr_4: mtc0 gp, sr / * Impossible directly on host CPU * / Addr_5: lw ra, 0x50 (sp) / * On host CPU Directly executable * / ○ Instruction code after replacement Addr_1: srl ra, ra, 6 / * No replacement * / Addr_2: sll ra, ra, 6 / * No replacement * / Addr_3: or gp, gp, ra / * Replace None * / Addr_4: .word 0xfffffffe / * Replacement of instruction * / Addr_5: lw ra, 0x50 (sp) / * No replacement * / The above srl, sll, or, lw instructions are operating as UNIX application programs Although the host CPU can be executed directly on the CPU simulator, the mtc0 instruction is a privileged instruction and must be used as a UNIX application program. CPU simulator that is running can not be executed directly. Therefore, the mtc0 instruction is an instruction simulation means calling means (in this example, .word 0xff
fffffe).

【0031】上述した具体例からわかるように、ステッ
プ102 では、UNIXのアプリケーションプログラムと
して動作しているCPUシミュレータが直接実行可能な
命令かどうかを判断し、直接実行可能な命令はステップ
103 でそのままメモリに配置する処理を行い、直接実行
できない命令の場合はステップ104 で命令シミュレーシ
ョン手段呼び出し命令(この例では.word 0xfffffffeを
使用) に置き換えてメモリに配置する処理を行ってい
る。
As can be seen from the specific example described above, in step 102, it is determined whether or not the CPU simulator operating as a UNIX application program is a directly executable instruction.
In step 103, the process of arranging in the memory as it is is performed, and in the case of an instruction that cannot be directly executed, in step 104, the process of arranging in the memory by replacing the instruction simulation means calling instruction (in this example, using .word 0xfffffffe) is performed.

【0032】また直接実行できない命令の場合には、ス
テップ10置き換えを行なった命令のアドレスと
命令コードを、図1の置き換え命令位置記憶領域14に
格納する処理を行っている。
[0032] In the case of the instruction can not be executed directly, in step 10 4, the address and instruction code of the instruction of performing the replacement is performed a process of storing the replacement instruction position storage area 14 in FIG. 1.

【0033】この例で、ステップ10で置き換え命令
位置記憶領域14に格納される情報は、
[0033] In this example, information stored in the instruction position storage area 14 replaced by Step 10 4,

【0034】 [0034]

【0035】という命令のアドレスと置き換えられるま
えの命令コードである。
This is the instruction code before it is replaced with the address of the instruction.

【0036】この例で命令シミュレーション手段呼び出
し手段として使用している“.word0xfffffffe ”という
命令コードは、R3000CPUでは不正命令である。UN
IX上のアプリケーションプログラムであるCPUシミ
ュレータがこの命令を実行した場合には、UNIXがシ
グナルハンドラと呼ばれる処理ルーチンを起動する。こ
の例で命令シミュレーション手段に制御を移すために
は、図示されないシグナルハンドラを別途用意し、この
シグナルハンドラから命令シミュレーション手段15を
呼び出すようにする必要がある。
The instruction code ".word0xfffffffe" used as the instruction simulation means calling means in this example is an illegal instruction in the R3000 CPU. UN
When the CPU simulator, which is an application program on the IX, executes this instruction, UNIX starts a processing routine called a signal handler. In order to transfer control to the instruction simulation means in this example, it is necessary to separately prepare a signal handler (not shown) and call the instruction simulation means 15 from this signal handler.

【0037】図3は、図1中の置き換え命令位置記憶領
域14中で記憶している情報の例を図示したものであ
る。置き換え命令位置記憶領域14中に格納されている
情報は、ホストCPU12で直接実行できない命令のア
ドレスとその命令のコードである。図3中では、説明の
ためアドレスをラベル名で、命令コードをアセンブラ表
記で示してある。この例では、ターゲットプログラム2
中のアドレス“Addr_4”にある命令“mtc0 gp,sr”、
アドレス“Addr_25 ”にある命令“mfc0 s0,sr”、ア
ドレス“Addr_48 ”にある命令“tlbp”、アドレス
“Addr_ 62 ”にある命令“tlbr”が命令置き換えの対
象となったことを示している。
FIG. 3 illustrates an example of information stored in the replacement instruction position storage area 14 in FIG. The information stored in the replacement instruction position storage area 14 is the address of an instruction that cannot be directly executed by the host CPU 12 and the code of the instruction. In FIG. 3, addresses are shown by label names and instruction codes are shown by assembler notation for explanation. In this example, target program 2
Instruction “mtc0 gp, sr” at address “Addr_4” in
This indicates that the instruction “mfc0 s0, sr” at the address “Addr_25”, the instruction “tlbp” at the address “Addr_48”, and the instruction “tlbr” at the address “Addr_62” have been replaced.

【0038】図4は、図1中の命令シミュレーション手
段15での処理を示したフローチャートである。
FIG. 4 is a flowchart showing the processing in the instruction simulation means 15 in FIG.

【0039】ステップ151 では、命令シミュレーション
手段呼び出し命令が実行された時点でのホストCPU1
2のレジスタ情報を収集する処理を行う。
At step 151, the host CPU 1 at the time when the instruction simulation means calling instruction is executed is executed.
A process of collecting the register information of No. 2 is performed.

【0040】次にステップ15では、命令シミュレー
ション手段呼び出し命令のアドレスをもとに、置き換え
命令位置記憶領域14から置き換えられる前の命令コー
ドを取得する処理を行う。
[0040] Next, in step 15 3, based on the address of the instruction simulation means call instruction, executes the process of acquiring the instruction code before it is replaced as a replacement instruction position storage area 14.

【0041】次にステップ15では、ステップ15
で取得した置き換え前の命令を解析し、置き換え前の命
令をシミュレーションする命令シミュレーション処理へ
実行を移す。
[0041] In the next step 15 4, step 15 3
Analyze the instruction before replacement obtained in the above, and execute the instruction simulation process for simulating the instruction before replacement.

【0042】ステップ15−1〜15−mは、命令
シミュレーション処理を行なう部分で、命令の種類ごと
に処理が用意されている。ここでは、ステップ151で
収集したレジスタ情報が格納されているステップ152
を参照および変更しながら命令のシミュレーションを行
う。
[0042] Step 15 5 -1~15 5 -m is a part for instruction simulation processing, the processing for each type of instruction is provided. Here, step 152 in which the register information collected in step 151 is stored.
Simulate the instruction while referring to and changing.

【0043】次にステップ15では、ステップ155
で行なわれた命令のシミュレーション結果変更されたレ
ジスタ情報をホストCPUのレジスタに復帰する処理を
行う。
[0043] In next step 15 6, step 155
The register information changed as a result of the simulation of the instruction executed in step 2 is returned to the register of the host CPU.

【0044】[0044]

【発明の効果】以上説明したように、本発明ではシミュ
レーション実行時にすべての命令コードを解釈およびシ
ミュレートする必要がないため、従来のCPUシミュレ
ーション方法よりも高速なシミュレーションが可能であ
る。
As described above, according to the present invention, it is not necessary to interpret and simulate all instruction codes at the time of executing a simulation, so that a simulation can be performed at a higher speed than a conventional CPU simulation method.

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

【図1】本発明を適用したCPUシミュレータの一実施
例の機能ブロック図である。
FIG. 1 is a functional block diagram of an embodiment of a CPU simulator to which the present invention is applied.

【図2】図1中の命令置き換え手段10の構成例を示す
機能ブロック図である。
FIG. 2 is a functional block diagram showing a configuration example of an instruction replacement unit 10 in FIG.

【図3】図1中の置き換え命令位置記憶領域14中に記
憶されている情報の例を示す図である。
FIG. 3 is a diagram showing an example of information stored in a replacement instruction position storage area 14 in FIG.

【図4】図1中の命令シミュレーション手段15の構成
例を示す機能ブロック図である。
FIG. 4 is a functional block diagram showing a configuration example of an instruction simulation means 15 in FIG. 1;

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

1 CPUシミュレータ 10 命令置き換え手段 11 メモリ 12 ホストCPU 13 置き換え後の命令コード領域 13-1,13-n 命令コード 13-2 命令シミュレーション手段呼びだし命令 14 置き換え命令位置記憶領域 15 命令シミュレーション手段 2 ターゲットプログラム 2-1 〜2-n 命令コード 3 外部記憶装置 Reference Signs List 1 CPU simulator 10 Instruction replacement means 11 Memory 12 Host CPU 13 Instruction code area after replacement 13-1,13-n instruction code 13-2 Instruction simulation means call instruction 14 Replacement instruction position storage area 15 Instruction simulation means 2 Target program 2 -1 to 2-n Instruction code 3 External storage device

───────────────────────────────────────────────────── フロントページの続き (56)参考文献 特開 平2−1020(JP,A) 特開 昭62−128339(JP,A) PATTERSON,HENNESS Y「COMPUTER ORGANIZ ATION & DESIGN:THE HARDWARE/SOFTWARE INTERFACE」Morgan Kaufmann Publisher s(1994),Appendix A (58)調査した分野(Int.Cl.6,DB名) G06F 9/44 G06F 11/26 ──────────────────────────────────────────────────続 き Continuation of the front page (56) References JP-A-2-1020 (JP, A) JP-A-62-128339 (JP, A) PATTERSON, HENNESS Y “COMPUTER ORGANIZATION & DESIGN: THE HARDWARE / SOFTWARE INTERFACE Morgan Kaufmann Publishers (1994), Appendix A (58) Fields studied (Int. Cl. 6 , DB names) G06F 9/44 G06F 11/26

Claims (1)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 ターゲットCPUのマシン語レベルの命
令をシミュレーションする命令シミュレーション手段を
ホストCPUによって実行するCPUシミュレーション
方法において、前記ホストCPUが前記ターゲットCP
Uのマシン語レベルの命令セットと互換もしくは上位互
換のマシン語命令セットを持つ場合、または前記ホスト
CPUが前記ターゲットCPUと同種のアーキテクチャ
を持つ場合、前記ターゲットCPU用に開発されたター
ゲットプログラムのロード時に前記ターゲットプログラ
ムのマシン語レベルの命令のうち、前記ホストCPUが
直接実行できる命令はそのままメモリ上に配置し、前記
ホストCPU上で動作しているオペレーテイングシステ
ムの制限および前記ターゲットCPUと前記ホストCP
Uの機能の相違により直接実行できない命令は命令シミ
ュレーション手段呼び出し命令に置き換えてメモリ上に
配置し、前記命令シミュレーション手段呼び出し命令に
置換された命令とそのアドレスとを記憶し、前記ホスト
CPUが直接実行可能な命令はホストCPUにより直接
実行し、前記ホストCPUが直接実行ができない命令は
置換した前記命令シュミレーション手段呼び出し命令に
より前記記憶されている対応する命令とアドレスとを参
照して呼び出される命令シミュレーション手段によって
シミュレーションされることを特徴とするCPUシミュ
レーション方法。
1. A CPU simulation method in which an instruction simulation means for simulating a machine language level instruction of a target CPU is executed by the host CPU.
Loading a target program developed for the target CPU if the host CPU has a machine language instruction set compatible or upward compatible with the instruction set at the machine language level of U, or if the host CPU has the same type of architecture as the target CPU; Sometimes the target program
Instructions that can be directly executed by the host CPU among the instructions at the machine language level of the system are directly arranged in the memory, and the restrictions on the operating system operating on the host CPU, the target CPU and the host CP
Instruction can not be executed directly by the difference in the U functionality is placed in the memory by replacing the instruction simulation unit call instruction, the instruction simulation unit call instruction
Instructions that can be directly executed by the host CPU are stored directly, and instructions that cannot be directly executed by the host CPU are stored.
The stored corresponding instruction and address are referred to by the replaced instruction simulation means calling instruction.
CPU simulation method characterized in that it is simulated by the instruction simulation means to be called by irradiation.
JP7109421A 1995-05-08 1995-05-08 CPU simulation method Expired - Fee Related JP2919302B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP7109421A JP2919302B2 (en) 1995-05-08 1995-05-08 CPU simulation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP7109421A JP2919302B2 (en) 1995-05-08 1995-05-08 CPU simulation method

Publications (2)

Publication Number Publication Date
JPH08305583A JPH08305583A (en) 1996-11-22
JP2919302B2 true JP2919302B2 (en) 1999-07-12

Family

ID=14509819

Family Applications (1)

Application Number Title Priority Date Filing Date
JP7109421A Expired - Fee Related JP2919302B2 (en) 1995-05-08 1995-05-08 CPU simulation method

Country Status (1)

Country Link
JP (1) JP2919302B2 (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6397242B1 (en) 1998-05-15 2002-05-28 Vmware, Inc. Virtualization system including a virtual machine monitor for a computer with a segmented architecture
US8631066B2 (en) 1998-09-10 2014-01-14 Vmware, Inc. Mechanism for providing virtual machines for use by multiple users
US7516453B1 (en) 1998-10-26 2009-04-07 Vmware, Inc. Binary translator with precise exception synchronization mechanism
JP4503203B2 (en) * 2001-07-03 2010-07-14 富士通株式会社 Method and apparatus for creating test program for evaluating information processing apparatus, and program describing processing for the same
JP4563669B2 (en) * 2003-11-25 2010-10-13 三菱電機株式会社 Instruction simulator
JP2006155272A (en) 2004-11-30 2006-06-15 Hitachi Ltd Control method and program for virtual computer
JP2007213556A (en) * 2006-01-11 2007-08-23 Matsushita Electric Ind Co Ltd Circuit analysis apparatus
JP4778359B2 (en) 2006-05-17 2011-09-21 エヌイーシーコンピュータテクノ株式会社 Emulation method and computer system
JP5961971B2 (en) * 2011-10-12 2016-08-03 富士通株式会社 Simulation apparatus, method, and program

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPS62128339A (en) * 1985-11-29 1987-06-10 Nec Corp Execution system for program including undefined hardware instruction
JPH021020A (en) * 1988-06-09 1990-01-05 Mitsubishi Electric Corp Programming device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
PATTERSON,HENNESSY「COMPUTER ORGANIZATION & DESIGN:THE HARDWARE/SOFTWARE INTERFACE」Morgan Kaufmann Publishers(1994),Appendix A

Also Published As

Publication number Publication date
JPH08305583A (en) 1996-11-22

Similar Documents

Publication Publication Date Title
US6078744A (en) Method and apparatus for improving compiler performance during subsequent compilations of a source program
US5911073A (en) Method and apparatus for dynamic process monitoring through an ancillary control code system
US5950009A (en) Method and apparatus for profile-based reordering of program portions in a computer program
US8423982B2 (en) Speculative compilation
US5579520A (en) System and methods for optimizing compiled code according to code object participation in program activities
JP3470948B2 (en) Dynamic compilation timing determination method, bytecode execution mode selection method, and computer
US6467082B1 (en) Methods and apparatus for simulating external linkage points and control transfers in source translation systems
EP0453394A2 (en) Dynamic process for the generation of biased pseudo-random test patterns for the functional verification of hardware designs
JP2000347874A (en) Method and device for structuring call rule prolog and epilog codes using register allocator
US7124407B1 (en) Method and apparatus for caching native code in a virtual machine interpreter
US6901583B1 (en) Method for testing of a software emulator while executing the software emulator on a target machine architecture
JP2919302B2 (en) CPU simulation method
US20060026584A1 (en) Explicit linking of dynamic link libraries
JPH0748182B2 (en) Program error detection method
KR100597414B1 (en) Data processing device and register allocation method using data processing device
US7219335B1 (en) Method and apparatus for stack emulation during binary translation
US6275985B1 (en) Method and apparatus for developing an application that implements garbage collection efficiently by combining proxy objects with compiler support
US20030070117A1 (en) Simulation apparatus and simulation method
JPH0766342B2 (en) Program test equipment
Lyu et al. A procedure-based dynamic software update
Chung et al. Improvement of compiled instruction set simulator by increasing flexibility and reducing compile time
JPH1165885A (en) Device and method for debugging software
JPH11134198A (en) Processor and method for compilation, device and method for program execution, and program storage medium
JP3745968B2 (en) Test system, test method, test program, and computer-readable recording medium recording the test program
JPS6292032A (en) Test method for program

Legal Events

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

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 19990406

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees