-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWritebackStage.C
More file actions
57 lines (49 loc) · 1.51 KB
/
WritebackStage.C
File metadata and controls
57 lines (49 loc) · 1.51 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
#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 "WritebackStage.h"
#include "MemoryStage.h"
#include "Status.h"
#include "Debug.h"
#include "Instructions.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 WritebackStage::doClockLow(PipeReg ** pregs, Stage ** stages)
{
W * wreg = (W *) pregs[WREG];
//might be able to delete this icode line below later
//uint64_t icode = wreg->geticode()->getOutput();
uint64_t stat = wreg->getstat()->getOutput();
if (stat != SAOK) return true;
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 WritebackStage::doClockHigh(PipeReg ** pregs)
{
W * wreg = (W *) pregs[WREG];
bool error;
uint64_t valM = wreg->getvalM()->getOutput();
uint64_t dstM = wreg->getdstM()->getOutput();
RegisterFile * regfile = RegisterFile::getInstance();
regfile->writeRegister(wreg->getvalE()->getOutput(), wreg->getdstE()->getOutput(), error);
regfile->writeRegister(valM, dstM, error);
}