2015-03-06 04:10:34 -05:00
|
|
|
from misoclib.com.liteeth.common import *
|
|
|
|
|
2015-04-13 04:20:02 -04:00
|
|
|
|
2015-03-06 04:10:34 -05:00
|
|
|
def LiteEthPHY(clock_pads, pads, **kwargs):
|
2015-08-22 06:08:49 -04:00
|
|
|
clk_freq = None if "clk_freq" not in kwargs else kwargs.pop("clk_freq")
|
2015-04-13 03:53:43 -04:00
|
|
|
# Autodetect PHY
|
|
|
|
if hasattr(pads, "source_stb"):
|
|
|
|
# This is a simulation PHY
|
|
|
|
from misoclib.com.liteeth.phy.sim import LiteEthPHYSim
|
|
|
|
return LiteEthPHYSim(pads)
|
|
|
|
elif hasattr(clock_pads, "gtx") and flen(pads.tx_data) == 8:
|
|
|
|
if hasattr(clock_pads, "tx"):
|
|
|
|
# This is a 10/100/1G PHY
|
|
|
|
from misoclib.com.liteeth.phy.gmii_mii import LiteEthPHYGMIIMII
|
2015-08-18 19:07:41 -04:00
|
|
|
return LiteEthPHYGMIIMII(clock_pads, pads, clk_freq=clk_freq, **kwargs)
|
2015-04-13 03:53:43 -04:00
|
|
|
else:
|
|
|
|
# This is a pure 1G PHY
|
|
|
|
from misoclib.com.liteeth.phy.gmii import LiteEthPHYGMII
|
|
|
|
return LiteEthPHYGMII(clock_pads, pads, **kwargs)
|
2015-08-04 18:50:55 -04:00
|
|
|
elif hasattr(pads, "rx_ctl"):
|
2015-08-05 04:33:08 -04:00
|
|
|
# This is a 10/100/1G RGMII PHY
|
|
|
|
raise ValueError("RGMII PHYs are specific to vendors (for now), use direct instantiation")
|
2015-04-13 03:53:43 -04:00
|
|
|
elif flen(pads.tx_data) == 4:
|
|
|
|
# This is a MII PHY
|
|
|
|
from misoclib.com.liteeth.phy.mii import LiteEthPHYMII
|
|
|
|
return LiteEthPHYMII(clock_pads, pads, **kwargs)
|
|
|
|
else:
|
|
|
|
raise ValueError("Unable to autodetect PHY from platform file, use direct instantiation")
|