Test different combinations of i, o, oe for InTriOut
authorStaf Verhaegen <staf@stafverhaegen.be>
Sun, 4 Apr 2021 16:06:42 +0000 (18:06 +0200)
committerStaf Verhaegen <staf@stafverhaegen.be>
Sun, 4 Apr 2021 16:08:37 +0000 (18:08 +0200)
Now run_iverilog_ls180.py show the multiple drive conflict for
sram_dq_oe signal.

ls180/pre_pnr/test.py

index 25e8caff1d71989be8f24f4ec01289e891f9194d..82dc5e87dece718809485cf03c704ef885f3fbce 100644 (file)
@@ -67,31 +67,39 @@ class JTAGPin:
         else:
             raise ValueError(f"Unsupported pin type {self.type_}")
 
-    def data(self, val):
-        if self.type_ in (IOType.In, IOType.Out):
-            return [val]
-        elif self.type_ == IOType.TriOut:
-            return [1, val]
-        elif self.type_ == IOType.InTriOut:
-            return [val, val, 1]
-        else:
-            raise ValueError(f"Unsupported pin type {self.type_}")
-
-    def check(self, wrap, val):
+    def data(self, *, i=None, o=None, oe=None):
         if self.type_ == IOType.In:
-            assert getattr(wrap.ti, f"{self.name}__core__i").value == val
+            assert i is not None
+            return [i]
         elif self.type_ == IOType.Out:
-            assert getattr(wrap.ti, f"{self.name}__pad__o").value == val
+            assert o is not None
+            return [o]
         elif self.type_ == IOType.TriOut:
-            assert getattr(wrap.ti, f"{self.name}__core__o").value == val
-            assert getattr(wrap.ti, f"{self.name}__core__oe").value == 1
+            assert (o is not None) and (oe is not None)
+            return [o, oe]
         elif self.type_ == IOType.InTriOut:
-            assert getattr(wrap.ti, f"{self.name}__core__i").value == val
-            assert getattr(wrap.ti, f"{self.name}__pad__o").value == val
-            assert getattr(wrap.ti, f"{self.name}__pad__oe").value == val
+            assert (i is not None) and(o is not None) and (oe is not None)
+            return [i, o, oe]
         else:
             raise ValueError(f"Unsupported pin type {self.type_}")
 
+    def check(self, *, wrap, i=None, o=None, oe=None):
+        if self.type_ in (IOType.In, IOType.InTriOut):
+            sig = f"{self.name}__core__i"
+            val = getattr(wrap.ti, sig).value
+            if val != i:
+                raise ValueError(f"'{sig}' should be {i}, not {val}")
+        if self.type_ in (IOType.Out, IOType.TriOut, IOType.InTriOut):
+            sig = f"{self.name}__pad__o"
+            val = getattr(wrap.ti, sig).value
+            if val != o:
+                raise ValueError(f"'{sig}' should be {o}, not {val}")
+        if self.type_ in (IOType.TriOut, IOType.InTriOut):
+            sig = f"{self.name}__pad__oe"
+            val = getattr(wrap.ti, sig).value
+            if val != oe:
+                raise ValueError(f"'{sig}' should be {oe}, not {val}")
+
 
 def log_pins(wrap, pins):
     for pin in pins:
@@ -236,20 +244,21 @@ def boundary_scan(wrap, *, jtag):
     log_pins(wrap, pins)
 
     yield jtag.load_ir([0, 0, 0, 0])
-    data = chain(*(pin.data(i%2) for i, pin in enumerate(pins)))
-    yield jtag.shift_data(data)
+    pinsdata = tuple(pin.data(i=i%2, o=((i%3)%2), oe=((i%5)%2))
+                     for i, pin in enumerate(pins))
+    yield jtag.shift_data(chain(*pinsdata))
 
     wrap.info("")
     wrap.info("After scan")
     log_pins(wrap, pins)
-#    pins[0].check(dut, 1)
+    for i, pin in enumerate(pins):
+        pin.check(wrap=wrap, i=i%2, o=((i%3)%2), oe=((i%5)%2))
 
     yield jtag.reset()
 
     wrap.info("")
     wrap.info("After reset")
     log_pins(wrap, pins)
-#    pins[0].check(dut, 0)
 
 
 @cocotb.test()