Skip to content

Commit afa9b88

Browse files
committedApr 12, 2015
liteeth/phy/gmii: fix clock generation for mii mode (clock_pads.tx is an input)
1 parent 3710afe commit afa9b88

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed
 

Diff for: ‎misoclib/com/liteeth/phy/gmii.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,24 @@ def __init__(self, pads):
4040
self.comb += source.eop.eq(eop)
4141

4242
class LiteEthPHYGMIICRG(Module, AutoCSR):
43-
def __init__(self, clock_pads, pads, with_hw_init_reset):
43+
def __init__(self, clock_pads, pads, with_hw_init_reset, mii_mode=0):
4444
self._reset = CSRStorage()
4545
###
4646
self.clock_domains.cd_eth_rx = ClockDomain()
4747
self.clock_domains.cd_eth_tx = ClockDomain()
48-
self.specials += DDROutput(1, 0, clock_pads.gtx, ClockSignal("eth_tx"))
49-
self.comb += [
50-
self.cd_eth_rx.clk.eq(clock_pads.rx), # Let the synthesis tool insert
51-
self.cd_eth_tx.clk.eq(self.cd_eth_rx.clk) # the appropriate clock buffer
52-
]
48+
49+
# RX : Let the synthesis tool insert the appropriate clock buffer
50+
self.comb += self.cd_eth_rx.clk.eq(clock_pads.rx)
51+
52+
# TX : GMII: Drive clock_pads.gtx, clock_pads.tx unused
53+
# MII: Use PHY clock_pads.tx as eth_tx_clk, do not drive clock_pads.gtx
54+
self.specials += DDROutput(1, mii_mode, clock_pads.gtx, ClockSignal("eth_tx"))
55+
# XXX Xilinx specific, replace BUFGMUX with a generic clock buffer?
56+
self.specials += Instance("BUFGMUX",
57+
i_I0=self.cd_eth_rx.clk,
58+
i_I1=clock_pads.tx,
59+
i_S=mii_mode,
60+
o_O=self.cd_eth_tx.clk)
5361

5462
if with_hw_init_reset:
5563
reset = Signal()

Diff for: ‎misoclib/com/liteeth/phy/gmii_mii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__(self, clock_pads, pads, with_hw_init_reset=True):
9494
self._mode = CSRStorage()
9595
mode = self._mode.storage
9696
# Note: we can use GMII CRG since it also handles tx clock pad used for MII
97-
self.submodules.crg = LiteEthPHYGMIICRG(clock_pads, pads, with_hw_init_reset)
97+
self.submodules.crg = LiteEthPHYGMIICRG(clock_pads, pads, with_hw_init_reset, mode==modes["MII"])
9898
self.submodules.clock_counter = LiteEthGMIIMIIClockCounter()
9999
self.submodules.tx = RenameClockDomains(LiteEthPHYGMIIMIITX(pads, mode), "eth_tx")
100100
self.submodules.rx = RenameClockDomains(LiteEthPHYGMIIMIIRX(pads, mode), "eth_rx")

0 commit comments

Comments
 (0)
Please sign in to comment.