test: add initial (minimal) test for clock abstraction modules.
authorFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 13 Mar 2020 11:24:36 +0000 (12:24 +0100)
committerFlorent Kermarrec <florent@enjoy-digital.fr>
Fri, 13 Mar 2020 11:38:23 +0000 (12:38 +0100)
Also fix divclk_divide_range on S6DCM.

litex/soc/cores/clock.py
test/test_clock.py [new file with mode: 0644]

index 127eb8336efb9616cf14dc39233e603d46ffc1ef..767659d5d33e6ae97c0879b8534ef6358d99e5ec 100644 (file)
@@ -229,7 +229,7 @@ class S6DCM(XilinxClocking):
         self.logger = logging.getLogger("S6DCM")
         self.logger.info("Creating S6DCM, {}.".format(colorer("speedgrade {}".format(speedgrade))))
         XilinxClocking.__init__(self)
-        self.divclk_divide_range = (1, 1) # FIXME
+        self.divclk_divide_range = (1, 2) # FIXME
         self.clkin_freq_range = {
             -1: (0.5e6, 200e6),
             -2: (0.5e6, 333e6),
diff --git a/test/test_clock.py b/test/test_clock.py
new file mode 100644 (file)
index 0000000..630d360
--- /dev/null
@@ -0,0 +1,69 @@
+# This file is Copyright (c) 2020 Florent Kermarrec <florent@enjoy-digital.fr>
+# License: BSD
+
+import unittest
+
+from litex.soc.cores.clock import *
+
+
+class TestClock(unittest.TestCase):
+    # Xilinx / Spartan 6
+    def test_s6pll(self):
+        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()
+
+    def test_s6dcm(self):
+        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
+    def test_s7pll(self):
+        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()
+
+    def test_s7mmcm(self):
+        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
+    def test_uspll(self):
+        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()
+
+    def test_usmmcm(self):
+        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()
+
+    # Lattice / iCE40
+    def test_ice40pll(self):
+        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
+    def test_ecp5pll(self):
+        pll = ECP5PLL()
+        pll.register_clkin(Signal(), 100e6)
+        for i in range(pll.nclkouts_max):
+            pll.create_clkout(ClockDomain("clkout{}".format(i)), 200e6)
+        pll.compute_config()