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:
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()