From 0a030fe17dc55883fcc4d564c63af129334c7c7b Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 8 Nov 2019 19:43:01 +0100 Subject: [PATCH] cores/code_8b10b/Decoder: add basic invalid symbols detection Check that we have 4,5 or 6 ones in the symbol. This does not report all invalid symbols but still allow detecting issues with the link. --- litex/soc/cores/code_8b10b.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/litex/soc/cores/code_8b10b.py b/litex/soc/cores/code_8b10b.py index 894449f0..552297c4 100644 --- a/litex/soc/cores/code_8b10b.py +++ b/litex/soc/cores/code_8b10b.py @@ -1,4 +1,5 @@ # This file is Copyright (c) 2016-2017 Sebastien Bourdeauducq +# This file is Copyright (c) 2019 Florent Kermarrec # License: BSD """ @@ -15,6 +16,9 @@ Note: This encoding is *not* used by DVI/HDMI (that uses a *different* 8b/10b scheme called TMDS). """ +from functools import reduce +from operator import add + from migen import * @@ -267,6 +271,7 @@ class Decoder(Module): self.input = Signal(10) self.d = Signal(8) self.k = Signal() + self.invalid = Signal() # # # @@ -304,3 +309,9 @@ class Decoder(Module): ] self.comb += self.d.eq(Cat(code5b, code3b)) + + # Basic invalid symbols detection: check that we have 4,5 or 6 ones in the symbol. This does + # not report all invalid symbols but still allow detecting issues with the link. + ones = Signal(4) + self.sync += ones.eq(reduce(add, [self.input[i] for i in range(10)])) + self.comb += self.invalid.eq((ones != 4) & (ones != 5) & (ones != 6)) -- 2.30.2