summaryrefslogtreecommitdiff
path: root/tests/controller.cc
blob: 1d1ddb696fa1754f0f78ac751093919bcd091f9e (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 "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>
#include <vector>

class ControllerPipeFixture
{
  public:
	ControllerPipeFixture()
	{
		this->d = new Dram(1);
		this->c = new Cache(this->d, 5, 0, 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->stage_num = 5;

		this->ct = new Controller(w, this->c, true);
	}
	~ControllerPipeFixture()
	{
		delete this->ct;
		delete this->c;
	};
	void fill_pipe()
	{
		InstrDTO *i = nullptr;
		int j;
		for (j = 0; j < this->stage_num + 1; ++j) {
			i = this->ct->advance(WAIT);
			REQUIRE(i == nullptr);
		}
	}
	int stage_num;
	Cache *c;
	Dram *d;
	Controller *ct;
};