Skip to content

Commit

Permalink
phy/ecp5rgmii.py: Add support for dynamic link speeds
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Jul 29, 2023
1 parent 64cceb2 commit 4588190
Show file tree
Hide file tree
Showing 3 changed files with 278 additions and 25 deletions.
8 changes: 7 additions & 1 deletion liteeth/mac/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ def add_preamble(self):
self.pipeline.append(tx_preamble)

def add_gap(self):
tx_gap = gap.LiteEthMACGap(phy_dw)
# Some Phy, ECP5 for example, have a clk enable signal to support
# dynamic link speeds.
# In the gap inserter we need to ensure this is enable holds for
# the gap counter. If not we would insert a gap that might be too
# short.
phy_tx_clk_en = getattr(phy, "tx_clk_en", None)
tx_gap = gap.LiteEthMACGap(phy_dw, clk_en = phy_tx_clk_en)
tx_gap = ClockDomainsRenamer("eth_tx")(tx_gap)
self.submodules += tx_gap
self.pipeline.append(tx_gap)
Expand Down
22 changes: 16 additions & 6 deletions liteeth/mac/gap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# MAC Gap ------------------------------------------------------------------------------------------

class LiteEthMACGap(Module):
def __init__(self, dw):
def __init__(self, dw, clk_en=None):
self.sink = sink = stream.Endpoint(eth_phy_description(dw))
self.source = source = stream.Endpoint(eth_phy_description(dw))

Expand All @@ -30,9 +30,19 @@ def __init__(self, dw):
NextState("GAP")
)
)
fsm.act("GAP",
NextValue(counter, counter + 1),
If(counter == (gap-1),
NextState("COPY")
if clk_en is None:
fsm.act("GAP",
NextValue(counter, counter + 1),
If(counter == (gap-1),
NextState("COPY")
)
)
else:
fsm.act("GAP",
If(clk_en,
NextValue(counter, counter + 1),
If(counter == (gap-1),
NextState("COPY")
)
),
)
)
Loading

0 comments on commit 4588190

Please sign in to comment.