diff --git a/cocotbext/eth/gmii.py b/cocotbext/eth/gmii.py index 0dd129a..1eceb13 100644 --- a/cocotbext/eth/gmii.py +++ b/cocotbext/eth/gmii.py @@ -28,7 +28,7 @@ import zlib from collections import deque import cocotb -from cocotb.triggers import RisingEdge, ReadOnly, Timer, First, Event +from cocotb.triggers import RisingEdge, Timer, First, Event from cocotb.utils import get_sim_time from .version import __version__ @@ -184,10 +184,9 @@ class GmiiSource(object): self.active = False while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None ifg_cnt = 0 self.active = False @@ -197,8 +196,6 @@ class GmiiSource(object): self.dv <= 0 continue - await RisingEdge(self.clock) - if self.enable is None or self.enable.value: if ifg_cnt > 0: # in IFG @@ -318,10 +315,9 @@ class GmiiSink(object): self.active = False while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None self.active = False continue @@ -375,5 +371,3 @@ class GmiiSink(object): if frame is not None: frame.data.append(d_val) frame.error.append(er_val) - - await RisingEdge(self.clock) diff --git a/cocotbext/eth/mii.py b/cocotbext/eth/mii.py index 8d5f112..a9dbb7c 100644 --- a/cocotbext/eth/mii.py +++ b/cocotbext/eth/mii.py @@ -26,7 +26,7 @@ import logging from collections import deque import cocotb -from cocotb.triggers import RisingEdge, ReadOnly, Timer, First, Event +from cocotb.triggers import RisingEdge, Timer, First, Event from cocotb.utils import get_sim_time from .version import __version__ @@ -103,10 +103,9 @@ class MiiSource(object): self.active = False while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None ifg_cnt = 0 self.active = False @@ -116,8 +115,6 @@ class MiiSource(object): self.dv <= 0 continue - await RisingEdge(self.clock) - if self.enable is None or self.enable.value: if ifg_cnt > 0: # in IFG @@ -235,10 +232,9 @@ class MiiSink(object): self.active = False while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None self.active = False continue @@ -290,5 +286,3 @@ class MiiSink(object): if frame is not None: frame.data.append(d_val) frame.error.append(er_val) - - await RisingEdge(self.clock) diff --git a/cocotbext/eth/ptp.py b/cocotbext/eth/ptp.py index 4a71384..f65e237 100644 --- a/cocotbext/eth/ptp.py +++ b/cocotbext/eth/ptp.py @@ -27,7 +27,7 @@ import math from fractions import Fraction import cocotb -from cocotb.triggers import RisingEdge, ReadOnly +from cocotb.triggers import RisingEdge from .version import __version__ @@ -178,10 +178,9 @@ class PtpClock(object): async def _run(self): while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) self.ts_96_s = 0 self.ts_96_ns = 0 self.ts_96_fns = 0 @@ -198,8 +197,6 @@ class PtpClock(object): self.pps <= 0 continue - await RisingEdge(self.clock) - if self.ts_step is not None: self.ts_step <= self.ts_updated self.ts_updated = False diff --git a/cocotbext/eth/rgmii.py b/cocotbext/eth/rgmii.py index 61bca69..c4e953e 100644 --- a/cocotbext/eth/rgmii.py +++ b/cocotbext/eth/rgmii.py @@ -26,7 +26,7 @@ import logging from collections import deque import cocotb -from cocotb.triggers import RisingEdge, FallingEdge, ReadOnly, Timer, First, Event +from cocotb.triggers import RisingEdge, FallingEdge, Timer, First, Event from cocotb.utils import get_sim_time from .version import __version__ @@ -103,10 +103,9 @@ class RgmiiSource(object): en = 0 while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None ifg_cnt = 0 self.active = False @@ -114,8 +113,6 @@ class RgmiiSource(object): self.ctrl <= 0 continue - await RisingEdge(self.clock) - if self.mii_select is None or not self.mii_select.value: # send high nibble after rising edge, leading in to falling edge self.data <= d >> 4 @@ -243,15 +240,20 @@ class RgmiiSink(object): er_val = 0 while True: - await ReadOnly() + await RisingEdge(self.clock) + + # capture low nibble on rising edge + d_val = self.data.value.integer + dv_val = self.ctrl.value.integer + + await FallingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None self.active = False continue - # capture high nibble after rising edge, leading in to falling edge + # capture high nibble on falling edge d_val |= self.data.value.integer << 4 er_val = dv_val ^ self.ctrl.value.integer @@ -301,12 +303,3 @@ class RgmiiSink(object): if frame is not None: frame.data.append(d_val) frame.error.append(er_val) - - await FallingEdge(self.clock) - await ReadOnly() - - # capture low nibble after falling edge, leading in to rising edge - d_val = self.data.value.integer - dv_val = self.ctrl.value.integer - - await RisingEdge(self.clock) diff --git a/cocotbext/eth/xgmii.py b/cocotbext/eth/xgmii.py index 9ef4c26..6aa487b 100644 --- a/cocotbext/eth/xgmii.py +++ b/cocotbext/eth/xgmii.py @@ -28,7 +28,7 @@ import zlib from collections import deque import cocotb -from cocotb.triggers import RisingEdge, ReadOnly, Timer, First, Event +from cocotb.triggers import RisingEdge, Timer, First, Event from cocotb.utils import get_sim_time from .version import __version__ @@ -192,10 +192,9 @@ class XgmiiSource(object): self.active = False while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None ifg_cnt = 0 deficit_idle_cnt = 0 @@ -204,8 +203,6 @@ class XgmiiSource(object): self.ctrl <= 0 continue - await RisingEdge(self.clock) - if self.enable is None or self.enable.value: if ifg_cnt + deficit_idle_cnt > self.byte_width-1 or (not self.enable_dic and ifg_cnt > 4): # in IFG @@ -345,10 +342,9 @@ class XgmiiSink(object): self.active = False while True: - await ReadOnly() + await RisingEdge(self.clock) if self.reset is not None and self.reset.value: - await RisingEdge(self.clock) frame = None self.active = False continue @@ -385,5 +381,3 @@ class XgmiiSink(object): else: frame.data.append(d_val) frame.ctrl.append(c_val) - - await RisingEdge(self.clock) diff --git a/tests/ptp_clock/test_ptp_clock.py b/tests/ptp_clock/test_ptp_clock.py index 676e148..649eb5b 100644 --- a/tests/ptp_clock/test_ptp_clock.py +++ b/tests/ptp_clock/test_ptp_clock.py @@ -116,6 +116,7 @@ async def run_load_timestamps(dut): tb.ptp_clock.set_ts_96(12345678) tb.ptp_clock.set_ts_64(12345678) + await RisingEdge(dut.clk) await RisingEdge(dut.clk) assert dut.ts_96.value.integer == 12345678+((tb.ptp_clock.period_ns << 16) + tb.ptp_clock.period_fns) @@ -164,6 +165,8 @@ async def run_seconds_increment(dut): tb.ptp_clock.set_ts_64(999990000*2**16) await RisingEdge(dut.clk) + await RisingEdge(dut.clk) + start_time = get_sim_time('sec') start_ts_96 = (dut.ts_96.value.integer >> 48) + ((dut.ts_96.value.integer & 0xffffffffffff)/2**16*1e-9) start_ts_64 = dut.ts_64.value.integer/2**16*1e-9