mirror of
https://github.com/enjoy-digital/usb3_pipe.git
synced 2025-01-04 10:18:41 +08:00
common: document
This commit is contained in:
parent
b49a928f21
commit
292076b4e6
@ -6,20 +6,24 @@ from migen import *
|
|||||||
# Helpers ------------------------------------------------------------------------------------------
|
# Helpers ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def K(x, y):
|
def K(x, y):
|
||||||
|
"""K code generator ex: K(28, 5) is COM Symbol"""
|
||||||
return (y << 5) | x
|
return (y << 5) | x
|
||||||
|
|
||||||
def D(x, y):
|
def D(x, y):
|
||||||
|
"""D code generator"""
|
||||||
return (y << 5) | x
|
return (y << 5) | x
|
||||||
|
|
||||||
def LinkConfig(reset=0, loopback=0, scrambling=1):
|
def LinkConfig(reset=0, loopback=0, scrambling=1):
|
||||||
|
"""Link Configuration of TS1/TS2 Ordered Sets."""
|
||||||
value = ( reset << 0)
|
value = ( reset << 0)
|
||||||
value |= ( loopback << 2)
|
value |= ( loopback << 2)
|
||||||
value |= ((not scrambling) << 3)
|
value |= ((not scrambling) << 3)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
# Symbols ------------------------------------------------------------------------------------------
|
# Symbols (6.3.5) ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class Symbol:
|
class Symbol:
|
||||||
|
"""Symbol definition with name, 8-bit value and description"""
|
||||||
def __init__(self, name, value, description=""):
|
def __init__(self, name, value, description=""):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.value = value
|
self.value = value
|
||||||
@ -38,9 +42,10 @@ EPF = Symbol("EPF", K(23, 7), "End Packet Framing")
|
|||||||
|
|
||||||
symbols = [SKP, SDP, EDB, SUB, COM, RSD, SHP, END, SLC, EPF]
|
symbols = [SKP, SDP, EDB, SUB, COM, RSD, SHP, END, SLC, EPF]
|
||||||
|
|
||||||
# Training Sequence Ordered Sets -------------------------------------------------------------------
|
# Training Sequence Ordered Sets (6.4.1.2) ---------------------------------------------------------
|
||||||
|
|
||||||
class OrderedSet(list):
|
class OrderedSet(list):
|
||||||
|
"""Ordered Set definition with name, 8-bit values and description"""
|
||||||
def __init__(self, name, values, description=""):
|
def __init__(self, name, values, description=""):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.values = values
|
self.values = values
|
||||||
@ -83,6 +88,7 @@ ordered_sets = [TSEQ, TS1, TS2]
|
|||||||
# Endianness Swap ----------------------------------------------------------------------------------
|
# Endianness Swap ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class EndiannessSwap(Module):
|
class EndiannessSwap(Module):
|
||||||
|
"""Swap the data bytes/ctrl bits of stream"""
|
||||||
def __init__(self, sink, source):
|
def __init__(self, sink, source):
|
||||||
assert len(sink.data) == len(source.data)
|
assert len(sink.data) == len(source.data)
|
||||||
assert len(sink.ctrl) == len(source.ctrl)
|
assert len(sink.ctrl) == len(source.ctrl)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user