litex/misoclib/com/liteeth/mac/core/gap.py

28 lines
826 B
Python
Raw Normal View History

from misoclib.com.liteeth.common import *
2015-04-13 04:20:02 -04:00
class LiteEthMACGap(Module):
def __init__(self, dw, ack_on_gap=False):
self.sink = sink = Sink(eth_phy_description(dw))
self.source = source = Source(eth_phy_description(dw))
2015-04-13 05:23:27 -04:00
# # #
gap = math.ceil(eth_interpacket_gap/(dw//8))
self.submodules.counter = counter = Counter(max=gap)
self.submodules.fsm = fsm = FSM(reset_state="COPY")
fsm.act("COPY",
counter.reset.eq(1),
Record.connect(sink, source),
If(sink.stb & sink.eop & sink.ack,
NextState("GAP")
)
)
fsm.act("GAP",
counter.ce.eq(1),
sink.ack.eq(int(ack_on_gap)),
If(counter.value == (gap-1),
NextState("COPY")
)
)