-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_icode
More file actions
145 lines (127 loc) · 4.08 KB
/
_icode
File metadata and controls
145 lines (127 loc) · 4.08 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <string>
#include <cstdint>
#include "RegisterFile.h"
#include "PipeRegField.h"
#include "PipeReg.h"
#include "F.h"
#include "D.h"
#include "M.h"
#include "W.h"
#include "Stage.h"
#include "FetchStage.h"
#include "Status.h"
#include "Debug.h"
/*
* doClockLow:
* Performs the Fetch stage combinational logic that is performed when
* the clock edge is low.
*
* @param: pregs - array of the pipeline register sets (F, D, E, M, W instances)
* @param: stages - array of stages (FetchStage, DecodeStage, ExecuteStage,
* MemoryStage, WritebackStage instances)
*/
bool FetchStage::doClockLow(PipeReg ** pregs, Stage ** stages) {
F * freg = (F *) pregs[FREG];
D * dreg = (D *) pregs[DREG];
uint64_t f_pc = 0, icode = 0, ifun = 0, valC = 0, valP = 0;
uint64_t rA = RNONE, rB = RNONE, stat = SAOK;
//code missing here to select the value of the PC
//and fetch the instruction from memory
//Fetching the instruction will allow the icode, ifun,
//rA, rB, and valC to be set.
//The lab assignment describes what methods need to be
//written.
//The value passed to setInput below will need to be changed
freg->getpredPC()->setInput(f_pc + 1);
//provide the input values for the D register
setDInput(dreg, stat, icode, ifun, rA, rB, valC, valP);
return false;
}
/* doClockHigh
* applies the appropriate control signal to the F
* and D register intances
*
* @param: pregs - array of the pipeline register (F, D, E, M, W instances)
*/
void FetchStage::doClockHigh(PipeReg ** pregs) {
F * freg = (F *) pregs[FREG];
D * dreg = (D *) pregs[DREG];
freg->getpredPC()->normal();
dreg->getstat()->normal();
dreg->geticode()->normal();
dreg->getifun()->normal();
dreg->getrA()->normal();
dreg->getrB()->normal();
dreg->getvalC()->normal();
dreg->getvalP()->normal();
}
/* setDInput
* provides the input to potentially be stored in the D register
* during doClockHigh
*
* @param: dreg - pointer to the D register instance
* @param: stat - value to be stored in the stat pipeline register within D
* @param: icode - value to be stored in the icode pipeline register within D
* @param: ifun - value to be stored in the ifun pipeline register within D
* @param: rA - value to be stored in the rA pipeline register within D
* @param: rB - value to be stored in the rB pipeline register within D
* @param: valC - value to be stored in the valC pipeline register within D
* @param: valP - value to be stored in the valP pipeline register within D
*/
void FetchStage::setDInput(D * dreg, uint64_t stat, uint64_t icode,
uint64_t ifun, uint64_t rA, uint64_t rB,
uint64_t valC, uint64_t valP)
{
dreg->getstat()->setInput(stat);
dreg->geticode()->setInput(icode);
dreg->getifun()->setInput(ifun);
dreg->getrA()->setInput(rA);
dreg->getrB()->setInput(rB);
dreg->getvalC()->setInput(valC);
dreg->getvalP()->setInput(valP);
}
/*
* PredictPC
*/
void PredictPC() {
}
/*
* PCincrement
*/
void PCincrement() {
}
/*
* selectPC
*/
void selectPC(F * f, M * m, W * w) {
uint64_t M_valA = m->getCnd()->getOutput();
uint64_t W_icode = w->geticode()->getOutput();
uint64_t F_predPC = f->getpredPC()->getOutput();
if (IJXX && M_valA) f_pc = M_valA;
else if (W_icode == IRET ) f_pc = W_icode;
else f_pc = F_predPC;
}
/*
* needRegIds
*/
void needRegIds(uint64_t f_icode) {
need_regids = (f_icode == IRRMOVQ) || (f_icode == IOPQ) ||
(f_icode == IPUSHQ) || (f_icode == IPOPQ) ||
(f_icode == IIRMOVQ) || (f_icode == IRMMOVQ) ||
(f_icode == IMRMOVQ);
}
/*
* needValC
*/
void needValC(uint64_t f_icode) {
need_valC = (f_icode == IIRMOVQ) || (f_icode == IRMMOVQ) ||
(f_icode == IMRMOVQ) || (f_icode == IJXX) ||
(f_icode == ICALL);
}
/*
* predictPC
*/
void predictPC(uint64_t f_icode, uint64_t f_valC, uint64_t f_valP) {
if (f_icode == IJXX || f_icode == ICALL) f_predPC = f_valC;
else f_predPC = f_valP;
}