forked from M-Labs/artiq-zynq
cxp pipeline: merge packet start & stop into 1 mod
This commit is contained in:
parent
0b8f3ba466
commit
f23ce2ef70
|
@ -3,22 +3,13 @@ from misoc.interconnect.csr import *
|
||||||
from misoc.interconnect import stream
|
from misoc.interconnect import stream
|
||||||
from misoc.cores.liteeth_mini.mac.crc import LiteEthMACCRCEngine, LiteEthMACCRCInserter
|
from misoc.cores.liteeth_mini.mac.crc import LiteEthMACCRCEngine, LiteEthMACCRCInserter
|
||||||
|
|
||||||
|
def K(x, y):
|
||||||
|
return ((y << 5) | x)
|
||||||
|
|
||||||
class Code_Inserter(Module):
|
class Code_Inserter(Module):
|
||||||
"""Code inserter
|
def __init__(self, layout, insert_infront=True, counts=4):
|
||||||
|
self.sink = sink = stream.Endpoint(layout)
|
||||||
Inserts data in the front or end of each packet.
|
self.source = source = stream.Endpoint(layout)
|
||||||
|
|
||||||
Attributes
|
|
||||||
----------
|
|
||||||
sink : in
|
|
||||||
Packet octets.
|
|
||||||
source : out
|
|
||||||
Preamble, SFD, and packet octets.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, cxp_phy_layout, insert_infront=True, counts=4):
|
|
||||||
self.sink = sink = stream.Endpoint(cxp_phy_layout)
|
|
||||||
self.source = source = stream.Endpoint(cxp_phy_layout)
|
|
||||||
|
|
||||||
self.data = Signal.like(sink.data)
|
self.data = Signal.like(sink.data)
|
||||||
self.k = Signal.like(sink.k)
|
self.k = Signal.like(sink.k)
|
||||||
|
@ -39,25 +30,25 @@ class Code_Inserter(Module):
|
||||||
|
|
||||||
self.submodules.fsm = fsm = FSM(reset_state="IDLE")
|
self.submodules.fsm = fsm = FSM(reset_state="IDLE")
|
||||||
|
|
||||||
|
|
||||||
if insert_infront:
|
if insert_infront:
|
||||||
fsm.act("IDLE",
|
fsm.act("IDLE",
|
||||||
sink.ack.eq(1), # = writable/not full
|
sink.ack.eq(1),
|
||||||
clr_cnt.eq(1),
|
clr_cnt.eq(1),
|
||||||
If(sink.stb, # = data input
|
If(sink.stb,
|
||||||
sink.ack.eq(0), # = full
|
sink.ack.eq(0),
|
||||||
NextState("INSERT"),
|
NextState("INSERT"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
fsm.act("INSERT",
|
fsm.act("INSERT",
|
||||||
source.stb.eq(1), # = writing data now
|
sink.ack.eq(0),
|
||||||
|
source.stb.eq(1),
|
||||||
source.data.eq(self.data),
|
source.data.eq(self.data),
|
||||||
source.k.eq(self.k),
|
source.k.eq(self.k),
|
||||||
If(cnt == counts - 1,
|
If(cnt == counts - 1,
|
||||||
If(source.ack, NextState("COPY"))
|
If(source.ack, NextState("COPY"))
|
||||||
).Else(
|
).Else(
|
||||||
inc_cnt.eq(source.ack)# = inc_counter only when next pipeline is ready to accept new data
|
inc_cnt.eq(source.ack)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -90,60 +81,40 @@ class Code_Inserter(Module):
|
||||||
)
|
)
|
||||||
|
|
||||||
fsm.act("INSERT",
|
fsm.act("INSERT",
|
||||||
source.stb.eq(1), # = writing data now
|
sink.ack.eq(0),
|
||||||
|
source.stb.eq(1),
|
||||||
source.data.eq(self.data),
|
source.data.eq(self.data),
|
||||||
source.k.eq(self.k),
|
source.k.eq(self.k),
|
||||||
If(cnt == counts - 1,
|
If(cnt == counts - 1,
|
||||||
source.eop.eq(1),
|
source.eop.eq(1),
|
||||||
If(source.ack, NextState("IDLE"))
|
If(source.ack, NextState("IDLE"))
|
||||||
).Else(
|
).Else(
|
||||||
inc_cnt.eq(source.ack) # = inc_counter only when next pipeline is ready to accept new data
|
inc_cnt.eq(source.ack)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def K(x, y):
|
|
||||||
return ((y << 5) | x)
|
|
||||||
|
|
||||||
def D(x, y):
|
class Packet_Wrapper(Module):
|
||||||
return ((y << 5) | x)
|
|
||||||
|
|
||||||
class Packet_Start_Inserter(Code_Inserter):
|
|
||||||
def __init__(self, layout):
|
def __init__(self, layout):
|
||||||
Code_Inserter.__init__(self, layout)
|
self.submodules.pak_start = pak_start = Code_Inserter(layout)
|
||||||
self.comb += [
|
self.submodules.pak_end = pak_end = Code_Inserter(layout, insert_infront=False)
|
||||||
self.data.eq(K(27, 7)),
|
|
||||||
self.k.eq(1),
|
self.sink = pak_start.sink
|
||||||
]
|
self.source = pak_end.source
|
||||||
|
|
||||||
class Packet_End_Inserter(Code_Inserter):
|
|
||||||
def __init__(self, layout):
|
|
||||||
Code_Inserter.__init__(self, layout, insert_infront=False)
|
|
||||||
self.comb += [
|
self.comb += [
|
||||||
self.data.eq(K(29, 7)),
|
pak_start.data.eq(K(27, 7)),
|
||||||
self.k.eq(1),
|
pak_start.k.eq(1),
|
||||||
|
pak_end.data.eq(K(29, 7)),
|
||||||
|
pak_end.k.eq(1),
|
||||||
|
|
||||||
|
pak_start.source.connect(pak_end.sink),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ResetInserter()
|
@ResetInserter()
|
||||||
@CEInserter()
|
@CEInserter()
|
||||||
class CXPCRC32(Module):
|
class CXPCRC32(Module):
|
||||||
"""CoaXPress CRC
|
|
||||||
|
|
||||||
Implement an CoaXPress CRC generator/checker.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
data_width : int
|
|
||||||
Width of the data bus.
|
|
||||||
|
|
||||||
Attributes
|
|
||||||
----------
|
|
||||||
d : in
|
|
||||||
Data input.
|
|
||||||
value : out
|
|
||||||
CRC value (used for generator).
|
|
||||||
error : out
|
|
||||||
CRC error (used for checker).
|
|
||||||
"""
|
|
||||||
# Section 9.2.2.2 (CXP-001-2021)
|
# Section 9.2.2.2 (CXP-001-2021)
|
||||||
width = 32
|
width = 32
|
||||||
polynom = 0x04C11DB7
|
polynom = 0x04C11DB7
|
||||||
|
|
Loading…
Reference in New Issue