From 2b752c4bc1acfa7341c2d16f350799faf44513de Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sat, 6 Aug 2022 15:24:47 -0400 Subject: [PATCH] tb: pcs: Specify clock periods directly Instead of calculating clock periods based on the desired frequncy, specify the periods diretly. This silences the following kind of error caused by floating point rounding: Unable to accurately represent 8000.000000000001(sec) with the simulator precision of 1e-12 Fixes: d351291 ("Initial commit") Signed-off-by: Sean Anderson --- tb/pcs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tb/pcs.py b/tb/pcs.py index 4ac789a..8fd3b11 100644 --- a/tb/pcs.py +++ b/tb/pcs.py @@ -224,7 +224,7 @@ async def pcs_send_codes(pcs, codes): @cocotb.test(timeout_time=10, timeout_unit='us') async def test_tx(pcs): - await cocotb.start(Clock(pcs.tx_clk, 1/125e6, units='sec').start()) + await cocotb.start(Clock(pcs.tx_clk, 8, units='ns').start()) async def tx_ce(): pcs.tx_ce.value = 1 while True: @@ -259,7 +259,7 @@ async def test_rx(pcs): pcs.pma_data_rx_valid.value = 2 pcs.link_status.value = 1 await Timer(1) - await cocotb.start(Clock(pcs.rx_clk, 1/125e6, units='sec').start()) + await cocotb.start(Clock(pcs.rx_clk, 8, units='ns').start()) packet = list(as_nibbles((0x55, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF))) # And test errors too