mac: Move LiteEthMACLastBE module to common.py and rename to LiteEthLastHandler.
This commit is contained in:
parent
a2a862dc1b
commit
0b5389feab
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of LiteEth.
|
# This file is part of LiteEth.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015-2021 Florent Kermarrec <florent@enjoy-digital.fr>
|
# Copyright (c) 2015-2024 Florent Kermarrec <florent@enjoy-digital.fr>
|
||||||
# SPDX-License-Identifier: BSD-2-Clause
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
|
||||||
from liteeth.common import *
|
from liteeth.common import *
|
||||||
|
@ -55,3 +55,31 @@ class LiteEthMACCrossbar(LiteEthCrossbar):
|
||||||
raise ValueError("Ethernet type {0:#x} already assigned".format(ethernet_type))
|
raise ValueError("Ethernet type {0:#x} already assigned".format(ethernet_type))
|
||||||
self.users[ethernet_type] = port
|
self.users[ethernet_type] = port
|
||||||
return port
|
return port
|
||||||
|
|
||||||
|
# Last Handler -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class LiteEthLastHandler(LiteXModule):
|
||||||
|
def __init__(self, layout):
|
||||||
|
self.sink = sink = stream.Endpoint(layout)
|
||||||
|
self.source = source = stream.Endpoint(layout)
|
||||||
|
|
||||||
|
# # #
|
||||||
|
|
||||||
|
self.fsm = fsm = FSM(reset_state="COPY")
|
||||||
|
fsm.act("COPY",
|
||||||
|
sink.connect(source),
|
||||||
|
source.last.eq(sink.last_be != 0),
|
||||||
|
If(sink.valid & sink.ready,
|
||||||
|
# If last Byte but not last packet token.
|
||||||
|
If(source.last & ~sink.last,
|
||||||
|
NextState("WAIT-LAST")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
fsm.act("WAIT-LAST",
|
||||||
|
# Accept incoming stream until we receive last packet token.
|
||||||
|
sink.ready.eq(1),
|
||||||
|
If(sink.valid & sink.last,
|
||||||
|
NextState("COPY")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -1,46 +1,36 @@
|
||||||
#
|
#
|
||||||
# This file is part of LiteEth.
|
# This file is part of LiteEth.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015-2020 Florent Kermarrec <florent@enjoy-digital.fr>
|
# Copyright (c) 2015-2024 Florent Kermarrec <florent@enjoy-digital.fr>
|
||||||
# Copyright (c) 2015 Sebastien Bourdeauducq <sb@m-labs.hk>
|
# Copyright (c) 2015 Sebastien Bourdeauducq <sb@m-labs.hk>
|
||||||
# Copyright (c) 2018 whitequark <whitequark@whitequark.org>
|
# Copyright (c) 2018 whitequark <whitequark@whitequark.org>
|
||||||
# SPDX-License-Identifier: BSD-2-Clause
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
|
||||||
from liteeth.common import *
|
from litex.gen import *
|
||||||
|
|
||||||
|
from liteeth.common import *
|
||||||
|
from liteeth.mac.common import LiteEthLastHandler
|
||||||
|
|
||||||
# MAC TX Last BE -----------------------------------------------------------------------------------
|
# MAC TX Last BE -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class LiteEthMACTXLastBE(Module):
|
class LiteEthMACTXLastBE(LiteXModule):
|
||||||
def __init__(self, dw):
|
def __init__(self, dw):
|
||||||
self.sink = sink = stream.Endpoint(eth_phy_description(dw))
|
self.sink = sink = stream.Endpoint(eth_phy_description(dw))
|
||||||
self.source = source = stream.Endpoint(eth_phy_description(dw))
|
self.source = source = stream.Endpoint(eth_phy_description(dw))
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
self.submodules.fsm = fsm = FSM(reset_state="COPY")
|
self.last_handler = LiteEthLastHandler(layout=eth_phy_description(dw))
|
||||||
fsm.act("COPY",
|
self.comb += [
|
||||||
sink.connect(source),
|
sink.connect(self.last_handler.sink),
|
||||||
source.last.eq(sink.last_be != 0),
|
self.last_handler.source.connect(source),
|
||||||
If(sink.valid & sink.ready,
|
]
|
||||||
# If last Byte but not last packet token.
|
|
||||||
If(source.last & ~sink.last,
|
|
||||||
NextState("WAIT-LAST")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
fsm.act("WAIT-LAST",
|
|
||||||
# Accept incoming stream until we receive last packet token.
|
|
||||||
sink.ready.eq(1),
|
|
||||||
If(sink.valid & sink.last,
|
|
||||||
NextState("COPY")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# MAC RX Last BE -----------------------------------------------------------------------------------
|
# MAC RX Last BE -----------------------------------------------------------------------------------
|
||||||
|
|
||||||
class LiteEthMACRXLastBE(Module):
|
class LiteEthMACRXLastBE(Module):
|
||||||
def __init__(self, dw):
|
def __init__(self, dw):
|
||||||
self.sink = sink = stream.Endpoint(eth_phy_description(dw))
|
self.sink = sink = stream.Endpoint(eth_phy_description(dw))
|
||||||
self.source = source = stream.Endpoint(eth_phy_description(dw))
|
self.source = source = stream.Endpoint(eth_phy_description(dw))
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
Loading…
Reference in New Issue