2015-02-26 03:41:47 -05:00
|
|
|
from misoclib.liteeth.common import *
|
|
|
|
from misoclib.liteeth.generic import *
|
2015-02-23 19:42:56 -05:00
|
|
|
|
|
|
|
class LiteEthPHYSimCRG(Module, AutoCSR):
|
|
|
|
def __init__(self):
|
|
|
|
self._reset = CSRStorage()
|
|
|
|
|
|
|
|
###
|
|
|
|
|
|
|
|
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 LiteEthPHYSim(Module, AutoCSR):
|
|
|
|
def __init__(self, pads):
|
|
|
|
self.dw = 8
|
|
|
|
self.submodules.crg = LiteEthPHYSimCRG()
|
|
|
|
self.sink = sink = Sink(eth_phy_description(8))
|
|
|
|
self.source = source = Source(eth_phy_description(8))
|
2015-02-25 11:47:44 -05:00
|
|
|
|
2015-02-23 19:42:56 -05:00
|
|
|
self.comb += [
|
|
|
|
pads.source_stb.eq(self.sink.stb),
|
|
|
|
pads.source_data.eq(self.sink.data),
|
2015-02-25 11:47:44 -05:00
|
|
|
self.sink.ack.eq(1)
|
|
|
|
]
|
2015-02-23 19:42:56 -05:00
|
|
|
|
2015-02-25 11:47:44 -05:00
|
|
|
self.sync += [
|
2015-02-23 19:42:56 -05:00
|
|
|
self.source.stb.eq(pads.sink_stb),
|
2015-02-25 11:47:44 -05:00
|
|
|
self.source.sop.eq(pads.sink_stb & ~self.source.stb),
|
|
|
|
self.source.data.eq(pads.sink_data),
|
|
|
|
]
|
|
|
|
self.comb += [
|
|
|
|
self.source.eop.eq(~pads.sink_stb & self.source.stb),
|
2015-02-23 19:42:56 -05:00
|
|
|
]
|