Reset processing on assert edge only to permit operations to be queued while reset is asserted

This commit is contained in:
Alex Forencich
2021-03-21 12:13:19 -07:00
parent 156fada616
commit 7fb8c4e28b
6 changed files with 187 additions and 183 deletions

View File

@@ -208,6 +208,43 @@ class AxiMasterWrite(Reset):
if self._process_write_resp_cr is not None:
self._process_write_resp_cr.kill()
self._process_write_resp_cr = None
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
while not self.write_command_queue.empty():
cmd = self.write_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_command:
cmd = self.current_write_command
self.current_write_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_write_resp_command_queue.empty():
cmd = self.int_write_resp_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_resp_command:
cmd = self.current_write_resp_command
self.current_write_resp_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.write_resp_queue.empty():
resp = self.write_resp_queue.get_nowait()
self.log.warning("Flushed write response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
else:
self.log.info("Reset de-asserted")
if self._process_write_cr is None:
@@ -215,43 +252,6 @@ class AxiMasterWrite(Reset):
if self._process_write_resp_cr is None:
self._process_write_resp_cr = cocotb.scheduler.start_soon(self._process_write_resp())
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
while not self.write_command_queue.empty():
cmd = self.write_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_command:
cmd = self.current_write_command
self.current_write_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_write_resp_command_queue.empty():
cmd = self.int_write_resp_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_resp_command:
cmd = self.current_write_resp_command
self.current_write_resp_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.write_resp_queue.empty():
resp = self.write_resp_queue.get_nowait()
self.log.warning("Flushed write response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
async def _process_write(self):
while True:
cmd = await self.write_command_queue.get()
@@ -565,6 +565,42 @@ class AxiMasterRead(Reset):
if self._process_read_resp_cr is not None:
self._process_read_resp_cr.kill()
self._process_read_resp_cr = None
self.ar_channel.clear()
self.r_channel.clear()
while not self.read_command_queue.empty():
cmd = self.read_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_command:
cmd = self.current_read_command
self.current_read_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_read_resp_command_queue.empty():
cmd = self.int_read_resp_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_resp_command:
cmd = self.current_read_resp_command
self.current_read_resp_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.read_data_queue.empty():
resp = self.read_data_queue.get_nowait()
self.log.warning("Flushed read response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
else:
self.log.info("Reset de-asserted")
if self._process_read_cr is None:
@@ -572,42 +608,6 @@ class AxiMasterRead(Reset):
if self._process_read_resp_cr is None:
self._process_read_resp_cr = cocotb.scheduler.start_soon(self._process_read_resp())
self.ar_channel.clear()
self.r_channel.clear()
while not self.read_command_queue.empty():
cmd = self.read_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_command:
cmd = self.current_read_command
self.current_read_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_read_resp_command_queue.empty():
cmd = self.int_read_resp_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_resp_command:
cmd = self.current_read_resp_command
self.current_read_resp_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.read_data_queue.empty():
resp = self.read_data_queue.get_nowait()
self.log.warning("Flushed read response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
async def _process_read(self):
while True:
cmd = await self.read_command_queue.get()

View File

@@ -75,15 +75,15 @@ class AxiRamWrite(Memory, Reset):
if self._process_write_cr is not None:
self._process_write_cr.kill()
self._process_write_cr = None
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
else:
self.log.info("Reset de-asserted")
if self._process_write_cr is None:
self._process_write_cr = cocotb.scheduler.start_soon(self._process_write())
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
async def _process_write(self):
while True:
aw = await self.aw_channel.recv()
@@ -195,14 +195,14 @@ class AxiRamRead(Memory, Reset):
if self._process_read_cr is not None:
self._process_read_cr.kill()
self._process_read_cr = None
self.ar_channel.clear()
self.r_channel.clear()
else:
self.log.info("Reset de-asserted")
if self._process_read_cr is None:
self._process_read_cr = cocotb.scheduler.start_soon(self._process_read())
self.ar_channel.clear()
self.r_channel.clear()
async def _process_read(self):
while True:
ar = await self.ar_channel.recv()

View File

@@ -151,6 +151,43 @@ class AxiLiteMasterWrite(Reset):
if self._process_write_resp_cr is not None:
self._process_write_resp_cr.kill()
self._process_write_resp_cr = None
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
while not self.write_command_queue.empty():
cmd = self.write_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_command:
cmd = self.current_write_command
self.current_write_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_write_resp_command_queue.empty():
cmd = self.int_write_resp_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_resp_command:
cmd = self.current_write_resp_command
self.current_write_resp_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.write_resp_queue.empty():
resp = self.write_resp_queue.get_nowait()
self.log.warning("Flushed write response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
else:
self.log.info("Reset de-asserted")
if self._process_write_cr is None:
@@ -158,43 +195,6 @@ class AxiLiteMasterWrite(Reset):
if self._process_write_resp_cr is None:
self._process_write_resp_cr = cocotb.scheduler.start_soon(self._process_write_resp())
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
while not self.write_command_queue.empty():
cmd = self.write_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_command:
cmd = self.current_write_command
self.current_write_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_write_resp_command_queue.empty():
cmd = self.int_write_resp_command_queue.get_nowait()
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_write_resp_command:
cmd = self.current_write_resp_command
self.current_write_resp_command = None
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.write_resp_queue.empty():
resp = self.write_resp_queue.get_nowait()
self.log.warning("Flushed write response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
async def _process_write(self):
while True:
cmd = await self.write_command_queue.get()
@@ -384,6 +384,42 @@ class AxiLiteMasterRead(Reset):
if self._process_read_resp_cr is not None:
self._process_read_resp_cr.kill()
self._process_read_resp_cr = None
self.ar_channel.clear()
self.r_channel.clear()
while not self.read_command_queue.empty():
cmd = self.read_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_command:
cmd = self.current_read_command
self.current_read_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_read_resp_command_queue.empty():
cmd = self.int_read_resp_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_resp_command:
cmd = self.current_read_resp_command
self.current_read_resp_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.read_data_queue.empty():
resp = self.read_data_queue.get_nowait()
self.log.warning("Flushed read response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
else:
self.log.info("Reset de-asserted")
if self._process_read_cr is None:
@@ -391,42 +427,6 @@ class AxiLiteMasterRead(Reset):
if self._process_read_resp_cr is None:
self._process_read_resp_cr = cocotb.scheduler.start_soon(self._process_read_resp())
self.ar_channel.clear()
self.r_channel.clear()
while not self.read_command_queue.empty():
cmd = self.read_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_command:
cmd = self.current_read_command
self.current_read_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.int_read_resp_command_queue.empty():
cmd = self.int_read_resp_command_queue.get_nowait()
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
if self.current_read_resp_command:
cmd = self.current_read_resp_command
self.current_read_resp_command = None
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.read_data_queue.empty():
resp = self.read_data_queue.get_nowait()
self.log.warning("Flushed read response during reset: %s", resp)
self.in_flight_operations = 0
self._idle.set()
async def _process_read(self):
while True:
cmd = await self.read_command_queue.get()

View File

@@ -72,15 +72,15 @@ class AxiLiteRamWrite(Memory, Reset):
if self._process_write_cr is not None:
self._process_write_cr.kill()
self._process_write_cr = None
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
else:
self.log.info("Reset de-asserted")
if self._process_write_cr is None:
self._process_write_cr = cocotb.scheduler.start_soon(self._process_write())
self.aw_channel.clear()
self.w_channel.clear()
self.b_channel.clear()
async def _process_write(self):
while True:
aw = await self.aw_channel.recv()
@@ -150,14 +150,14 @@ class AxiLiteRamRead(Memory, Reset):
if self._process_read_cr is not None:
self._process_read_cr.kill()
self._process_read_cr = None
self.ar_channel.clear()
self.r_channel.clear()
else:
self.log.info("Reset de-asserted")
if self._process_read_cr is None:
self._process_read_cr = cocotb.scheduler.start_soon(self._process_read())
self.ar_channel.clear()
self.r_channel.clear()
async def _process_read(self):
while True:
ar = await self.ar_channel.recv()

View File

@@ -365,13 +365,13 @@ class AxiStreamBase(Reset):
if self._run_cr is not None:
self._run_cr.kill()
self._run_cr = None
self.active = False
else:
self.log.info("Reset de-asserted")
if self._run_cr is None:
self._run_cr = cocotb.scheduler.start_soon(self._run())
self.active = False
async def _run(self):
raise NotImplementedError()
@@ -441,19 +441,20 @@ class AxiStreamSource(AxiStreamBase, AxiStreamPause):
def _handle_reset(self, state):
super()._handle_reset(state)
self.bus.tdata <= 0
if hasattr(self.bus, "tvalid"):
self.bus.tvalid <= 0
if hasattr(self.bus, "tlast"):
self.bus.tlast <= 0
if hasattr(self.bus, "tkeep"):
self.bus.tkeep <= 0
if hasattr(self.bus, "tid"):
self.bus.tid <= 0
if hasattr(self.bus, "tdest"):
self.bus.tdest <= 0
if hasattr(self.bus, "tuser"):
self.bus.tuser <= 0
if state:
self.bus.tdata <= 0
if hasattr(self.bus, "tvalid"):
self.bus.tvalid <= 0
if hasattr(self.bus, "tlast"):
self.bus.tlast <= 0
if hasattr(self.bus, "tkeep"):
self.bus.tkeep <= 0
if hasattr(self.bus, "tid"):
self.bus.tid <= 0
if hasattr(self.bus, "tdest"):
self.bus.tdest <= 0
if hasattr(self.bus, "tuser"):
self.bus.tuser <= 0
async def _run(self):
frame = None
@@ -659,8 +660,9 @@ class AxiStreamSink(AxiStreamMonitor, AxiStreamPause):
def _handle_reset(self, state):
super()._handle_reset(state)
if hasattr(self.bus, "tready"):
self.bus.tready <= 0
if state:
if hasattr(self.bus, "tready"):
self.bus.tready <= 0
async def _run(self):
frame = None

View File

@@ -143,13 +143,13 @@ class StreamBase(Reset):
if self._run_cr is not None:
self._run_cr.kill()
self._run_cr = None
self.active = False
else:
self.log.info("Reset de-asserted")
if self._run_cr is None:
self._run_cr = cocotb.scheduler.start_soon(self._run())
self.active = False
async def _run(self):
raise NotImplementedError()
@@ -205,8 +205,9 @@ class StreamSource(StreamBase, StreamPause):
def _handle_reset(self, state):
super()._handle_reset(state)
if self.valid is not None:
self.valid <= 0
if state:
if self.valid is not None:
self.valid <= 0
async def _run(self):
while True:
@@ -295,8 +296,9 @@ class StreamSink(StreamMonitor, StreamPause):
def _handle_reset(self, state):
super()._handle_reset(state)
if self.ready is not None:
self.ready <= 0
if state:
if self.ready is not None:
self.ready <= 0
async def _run(self):
while True: