Skip to content

Commit d91fe6b

Browse files
committed
review: Use XLSChannel semantics
Signed-off-by: Robert Winkler <[email protected]>
1 parent 23afd2a commit d91fe6b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

xls/examples/cocotb/cocotb_running_counter.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import cocotb
1616

1717
from cocotb.clock import Clock
18-
from cocotb.triggers import Event, ClockCycles
18+
from cocotb.triggers import Event, ClockCycles, RisingEdge
1919
from cocotb.binary import BinaryValue
2020

2121
from cocotb_bus.scoreboard import Scoreboard
@@ -45,11 +45,17 @@ def terminate_cb(transaction):
4545
terminate.set()
4646

4747
monitor.add_callback(terminate_cb)
48-
monitor.bus.rdy.setimmediatevalue(1)
49-
5048
return (clock, driver, terminate)
5149

5250

51+
@cocotb.coroutine
52+
async def recv(dut):
53+
dut.running_counter__cnt_s_rdy.setimmediatevalue(0)
54+
while True:
55+
await RisingEdge(dut.clk)
56+
dut.running_counter__cnt_s_rdy.value = dut.running_counter__cnt_s_vld.value
57+
58+
5359
@cocotb.coroutine
5460
async def reset(clk, rst, cycles=1):
5561
rst.setimmediatevalue(1)
@@ -65,6 +71,8 @@ async def counter_test(dut):
6571
(clock, driver, terminate) = init_sim(dut, data_to_send, data_to_recv)
6672

6773
cocotb.start_soon(clock.start())
74+
cocotb.start_soon(recv(dut))
75+
6876
await reset(dut.clk, dut.rst, 10)
6977
await driver.write(data_to_send)
7078
await terminate.wait()

xls/simulation/cocotb/cocotb_xls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ def __init__(
6363
async def _monitor_recv(self) -> None:
6464
while True:
6565
await RisingEdge(self.clock)
66-
if self.bus.vld.value and self.bus.rdy.value:
66+
if self.bus.rdy.value:
6767
vec = self.bus.data.value
6868
self._recv(vec)

0 commit comments

Comments
 (0)