ecp5_5g_evn: add variable IO standards and SERDES resources.
authorx44203 <60701660+x44203@users.noreply.github.com>
Fri, 20 Mar 2020 08:03:43 +0000 (09:03 +0100)
committerGitHub <noreply@github.com>
Fri, 20 Mar 2020 08:03:43 +0000 (08:03 +0000)
nmigen_boards/ecp5_5g_evn.py

index b38e3aee99c0887c1b247a4c99755e701f827b15..4c3f5db011e0f2a4f1a6336ccd54653ccd0f1c1b 100644 (file)
@@ -15,15 +15,66 @@ class ECP55GEVNPlatform(LatticeECP5Platform):
     speed       = "8"
     default_clk = "clk12"
     default_rst = "rst"
+
+    def __init__(self, *, VCCIO1="2V5", VCCIO6="3V3", **kwargs):
+        """
+        VCCIO1 is connected by default to 2.5 V via R100 (can be set to 3.3 V by disconnecting
+        R100 and connecting R105)
+        VCCIO6 is connected to 3.3 V by default via R99 (can be switched to 2.5 V with R104,
+        see page 51 in the ECP5-5G-EVN datasheet)
+        """
+        super().__init__(**kwargs)
+        assert VCCIO1 in ("3V3", "2V5")
+        assert VCCIO6 in ("3V3", "2V5")
+        self._VCCIO1 = VCCIO1
+        self._VCCIO6 = VCCIO6
+
+    def _vccio_to_iostandard(self, vccio):
+        if vccio == "2V5":
+            return "LVCMOS25"
+        if vccio == "3V3":
+            return "LVCMOS33"
+        assert False
+
+    def bank1_iostandard(self):
+        return self._vccio_to_iostandard(self._VCCIO1)
+
+    def bank6_iostandard(self):
+        return self._vccio_to_iostandard(self._VCCIO6)
+
     resources   = [
         Resource("rst", 0, PinsN("G2", dir="i"), Attrs(IO_TYPE="LVCMOS33")),
         Resource("clk12", 0, Pins("A10", dir="i"),
                  Clock(12e6), Attrs(IO_TYPE="LVCMOS33")),
 
-        *LEDResources(pins="A13 A12 B19 A18 B18 C17 A17 B17",
-                      attrs=Attrs(IO_TYPE="LVCMOS33")),
-        *SwitchResources(pins="P4", invert=True,
-                         attrs=Attrs(IO_TYPE="LVCMOS33")),
+        *LEDResources(pins="A13 A12 B19 A18 B18 C17 A17 B17", invert=True,
+                      attrs=Attrs(IO_TYPE=bank1_iostandard)),
+        *ButtonResources(pins="P4", invert=True,
+                         attrs=Attrs(IO_TYPE=bank6_iostandard)),
+        *SwitchResources(pins={1: "J1", 2: "H1", 3: "K1"}, invert=True,
+                         attrs=Attrs(IO_TYPE=bank6_iostandard)),
+        *SwitchResources(pins={4: "E15", 5: "D16", 6: "B16", 7: "C16", 8: "A16"}, invert=True,
+                         attrs=Attrs(IO_TYPE=bank1_iostandard)),
+
+        Resource("serdes", 0,
+            Subsignal("tx", DiffPairs("W4", "W5", dir="o")),
+            Subsignal("rx", DiffPairs("Y5", "Y6", dir="i")),
+        ),
+        Resource("serdes", 1,
+            Subsignal("tx", DiffPairs("W8", "W9", dir="o")),
+            Subsignal("rx", DiffPairs("Y7", "Y8", dir="i")),
+        ),
+        Resource("serdes", 2,
+            Subsignal("tx", DiffPairs("W13", "W14", dir="o")),
+            Subsignal("rx", DiffPairs("Y14", "Y15", dir="i")),
+        ),
+        Resource("serdes", 3,
+            Subsignal("tx", DiffPairs("W17", "W18", dir="o")),
+            Subsignal("rx", DiffPairs("Y16", "Y17", dir="i")),
+        ),
+
+        Resource("serdes_clk", 0, DiffPairs("Y11", "Y12", dir="i")),
+        Resource("serdes_clk", 1, DiffPairs("Y19", "W20", dir="i")), # 200 MHz
 
         # TODO: add other resources
     ]