From ee2045c20c52b3b6681878e17ee42f99d99f5bab Mon Sep 17 00:00:00 2001 From: Daniel Benusovich Date: Sun, 21 Apr 2019 18:24:07 -0700 Subject: [PATCH] Add ubit test for set associative --- TLB/test/test_set_associative_cache.py | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 TLB/test/test_set_associative_cache.py diff --git a/TLB/test/test_set_associative_cache.py b/TLB/test/test_set_associative_cache.py new file mode 100644 index 00000000..d681425f --- /dev/null +++ b/TLB/test/test_set_associative_cache.py @@ -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") -- 2.30.2