Remove drive

This commit is contained in:
Alex Forencich
2021-01-07 20:08:19 -08:00
parent 97abb032d8
commit 154d3b11f4

View File

@@ -145,27 +145,15 @@ class StreamSource(StreamBase, StreamPause):
def __init__(self, entity, name, clock, reset=None, *args, **kwargs): def __init__(self, entity, name, clock, reset=None, *args, **kwargs):
super().__init__(entity, name, clock, reset, *args, **kwargs) super().__init__(entity, name, clock, reset, *args, **kwargs)
self.drive_obj = None
self.drive_sync = Event()
self.active = False self.active = False
cocotb.fork(self._run_source())
cocotb.fork(self._run()) cocotb.fork(self._run())
async def drive(self, obj):
if self.drive_obj is not None:
self.drive_sync.clear()
await self.drive_sync.wait()
self.drive_obj = obj
async def send(self, obj): async def send(self, obj):
self.send_nowait(obj) self.send_nowait(obj)
def send_nowait(self, obj): def send_nowait(self, obj):
self.queue.append(obj) self.queue.append(obj)
self.queue_sync.set()
def idle(self): def idle(self):
return self.empty() and not self.active return self.empty() and not self.active
@@ -174,12 +162,7 @@ class StreamSource(StreamBase, StreamPause):
while not self.idle(): while not self.idle():
await RisingEdge(self.clock) await RisingEdge(self.clock)
def clear(self): async def _run(self):
self.queue.clear()
self.drive_obj = None
self.drive_sync.set()
async def _run_source(self):
while True: while True:
await RisingEdge(self.clock) await RisingEdge(self.clock)
@@ -195,25 +178,15 @@ class StreamSource(StreamBase, StreamPause):
continue continue
if (ready_sample and valid_sample) or (not valid_sample): if (ready_sample and valid_sample) or (not valid_sample):
if self.drive_obj and not self.pause: if self.queue and not self.pause:
self.bus.drive(self.drive_obj) self.bus.drive(self.queue.popleft())
self.drive_obj = None
self.drive_sync.set()
if self.valid is not None: if self.valid is not None:
self.valid <= 1 self.valid <= 1
self.active = True self.active = True
else: else:
if self.valid is not None: if self.valid is not None:
self.valid <= 0 self.valid <= 0
self.active = bool(self.drive_obj) self.active = bool(self.queue)
async def _run(self):
while True:
while not self.queue:
self.queue_sync.clear()
await self.queue_sync.wait()
await self.drive(self.queue.popleft())
class StreamMonitor(StreamBase): class StreamMonitor(StreamBase):