From: Staf Verhaegen Date: Sun, 4 Apr 2021 16:06:42 +0000 (+0200) Subject: Test different combinations of i, o, oe for InTriOut X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8bb3a13b5e0c87705346e20d2214c54f4223f671;p=soc-cocotb-sim.git Test different combinations of i, o, oe for InTriOut Now run_iverilog_ls180.py show the multiple drive conflict for sram_dq_oe signal. --- diff --git a/ls180/pre_pnr/test.py b/ls180/pre_pnr/test.py index 25e8caf..82dc5e8 100644 --- a/ls180/pre_pnr/test.py +++ b/ls180/pre_pnr/test.py @@ -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()