Skip to content

Commit

Permalink
test_husky.py: make test_pll smarter
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcrypt committed Sep 5, 2023
1 parent dc2a9a2 commit 9206b1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test_husky.py
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,9 @@ def test_pll(fulltest, freq, adc_mul, xtal, oversample, tolerance, reps, desc):
else:
refclk = 'target'
exp_phase = get_adc_clock_phase(refclk)
half_period = oversample//adc_mul//2
if exp_phase > half_period:
exp_phase -= half_period*2
for i in range(reps):
for op in ['recal', 'reset']:
if op == 'recal':
Expand All @@ -1871,6 +1874,9 @@ def test_pll(fulltest, freq, adc_mul, xtal, oversample, tolerance, reps, desc):
assert scope.clock.pll.pll_locked
assert scope.LA.locked
delta = get_adc_clock_phase(refclk)
half_period = oversample//adc_mul//2
if delta > half_period:
delta -= 2*half_period
if abs(delta - exp_phase) >= oversample//adc_mul//2 + tolerance:
# this is the real error that we're testing for:
assert False, 'Uh-oh, looks like a 180 degree phase shift! exp_phase=%d, delta=%d, op=%s, iteration=%d' % (exp_phase, delta, op, i)
Expand Down

0 comments on commit 9206b1c

Please sign in to comment.