From 2416cce2eec7ecdf0587896620806c465747eada Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 22 Mar 2025 14:19:10 -0400 Subject: Add controller.h, implementation and tests. --- tests/controller.cc | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/controller.cc (limited to 'tests/controller.cc') 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 +#include + +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 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); +} -- cgit v1.2.3