cool! countzero unit test works!
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 15 May 2020 11:18:25 +0000 (12:18 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 15 May 2020 11:18:25 +0000 (12:18 +0100)
src/soc/countzero/test/test_countzero.py

index 3647cb4d3b46acb1a95a02b9252d9ee1000e2d5b..538db15c82ddd16598f05647ead32b314d5306a0 100644 (file)
@@ -13,7 +13,7 @@ class ZeroCounterTestCase(FHDLTestCase):
         m.submodules.dut = dut = ZeroCounter()
 
         sim = Simulator(m)
-        sim.add_clock(1e-6)
+        sim.add_clock(1e-6)
 
         def process():
             print("test zero input")
@@ -43,6 +43,18 @@ class ZeroCounterTestCase(FHDLTestCase):
             assert(result == 0x20)
             # TODO next tests
 
+            yield dut.rs_i.eq(0b00010000)
+            yield dut.is_32bit_i.eq(0)
+            yield dut.count_right_i.eq(0)
+            yield Delay(1e-6)
+            result = yield dut.result_o
+            assert result == 4, "result %d" % result
+
+            yield dut.count_right_i.eq(1)
+            yield Delay(1e-6)
+            result = yield dut.result_o
+            assert result == 59, "result %d" % result
+
         sim.add_process(process)  # or sim.add_sync_process(process), see below
 
         # run test and write vcd