blob: e3b9f3c63e2361c351312511b708b76fecb97e20 (
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
49
50
51
|
#include "controller.h"
#include "cache.h"
#include "dram.h"
#include "ex.h"
#include "id.h"
#include "if.h"
#include "mm.h"
#include "wb.h"
#include <algorithm>
#include <catch2/catch_test_macros.hpp>
class ControllerPipeFixture
{
public:
ControllerPipeFixture()
{
this->c = new Cache(new Dram(3), 1);
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->ct = new Controller(w, this->c, true);
}
~ControllerPipeFixture()
{
delete this->ct;
delete this->c;
};
Cache *c;
Controller *ct;
};
TEST_CASE_METHOD(
ControllerPipeFixture,
"Contructor resets gettable fields",
"[controller_pipe]")
{
std::array<int, GPR_NUM> gprs;
gprs = this->ct->get_gprs();
CHECK(this->ct->get_clock_cycle() == 1);
CHECK(std::all_of(
gprs.begin(), gprs.end(), [](int value) { return value == 0; }));
// change me later
CHECK(this->ct->get_pc() == 0);
}
|