Convert send/recv to blocking, add nonblocking send_nowait/recv_nowait
This commit is contained in:
@@ -163,7 +163,10 @@ class XgmiiSource(object):
|
||||
|
||||
cocotb.fork(self._run())
|
||||
|
||||
def send(self, frame):
|
||||
async def send(self, frame):
|
||||
self.send_nowait(frame)
|
||||
|
||||
def send_nowait(self, frame):
|
||||
frame = XgmiiFrame(frame)
|
||||
self.queue_occupancy_bytes += len(frame)
|
||||
self.queue_occupancy_frames += 1
|
||||
@@ -305,7 +308,13 @@ class XgmiiSink(object):
|
||||
|
||||
cocotb.fork(self._run())
|
||||
|
||||
def recv(self):
|
||||
async def recv(self, compact=True):
|
||||
while self.empty():
|
||||
self.sync.clear()
|
||||
await self.sync.wait()
|
||||
return self.recv_nowait(compact)
|
||||
|
||||
def recv_nowait(self, compact=True):
|
||||
if self.queue:
|
||||
frame = self.queue.popleft()
|
||||
self.queue_occupancy_bytes -= len(frame)
|
||||
|
||||
Reference in New Issue
Block a user