Skip to content

Commit

Permalink
phy: Avoid Xilinx's specific BUFG and use synchronous logic to improv…
Browse files Browse the repository at this point in the history
…e timings.
  • Loading branch information
enjoy-digital committed May 13, 2024
1 parent 1e55953 commit 15bc2db
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions litesdcard/phy.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,15 @@ def __init__(self):
cases["default"] = clk.eq(clks[0])
for i in range(2, 9):
cases[2**i] = clk.eq(clks[i-1])
self.comb += Case(self.divider.storage, cases)

# FIXME: Use BUFG to improve timings on large Xilinx desings, try to improve and make it more generic.
from litex.gen import LiteXContext
from litex.build.xilinx import XilinxPlatform
if isinstance(LiteXContext.platform, XilinxPlatform):
self.specials += Instance("BUFG", i_I=clk & ~clk_d, o_O=self.ce)
else:
self.comb += self.ce.eq(clk & ~clk_d)
self.sync += Case(self.divider.storage, cases)
self.sync += self.ce.eq(clk & ~clk_d)

# Ensure we don't get short pulses on the SDCard Clk.
ce_delayed = Signal()
ce_latched = Signal()
self.sync += If(clk_d, ce_delayed.eq(self.clk_en))
self.comb += If(clk_d, ce_latched.eq(self.clk_en)).Else(ce_latched.eq(ce_delayed))
self.comb += self.clk.eq(~clk & ce_latched)
self.sync += self.clk.eq(~clk & ce_latched)

# SDCard PHY Read ----------------------------------------------------------------------------------

Expand Down

0 comments on commit 15bc2db

Please sign in to comment.