-
Notifications
You must be signed in to change notification settings - Fork 1
/
IAG.h
40 lines (37 loc) · 799 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
#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;
}
};