From 477e51849a323f0e86530e0d67b9533c91902361 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Mon, 13 Dec 2021 19:46:06 +0100 Subject: [PATCH] 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 --- litex/soc/cores/prbs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/litex/soc/cores/prbs.py b/litex/soc/cores/prbs.py index afc45e0bf..61f69ca7a 100644 --- a/litex/soc/cores/prbs.py +++ b/litex/soc/cores/prbs.py @@ -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,