summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbd <bdunaisky@umass.edu>2025-03-23 17:47:34 +0000
committerGitHub <noreply@github.com>2025-03-23 17:47:34 +0000
commit877aa98855fad77ef93a8c9f5a5e8191fbb9e699 (patch)
tree75d92632f6e9b2f112e45791af9dc01389039557 /tests
parent8a0a483c0e63fd2be6f514a20ae7309e2e768c94 (diff)
parentdf2391b70b89f15be7932d18fa77f950fc452f31 (diff)
Merge pull request #30 from bdunahu/bdunahu
Add controller.h, implementation and tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/cache.cc1
-rw-r--r--tests/controller.cc39
-rw-r--r--tests/dram.cc1
3 files changed, 39 insertions, 2 deletions
diff --git a/tests/cache.cc b/tests/cache.cc
index c64f00e..0b04bce 100644
--- a/tests/cache.cc
+++ b/tests/cache.cc
@@ -1,5 +1,4 @@
#include "cache.h"
-#include "definitions.h"
#include "dram.h"
#include <catch2/catch_test_macros.hpp>
diff --git a/tests/controller.cc b/tests/controller.cc
new file mode 100644
index 0000000..a1b8123
--- /dev/null
+++ b/tests/controller.cc
@@ -0,0 +1,39 @@
+#include "controller.h"
+#include "cache.h"
+#include "dram.h"
+#include <algorithm>
+#include <catch2/catch_test_macros.hpp>
+
+class ControllerPipeFixture
+{
+ public:
+ ControllerPipeFixture()
+ {
+ this->c = new Cache(new Dram(3), 1);
+ this->ct = new Controller(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() == 0);
+ CHECK(std::all_of(
+ gprs.begin(), gprs.end(), [](int value) { return value == 0; }));
+ // change me later
+ CHECK(this->ct->get_pc() == 0);
+}
diff --git a/tests/dram.cc b/tests/dram.cc
index 7329bf2..0e97e81 100644
--- a/tests/dram.cc
+++ b/tests/dram.cc
@@ -1,5 +1,4 @@
#include "dram.h"
-#include "definitions.h"
#include <array>
#include <catch2/catch_test_macros.hpp>