summaryrefslogtreecommitdiff
path: root/tests/c11.h
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-04-16 12:41:34 -0400
committerGitHub <noreply@github.com>2025-04-16 12:41:34 -0400
commit43e660152ebf1d8c8aa46f5478d4d26885d4a12c (patch)
tree41ab4e108784f6c180ad23fcc3bd3bf9440a9a2b /tests/c11.h
parentbe2bc108dc112ae7e21d4a77f7bcbfac88d6fcd4 (diff)
parent71f69927931e007d0bac13b9268b6a697b45c70a (diff)
Merge pull request #2 from bdunahu/bdunahu
[WIP] Memory Rewrite
Diffstat (limited to 'tests/c11.h')
-rw-r--r--tests/c11.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/c11.h b/tests/c11.h
new file mode 100644
index 0000000..e5599db
--- /dev/null
+++ b/tests/c11.h
@@ -0,0 +1,54 @@
+#include "cache.h"
+#include "dram.h"
+#include "storage.h"
+#include <algorithm>
+#include <array>
+#include <catch2/catch_test_macros.hpp>
+#include <functional>
+
+/**
+ * one way associative, single level
+ */
+class C11
+{
+ public:
+ C11()
+ {
+ this->m_delay = 4;
+ this->c_delay = 2;
+ this->mem = new int();
+ this->fetch = new int();
+ this->c = new Cache(new Dram(this->m_delay), 5, 0, this->c_delay);
+ this->expected = {0, 0, 0, 0};
+ this->actual = this->c->view(0, 1)[0];
+ }
+
+ ~C11()
+ {
+ delete this->c;
+ delete this->mem;
+ delete this->fetch;
+ }
+
+ void
+ wait_then_do(int delay, std::function<int()> f)
+ {
+ for (int i = 0; i < delay; ++i) {
+ int r = f();
+
+ // check response
+ CHECK(!r);
+ // check for early modifications
+ actual = c->view(0, 1)[0];
+ REQUIRE(this->expected == this->actual);
+ }
+ }
+
+ int m_delay;
+ int c_delay;
+ Cache *c;
+ int *mem;
+ int *fetch;
+ std::array<signed int, LINE_SIZE> expected;
+ std::array<signed int, LINE_SIZE> actual;
+};