Skip to content

Commit 84a975b

Browse files
committed
fix: check if an EOF has been set without an SOF in the Cocotb MFB monitor
1 parent 9251cc2 commit 84a975b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

python/cocotbext/cocotbext/ofm/mfb/monitors.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,19 @@ async def _monitor_recv(self):
7878
self.log.debug(f"ee_idx {str(ee_idx)}")
7979
self.log.debug(f"ss_idx {str(ss_idx)}")
8080

81-
if (self._eof_arr[rr] == 1) and (in_frame):
82-
# Checks if there is a packet that is being processed and if it ends in this region.
83-
self.log.debug("Frame End")
84-
in_frame = False
85-
eof_done = True
86-
frame += data_bytes[rs_inx:ee_idx]
87-
self.item_cnt += len(data_bytes[rs_inx:ee_idx])*8 // self._item_width
88-
self.log.debug(f"frame done {frame.hex()}")
89-
self._recv(frame)
90-
self.frame_cnt += 1
81+
if self._eof_arr[rr] == 1:
82+
if in_frame:
83+
# Checks if there is a packet that is being processed and if it ends in this region.
84+
self.log.debug("Frame End")
85+
in_frame = False
86+
eof_done = True
87+
frame += data_bytes[rs_inx:ee_idx]
88+
self.item_cnt += len(data_bytes[rs_inx:ee_idx])*8 // self._item_width
89+
self.log.debug(f"frame done {frame.hex()}")
90+
self._recv(frame)
91+
self.frame_cnt += 1
92+
elif self._sof_arr[rr] == 1 and (self._eof_pos_arr[rr] < self._sof_pos_arr[rr]):
93+
raise MFBProtocolError("MFB error: an end-of-frame received before a start-of-frame!")
9194

9295
if in_frame:
9396
# Region with a valid 'middle of packet'.

0 commit comments

Comments
 (0)