当前位置:   article > 正文

C++ 计算机组成原理 模拟Pipeline_pipeline lw

pipeline lw

pipeline

题目:

以C/C++实现Pipeline处理器指令运作模拟程序。设计下列指令:
lw, sw, add, addi, sub, and, andi, or, slt, beq
并且能够检查和处理几个预测data hazard, hazard with load, branch hazard。

输出:

其中SampleInput.txt的初始化是根据Sample的初始data设置的,其余都是按照题目要求设置的:
regs[10] = { 0,9,5,7,1,2,3,4,5,6 };
mem[5] = { 5,9,4,8,7 };

程序:

输入文件"General", “Datahazard”, “Lwhazard”, “Branchhazard”
输出文件"genResult.txt",“dataResult.txt”,“loadResult.txt”, “branchResult.txt”

读取文件(一次性read):
readFile();

存储instruction:
vector<bitset<32>> instruction;

计算方法上使用五个struct和六个函数:
struct IF_Path
struct ID_Path
struct EX_Path
struct MEM_Path
struct WB_Path

主要类:

class Pipeline(inputFile, outputFile):
{
	readInstruct();
	Display();
	MEM_WB();
	EX_MEM();
	ID_EX();
	IF_ID();
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

代码链接:https://github.com/Yundi339/Pipeline/tree/master/Pipeline

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/254677
推荐阅读
相关标签
  

闽ICP备14008679号