blob: 65e5676befa02cf9eb3b2e9170c6863b334ec48f (
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
47
48
|
#include "controller.h"
#include "response.h"
#include "storage.h"
Controller::Controller(Stage *stage, Storage *storage, bool is_pipelined)
: Stage(stage)
{
this->clock_cycle = 1;
this->storage = storage;
this->is_pipelined = is_pipelined;
this->pc = 0x0;
this->checked_out = {};
this->gprs = {0};
// grant side-door access
this->id = SIDE;
}
void Controller::run_for(int number)
{
int i;
for (i = 0; i < number; ++i) {
this->advance(WAIT);
}
}
int Controller::get_clock_cycle() { return this->clock_cycle; }
std::array<int, GPR_NUM> Controller::get_gprs() { return this->gprs; }
void Controller::set_gprs(int index, int value) { this->gprs[index] = value; }
void Controller::set_pipelined(bool value) { this->is_pipelined = value; }
int Controller::get_pc() { return this->pc; }
InstrDTO *Controller::advance(Response p)
{
InstrDTO *r;
r = this->next->advance(p);
++this->clock_cycle;
return r;
}
void Controller::advance_helper()
{
// TODO: check halt condition and call UI to refresh
}
|