8B10B编解码
encdec8b10b的Python项目详细描述
ENCDEC8B10B
编码和解码8b10b编码
获取
python3 -m pip install encdec8b10b
用法
编码数据字节
from encdec8b10b import EncDec8B10B
running_disp = 0
byte_to_enc = 0xf
running_disp, encoded = EncDec8B10B.enc_8b10b(byte_to_enc, running_disp)
print(hex(encoded))
Output >> 0xba
编码控制字节
from encdec8b10b import EncDec8B10B
running_disp = 0
byte_to_enc = 0xbc # comma
ctrl = 1
running_disp, encoded = EncDec8B10B.enc_8b10b(byte_to_enc, running_disp, ctrl)
print(hex(encoded))
Output >> 0x17c
解码数据字节
from encdec8b10b import EncDec8B10B
byte_to_dec = 0xba
ctrl, decoded = EncDec8B10B.dec_8b10b(byte_to_dec)
print(hex(decoded))
Output >> 0xf
# ctrl variable confirm that it was a data byte
print(ctrl)
Output >> 0
解码控制字节
from encdec8b10b import EncDec8B10B
byte_to_dec = 0x17c # comma encoded
ctrl, decoded = EncDec8B10B.dec_8b10b(byte_to_dec)
print(hex(decoded))
Output >> 0xbc
# ctrl variable confirm that it was a control byte
print(ctrl)
Output >> 1
冗长
这两个函数都有一个详细模式,以便更容易确认正在发生的一切:
from encdec8b10b import EncDec8B10B
running_disp = 0
byte_to_enc = 0xA0
running_disp, encoded = EncDec8B10B.enc_8b10b(byte_to_enc, running_disp, verbose=True)
Output >> Encoder - In: A0 - Encoded: 146 - Running Disparity: 0
ctrl, decoded = EncDec8B10B.dec_8b10b(encoded, verbose=True)
Output >> Decoded: A0 - Control: 0
8b10b
8b10b编码于1983年由al-widmer和peter-franaszek实现。它仍然广泛应用于高速电子领域。
谢谢
- Ryu Shinhyung用于创建此模块中使用的表
- Chuck Benz用于创建出色的组合8b10b模块
- Alex Forencich对于他的8b10b Matlab脚本