赞
踩
以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();
}
代码链接:https://github.com/Yundi339/Pipeline/tree/master/Pipeline
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。