⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sim_proc.h

📁 run mips program using C++
💻 H
字号:
/* * The skeleton gives two classes: Program and Simulator. * * The Program class stores all information of the given assembly program, and * the Simulator class realizes the assembly language simulator. * * Basically, you are asked to implement the assigned functions in Simulator. * You can make use of the functions provided in the Program class, and * you are not suggested to make changes in the Program class, while you may * make small changes according to your implementation. * * NOTICE: We can not guarantee the appearance of any possible bug!! * * The start address of the program is fixed to zero, i.e. PC should be initialzed to zero. * * There is one limitation to the format of the program that the label should occupy a single line, * which means you should write *		Label: *		add $s0, $t0, $t1 * The format of *		Label: add $s0, $t0, $t1 * may cause an error in the program. * * Compiled and tested under VC6.0, compitable with VC7.0 or above * *			Vincent Liu, Andy He *			       14 Apr 2007 */#ifndef _SIMULATOR_H_#define _SIMULATOR_H_#include "structures.h"#include "loader.h"// the simulator class, you mainly need to work on itclass Simulator{public:	// the functions you are going to implement	// if necessarily, please change the type of the params and return values of the	// first five functions used for the five phases of going through one instruction	unsigned int Fetch(unsigned int PC);	unsigned int Decode(const unsigned int IR);	unsigned int Execute(const unsigned int IR);	unsigned int MemoryAccess(const unsigned int IR);	unsigned int WriteBack(const unsigned int IR);	void	ComputeSignals(int phase, const unsigned int IR);	// compute the values of all signals	// the function can be changed according to your implementation	int StartSimulation(Program p);		// call this function to start a simulation	// the function you are not allowed to modify	void PrintAllSignalsAndRegs();		// print out the values of all signals and 'used' registers	unsigned int GetOP(const unsigned int IR);	unsigned int GetRS(const unsigned int IR);	unsigned int GetRT(const unsigned int IR);	unsigned int GetRD(const unsigned int IR);	unsigned int GetSH(const unsigned int IR);	unsigned int GetFN(const unsigned int IR);	unsigned int GetIM(const unsigned int IR);	unsigned int GetAD(const unsigned int IR);	void SetRD(const unsigned int IR, unsigned int value);	void SetRT(const unsigned int IR, unsigned int value);	Simulator();	~Simulator();private:	unsigned int PC;		// the PC register	unsigned int A, B;		// the A, B registers	unsigned int ALUOut;	// the ALUOut register	unsigned int MDR;		// the MDR register	SignalSet	 signals;	// signal set	Program		 prog;		// an instance of the treated Program};#endif // _SIMULATOR_H_int getInputPram(int argc, char** argv);void printTitle();FILE *fp;char outputFile[MAX_FILE_NAME];char inputFile[MAX_FILE_NAME];bool ifPrintOut;bool ifWriteToFile;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -