Skip to content

Commit

Permalink
phy/common: use CSRField for MDIO registers
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Jan 28, 2020
1 parent 8edf4f3 commit f532a12
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions liteeth/phy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
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),
Expand All @@ -25,14 +26,21 @@ def __init__(self):

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]),
Expand Down

0 comments on commit f532a12

Please sign in to comment.