Browse Source

rename so name is consistent...

blinkled
John-Mark Gurney 2 years ago
parent
commit
455c410b89
2 changed files with 7 additions and 6 deletions
  1. +1
    -1
      blinkled/encdec8b10b/encdec8b10b/__init__.py
  2. +6
    -5
      blinkled/encdec8b10b/encdec8b10b/core.py

+ 1
- 1
blinkled/encdec8b10b/encdec8b10b/__init__.py View File

@@ -1 +1 @@
from .core import EncDec_8B10B as EncDec8B10B
from .core import EncDec8B10B as EncDec8B10B

+ 6
- 5
blinkled/encdec8b10b/encdec8b10b/core.py View File

@@ -3,9 +3,10 @@
import re

class ControlSymbol(int):
pass
def __repr__(self):
return 'ControlSymbol(%#x)' % self

class EncDec_8B10B(object):
class EncDec8B10B(object):
# Table 36-3 of 802.3-2018 has symbols for 1000Base-X coding

COMMA = ControlSymbol(0xbc)
@@ -2117,7 +2118,7 @@ class EncDec_8B10B(object):
If a control byte is received, it is returned by itself as an
instance of ControlSymbol.

Note that it needs to receive an EncDec_8B10B.COMMA control byte
Note that it needs to receive an EncDec8B10B.COMMA control byte
first to establish sync, and then will data after that.
'''

@@ -2192,7 +2193,7 @@ class EncDec_8B10B(object):
'''Encode a single byte to 10 bits.'''

assert data_in <= 0xFF, "Data in must be maximum one byte"
encoded = int(EncDec_8B10B.enc_lookup[(
encoded = int(EncDec8B10B.enc_lookup[(
ctrl << 9) + (running_disparity << 8) + data_in], 2)
new_disparity = (encoded >> 10) & 1
encoded = encoded & 0x3FF
@@ -2205,7 +2206,7 @@ class EncDec_8B10B(object):
'''Decode 10 bits into a byte.'''

assert data_in <= 0x3FF, "Data in must be maximum 10 bits"
decoded = EncDec_8B10B.dec_lookup[(data_in)]
decoded = EncDec8B10B.dec_lookup[(data_in)]
if decoded == "DEC8b10bERR":
raise Exception(
"Input to 8B10B Decoder is not a 8B10B Encoded Word")


Loading…
Cancel
Save