Skip to content

Commit d0e7bcb

Browse files
committed
Merge branch 'kondys_cocotb_mfb_monitor' into 'devel'
Add error checking for a EOF without SOF (or duplicate EOF) See merge request ndk/ndk-fpga!100
2 parents abcb471 + f1423f3 commit d0e7bcb

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

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

Lines changed: 15 additions & 12 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'.
@@ -99,15 +102,15 @@ async def _monitor_recv(self):
99102
# Checking for beginning of a packet.
100103
self.log.debug("Frame Start")
101104
if in_frame:
102-
raise MFBProtocolError("Duplicate start-of-frame received on MFB bus!")
105+
raise MFBProtocolError("MFB error: a start-of-frame received without an end-of-frame!")
103106
in_frame = True
104107
frame = b""
105108

106109
if (self._eof_arr[rr] == 1) and (not eof_done):
107110
# Checking if the packet ends in the same regions where it began.
108111
self.log.debug("Frame End in single region")
109112
if not in_frame:
110-
raise MFBProtocolError("Duplicate end-of-frame received on MFB bus!")
113+
raise MFBProtocolError("MFB error: an end-of-frame received without a start-of-frame!")
111114
in_frame = False
112115
frame += data_bytes[ss_idx:ee_idx]
113116
self.item_cnt += len(data_bytes[ss_idx:ee_idx])*8 // self._item_width

0 commit comments

Comments
 (0)