phy: rename sim to model and remove from autodetect

This commit is contained in:
Florent Kermarrec 2015-11-14 03:43:27 +01:00
parent 88e18dfa23
commit c1d7f2d427
2 changed files with 7 additions and 11 deletions

View File

@ -3,11 +3,7 @@ from liteeth.common import *
def LiteEthPHY(clock_pads, pads, clk_freq=None, **kwargs):
# Autodetect PHY
if hasattr(pads, "source_stb"):
# This is a simulation PHY
from liteeth.phy.sim import LiteEthPHYSim
return LiteEthPHYSim(pads)
elif hasattr(clock_pads, "gtx") and len(pads.tx_data) == 8:
if hasattr(clock_pads, "gtx") and len(pads.tx_data) == 8:
if hasattr(clock_pads, "tx"):
# This is a 10/100/1G PHY
from liteeth.phy.gmii_mii import LiteEthPHYGMIIMII

View File

@ -1,9 +1,9 @@
import os
from liteeth.common import *
from litex.soc.cores.liteeth_mini.common import *
class LiteEthPHYSimCRG(Module, AutoCSR):
class LiteEthPHYModelCRG(Module, AutoCSR):
def __init__(self):
self._reset = CSRStorage()
@ -23,10 +23,10 @@ class LiteEthPHYSimCRG(Module, AutoCSR):
]
class LiteEthPHYSim(Module, AutoCSR):
class LiteEthPHYModel(Module, AutoCSR):
def __init__(self, pads, tap="tap0", ip_address="192.168.0.14"):
self.dw = 8
self.submodules.crg = LiteEthPHYSimCRG()
self.submodules.crg = LiteEthPHYModelCRG()
self.sink = sink = Sink(eth_phy_description(8))
self.source = source = Source(eth_phy_description(8))
self.tap = tap
@ -47,12 +47,12 @@ class LiteEthPHYSim(Module, AutoCSR):
self.source.eop.eq(~pads.sink_stb & self.source.stb),
]
# XXX avoid use of os.system
# TODO avoid use of os.system
os.system("openvpn --mktun --dev {}".format(self.tap))
os.system("ifconfig {} {} up".format(self.tap, self.ip_address))
os.system("mknod /dev/net/{} c 10 200".format(self.tap))
def do_exit(self, *args, **kwargs):
# XXX avoid use of os.system
# TODO avoid use of os.system
os.system("rm -f /dev/net/{}".format(self.tap))
os.system("openvpn --rmtun --dev {}".format(self.tap))