cores/prbs: Define PRBS_CONFIG constants and use them in code. Also simplify PRBSGenerator data selection.

This commit is contained in:
Florent Kermarrec 2022-01-27 17:09:20 +01:00
parent ccd3ab17be
commit 162231fb8f
1 changed files with 21 additions and 15 deletions

View File

@ -12,6 +12,13 @@ from migen import *
from migen.genlib.misc import WaitTimer from migen.genlib.misc import WaitTimer
from migen.genlib.cdc import MultiReg from migen.genlib.cdc import MultiReg
# Constants ----------------------------------------------------------------------------------------
PRBS_CONFIG_OFF = 0b00
PRBS_CONFIG_PRBS7 = 0b01
PRBS_CONFIG_PRBS15 = 0b10
PRBS_CONFIG_PRBS31 = 0b11
# PRBS Generators ---------------------------------------------------------------------------------- # PRBS Generators ----------------------------------------------------------------------------------
class PRBSGenerator(Module): class PRBSGenerator(Module):
@ -69,15 +76,12 @@ class PRBSTX(Module):
# PRBS Selection. # PRBS Selection.
prbs_data = Signal(width) prbs_data = Signal(width)
self.comb += [ self.comb += Case(self.config, {
If(config == 0b11, PRBS_CONFIG_OFF : prbs_data.eq(0),
prbs_data.eq(prbs31.o) PRBS_CONFIG_PRBS7 : prbs_data.eq(prbs7.o),
).Elif(config == 0b10, PRBS_CONFIG_PRBS15 : prbs_data.eq(prbs15.o),
prbs_data.eq(prbs15.o) PRBS_CONFIG_PRBS31 : prbs_data.eq(prbs31.o),
).Else( })
prbs_data.eq(prbs7.o)
)
]
# Optional Bits Reversing. # Optional Bits Reversing.
if reverse: if reverse:
@ -163,19 +167,21 @@ class PRBSRX(Module):
self.comb += [ self.comb += [
prbs7.i.eq( prbs_data), prbs7.i.eq( prbs_data),
prbs15.i.eq(prbs_data), prbs15.i.eq(prbs_data),
prbs31.i.eq(prbs_data) prbs31.i.eq(prbs_data),
] ]
# Errors count (with optional saturation). # Errors count (with optional saturation).
self.sync += [ self.sync += [
If(config == 0, If(config == PRBS_CONFIG_OFF,
errors.eq(0) errors.eq(0)
).Elif(~self.pause & (~with_errors_saturation | (errors != (2**32-1))), ).Elif(~self.pause & (~with_errors_saturation | (errors != (2**32-1))),
If(config == 0b01, If(config == PRBS_CONFIG_PRBS7,
errors.eq(errors + (prbs7.errors != 0)) errors.eq(errors + (prbs7.errors != 0))
).Elif(config == 0b10, ),
If(config == PRBS_CONFIG_PRBS15,
errors.eq(errors + (prbs15.errors != 0)) errors.eq(errors + (prbs15.errors != 0))
).Elif(config == 0b11, ),
If(config == PRBS_CONFIG_PRBS31,
errors.eq(errors + (prbs31.errors != 0)) errors.eq(errors + (prbs31.errors != 0))
) )
) )