JPH08305583A - Method for simulating cpu - Google Patents

Method for simulating cpu

Info

Publication number
JPH08305583A
JPH08305583A JP7109421A JP10942195A JPH08305583A JP H08305583 A JPH08305583 A JP H08305583A JP 7109421 A JP7109421 A JP 7109421A JP 10942195 A JP10942195 A JP 10942195A JP H08305583 A JPH08305583 A JP H08305583A
Authority
JP
Japan
Prior art keywords
instruction
cpu
simulation
replacement
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.)
Granted
Application number
JP7109421A
Other languages
Japanese (ja)
Other versions
JP2919302B2 (en
Inventor
Naoki Sato
直樹 佐藤
Osamu Nakakoshi
修 中越
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.)
N II C JOHO SYST KK
NEC Corp
Original Assignee
N II C JOHO SYST KK
NEC Corp
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 N II C JOHO SYST KK, NEC Corp filed Critical N II C JOHO SYST 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)

Abstract

PURPOSE: To do simulation of a target program working on a host CPU at a high speed working on a target CPU. CONSTITUTION: An instruction replacement means 10 replaces an instruction not executed directly on a host CPU with an instruction simulation means call instruction while leaving an instruction code directly executed by the host CPU among instructions included in a target program 2, stores the replaced code to an instruction code area 13 and an address of the replaced instruction and the instruction code are stored in a replacement instruction position storage area 14. When the host CPU 12 executes the instruction code stored in the instruction code area after the replacement, the instruction executed directly is directly executed and when the instruction simulation means call instruction is executed, an instruction simulation means 15 is called and the instruction not directly executed is simulated.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、ターゲットCPUの動
作をホストCPU上でシミュレートする方法に関し、特
に、高速なCPUシミュレーション方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention 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 debug or performance analysis is performed on the target machine, a program developed for the target CPU (referred to as a target program) is debugged and performance is improved. Target CP is used as an evaluation method.
There is a method of simulating the operation of the target CPU related to the target program on a CPU simulator including a host CPU which is a CPU different from U, and the method is an interpreter method for sequentially interpreting and executing the source program for the target CPU. It is roughly divided into a CPU simulation method used and a CPU simulation method using an object simulation method for sequentially interpreting and executing the machine language code of the target CPU (for example, edited by the Institute of Electronics and Communication Engineers Handbook Committee,
Ohmsha Co., Ltd., issued March 30, 1988, first edition "Electronic Information and Communication Handbook Second Volume", page 1857, 5 ・ 3 "Simulator").

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

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

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

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

【0007】[0007]

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

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

【0009】[0009]

【課題を解決するための手段】本発明は、ターゲットC
PUのマシン語レベルの命令をシミュレーションする
命令シミュレーション手段をホストCPUによって実行
するCPUシミュレーション方法において、前記ホスト
CPUが前記ターゲットCPUのマシン語レベルの命令
セットと互換もしくは上位互換のマシン語命令セットを
持つ場合、または前記ホストCPUが前記ターゲットC
PUと同種のアーキテクチャを持つ場合、前記ターゲッ
トCPU用に開発されたターゲットプログラムのマシン
語レベルの命令のうち、前記ホストCPUが直接実行で
きる命令はそのままメモリ上に配置し、前記ホストCP
U上で動作しているオペレーティングシステムの制限お
よび前記ターゲットCPUと前記ホストCPUの機能の
相違により直接実行できない命令は命令シミュレーショ
ン手段呼び出し命令に置き換えてメモリ上に配置するこ
とにより、前記ホストCPUが直接実行可能な命令はホ
ストCPUにより直接実行し、前記ホストCPUが直接
実行ができない命令は前記命令シミュレーション手段呼
び出し命令により呼び出される命令シミュレーション手
段によってシミュレーションされることを特とするも
のである。
The present invention provides a target C
Simulate PU machine language level instructions
In a CPU simulation method for executing an instruction simulation means by a host CPU, when the host CPU has a machine language instruction set compatible with or higher than the machine language level instruction set of the target CPU, or the host CPU has the target C
In the case of having the same kind of architecture as the PU, of the machine language level instructions of the target program developed for the target CPU, the instructions that can be directly executed by the host CPU are directly placed in the memory, and the host CP
An instruction that cannot be directly executed due to a limitation of the operating system operating on U and a difference in function between the target CPU and the host CPU is replaced with an instruction simulating means calling instruction and placed in the memory so that the host CPU directly executable instructions executed directly by the host CPU, the instructions the host CPU can not directly execute it is an feature that is simulated by the instruction simulation unit that is called by the instruction simulation unit call instruction.

【0010】[0010]

【実施例】次に本発明の実施例について図面を参照して
詳細に説明する。
Embodiments of the present invention will now be described in detail with reference to the drawings.

【0011】図1は本発明によるCPUシミュレーショ
ン方法を適用したCPUシミュレータの一実施例を示す
構成図である。
このCPUシミュレータ1は、ホストCPU12と、メ
モリ11とを具備する。メモリ11は、ターゲットプロ
グラム2に含まれる、ホストCPU12で直接実行でき
ない命令を、命令シミュレーション手段15を呼び出す
命令に置き換える処理、および置き換えを行う以前の命
令コードとそのアドレスを置き換え命令位置記憶領域1
4に登録する命令置き換え手段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 includes a host CPU 12 and a CPU.
Mori 11 and. The memory 11 replaces an instruction included in the target program 2 that cannot be directly executed by the host CPU 12 with an instruction that calls the instruction simulation means 15, and replaces an instruction code and its address before the instruction replacement storage area 1
4, the instruction replacement means 10 , the instruction code area 13 after replacement, and the replacement instruction position storage area 14
, Instruction simulation means 15 are stored.

【0012】ターゲットプログラム2は、ターゲットC
PU (図示せず。以下同じ)用に開発されたプログラム
であり、ターゲットCPUのマシン語レベルの命令コー
ド2-1 〜2-n で構成されている。
The target program 2 is the target C
It is a program developed for a PU (not shown; the same applies hereinafter), and is composed of machine language level instruction codes 2-1 to 2-n 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 post-replacement instruction code area 13 is a set of instructions that can be directly executed by the host CPU 12 among the instruction codes included in the target program 2 and instructions that cannot be directly executed by the CPU 12 are replaced by instruction simulation means calling instructions. is there. Of the instruction codes in the target program 2, if the instruction code 2-2 cannot be directly executed by the host CPU 12, it is converted into an instruction simulation means call instruction 13-2 and placed in the memory 11. Command code 2-1 and 2-n are host C
In the case of executable instructions directly by PU12, it is arranged as the instruction code 13-1,13-n on intact memory 11.

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

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

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

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

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

【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 simulating means call instruction, the instruction code is directly executed by the host CPU 12.
When the executed instruction is the instruction simulating means calling instruction, the execution shifts to the instruction simulating means 15.

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

【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, so that the target CP of 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 flow chart showing the processing of the instruction replacement means 10. In step 101, it performs a process of reading a command of the target program stored in the memory or file (not shown) or the like.

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

【0025】ステップ103 では、ステップ101 で読み込
んだ命令コードを置き換え後の命令コード領域13へ格
納する処理を行う。
In step 103, the instruction code read in step 101 is stored in the replaced instruction code area 13.

【0026】ステップ104 では、命令シミュレーション
手段呼び出し命令を置き換え後の命令コード領域13へ
格納する処理を行う。
In step 104, the instruction simulation means call instruction is stored in the instruction code area 13 after replacement.

【0027】ステップ105 では、ステップ101 で読み込
んだ命令コードとその命令コードがメモリ上で配置され
るアドレスを置き換え命令位置記憶手段14へ格納する
処理を行う。
In step 105, the instruction code read in step 101 and the address where the instruction code is arranged in the memory are stored in the replacement instruction position storage means 14.

【0028】ステップ106 では、ターゲットプログラム
2の命令コードをすべて読み込んだかどうかを判別し、
すべての命令を読み込んでいない場合にはステップ101
へ進み、すべての命令を読み込んだ場合には、処理を終
了する。
[0028] In step 106, it is determined whether or not read all the instruction code of the target program 2,
Step 101 if all instructions have not been read
If all the instructions have been read, the process ends.

【0029】以下に、ターゲットCPUがMIPS社の
R3000で、ホストCPUがR3000でオペレーティングシ
ステムとしてUNIXを搭載しCPUシミュレータがU
NIXのアプリケーションプログラムとして動作する場
合の命令置き換えの例をアセンブラ表記で示す。また、
命令の配置されるアドレスは説明のためAddr_1 〜Addr
_5 というラベル名を使用する。
Below, the target CPU is M3000 R3000, the host CPU is R3000, UNIX is installed as an operating system, and the CPU simulator is U.
An example of instruction replacement when operating as a NIX application program is shown in assembler notation. Also,
The address where the instruction is arranged is Addr_1 to Addr for the purpose of 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 the target program Addr_1: srl ra, ra, 6 / * Directly executable on the host CPU * / Addr_2: sll ra, ra, 6 / * Directly executable on the host CPU * / Addr_3: or gp, gp, ra / * Can be executed directly on the host CPU * / Addr_4: mtc0 gp, sr / * Cannot be executed directly on the host CPU * / Addr_5: lw ra, 0x50 (sp) / * On the 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 / * Replacement None * / Addr_4: .word 0xfffffffe / * Replace instruction * / Addr_5: lw ra, 0x50 (sp) / * No replacement * / The above srl, sll, or, lw instructions operate as UNIX application programs. Although the host CPU can be executed directly on the CPU simulator, the mtc0 instruction is a privileged instruction, so it must be a UNIX application program. CPU simulator that is running can not be executed directly. Therefore, the mtc0 instruction is the instruction simulation means calling means (.word 0xff in this example).
I am using 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 the CPU simulator operating as the UNIX application program can directly execute the instruction.
In step 103, the process of arranging in the memory is performed as it is, and in the case of an instruction that cannot be directly executed, in step 104, it is replaced with the instruction simulation means calling instruction (in this example, .word 0xfffffffe is used) and is placed in the memory.

【0032】また直接実行できない命令の場合には、ス
テップ105 で置き換えを行った命令のアドレスと命令コ
ードを、図1の置き換え命令位置記憶領域14に格納す
る処理を行っている。
If the instruction cannot be directly executed, the address and the instruction code of the instruction replaced in step 105 are stored in the replacement instruction position storage area 14 of FIG.

【0033】この例で、ステップ105 で置き換え命令位
置記憶領域14に格納される情報は、
In this example, the information stored in the replacement command position storage area 14 in step 105 is

【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 a CPU simulator, which is an application program on IX, executes this instruction, UNIX starts a processing routine called a signal handler. In this example, in order to transfer control to the instruction simulation means, 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 shows an example of information stored in the replacement command 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 that instruction. In FIG. 3, for the sake of explanation, addresses are shown as label names and instruction codes are shown in assembler notation. In this example, target program 2
The instruction “mtc0 gp, sr” at the address “Addr_4” in the
It 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 subject to instruction replacement.

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

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

【0040】次にステップ152 では、命令シミュレーシ
ョン手段呼び出し命令のアドレスをもとに、置き換え命
令位置記憶領域14から置き換えられる前の命令コード
を取得する処理を行う。
Next, at step 152, processing for acquiring the instruction code before being replaced from the replacement instruction position storage area 14 is performed based on the address of the instruction simulating means calling instruction.

【0041】次にステップ153 では、ステップ152 で取
得した置き換え前の命令を解析し、置き換え前の命令を
シミュレーションする命令シミュレーション処理へ実行
を移す。
Next, at step 153, the instruction before replacement obtained at step 152 is analyzed, and the execution is shifted to the instruction simulation processing for simulating the instruction before replacement.

【0042】ステップ154-1 〜154-m は、命令のシミュ
レーション処理を行う部分で、命令の種類ごとに処理が
用意されている。ここでは、ステップ151 で収集したレ
ジスタ情報を参照および変更しながら命令のシミュレー
ションを行う。
Steps 154-1 to 154-m are parts for performing instruction simulation processing, and processing is prepared for each type of instruction. Here, a simulation of the instruction referring Oyo change beauty the collected register information in step 151.

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

【0044】[0044]

【発明の効果】以上説明したように、本発明ではシミュ
レーション実行時にすべての命令コードを解釈およびシ
ミュレートする必要がないため、従来のCPUシミュレ
ショ ン方法よりも高速なシミュレーションが可能であ
る。
As described in the foregoing, in the present invention because there is no need to interpret and simulate all the instruction code during simulation run, which enables high-speed simulation than conventional CPU simulation method.

【図面の簡単な説明】[Brief description of 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 instruction replacing means 10 in FIG.

【図3】図1中の置き換え命令位置記憶領域14中に記
憶されている情報の例を示す図である。
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.

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

1 CPUシミュレータ 10 命令置き換え手段 11 メモリ 12 ホストCPU 13 置き換え後の命令コード領域 13-1,13-n 命令コード 13-2 命令シミュレーション手段呼びだし命令 14 置き換え命令位置記憶領域 15 命令シミュレーション手段 2 ターゲットプログラム 2-1 〜2-n 命令コード 3 外部記憶装置 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 Calling 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

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】 ターゲットCPUのマシン語レベルの命
令をシミュレーションする命令シミュレーション手段を
ホストCPUによって実行するCPUシミュレーション
方法において、 前記ホストCPUが前記ターゲットCPUのマシン語レ
ベルの命令セットと互換もしくは上位互換のマシン語命
令セットを持つ場合、または前記ホストCPUが前記タ
ーゲットCPUと同種のアーキテクチャを持つ場合、前
記ターゲットCPU用に開発されたターゲットプログラ
ムのマシン語レベルの命令のうち、前記ホストCPUが
直接実行できる命令はそのままメモリ上に配置し、前記
ホストCPU上で動作しているオペレーティングシステ
ムの制限および前記ターゲットCPUと前記ホストCP
Uの機能の相違により直接実行できない命令は命令シミ
ュレーション手段呼び出し命令に置き換えてメモリ上に
配置することにより、前記ホストCPUが直接実行可能
な命令はホストCPUにより直接実行し、前記ホストC
PUが直接実行ができない命令は前記命令シミュレーシ
ョン手段呼び出し命令により呼び出される命令シミュレ
ーション手段によってシミュレーションされることを特
とする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 a host CPU, wherein the host CPU is compatible or upward compatible with a machine language level instruction set of the target CPU. Of the machine language level instructions of the target program developed for the target CPU, the host CPU can directly execute if it has a machine language instruction set or if the host CPU has the same architecture as the target CPU. The instruction is placed in the memory as it is, the limitation of the operating system operating on the host CPU and the target CPU and the host CP.
Instructions that cannot be directly executed due to a difference in the function of U are replaced with instruction simulation means calling instructions and placed in the memory, so that instructions that can be directly executed by the host CPU are directly executed by the host CPU and the host C
The instruction that the PU cannot directly execute is simulated by the instruction simulation means called by the instruction simulation means call instruction.
CPU simulation method and butterflies.
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 true JPH08305583A (en) 1996-11-22
JP2919302B2 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)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003015914A (en) * 2001-07-03 2003-01-17 Fujitsu Ltd Method for producing test program for evaluating information processing unit, device and program describing processing therefor
US6785886B1 (en) 1998-05-15 2004-08-31 Vmware, Inc. Deferred shadowing of segment descriptors in a virtual machine monitor for a segmented computer architecture
JP2005157640A (en) * 2003-11-25 2005-06-16 Mitsubishi Electric Corp Instruction simulation device, instruction simulation method and instruction simulation program
JP2007213556A (en) * 2006-01-11 2007-08-23 Matsushita Electric Ind Co Ltd Circuit analysis apparatus
JP2007310546A (en) * 2006-05-17 2007-11-29 Nec Computertechno Ltd Emulation method and computer system
US7516453B1 (en) 1998-10-26 2009-04-07 Vmware, Inc. Binary translator with precise exception synchronization mechanism
US7725642B2 (en) 2004-11-30 2010-05-25 Hitachi, Ltd. Method and program for partitioning a physical computer into logical partitions
KR101332499B1 (en) * 2011-10-12 2013-11-26 후지쯔 가부시끼가이샤 Simulation apparatus, simulation method, and recording medium
US8631066B2 (en) 1998-09-10 2014-01-14 Vmware, Inc. Mechanism for providing virtual machines for use by multiple users

Citations (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

Patent Citations (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

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6785886B1 (en) 1998-05-15 2004-08-31 Vmware, Inc. Deferred shadowing of segment descriptors in a virtual machine monitor for a segmented computer architecture
US8631066B2 (en) 1998-09-10 2014-01-14 Vmware, Inc. Mechanism for providing virtual machines for use by multiple users
US9323550B2 (en) 1998-09-10 2016-04-26 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
JP2003015914A (en) * 2001-07-03 2003-01-17 Fujitsu Ltd Method for producing test program for evaluating information processing unit, device and program describing processing therefor
JP2005157640A (en) * 2003-11-25 2005-06-16 Mitsubishi Electric Corp Instruction simulation device, instruction simulation method and instruction simulation program
JP4563669B2 (en) * 2003-11-25 2010-10-13 三菱電機株式会社 Instruction simulator
US7725642B2 (en) 2004-11-30 2010-05-25 Hitachi, Ltd. Method and program for partitioning a physical computer into logical partitions
JP2007213556A (en) * 2006-01-11 2007-08-23 Matsushita Electric Ind Co Ltd Circuit analysis apparatus
JP2007310546A (en) * 2006-05-17 2007-11-29 Nec Computertechno Ltd Emulation method and computer system
US8392893B2 (en) 2006-05-17 2013-03-05 Nec Computertechno, Ltd. Emulation method and computer system
KR101332499B1 (en) * 2011-10-12 2013-11-26 후지쯔 가부시끼가이샤 Simulation apparatus, simulation method, and recording medium

Also Published As

Publication number Publication date
JP2919302B2 (en) 1999-07-12

Similar Documents

Publication Publication Date Title
US6078744A (en) Method and apparatus for improving compiler performance during subsequent compilations of a source program
US5950009A (en) Method and apparatus for profile-based reordering of program portions in a computer program
US6292940B1 (en) Program complete system and its compile method for efficiently compiling a source program including an indirect call for a procedure
US6467082B1 (en) Methods and apparatus for simulating external linkage points and control transfers in source translation systems
EP0905617B1 (en) Method for generating a java bytecode data flow graph
US7016807B2 (en) Device and method for monitoring a program execution
EP0428560A1 (en) Machine process for translating programs in binary machine language into another binary machine language
US6625807B1 (en) Apparatus and method for efficiently obtaining and utilizing register usage information during software binary translation
JPH08305583A (en) Method for simulating cpu
KR100597414B1 (en) Data processing device and register allocation method using data processing device
US7219335B1 (en) Method and apparatus for stack emulation during binary translation
JPH0766342B2 (en) Program test equipment
CN112882701A (en) Executable file static pile inserting technical framework supporting multiple architectures
JPH096646A (en) Program simulation device
KR100345401B1 (en) Method and apparatus for binary program translation
JP2729795B2 (en) Parallel computer and control method thereof
Gyllstrom et al. The universal compiling system
JP3323147B2 (en) Compiling device, compiling method, and recording medium recording compiler program
JPH06202903A (en) Cpu simulation and cpu simulator
JP3018783B2 (en) Compilation method
JPH07192034A (en) Interpreter type simulation method
JPH06119203A (en) Debugging line deleting device
CN117435171A (en) Integrated development method for RISC-V architecture processor
CN116775127A (en) Static symbol execution pile inserting method based on RetroWrite framework
JPH05224908A (en) Program production system

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