From 0b5b93c30da61e27e91e04ae9213d0a504b8e17e Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Sat, 9 Apr 2022 15:06:12 -0500 Subject: [PATCH] Wire up missing CRG / DDR3 clock control / reset signals --- src/ecp5_crg.py | 20 ++++++++++++-------- src/ls2.py | 4 ++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/ecp5_crg.py b/src/ecp5_crg.py index 5c975d6..b1bd03c 100644 --- a/src/ecp5_crg.py +++ b/src/ecp5_crg.py @@ -173,6 +173,10 @@ class ECP5CRG(Elaboratable): self.sys_clk_freq = sys_clk_freq self.pod_bits = pod_bits + # DDR clock control signals + self.ddr_clk_stop = Signal() + self.ddr_clk_reset = Signal() + def elaborate(self, platform): m = Module() @@ -204,16 +208,16 @@ class ECP5CRG(Elaboratable): i_GSR=gsr1), ] - # PLL - m.submodules.pll = pll = PLL(ClockSignal("rawclk"), reset=~reset) - - # Power-on delay (655us) + # Power-on delay podcnt = Signal(self.pod_bits, reset=-1) pod_done = Signal() - with m.If((podcnt != 0) & pll.locked): + with m.If(podcnt != 0): m.d.rawclk += podcnt.eq(podcnt-1) m.d.rawclk += pod_done.eq(podcnt == 0) + # PLL + m.submodules.pll = pll = PLL(ClockSignal("rawclk"), reset=~pod_done|~reset) + # Generating sync2x (200Mhz) and init (25Mhz) from extclk cd_sync2x = ClockDomain("sync2x", local=False) cd_sync2x_unbuf = ClockDomain("sync2x_unbuf", @@ -228,7 +232,7 @@ class ECP5CRG(Elaboratable): pll.create_clkout(ClockSignal("init"), 25e6) m.submodules += Instance("ECLKSYNCB", i_ECLKI = ClockSignal("sync2x_unbuf"), - i_STOP = 0, + i_STOP = self.ddr_clk_stop, o_ECLKO = ClockSignal("sync2x")) m.domains += cd_sync2x_unbuf m.domains += cd_sync2x @@ -239,7 +243,7 @@ class ECP5CRG(Elaboratable): m.d.comb += reset_ok.eq(~pll.locked|~pod_done) m.d.comb += ResetSignal("init").eq(reset_ok) m.d.comb += ResetSignal("sync").eq(reset_ok) - m.d.comb += ResetSignal("dramsync").eq(reset_ok) + m.d.comb += ResetSignal("dramsync").eq(reset_ok|self.ddr_clk_reset) # # Generating sync (100Mhz) from sync2x @@ -247,7 +251,7 @@ class ECP5CRG(Elaboratable): p_DIV="2.0", i_ALIGNWD=0, i_CLKI=ClockSignal("sync2x"), - i_RST=0, + i_RST=ResetSignal("dramsync"), o_CDIVX=ClockSignal("sync")) # temporarily set dram sync clock exactly equal to main sync diff --git a/src/ls2.py b/src/ls2.py index c4c63bc..6cd644f 100644 --- a/src/ls2.py +++ b/src/ls2.py @@ -518,6 +518,10 @@ class DDR3SoC(SoC, Elaboratable): # grrr, same problem with drambone: not WB4-pipe compliant comb += drambone.bus.stall.eq(drambone.bus.cyc & ~drambone.bus.ack) + # DRAM clock control / reset signals + comb += self.crg.ddr_clk_stop.eq(self.ddrphy.init.stop) + comb += self.crg.ddr_clk_reset.eq(self.ddrphy.init.reset) + # add hyperram module if hasattr(self, "hyperram"): m.submodules.hyperram = hyperram = self.hyperram -- 2.30.2