Skip to content

Commit 89ee44d

Browse files
committed
Add test for PCIe spread spectrum clocking
Signed-off-by: Alex Forencich <alex@alexforencich.com>
1 parent 36cf9c9 commit 89ee44d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tb/ptp_td_leaf/test_ptp_td_leaf.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,40 @@ async def run_test(dut):
421421
assert abs(mean(rel_diffs)) < 5
422422
assert abs(mean(tod_diffs)) < 5
423423

424+
await RisingEdge(dut.clk)
425+
tb.log.info("Coherent tracking (250 MHz +0/-0.5%)")
426+
427+
tb.set_ptp_clock_period(6.4)
428+
tb.set_clock_period(4.0)
429+
430+
await RisingEdge(dut.clk)
431+
432+
period = 4.000
433+
step = 0.0002
434+
period_min = 4.0
435+
period_max = 4.0*(1+0.005)
436+
437+
for i in range(5000):
438+
period += step
439+
440+
if period <= period_min:
441+
step = abs(step)
442+
if period >= period_max:
443+
step = -abs(step)
444+
445+
tb.set_clock_period(period)
446+
447+
for i in range(20):
448+
await RisingEdge(dut.clk)
449+
450+
assert tb.dut.locked.value.integer
451+
452+
rel_diffs, tod_diffs = await tb.measure_ts_diff()
453+
tb.log.info(f"Difference (rel): {mean(rel_diffs)} ns (stdev: {stdev(rel_diffs)})")
454+
tb.log.info(f"Difference (ToD): {mean(tod_diffs)} ns (stdev: {stdev(tod_diffs)})")
455+
assert abs(mean(rel_diffs)) < 5
456+
assert abs(mean(tod_diffs)) < 5
457+
424458
await RisingEdge(dut.clk)
425459
tb.log.info("Significantly slower (100 MHz)")
426460

0 commit comments

Comments
 (0)