From 23b682daa011ace5cfbfbe2b60ece7369cbe403c Mon Sep 17 00:00:00 2001 From: Tobias Platen Date: Sat, 30 May 2020 21:11:02 +0200 Subject: [PATCH] unit test for DataMerger --- src/soc/experiment/l0_cache.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/soc/experiment/l0_cache.py b/src/soc/experiment/l0_cache.py index 351d09cc..3e2c453c 100644 --- a/src/soc/experiment/l0_cache.py +++ b/src/soc/experiment/l0_cache.py @@ -146,7 +146,7 @@ class DataMergerRecord(Record): #FIXME: make resetless -# TODO: unit test +# TODO: formal verification class DataMerger(Elaboratable): """DataMerger @@ -530,7 +530,22 @@ def l0_cache_ldst(dut): assert data2 == result2, "data2 %x != %x" % (result2, data2) def data_merger_merge(dut): - print("TODO") + print("data_merger") + #starting with all inputs zero + en = yield dut.data_o.en + data = yield dut.data_o.data + assert en == 0, "en must be zero" + assert data == 0, "data must be zero" + yield + yield dut.addr_array_i[0].eq(0xFF) + for j in range(dut.array_size): + yield dut.data_i[j].en.eq(1 << j) + yield dut.data_i[j].data.eq(0xFF << (16*j)) + yield + en = yield dut.data_o.en + data = yield dut.data_o.data + assert data == 0xff00ff00ff00ff00ff00ff00ff00ff + assert en == 0xff yield def test_l0_cache(): @@ -556,4 +571,4 @@ def test_data_merger(): if __name__ == '__main__': test_l0_cache() - #test_data_merger() + test_data_merger() -- 2.30.2