Refactor reset handling code

This commit is contained in:
Alex Forencich
2021-03-22 22:02:53 -07:00
parent c677ab245c
commit a285f008ca
2 changed files with 32 additions and 44 deletions

View File

@@ -208,31 +208,28 @@ class AxiMasterWrite(Reset):
self.w_channel.clear()
self.b_channel.clear()
while not self.write_command_queue.empty():
cmd = self.write_command_queue.get_nowait()
def flush_cmd(cmd):
self.log.warning("Flushed write operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.write_command_queue.empty():
cmd = self.write_command_queue.get_nowait()
flush_cmd(cmd)
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)
flush_cmd(cmd)
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)
flush_cmd(cmd)
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)
flush_cmd(cmd)
for q in self.int_write_resp_queue_list:
while not q.empty():
@@ -559,31 +556,28 @@ class AxiMasterRead(Reset):
self.ar_channel.clear()
self.r_channel.clear()
while not self.read_command_queue.empty():
cmd = self.read_command_queue.get_nowait()
def flush_cmd(cmd):
self.log.warning("Flushed read operation during reset: %s", cmd)
if cmd.event:
cmd.event.set(None)
while not self.read_command_queue.empty():
cmd = self.read_command_queue.get_nowait()
flush_cmd(cmd)
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)
flush_cmd(cmd)
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)
flush_cmd(cmd)
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)
flush_cmd(cmd)
for q in self.int_read_resp_queue_list:
while not q.empty():