Add ubit test for set associative
authorDaniel Benusovich <flyingmonkeys1996@gmail.com>
Mon, 22 Apr 2019 01:24:07 +0000 (18:24 -0700)
committerDaniel Benusovich <flyingmonkeys1996@gmail.com>
Mon, 22 Apr 2019 01:24:07 +0000 (18:24 -0700)
TLB/test/test_set_associative_cache.py [new file with mode: 0644]

diff --git a/TLB/test/test_set_associative_cache.py b/TLB/test/test_set_associative_cache.py
new file mode 100644 (file)
index 0000000..d681425
--- /dev/null
@@ -0,0 +1,39 @@
+import sys
+sys.path.append("../src")
+sys.path.append("../../TestUtil")
+
+from nmigen.compat.sim import run_simulation
+
+from SetAssociativeCache import SetAssociativeCache
+
+from test_helper import assert_eq, assert_ne, assert_op
+
+def set_sac(dut, e, c, s, t, d):
+    yield dut.enable.eq(e)
+    yield dut.command.eq(c)
+    yield dut.cset.eq(s)
+    yield dut.tag.eq(t)
+    yield dut.data_i.eq(d)
+    yield
+
+def testbench(dut):
+    enable = 1
+    command = 2
+    cset = 1
+    tag = 2
+    data = 3
+    yield from set_sac(dut, enable, command, cset, tag, data)
+    yield
+
+    enable = 1
+    command = 2
+    cset = 1
+    tag = 5
+    data = 8
+    yield from set_sac(dut, enable, command, cset, tag, data)
+    yield
+
+if __name__ == "__main__":
+    dut = SetAssociativeCache(4, 4, 4, 4)
+    run_simulation(dut, testbench(dut), vcd_name="Waveforms/test_set_associative_cache.vcd")
+    print("Set Associative Cache Unit Test Success")