2020-08-23 09:40:21 -04:00
|
|
|
#
|
|
|
|
# This file is part of LiteX.
|
|
|
|
#
|
|
|
|
# Copyright (c) 2020 Florent Kermarrec <florent@enjoy-digital.fr>
|
|
|
|
# SPDX-License-Identifier: BSD-2-Clause
|
2020-03-13 07:24:36 -04:00
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
2020-11-09 04:37:20 -05:00
|
|
|
from migen import *
|
|
|
|
|
2020-03-13 07:24:36 -04:00
|
|
|
from litex.soc.cores.clock import *
|
|
|
|
|
|
|
|
|
|
|
|
class TestClock(unittest.TestCase):
|
|
|
|
# Xilinx / Spartan 6
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_s6_pll(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
pll = S6PLL()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_s6_dcm(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
dcm = S6DCM()
|
|
|
|
dcm.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(dcm.nclkouts_max):
|
|
|
|
dcm.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
dcm.compute_config()
|
|
|
|
|
|
|
|
# Xilinx / 7-Series
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_s7_pll(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
pll = S7PLL()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_s7_mmcm(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
mmcm = S7MMCM()
|
|
|
|
mmcm.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(mmcm.nclkouts_max):
|
|
|
|
mmcm.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
mmcm.compute_config()
|
|
|
|
|
|
|
|
# Xilinx / Ultrascale
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_us_pll(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
pll = USPLL()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_us_mmcm(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
mmcm = USMMCM()
|
|
|
|
mmcm.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(mmcm.nclkouts_max):
|
|
|
|
mmcm.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
mmcm.compute_config()
|
|
|
|
|
2020-09-03 12:57:05 -04:00
|
|
|
# Xilinx / Ultrascale Plus
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_us_ppll(self):
|
2020-09-03 12:57:05 -04:00
|
|
|
pll = USPPLL()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_us_pmmcm(self):
|
2020-09-03 12:57:05 -04:00
|
|
|
mmcm = USPMMCM()
|
|
|
|
mmcm.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(mmcm.nclkouts_max):
|
|
|
|
mmcm.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
mmcm.compute_config()
|
|
|
|
|
2020-11-09 04:37:20 -05:00
|
|
|
# Intel / CycloneIV
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_cycloneiv_pll(self):
|
2020-11-09 04:37:20 -05:00
|
|
|
pll = CycloneIVPLL()
|
|
|
|
pll.register_clkin(Signal(), 50e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 100e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
|
|
|
# Intel / CycloneV
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_cyclonev_pll(self):
|
2020-11-09 04:37:20 -05:00
|
|
|
pll = CycloneVPLL()
|
|
|
|
pll.register_clkin(Signal(), 50e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 100e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
|
|
|
# Intel / Cyclone10
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_cyclone10_pll(self):
|
2020-11-09 04:37:20 -05:00
|
|
|
pll = Cyclone10LPPLL()
|
|
|
|
pll.register_clkin(Signal(), 50e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 100e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
|
|
|
# Intel / Max10
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_max10_pll(self):
|
2020-11-09 04:37:20 -05:00
|
|
|
pll = Max10PLL()
|
|
|
|
pll.register_clkin(Signal(), 50e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 100e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
2020-03-13 07:24:36 -04:00
|
|
|
# Lattice / iCE40
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_ice40_pll(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
pll = USMMCM()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
|
|
|
for i in range(pll.nclkouts_max):
|
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
|
|
|
# Lattice / ECP5
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_ecp5_pll(self):
|
2020-03-13 07:24:36 -04:00
|
|
|
pll = ECP5PLL()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
2021-07-26 07:38:14 -04:00
|
|
|
for i in range(pll.nclkouts_max-1):
|
2021-07-08 09:11:47 -04:00
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6, uses_dpa=(i != 0))
|
|
|
|
pll.expose_dpa()
|
2020-03-13 07:24:36 -04:00
|
|
|
pll.compute_config()
|
2020-04-07 10:59:53 -04:00
|
|
|
|
2021-09-15 01:00:24 -04:00
|
|
|
# Test corner cases that have historically had trouble:
|
|
|
|
pll = ECP5PLL()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
|
|
|
pll.create_clkout(ClockDomain("clkout1"), 350e6)
|
|
|
|
pll.create_clkout(ClockDomain("clkout2"), 350e6)
|
|
|
|
pll.create_clkout(ClockDomain("clkout3"), 175e6)
|
|
|
|
pll.create_clkout(ClockDomain("clkout4"), 175e6)
|
|
|
|
pll.compute_config()
|
|
|
|
|
2022-01-25 04:49:33 -05:00
|
|
|
def test_ecp5_delay(self):
|
|
|
|
delay = ECP5Delay()
|
|
|
|
|
2020-11-09 04:37:20 -05:00
|
|
|
# Lattice / NX
|
|
|
|
def test_nxpll(self):
|
|
|
|
pll = NXPLL()
|
|
|
|
pll.register_clkin(Signal(), 100e6)
|
2020-04-07 11:24:12 -04:00
|
|
|
for i in range(pll.nclkouts_max):
|
2020-11-09 04:37:20 -05:00
|
|
|
pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
|
2020-04-07 11:24:12 -04:00
|
|
|
pll.compute_config()
|