phy/common: use CSRField for MDIO registers

This commit is contained in:
Florent Kermarrec 2020-01-28 10:43:33 +01:00
parent 8edf4f3f9a
commit f532a12b40
1 changed files with 14 additions and 6 deletions

View File

@ -6,15 +6,16 @@ from liteeth.common import *
from migen.genlib.cdc import MultiReg
from migen.fhdl.specials import Tristate
class LiteEthPHYHWReset(Module):
def __init__(self):
self.reset = Signal()
# # #
counter = Signal(max=512)
counter = Signal(max=512)
counter_done = Signal()
counter_ce = Signal()
counter_ce = Signal()
self.sync += If(counter_ce, counter.eq(counter + 1))
self.comb += [
counter_done.eq(counter == 256),
@ -25,14 +26,21 @@ class LiteEthPHYHWReset(Module):
class LiteEthPHYMDIO(Module, AutoCSR):
def __init__(self, pads):
self._w = CSRStorage(3, name="w")
self._r = CSRStatus(1, name="r")
self._w = CSRStorage(fields=[
CSRField("mdc", size=1),
CSRField("oe", size=1),
CSRField("w", size=1)],
name="w")
self._r = CSRStatus(fields=[
CSRField("r", size=1)],
name="r")
# # #
data_w = Signal()
data_w = Signal()
data_oe = Signal()
data_r = Signal()
data_r = Signal()
self.comb +=[
pads.mdc.eq(self._w.storage[0]),
data_oe.eq(self._w.storage[1]),