Skip to content

Commit

Permalink
target: add rst signal to CRG to allow full reset of the SoC on reboo…
Browse files Browse the repository at this point in the history
…t command.
  • Loading branch information
enjoy-digital committed Nov 4, 2020
1 parent aa6b9ca commit 2b17dc1
Show file tree
Hide file tree
Showing 49 changed files with 109 additions and 43 deletions.
5 changes: 3 additions & 2 deletions litex_boards/targets/ac701.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys4x = ClockDomain(reset_less=True)
self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True)
self.clock_domains.cd_clk200 = ClockDomain()
self.clock_domains.cd_idelay = ClockDomain()

# # #

self.submodules.pll = pll = S7PLL(speedgrade=-1)
self.comb += pll.reset.eq(platform.request("cpu_reset"))
self.comb += pll.reset.eq(platform.request("cpu_reset") | self.rst)
pll.register_clkin(platform.request("clk200"), 200e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys4x, 4*sys_clk_freq)
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/acorn_cle_215.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

class CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys4x = ClockDomain(reset_less=True)
self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True)
Expand All @@ -62,6 +63,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = S7PLL()
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk200, 200e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys4x, 4*sys_clk_freq)
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/aller.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

class CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys4x = ClockDomain(reset_less=True)
self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True)
Expand All @@ -46,6 +47,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = S7PLL()
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk100, 100e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys4x, 4*sys_clk_freq)
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/alveo_u250.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys4x = ClockDomain(reset_less=True)
self.clock_domains.cd_pll4x = ClockDomain(reset_less=True)
Expand All @@ -41,7 +42,7 @@ def __init__(self, platform, sys_clk_freq):
# # #

self.submodules.pll = pll = USMMCM(speedgrade=-2)
self.comb += pll.reset.eq(0) # FIXME
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(platform.request("clk300", 0), 300e6)
pll.create_clkout(self.cd_pll4x, sys_clk_freq*4, buf=None, with_reset=False)
pll.create_clkout(self.cd_idelay, 500e6, with_reset=False)
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/arty.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys4x = ClockDomain(reset_less=True)
self.clock_domains.cd_sys4x_dqs = ClockDomain(reset_less=True)
Expand All @@ -38,7 +39,7 @@ def __init__(self, platform, sys_clk_freq):
# # #

self.submodules.pll = pll = S7PLL(speedgrade=-1)
self.comb += pll.reset.eq(~platform.request("cpu_reset"))
self.comb += pll.reset.eq(~platform.request("cpu_reset") | self.rst)
pll.register_clkin(platform.request("clk100"), 100e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys4x, 4*sys_clk_freq)
Expand Down
6 changes: 3 additions & 3 deletions litex_boards/targets/arty_s7.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys2x = ClockDomain(reset_less=True)
self.clock_domains.cd_sys4x = ClockDomain(reset_less=True)
Expand All @@ -37,7 +38,7 @@ def __init__(self, platform, sys_clk_freq):
# # #

self.submodules.pll = pll = S7PLL(speedgrade=-1)
self.comb += pll.reset.eq(~platform.request("cpu_reset"))
self.comb += pll.reset.eq(~platform.request("cpu_reset") | self.rst)
pll.register_clkin(platform.request("clk100"), 100e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys2x, 2*sys_clk_freq)
Expand Down Expand Up @@ -67,8 +68,7 @@ def __init__(self, sys_clk_freq=int(100e6), **kwargs):
self.submodules.ddrphy = s7ddrphy.A7DDRPHY(platform.request("ddram"),
memtype = "DDR3",
nphases = 4,
sys_clk_freq = sys_clk_freq,
interface_type = "MEMORY")
sys_clk_freq = sys_clk_freq)
self.add_csr("ddrphy")
self.add_sdram("sdram",
phy = self.ddrphy,
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/c10lprefkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys_ps = ClockDomain(reset_less=True)

Expand All @@ -42,7 +43,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = Cyclone10LPPLL(speedgrade="-A7")
self.comb += pll.reset.eq(~platform.request("cpu_reset"))
self.comb += pll.reset.eq(~platform.request("cpu_reset") | self.rst)
pll.register_clkin(clk12, 12e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=90)
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/camlink_4k.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_init = ClockDomain()
self.clock_domains.cd_por = ClockDomain(reset_less=True)
self.clock_domains.cd_sys = ClockDomain()
Expand All @@ -51,7 +52,7 @@ def __init__(self, platform, sys_clk_freq):

# pll
self.submodules.pll = pll = ECP5PLL()
self.comb += pll.reset.eq(~por_done)
self.comb += pll.reset.eq(~por_done | self.rst)
pll.register_clkin(clk27, 27e6)
pll.create_clkout(self.cd_sys2x_i, 2*sys_clk_freq)
pll.create_clkout(self.cd_init, 27e6)
Expand Down
5 changes: 3 additions & 2 deletions litex_boards/targets/colorlight_5a_75x.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq, use_internal_osc=False, with_usb_pll=False, with_rst=True, sdram_rate="1:1"):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
if sdram_rate == "1:2":
self.clock_domains.cd_sys2x = ClockDomain()
Expand All @@ -91,7 +92,7 @@ def __init__(self, platform, sys_clk_freq, use_internal_osc=False, with_usb_pll=

# PLL
self.submodules.pll = pll = ECP5PLL()
self.comb += pll.reset.eq(~rst_n)
self.comb += pll.reset.eq(~rst_n | self.rst)
pll.register_clkin(clk, clk_freq)
pll.create_clkout(self.cd_sys, sys_clk_freq)
if sdram_rate == "1:2":
Expand All @@ -103,7 +104,7 @@ def __init__(self, platform, sys_clk_freq, use_internal_osc=False, with_usb_pll=
# USB PLL
if with_usb_pll:
self.submodules.usb_pll = usb_pll = ECP5PLL()
self.comb += usb_pll.reset.eq(~rst_n)
self.comb += usb_pll.reset.eq(~rst_n | self.rst)
usb_pll.register_clkin(clk, clk_freq)
self.clock_domains.cd_usb_12 = ClockDomain()
self.clock_domains.cd_usb_48 = ClockDomain()
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/crosslink_nx_evn.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_por = ClockDomain()

Expand All @@ -49,7 +50,7 @@ def __init__(self, platform, sys_clk_freq):
self.comb += self.cd_por.clk.eq(self.cd_sys.clk)
self.sync.por += If(por_counter != 0, por_counter.eq(por_counter - 1))
self.specials += AsyncResetSynchronizer(self.cd_por, ~rst_n)
self.specials += AsyncResetSynchronizer(self.cd_sys, (por_counter != 0))
self.specials += AsyncResetSynchronizer(self.cd_sys, (por_counter != 0) | self.rst)


# BaseSoC ------------------------------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/crosslink_nx_vip.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_por = ClockDomain()

Expand All @@ -55,7 +56,7 @@ def __init__(self, platform, sys_clk_freq):
self.comb += self.cd_por.clk.eq(self.cd_sys.clk)
self.sync.por += If(por_counter != 0, por_counter.eq(por_counter - 1))
self.specials += AsyncResetSynchronizer(self.cd_por, ~rst_n)
self.specials += AsyncResetSynchronizer(self.cd_sys, (por_counter != 0))
self.specials += AsyncResetSynchronizer(self.cd_sys, (por_counter != 0) | self.rst)


# BaseSoC ------------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/de0nano.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq, sdram_rate="1:1"):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
if sdram_rate == "1:2":
self.clock_domains.cd_sys2x = ClockDomain()
Expand All @@ -43,6 +44,7 @@ def __init__(self, platform, sys_clk_freq, sdram_rate="1:1"):

# PLL
self.submodules.pll = pll = CycloneIVPLL(speedgrade="-6")
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk50, 50e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
if sdram_rate == "1:2":
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/de10lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys_ps = ClockDomain(reset_less=True)
self.clock_domains.cd_vga = ClockDomain(reset_less=True)
Expand All @@ -43,6 +44,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = Max10PLL(speedgrade="-7")
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk50, 50e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=90)
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/de10nano.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq, with_sdram=False, sdram_rate="1:1"):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
if sdram_rate == "1:2":
self.clock_domains.cd_sys2x = ClockDomain()
Expand All @@ -47,6 +48,7 @@ def __init__(self, platform, sys_clk_freq, with_sdram=False, sdram_rate="1:1"):

# PLL
self.submodules.pll = pll = CycloneVPLL(speedgrade="-I7")
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk50, 50e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
if sdram_rate == "1:2":
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/de1soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys_ps = ClockDomain(reset_less=True)

Expand All @@ -38,6 +39,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = CycloneVPLL(speedgrade="-C6")
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk50, 50e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=90)
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/de2_115.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys_ps = ClockDomain(reset_less=True)

Expand All @@ -38,6 +39,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = CycloneIVPLL(speedgrade="-7")
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk50, 50e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=90)
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/ecp5_evn.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq, x5_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()

# # #
Expand All @@ -37,7 +38,7 @@ def __init__(self, platform, sys_clk_freq, x5_clk_freq):

# pll
self.submodules.pll = pll = ECP5PLL()
self.comb += pll.reset.eq(~rst_n)
self.comb += pll.reset.eq(~rst_n | self.rst)
pll.register_clkin(clk, x5_clk_freq or 12e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)

Expand Down
7 changes: 4 additions & 3 deletions litex_boards/targets/ecpix5.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_init = ClockDomain()
self.clock_domains.cd_por = ClockDomain(reset_less=True)
self.clock_domains.cd_sys = ClockDomain()
Expand All @@ -54,7 +55,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = ECP5PLL()
self.comb += pll.reset.eq(~por_done | ~rst_n)
self.comb += pll.reset.eq(~por_done | ~rst_n | self.rst)
pll.register_clkin(clk100, 100e6)
pll.create_clkout(self.cd_sys2x_i, 2*sys_clk_freq)
pll.create_clkout(self.cd_init, 25e6)
Expand All @@ -69,8 +70,8 @@ def __init__(self, platform, sys_clk_freq):
i_CLKI = self.cd_sys2x.clk,
i_RST = self.reset,
o_CDIVX = self.cd_sys.clk),
AsyncResetSynchronizer(self.cd_sys, ~pll.locked | self.reset),
AsyncResetSynchronizer(self.cd_sys2x, ~pll.locked | self.reset),
AsyncResetSynchronizer(self.cd_sys, ~pll.locked | self.reset | self.rst),
AsyncResetSynchronizer(self.cd_sys2x, ~pll.locked | self.reset | self.rst),
]

# BaseSoC ------------------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/fk33.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()

# # #

self.submodules.pll = pll = USPMMCM(speedgrade=-2)
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(platform.request("clk200"), 200e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)

Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/fomu.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
assert sys_clk_freq == 12e6
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_por = ClockDomain(reset_less=True)
self.clock_domains.cd_usb_12 = ClockDomain()
Expand All @@ -53,6 +54,7 @@ def __init__(self, platform, sys_clk_freq):

# USB PLL
self.submodules.pll = pll = iCE40PLL()
self.comb += pll.reset.eq(self.rst)
pll.clko_freq_range = ( 12e6, 275e9) # FIXME: improve iCE40PLL to avoid lowering clko_freq_min.
pll.register_clkin(clk48, 48e6)
pll.create_clkout(self.cd_usb_12, 12e6, with_reset=False)
Expand Down
3 changes: 2 additions & 1 deletion litex_boards/targets/genesys2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys4x = ClockDomain(reset_less=True)
self.clock_domains.cd_idelay = ClockDomain()

# # #

self.submodules.pll = pll = S7MMCM(speedgrade=-2)
self.comb += pll.reset.eq(~platform.request("cpu_reset_n"))
self.comb += pll.reset.eq(~platform.request("cpu_reset_n") | self.rst)
pll.register_clkin(platform.request("clk200"), 200e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys4x, 4*sys_clk_freq)
Expand Down
2 changes: 2 additions & 0 deletions litex_boards/targets/hadbadge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

class _CRG(Module):
def __init__(self, platform, sys_clk_freq):
self.rst = Signal()
self.clock_domains.cd_sys = ClockDomain()
self.clock_domains.cd_sys_ps = ClockDomain(reset_less=True)

Expand All @@ -45,6 +46,7 @@ def __init__(self, platform, sys_clk_freq):

# PLL
self.submodules.pll = pll = ECP5PLL()
self.comb += pll.reset.eq(self.rst)
pll.register_clkin(clk8, 8e6)
pll.create_clkout(self.cd_sys, sys_clk_freq)
pll.create_clkout(self.cd_sys_ps, sys_clk_freq, phase=90)
Expand Down
Loading

0 comments on commit 2b17dc1

Please sign in to comment.