litex/misoclib/ethmac/phy/loopback.py

34 lines
856 B
Python
Raw Normal View History

2014-11-20 19:47:11 -05:00
from migen.fhdl.std import *
from migen.flow.actor import Sink, Source
from migen.bank.description import *
from migen.genlib.record import *
2014-11-20 21:01:48 -05:00
from misoclib.ethmac.common import *
2014-11-20 19:47:11 -05:00
class LoopbackPHYCRG(Module, AutoCSR):
def __init__(self):
self._reset = CSRStorage()
2014-11-20 21:01:48 -05:00
2014-11-20 19:47:11 -05:00
###
2014-11-20 21:01:48 -05:00
2014-11-20 19:47:11 -05:00
self.clock_domains.cd_eth_rx = ClockDomain()
self.clock_domains.cd_eth_tx = ClockDomain()
self.comb += [
self.cd_eth_rx.clk.eq(ClockSignal()),
self.cd_eth_tx.clk.eq(ClockSignal())
]
reset = self._reset.storage
self.comb += [
self.cd_eth_rx.rst.eq(reset),
self.cd_eth_tx.rst.eq(reset)
]
class LoopbackPHY(Module, AutoCSR):
def __init__(self):
self.dw = 8
self.submodules.crg = LoopbackPHYCRG()
self.sink = sink = Sink(eth_description(8))
self.source = source = Source(eth_description(8))
self.comb += Record.connect(self.sink, self.source)