From f4c2b1eb1fbf9500c4479543432dacd9fdcaae74 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sun, 30 Oct 2022 22:14:18 -0400 Subject: [PATCH] pmd_dp83223: Don't intentionally cause bit errors On stretches without transitions, we can lose (or gain) a bit, depending on how the reciever is reckoning. This can cause spurious test failures when we get especially unlucky. Keep track of our running disparity (time-wise, not value-wise) and keep perfect time until we get a transition (or we start moving back in the right direction). Signed-off-by: Sean Anderson --- tb/pmd_dp83223_rx.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tb/pmd_dp83223_rx.py b/tb/pmd_dp83223_rx.py index be16d4a..f9f5807 100644 --- a/tb/pmd_dp83223_rx.py +++ b/tb/pmd_dp83223_rx.py @@ -40,8 +40,23 @@ async def test_rx(pmd, delays): # random phase await Timer(random.randrange(1, 8000), units='ps') pmd.signal_detect.value = 1 + + last_bit = ins[0] + running_disparity = 0 for i, delay in zip(ins, delays(len(ins))): pmd.indicate_data.value = i + # Keep track of how far off we are... + if i != last_bit: + running_disparity = 0 + running_disparity += 8000 - delay + last_bit = i + + # If we get more than a quarter cycle off, use perfect delay until + # we get a transition + if abs(running_disparity) >= 2000: + running_disparity -= 8000 - delay + delay = 8000 + try: pmd.delay.value = delay except AttributeError: