Merge pull request #406 from chmousset/fix/icebreaker_bitsy
[fix] instanciate PLL for valentyUSB
This commit is contained in:
commit
32f507cc08
|
@ -34,7 +34,9 @@ mB = 1024*kB
|
||||||
# CRG ----------------------------------------------------------------------------------------------
|
# CRG ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class _CRG(Module):
|
class _CRG(Module):
|
||||||
def __init__(self, platform, sys_clk_freq):
|
def __init__(self, platform, sys_clk_freq=48e6, with_usb_pll=False):
|
||||||
|
assert not with_usb_pll or sys_clk_freq == 48e6
|
||||||
|
|
||||||
self.rst = Signal()
|
self.rst = Signal()
|
||||||
self.clock_domains.cd_sys = ClockDomain()
|
self.clock_domains.cd_sys = ClockDomain()
|
||||||
self.clock_domains.cd_por = ClockDomain()
|
self.clock_domains.cd_por = ClockDomain()
|
||||||
|
@ -53,6 +55,37 @@ class _CRG(Module):
|
||||||
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
|
||||||
|
if with_usb_pll:
|
||||||
|
self.clock_domains.cd_usb_12 = ClockDomain()
|
||||||
|
self.clock_domains.cd_usb_48 = ClockDomain()
|
||||||
|
locked = Signal()
|
||||||
|
self.specials.pll = pll = Instance("SB_PLL40_2F_PAD",
|
||||||
|
i_PACKAGEPIN = clk12,
|
||||||
|
i_RESETB = rst_n,
|
||||||
|
i_BYPASS = C(0),
|
||||||
|
|
||||||
|
# o_PLLOUTGLOBALA = self.cd_sys.clk,
|
||||||
|
o_PLLOUTGLOBALA = self.cd_usb_48.clk,
|
||||||
|
o_PLLOUTGLOBALB = self.cd_usb_12.clk,
|
||||||
|
o_LOCK = locked,
|
||||||
|
|
||||||
|
# Create a 48 MHz PLL clock...
|
||||||
|
p_FEEDBACK_PATH = "SIMPLE",
|
||||||
|
p_PLLOUT_SELECT_PORTA = "GENCLK",
|
||||||
|
p_PLLOUT_SELECT_PORTB = "SHIFTREG_0deg",
|
||||||
|
p_DIVR = 0,
|
||||||
|
p_DIVF = 63,
|
||||||
|
p_DIVQ = 4,
|
||||||
|
p_FILTER_RANGE = 1,
|
||||||
|
)
|
||||||
|
self.specials += AsyncResetSynchronizer(self.cd_sys, ~por_done | ~locked)
|
||||||
|
platform.add_period_constraint(self.cd_sys.clk, 48e6)
|
||||||
|
platform.add_period_constraint(self.cd_usb_48.clk, 48e6)
|
||||||
|
platform.add_period_constraint(self.cd_usb_12.clk, 12e6)
|
||||||
|
self.comb += [
|
||||||
|
self.cd_sys.clk.eq(self.cd_usb_48.clk),
|
||||||
|
]
|
||||||
|
else:
|
||||||
self.submodules.pll = pll = iCE40PLL(primitive="SB_PLL40_PAD")
|
self.submodules.pll = pll = iCE40PLL(primitive="SB_PLL40_PAD")
|
||||||
self.comb += pll.reset.eq(~rst_n) # FIXME: Add proper iCE40PLL reset support and add back | self.rst.
|
self.comb += pll.reset.eq(~rst_n) # FIXME: Add proper iCE40PLL reset support and add back | self.rst.
|
||||||
pll.register_clkin(clk12, 12e6)
|
pll.register_clkin(clk12, 12e6)
|
||||||
|
@ -60,6 +93,7 @@ class _CRG(Module):
|
||||||
self.specials += AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked)
|
self.specials += AsyncResetSynchronizer(self.cd_sys, ~por_done | ~pll.locked)
|
||||||
platform.add_period_constraint(self.cd_sys.clk, 1e9/sys_clk_freq)
|
platform.add_period_constraint(self.cd_sys.clk, 1e9/sys_clk_freq)
|
||||||
|
|
||||||
|
|
||||||
# BaseSoC ------------------------------------------------------------------------------------------
|
# BaseSoC ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class BaseSoC(SoCCore):
|
class BaseSoC(SoCCore):
|
||||||
|
@ -67,7 +101,10 @@ class BaseSoC(SoCCore):
|
||||||
platform = icebreaker_bitsy.Platform(revision=revision)
|
platform = icebreaker_bitsy.Platform(revision=revision)
|
||||||
|
|
||||||
# CRG --------------------------------------------------------------------------------------
|
# CRG --------------------------------------------------------------------------------------
|
||||||
self.submodules.crg = _CRG(platform, sys_clk_freq)
|
with_usb_acm = kwargs["uart_name"] == "usb_acm"
|
||||||
|
if with_usb_acm:
|
||||||
|
sys_clk_freq = 48e6
|
||||||
|
self.submodules.crg = _CRG(platform, sys_clk_freq, with_usb_pll=with_usb_acm)
|
||||||
|
|
||||||
# SoCCore ----------------------------------------------------------------------------------
|
# SoCCore ----------------------------------------------------------------------------------
|
||||||
# Disable Integrated ROM/SRAM since too large for iCE40 and UP5K has specific SPRAM.
|
# Disable Integrated ROM/SRAM since too large for iCE40 and UP5K has specific SPRAM.
|
||||||
|
|
Loading…
Reference in New Issue