cores/prbs: Add a 'wrap' option to PRBSRX

If enabled, then the error count wraps around when it
reaches the limit of the 32b counter instead of saturating
to a max value.

Software can then detect the wrap and act accordingly.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2021-12-13 19:46:06 +01:00
parent 16a43e983e
commit 477e51849a
1 changed files with 2 additions and 2 deletions

View File

@ -137,7 +137,7 @@ class PRBS31Checker(PRBSChecker):
# PRBS RX ------------------------------------------------------------------------------------------
class PRBSRX(Module):
def __init__(self, width, reverse=False):
def __init__(self, width, reverse=False, wrap=False):
self.config = Signal(2)
self.pause = Signal()
self.i = Signal(width)
@ -170,7 +170,7 @@ class PRBSRX(Module):
self.sync += [
If(config == 0,
errors.eq(0)
).Elif(~self.pause & (errors != (2**32-1)),
).Elif(~self.pause & ((errors != (2**32-1)) | wrap),
If(config == 0b01,
errors.eq(errors + (prbs7.errors != 0))
).Elif(config == 0b10,