blob: 93fd0e083b8bcbec6a8918344b990abe9b068e4e (
plain)
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
|
#include "controller.h"
#include "ex.h"
#include "id.h"
#include "if.h"
#include "mm.h"
#include "response.h"
#include "storage.h"
#include "wb.h"
Controller::Controller(Storage *storage, bool is_pipelined)
: Stage(nullptr)
{
this->clock_cycle = 0;
this->storage = storage;
this->is_pipelined = is_pipelined;
this->pc = 0x0;
this->gprs = {0};
IF *f = new IF(nullptr);
ID *d = new ID(f);
EX *e = new EX(d);
MM *m = new MM(e);
WB *w = new WB(m);
this->next = w;
}
void Controller::run_for(int number)
{
int i;
for (i = 0; i < number; ++i) {
this->advance();
}
}
int Controller::get_clock_cycle() { return this->clock_cycle; }
std::array<int, GPR_NUM> Controller::get_gprs() { return this->gprs; }
int Controller::get_pc() { return this->pc; }
Response Controller::advance()
{
this->next->advance();
++this->clock_cycle;
return OK;
}
|