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

📄 simulator.h

📁 计算机系统结构中实现记分牌算法的一个模拟器
💻 H
字号:
// Simulator.h: interface for the CSimulator class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SIMULATOR_H__412C4E79_BEC2_4562_9916_5897A4E04D03__INCLUDED_)
#define AFX_SIMULATOR_H__412C4E79_BEC2_4562_9916_5897A4E04D03__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

//typedef enum {LD, MULT, SUBD, DIVD, ADDD} Operation;
typedef enum {BUSY, OP, FI, FJ, FK, QJ, QK, RJ, RK} UiSta;
typedef enum {WAIT_ISSUE, WAIT_READ,WAIT_EXCUTE, WAIT_WRITE, FINISHED} WaitSta;
typedef enum {ISSUE, READ, EXCUTE, WRITE,NOTHING} RunType;
enum {INTEGER, MULT1, MULT2,ADD, DIVIDE};

struct FunUnit{
	char *Name;
	bool Busy;
	char *Op;
	char *Fi;
	char *Fj;
	char *Fk;
	FunUnit *Qj;
	FunUnit *Qk;
	bool Rj;
	bool Rk;	
};

struct Instruction {
	char op[6];
	char destReg[4];
	char srcOperand1[4];
	char srcOperand2[4];
	FunUnit *unitUsed;
	WaitSta waitSta;
	int ExcuteTime;
};

class CSimulator  
{
public:
	Instruction *curPro;
	int insNum;
	FunUnit *funUnit;
	FunUnit *Register[31];

	CListCtrl *pProList;
	CListCtrl *pInsList;
	CListCtrl *pFunList;
	CListCtrl *pRegList;

public:
	int * numItem;
	RunType GetRunType(Instruction *ins, int num);
	int GetIndex(char *RegName);
	
	void UpdateList();
	bool RunStep(int curStep);
	bool WriteResult(Instruction *ins);
	bool ExcuteInstruction(Instruction *ins);
	bool ReadOperand(Instruction *ins);
	bool Issue(Instruction *ins);
	int GetPeriods(Instruction ins);
	FunUnit * GetFunUnit(Instruction *ins);
	void initial(CString filePath);

	CSimulator(CListCtrl *m_cProList, CListCtrl *m_cInsStaList, CListCtrl * m_cFunList, CListCtrl *m_cRegList);
	virtual ~CSimulator();

};

#endif // !defined(AFX_SIMULATOR_H__412C4E79_BEC2_4562_9916_5897A4E04D03__INCLUDED_)

⌨️ 快捷键说明

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