forked from Nilanshrajput/AC2MC-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IAG.h
41 lines (37 loc) · 800 Bytes
/
IAG.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <iostream>
#include"InterStateBuffers.h"
#include"ALU.h"
using namespace std;
// Instruction Adddress generator
class IAG{
public:
//For unpipelined version
void step(InterStateBuffers &isb, ALU &alu){
if(isb.isjalr == true){
isb.PC = isb.RZ.readInt();
}
else if(isb.insType == 5){
isb.PC = isb.PC + isb.pc_offset;
}
else if(isb.insType == 3 && alu.state == true){
isb.PC = isb.PC + isb.pc_offset;
}
else{
isb.PC++;
}
isb.return_address = isb.PC+1;
return;
}
//For pipelined version
void update(InterStateBuffers &isb){
isb.PC++;
isb.return_address = isb.PC+1;
return;
}
void jumpPC(InterStateBuffers &isb,int branchTarget){
isb.PC = branchTarget;
isb.return_address = isb.PC+1;
return;
}
};