Clean up and lint removal
This commit is contained in:
@@ -26,4 +26,3 @@ from .version import __version__
|
||||
|
||||
from .gmii import GmiiFrame, GmiiSource, GmiiSink
|
||||
from .xgmii import XgmiiFrame, XgmiiSource, XgmiiSink
|
||||
|
||||
|
||||
@@ -24,12 +24,17 @@ THE SOFTWARE.
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
# Ethernet frame
|
||||
class EthPre(enum.IntEnum):
|
||||
PRE = 0x55
|
||||
SFD = 0xD5
|
||||
|
||||
|
||||
ETH_PREAMBLE = b'\x55\x55\x55\x55\x55\x55\x55\xd5'
|
||||
|
||||
|
||||
# XGMII control characters
|
||||
class XgmiiCtrl(enum.IntEnum):
|
||||
IDLE = 0x07
|
||||
LPI = 0x06
|
||||
@@ -45,6 +50,8 @@ class XgmiiCtrl(enum.IntEnum):
|
||||
RES5 = 0xf7
|
||||
SIG_OS = 0x5c
|
||||
|
||||
|
||||
# BASE-R control characters
|
||||
class BaseRCtrl(enum.IntEnum):
|
||||
IDLE = 0x00
|
||||
LPI = 0x06
|
||||
@@ -56,14 +63,20 @@ class BaseRCtrl(enum.IntEnum):
|
||||
RES_4 = 0x66
|
||||
RES_5 = 0x78
|
||||
|
||||
|
||||
# BASE-R O codes
|
||||
class BaseRO(enum.IntEnum):
|
||||
SEQ_OS = 0x0
|
||||
SIG_OS = 0xf
|
||||
|
||||
|
||||
# BASE-R sync header
|
||||
class BaseRSync(enum.IntEnum):
|
||||
DATA = 0b10
|
||||
CTRL = 0b01
|
||||
|
||||
|
||||
# BASE-R block type field
|
||||
class BaseRBlockType(enum.IntEnum):
|
||||
CTRL = 0x1e # C7 C6 C5 C4 C3 C2 C1 C0 BT
|
||||
OS_4 = 0x2d # D7 D6 D5 O4 C3 C2 C1 C0 BT
|
||||
@@ -80,4 +93,3 @@ class BaseRBlockType(enum.IntEnum):
|
||||
TERM_5 = 0xd2 # C7 C6 D4 D3 D2 D1 D0 BT
|
||||
TERM_6 = 0xe1 # C7 D5 D4 D3 D2 D1 D0 BT
|
||||
TERM_7 = 0xff # D6 D5 D4 D3 D2 D1 D0 BT
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ from collections import deque
|
||||
from .version import __version__
|
||||
from .constants import EthPre, ETH_PREAMBLE
|
||||
|
||||
|
||||
class GmiiFrame(object):
|
||||
def __init__(self, data=None, error=None):
|
||||
self.data = bytearray()
|
||||
@@ -80,10 +81,10 @@ class GmiiFrame(object):
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
f"{type(self).__name__}(data={repr(self.data)}, " +
|
||||
f"error={repr(self.error)}, " +
|
||||
f"rx_sim_time={repr(self.rx_sim_time)})"
|
||||
)
|
||||
f"{type(self).__name__}(data={repr(self.data)}, "
|
||||
f"error={repr(self.error)}, "
|
||||
f"rx_sim_time={repr(self.rx_sim_time)})"
|
||||
)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.data)
|
||||
@@ -191,7 +192,7 @@ class GmiiSource(object):
|
||||
frame = self.queue.popleft()
|
||||
self.queue_occupancy_bytes -= len(frame)
|
||||
self.queue_occupancy_frames -= 1
|
||||
self.log.info(f"TX frame: {frame}")
|
||||
self.log.info("TX frame: %s", frame)
|
||||
frame.normalize()
|
||||
|
||||
if self.mii_select is not None and self.mii_select.value:
|
||||
@@ -343,7 +344,7 @@ class GmiiSink(object):
|
||||
frame.error = error
|
||||
|
||||
frame.compact()
|
||||
self.log.info(f"RX frame: {frame}")
|
||||
self.log.info("RX frame: %s", frame)
|
||||
|
||||
self.queue_occupancy_bytes += len(frame)
|
||||
self.queue_occupancy_frames += 1
|
||||
@@ -362,4 +363,3 @@ class GmiiSink(object):
|
||||
|
||||
class GmiiMonitor(GmiiSink):
|
||||
pass
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ from collections import deque
|
||||
from .version import __version__
|
||||
from .constants import EthPre, ETH_PREAMBLE, XgmiiCtrl
|
||||
|
||||
|
||||
class XgmiiFrame(object):
|
||||
def __init__(self, data=None, ctrl=None):
|
||||
self.data = bytearray()
|
||||
@@ -82,11 +83,11 @@ class XgmiiFrame(object):
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
f"{type(self).__name__}(data={repr(self.data)}, " +
|
||||
f"ctrl={repr(self.ctrl)}, " +
|
||||
f"rx_sim_time={repr(self.rx_sim_time)}, " +
|
||||
f"rx_start_lane={repr(self.rx_start_lane)})"
|
||||
)
|
||||
f"{type(self).__name__}(data={repr(self.data)}, "
|
||||
f"ctrl={repr(self.ctrl)}, "
|
||||
f"rx_sim_time={repr(self.rx_sim_time)}, "
|
||||
f"rx_start_lane={repr(self.rx_start_lane)})"
|
||||
)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.data)
|
||||
@@ -200,7 +201,7 @@ class XgmiiSource(object):
|
||||
frame = self.queue.popleft()
|
||||
self.queue_occupancy_bytes -= len(frame)
|
||||
self.queue_occupancy_frames -= 1
|
||||
self.log.info(f"TX frame: {frame}")
|
||||
self.log.info("TX frame: %s", frame)
|
||||
frame.normalize()
|
||||
assert frame.data[0] == EthPre.PRE
|
||||
assert frame.ctrl[0] == 0
|
||||
@@ -210,7 +211,12 @@ class XgmiiSource(object):
|
||||
frame.ctrl.append(1)
|
||||
|
||||
# offset start
|
||||
if (self.byte_width > 4 and ifg_cnt > (3-deficit_idle_cnt if self.enable_dic else 0)) or self.force_offset_start:
|
||||
if self.enable_dic:
|
||||
min_ifg = 3 - deficit_idle_cnt
|
||||
else:
|
||||
min_ifg = 0
|
||||
|
||||
if self.byte_width > 4 and (ifg_cnt > min_ifg or self.force_offset_start):
|
||||
ifg_cnt = ifg_cnt-4
|
||||
frame.data = bytearray([XgmiiCtrl.IDLE]*4)+frame.data
|
||||
frame.ctrl = [1]*4+frame.ctrl
|
||||
@@ -343,7 +349,7 @@ class XgmiiSink(object):
|
||||
frame.ctrl.append(c_val)
|
||||
|
||||
frame.compact()
|
||||
self.log.info(f"RX frame: {frame}")
|
||||
self.log.info("RX frame: %s", frame)
|
||||
|
||||
self.queue_occupancy_bytes += len(frame)
|
||||
self.queue_occupancy_frames += 1
|
||||
@@ -361,4 +367,3 @@ class XgmiiSink(object):
|
||||
|
||||
class XgmiiMonitor(XgmiiSink):
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user