mac/padding: Add 32 bit support to inserter

*Should* also work for 16/64 bit
This commit is contained in:
David Sawatzke 2021-08-08 21:10:01 +02:00
parent 0fb14d3c3f
commit 3e7979920a
1 changed files with 12 additions and 2 deletions

View File

@ -14,12 +14,14 @@ from liteeth.common import *
class LiteEthMACPaddingInserter(Module):
def __init__(self, dw, padding):
assert dw in [8, 16, 32, 64]
self.sink = sink = stream.Endpoint(eth_phy_description(dw))
self.source = source = stream.Endpoint(eth_phy_description(dw))
# # #
padding_limit = math.ceil(padding/(dw/8))-1
last_be = 2**((padding-1)%(dw//8))
counter = Signal(16)
counter_done = Signal()
@ -33,8 +35,14 @@ class LiteEthMACPaddingInserter(Module):
If(sink.last,
If(~counter_done,
source.last.eq(0),
source.last_be.eq(0),
NextState("PADDING")
).Else(
).Elif((counter == padding_limit) & (last_be > sink.last_be),
# If the right amount of data words are transmitted, but
# too few bytes, transmit more bytes of the word. The
# formerly "unused" bytes get transmitted as well
source.last_be.eq(last_be)
). Else(
NextValue(counter, 0),
)
)
@ -42,7 +50,9 @@ class LiteEthMACPaddingInserter(Module):
)
fsm.act("PADDING",
source.valid.eq(1),
source.last.eq(counter_done),
If(counter_done,
source.last_be.eq(last_be),
source.last.eq(1)),
source.data.eq(0),
If(source.valid & source.ready,
NextValue(counter, counter + 1),