From 78bc28881244109922e7d6c04476fcd435b59768 Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Sun, 21 Mar 2021 12:22:51 -0700 Subject: [PATCH] Use start_soon instead of fork --- cocotbext/eth/gmii.py | 8 ++++---- cocotbext/eth/mii.py | 6 +++--- cocotbext/eth/ptp.py | 2 +- cocotbext/eth/reset.py | 2 +- cocotbext/eth/rgmii.py | 8 ++++---- cocotbext/eth/xgmii.py | 4 ++-- tests/gmii/test_gmii.py | 4 ++-- tests/mii/test_mii.py | 4 ++-- tests/ptp_clock/test_ptp_clock.py | 2 +- tests/rgmii/test_rgmii.py | 4 ++-- tests/xgmii/test_xgmii.py | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cocotbext/eth/gmii.py b/cocotbext/eth/gmii.py index 4fac4d5..a6609aa 100644 --- a/cocotbext/eth/gmii.py +++ b/cocotbext/eth/gmii.py @@ -219,7 +219,7 @@ class GmiiSource(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False self.data <= 0 @@ -382,7 +382,7 @@ class GmiiSink(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False @@ -479,12 +479,12 @@ class GmiiPhy: self._clock_cr.kill() if self.speed == 1000e6: - self._clock_cr = cocotb.fork(self._run_clocks(8*1e9/self.speed)) + self._clock_cr = cocotb.scheduler.start_soon(self._run_clocks(8*1e9/self.speed)) self.tx.mii_mode = False self.rx.mii_mode = False self.tx.clock = self.gtx_clk else: - self._clock_cr = cocotb.fork(self._run_clocks(4*1e9/self.speed)) + self._clock_cr = cocotb.scheduler.start_soon(self._run_clocks(4*1e9/self.speed)) self.tx.mii_mode = True self.rx.mii_mode = True self.tx.clock = self.tx_clk diff --git a/cocotbext/eth/mii.py b/cocotbext/eth/mii.py index 5f85891..7c29049 100644 --- a/cocotbext/eth/mii.py +++ b/cocotbext/eth/mii.py @@ -120,7 +120,7 @@ class MiiSource(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False self.data <= 0 @@ -276,7 +276,7 @@ class MiiSink(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False @@ -367,7 +367,7 @@ class MiiPhy: if self._clock_cr is not None: self._clock_cr.kill() - self._clock_cr = cocotb.fork(self._run_clocks(4*1e9/self.speed)) + self._clock_cr = cocotb.scheduler.start_soon(self._run_clocks(4*1e9/self.speed)) async def _run_clocks(self, period): half_period = get_sim_steps(period / 2.0, 'ns') diff --git a/cocotbext/eth/ptp.py b/cocotbext/eth/ptp.py index 7ac2992..656ce0a 100644 --- a/cocotbext/eth/ptp.py +++ b/cocotbext/eth/ptp.py @@ -189,7 +189,7 @@ class PtpClock(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.ts_96_s = 0 self.ts_96_ns = 0 diff --git a/cocotbext/eth/reset.py b/cocotbext/eth/reset.py index dca90aa..b0f0cb5 100644 --- a/cocotbext/eth/reset.py +++ b/cocotbext/eth/reset.py @@ -33,7 +33,7 @@ class Reset: self._reset_state = True if reset_signal is not None: - cocotb.fork(self._run_reset(reset_signal, bool(active_level))) + cocotb.scheduler.start_soon(self._run_reset(reset_signal, bool(active_level))) self._update_reset() diff --git a/cocotbext/eth/rgmii.py b/cocotbext/eth/rgmii.py index a651835..510eff0 100644 --- a/cocotbext/eth/rgmii.py +++ b/cocotbext/eth/rgmii.py @@ -120,7 +120,7 @@ class RgmiiSource(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False self.data <= 0 @@ -290,7 +290,7 @@ class RgmiiSink(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False @@ -396,11 +396,11 @@ class RgmiiPhy: self._clock_cr.kill() if self.speed == 1000e6: - self._clock_cr = cocotb.fork(self._run_clock(8*1e9/self.speed)) + self._clock_cr = cocotb.scheduler.start_soon(self._run_clock(8*1e9/self.speed)) self.tx.mii_mode = False self.rx.mii_mode = False else: - self._clock_cr = cocotb.fork(self._run_clock(4*1e9/self.speed)) + self._clock_cr = cocotb.scheduler.start_soon(self._run_clock(4*1e9/self.speed)) self.tx.mii_mode = True self.rx.mii_mode = True diff --git a/cocotbext/eth/xgmii.py b/cocotbext/eth/xgmii.py index 6db1a05..fc611dc 100644 --- a/cocotbext/eth/xgmii.py +++ b/cocotbext/eth/xgmii.py @@ -225,7 +225,7 @@ class XgmiiSource(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False self.data <= 0 @@ -404,7 +404,7 @@ class XgmiiSink(Reset): else: self.log.info("Reset de-asserted") if self._run_cr is None: - self._run_cr = cocotb.fork(self._run()) + self._run_cr = cocotb.scheduler.start_soon(self._run()) self.active = False diff --git a/tests/gmii/test_gmii.py b/tests/gmii/test_gmii.py index e18a929..a72b6ef 100644 --- a/tests/gmii/test_gmii.py +++ b/tests/gmii/test_gmii.py @@ -47,7 +47,7 @@ class TB: self._enable_generator = None self._enable_cr = None - cocotb.fork(Clock(dut.clk, 2, units="ns").start()) + cocotb.scheduler.start_soon(Clock(dut.clk, 2, units="ns").start()) self.source = GmiiSource(dut.gmii_d, dut.gmii_er, dut.gmii_en, dut.clk, dut.rst, dut.gmii_clk_en, dut.gmii_mii_sel) @@ -76,7 +76,7 @@ class TB: self._enable_generator = generator if self._enable_generator is not None: - self._enable_cr = cocotb.fork(self._run_enable()) + self._enable_cr = cocotb.scheduler.start_soon(self._run_enable()) def clear_enable_generator(self): self.set_enable_generator(None) diff --git a/tests/mii/test_mii.py b/tests/mii/test_mii.py index 3d146f8..8f7cbf0 100644 --- a/tests/mii/test_mii.py +++ b/tests/mii/test_mii.py @@ -47,7 +47,7 @@ class TB: self._enable_generator = None self._enable_cr = None - cocotb.fork(Clock(dut.clk, 2, units="ns").start()) + cocotb.scheduler.start_soon(Clock(dut.clk, 2, units="ns").start()) self.source = MiiSource(dut.mii_d, dut.mii_er, dut.mii_en, dut.clk, dut.rst, dut.mii_clk_en) @@ -75,7 +75,7 @@ class TB: self._enable_generator = generator if self._enable_generator is not None: - self._enable_cr = cocotb.fork(self._run_enable()) + self._enable_cr = cocotb.scheduler.start_soon(self._run_enable()) def clear_enable_generator(self): self.set_enable_generator(None) diff --git a/tests/ptp_clock/test_ptp_clock.py b/tests/ptp_clock/test_ptp_clock.py index e114dd2..6588914 100644 --- a/tests/ptp_clock/test_ptp_clock.py +++ b/tests/ptp_clock/test_ptp_clock.py @@ -43,7 +43,7 @@ class TB: self.log = logging.getLogger("cocotb.tb") self.log.setLevel(logging.DEBUG) - cocotb.fork(Clock(dut.clk, 6.4, units="ns").start()) + cocotb.scheduler.start_soon(Clock(dut.clk, 6.4, units="ns").start()) self.ptp_clock = PtpClock( ts_96=dut.ts_96, diff --git a/tests/rgmii/test_rgmii.py b/tests/rgmii/test_rgmii.py index e45f649..166be9e 100644 --- a/tests/rgmii/test_rgmii.py +++ b/tests/rgmii/test_rgmii.py @@ -47,7 +47,7 @@ class TB: self._enable_generator = None self._enable_cr = None - cocotb.fork(Clock(dut.clk, 2, units="ns").start()) + cocotb.scheduler.start_soon(Clock(dut.clk, 2, units="ns").start()) self.source = RgmiiSource(dut.rgmii_d, dut.rgmii_ctl, dut.clk, dut.rst, dut.rgmii_clk_en, dut.rgmii_mii_sel) self.sink = RgmiiSink(dut.rgmii_d, dut.rgmii_ctl, dut.clk, dut.rst, dut.rgmii_clk_en, dut.rgmii_mii_sel) @@ -74,7 +74,7 @@ class TB: self._enable_generator = generator if self._enable_generator is not None: - self._enable_cr = cocotb.fork(self._run_enable()) + self._enable_cr = cocotb.scheduler.start_soon(self._run_enable()) def clear_enable_generator(self): self.set_enable_generator(None) diff --git a/tests/xgmii/test_xgmii.py b/tests/xgmii/test_xgmii.py index 0ffd5d7..87fb9ec 100644 --- a/tests/xgmii/test_xgmii.py +++ b/tests/xgmii/test_xgmii.py @@ -48,7 +48,7 @@ class TB: self._enable_generator = None self._enable_cr = None - cocotb.fork(Clock(dut.clk, 2, units="ns").start()) + cocotb.scheduler.start_soon(Clock(dut.clk, 2, units="ns").start()) self.source = XgmiiSource(dut.xgmii_d, dut.xgmii_c, dut.clk, dut.rst, dut.xgmii_clk_en) self.sink = XgmiiSink(dut.xgmii_d, dut.xgmii_c, dut.clk, dut.rst, dut.xgmii_clk_en) @@ -74,7 +74,7 @@ class TB: self._enable_generator = generator if self._enable_generator is not None: - self._enable_cr = cocotb.fork(self._run_enable()) + self._enable_cr = cocotb.scheduler.start_soon(self._run_enable()) def clear_enable_generator(self): self.set_enable_generator(None)