mirror of
https://github.com/litex-hub/litex-boards.git
synced 2025-01-03 03:43:36 -05:00
targets: cleanup ECP5 CRGs
This commit is contained in:
parent
82601ff700
commit
babbc676eb
5 changed files with 26 additions and 41 deletions
|
@ -37,19 +37,19 @@ class _CRG(Module):
|
||||||
|
|
||||||
self.stop = Signal()
|
self.stop = Signal()
|
||||||
|
|
||||||
# clk / rst
|
# Clk / Rst
|
||||||
clk100 = platform.request("clk100")
|
clk100 = platform.request("clk100")
|
||||||
rst_n = platform.request("rst_n")
|
rst_n = platform.request("rst_n")
|
||||||
platform.add_period_constraint(clk100, 1e9/100e6)
|
platform.add_period_constraint(clk100, 1e9/100e6)
|
||||||
|
|
||||||
# power on reset
|
# Power on reset
|
||||||
por_count = Signal(16, reset=2**16-1)
|
por_count = Signal(16, reset=2**16-1)
|
||||||
por_done = Signal()
|
por_done = Signal()
|
||||||
self.comb += self.cd_por.clk.eq(ClockSignal())
|
self.comb += self.cd_por.clk.eq(ClockSignal())
|
||||||
self.comb += por_done.eq(por_count == 0)
|
self.comb += por_done.eq(por_count == 0)
|
||||||
self.sync.por += If(~por_done, por_count.eq(por_count - 1))
|
self.sync.por += If(~por_done, por_count.eq(por_count - 1))
|
||||||
|
|
||||||
# pll
|
# PLL
|
||||||
self.submodules.pll = pll = ECP5PLL()
|
self.submodules.pll = pll = ECP5PLL()
|
||||||
pll.register_clkin(clk100, 100e6)
|
pll.register_clkin(clk100, 100e6)
|
||||||
pll.create_clkout(self.cd_sys2x_i, 2*sys_clk_freq)
|
pll.create_clkout(self.cd_sys2x_i, 2*sys_clk_freq)
|
||||||
|
@ -66,7 +66,7 @@ class _CRG(Module):
|
||||||
i_RST = self.cd_sys2x.rst,
|
i_RST = self.cd_sys2x.rst,
|
||||||
o_CDIVX = self.cd_sys.clk),
|
o_CDIVX = self.cd_sys.clk),
|
||||||
AsyncResetSynchronizer(self.cd_init, ~por_done | ~pll.locked | ~rst_n),
|
AsyncResetSynchronizer(self.cd_init, ~por_done | ~pll.locked | ~rst_n),
|
||||||
AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked | ~rst_n)
|
AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked | ~rst_n)
|
||||||
]
|
]
|
||||||
|
|
||||||
# BaseSoC ------------------------------------------------------------------------------------------
|
# BaseSoC ------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -31,22 +31,18 @@ class _CRG(Module):
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
self.cd_sys.clk.attr.add("keep")
|
# Clk / Rst
|
||||||
self.cd_sys_ps.clk.attr.add("keep")
|
|
||||||
|
|
||||||
# clk / rst
|
|
||||||
clk8 = platform.request("clk8")
|
clk8 = platform.request("clk8")
|
||||||
rst = Signal()
|
|
||||||
platform.add_period_constraint(clk8, 1e9/8e6)
|
platform.add_period_constraint(clk8, 1e9/8e6)
|
||||||
|
|
||||||
# pll
|
# PLL
|
||||||
self.submodules.pll = pll = ECP5PLL()
|
self.submodules.pll = pll = ECP5PLL()
|
||||||
pll.register_clkin(clk8, 8e6)
|
pll.register_clkin(clk8, 8e6)
|
||||||
pll.create_clkout(self.cd_sys, sys_clk_freq, phase=11)
|
pll.create_clkout(self.cd_sys, sys_clk_freq, phase=11)
|
||||||
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=20)
|
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=20)
|
||||||
self.specials += AsyncResetSynchronizer(self.cd_sys, rst)
|
self.specials += AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked)
|
||||||
|
|
||||||
# sdram clock
|
# SDRAM clock
|
||||||
self.comb += platform.request("sdram_clock").eq(self.cd_sys_ps.clk)
|
self.comb += platform.request("sdram_clock").eq(self.cd_sys_ps.clk)
|
||||||
|
|
||||||
# BaseSoC ------------------------------------------------------------------------------------------
|
# BaseSoC ------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -35,18 +35,18 @@ class _CRG(Module):
|
||||||
|
|
||||||
self.stop = Signal()
|
self.stop = Signal()
|
||||||
|
|
||||||
# clk / rst
|
# Clk / Rst
|
||||||
clk48 = platform.request("clk48")
|
clk48 = platform.request("clk48")
|
||||||
platform.add_period_constraint(clk48, 1e9/48e6)
|
platform.add_period_constraint(clk48, 1e9/48e6)
|
||||||
|
|
||||||
# power on reset
|
# Power on reset
|
||||||
por_count = Signal(16, reset=2**16-1)
|
por_count = Signal(16, reset=2**16-1)
|
||||||
por_done = Signal()
|
por_done = Signal()
|
||||||
self.comb += self.cd_por.clk.eq(ClockSignal())
|
self.comb += self.cd_por.clk.eq(ClockSignal())
|
||||||
self.comb += por_done.eq(por_count == 0)
|
self.comb += por_done.eq(por_count == 0)
|
||||||
self.sync.por += If(~por_done, por_count.eq(por_count - 1))
|
self.sync.por += If(~por_done, por_count.eq(por_count - 1))
|
||||||
|
|
||||||
# pll
|
# PLL
|
||||||
sys2x_clk_ecsout = Signal()
|
sys2x_clk_ecsout = Signal()
|
||||||
self.submodules.pll = pll = ECP5PLL()
|
self.submodules.pll = pll = ECP5PLL()
|
||||||
pll.register_clkin(clk48, 48e6)
|
pll.register_clkin(clk48, 48e6)
|
||||||
|
@ -69,7 +69,7 @@ class _CRG(Module):
|
||||||
i_RST = self.cd_sys2x.rst,
|
i_RST = self.cd_sys2x.rst,
|
||||||
o_CDIVX = self.cd_sys.clk),
|
o_CDIVX = self.cd_sys.clk),
|
||||||
AsyncResetSynchronizer(self.cd_init, ~por_done | ~pll.locked),
|
AsyncResetSynchronizer(self.cd_init, ~por_done | ~pll.locked),
|
||||||
AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked)
|
AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked)
|
||||||
]
|
]
|
||||||
|
|
||||||
# BaseSoC ------------------------------------------------------------------------------------------
|
# BaseSoC ------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -34,27 +34,21 @@ class _CRG(Module):
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
self.cd_init.clk.attr.add("keep")
|
|
||||||
self.cd_por.clk.attr.add("keep")
|
|
||||||
self.cd_sys.clk.attr.add("keep")
|
|
||||||
self.cd_sys2x.clk.attr.add("keep")
|
|
||||||
self.cd_sys2x_i.clk.attr.add("keep")
|
|
||||||
|
|
||||||
self.stop = Signal()
|
self.stop = Signal()
|
||||||
|
|
||||||
# clk / rst
|
# Clk / Rst
|
||||||
clk12 = platform.request("clk12")
|
clk12 = platform.request("clk12")
|
||||||
rst = platform.request("user_btn", 0)
|
rst = platform.request("user_btn", 0)
|
||||||
platform.add_period_constraint(clk12, 1e9/12e6)
|
platform.add_period_constraint(clk12, 1e9/12e6)
|
||||||
|
|
||||||
# power on reset
|
# Power on reset
|
||||||
por_count = Signal(16, reset=2**16-1)
|
por_count = Signal(16, reset=2**16-1)
|
||||||
por_done = Signal()
|
por_done = Signal()
|
||||||
self.comb += self.cd_por.clk.eq(ClockSignal())
|
self.comb += self.cd_por.clk.eq(ClockSignal())
|
||||||
self.comb += por_done.eq(por_count == 0)
|
self.comb += por_done.eq(por_count == 0)
|
||||||
self.sync.por += If(~por_done, por_count.eq(por_count - 1))
|
self.sync.por += If(~por_done, por_count.eq(por_count - 1))
|
||||||
|
|
||||||
# pll
|
# PLL
|
||||||
sys2x_clk_ecsout = Signal()
|
sys2x_clk_ecsout = Signal()
|
||||||
self.submodules.pll = pll = ECP5PLL()
|
self.submodules.pll = pll = ECP5PLL()
|
||||||
pll.register_clkin(clk12, 12e6)
|
pll.register_clkin(clk12, 12e6)
|
||||||
|
@ -77,11 +71,10 @@ class _CRG(Module):
|
||||||
i_RST = self.cd_sys2x.rst,
|
i_RST = self.cd_sys2x.rst,
|
||||||
o_CDIVX = self.cd_sys.clk),
|
o_CDIVX = self.cd_sys.clk),
|
||||||
AsyncResetSynchronizer(self.cd_init, ~por_done | ~pll.locked | rst),
|
AsyncResetSynchronizer(self.cd_init, ~por_done | ~pll.locked | rst),
|
||||||
AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked | rst)
|
AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked | rst)
|
||||||
]
|
]
|
||||||
|
|
||||||
vtt_en = platform.request("dram_vtt_en")
|
self.comb += platform.request("dram_vtt_en").eq(1)
|
||||||
self.comb += vtt_en.eq(1)
|
|
||||||
|
|
||||||
# BaseSoC ------------------------------------------------------------------------------------------
|
# BaseSoC ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -28,28 +28,24 @@ class _CRG(Module):
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
self.cd_sys.clk.attr.add("keep")
|
# Clk / Rst
|
||||||
self.cd_sys_ps.clk.attr.add("keep")
|
|
||||||
|
|
||||||
# clk / rst
|
|
||||||
clk25 = platform.request("clk25")
|
clk25 = platform.request("clk25")
|
||||||
rst = platform.request("rst")
|
rst = platform.request("rst")
|
||||||
platform.add_period_constraint(clk25, 40.0)
|
platform.add_period_constraint(clk25, 1e9/25e6)
|
||||||
|
|
||||||
# pll
|
# PLL
|
||||||
self.submodules.pll = pll = ECP5PLL()
|
self.submodules.pll = pll = ECP5PLL()
|
||||||
self.comb += pll.reset.eq(rst)
|
self.comb += pll.reset.eq(rst)
|
||||||
pll.register_clkin(clk25, 25e6)
|
pll.register_clkin(clk25, 25e6)
|
||||||
pll.create_clkout(self.cd_sys, sys_clk_freq, phase=11)
|
pll.create_clkout(self.cd_sys, sys_clk_freq, phase=11)
|
||||||
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=20)
|
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=20)
|
||||||
self.specials += AsyncResetSynchronizer(self.cd_sys, rst)
|
self.specials += AsyncResetSynchronizer(self.cd_sys, ~pll.locked | rst)
|
||||||
|
|
||||||
# sdram clock
|
# SDRAM clock
|
||||||
self.comb += platform.request("sdram_clock").eq(self.cd_sys_ps.clk)
|
self.comb += platform.request("sdram_clock").eq(self.cd_sys_ps.clk)
|
||||||
|
|
||||||
# Stop ESP32 from resetting FPGA
|
# Prevent ESP32 from resetting FPGA
|
||||||
wifi_gpio0 = platform.request("wifi_gpio0")
|
self.comb += platform.request("wifi_gpio0").eq(1)
|
||||||
self.comb += wifi_gpio0.eq(1)
|
|
||||||
|
|
||||||
# BaseSoC ------------------------------------------------------------------------------------------
|
# BaseSoC ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue