vendor.fpga.lattice_ice40: allow instantiating SB_GB_IO via extras.
authorwhitequark <cz@m-labs.hk>
Mon, 3 Jun 2019 07:54:28 +0000 (07:54 +0000)
committerwhitequark <cz@m-labs.hk>
Mon, 3 Jun 2019 07:54:28 +0000 (07:54 +0000)
nmigen/vendor/fpga/lattice_ice40.py
nmigen/vendor/ice40_hx1k_blink_evn.py
nmigen/vendor/icestick.py
nmigen/vendor/tinyfpga_bx.py

index 778e9c76621e9e946c0849f23a4784344b889735..b8852d1375177ef3530b2401e4c11f8ddd7f2c37 100644 (file)
@@ -119,6 +119,12 @@ class LatticeICE40Platform(TemplatedPlatform):
     def _get_io_buffer(self, pin, port, extras):
         m = Module()
 
+        if "GLOBAL" in extras:
+            is_global_input = bool(extras["GLOBAL"])
+            del extras["GLOBAL"]
+        else:
+            is_global_input = False
+
         if "i" in pin.dir and pin.xdr == 2:
             i0_ff = Signal.like(pin.i0, name="{}_ff".format(pin.i0.name))
             i1_ff = Signal.like(pin.i1, name="{}_ff".format(pin.i1.name))
@@ -162,9 +168,11 @@ class LatticeICE40Platform(TemplatedPlatform):
                 io_args.append(("i", "OUTPUT_CLK", pin.o_clk))
 
             if "i" in pin.dir:
-                if pin.xdr < 2:
+                if pin.xdr == 0 and is_global_input:
+                    io_args.append(("o", "GLOBAL_BUFFER_OUTPUT", pin.i[bit]))
+                elif pin.xdr < 2:
                     io_args.append(("o", "D_IN_0",  pin.i[bit]))
-                if pin.xdr == 2:
+                elif pin.xdr == 2:
                     # Re-register both inputs before they enter fabric. This increases hold time
                     # to an entire cycle, and adds one cycle of latency.
                     io_args.append(("o", "D_IN_0",  i0_ff))
@@ -172,7 +180,7 @@ class LatticeICE40Platform(TemplatedPlatform):
             if "o" in pin.dir:
                 if pin.xdr < 2:
                     io_args.append(("i", "D_OUT_0", pin.o[bit]))
-                if pin.xdr == 2:
+                elif pin.xdr == 2:
                     # Re-register negedge output after it leaves fabric. This increases setup time
                     # to an entire cycle, and doesn't add latency.
                     io_args.append(("i", "D_OUT_0", pin.o0[bit]))
@@ -181,7 +189,10 @@ class LatticeICE40Platform(TemplatedPlatform):
             if pin.dir in ("oe", "io"):
                 io_args.append(("i", "OUTPUT_ENABLE", pin.oe))
 
-            m.submodules += Instance("SB_IO", *io_args)
+            if is_global_input:
+                m.submodules += Instance("SB_GB_IO", *io_args)
+            else:
+                m.submodules += Instance("SB_IO", *io_args)
 
         return m
 
index 1f4488291fb13499efbc3ef1d814c0cf0eacb600..cc6d5a55dcf5f84a1ef637c1e9ce8f3a9b38c100 100644 (file)
@@ -12,7 +12,8 @@ class ICE40HX1KBlinkEVNPlatform(IceBurnProgrammerMixin, LatticeICE40Platform):
         ("clk3p3", 3.3e6),
     ]
     resources = [
-        Resource("clk3p3", 0, Pins("13", dir="i"), extras={"IO_STANDARD": "SB_LVCMOS33"}),
+        Resource("clk3p3", 0, Pins("13", dir="i"),
+                 extras={"GLOBAL": "1", "IO_STANDARD": "SB_LVCMOS33"}),
 
         Resource("user_led", 0, Pins("59", dir="o"), extras={"IO_STANDARD": "SB_LVCMOS33"}),
         Resource("user_led", 1, Pins("56", dir="o"), extras={"IO_STANDARD": "SB_LVCMOS33"}),
index 4d1ecfdcd10c7a55adf6c422053e1696205111d4..f2f2da6e8c24be4e04d8ddabb6c0894919f00c72 100644 (file)
@@ -12,7 +12,8 @@ class ICEStickPlatform(IceStormProgrammerMixin, LatticeICE40Platform):
         ("clk12", 12e6),
     ]
     resources = [
-        Resource("clk12", 0, Pins("21", dir="i"), extras={"IO_STANDARD": "SB_LVCMOS33"}),
+        Resource("clk12", 0, Pins("21", dir="i"),
+                 extras={"GLOBAL": "1", "IO_STANDARD": "SB_LVCMOS33"}),
 
         Resource("user_led", 0, Pins("99", dir="o"), extras={"IO_STANDARD": "SB_LVCMOS33"}),
         Resource("user_led", 1, Pins("98", dir="o"), extras={"IO_STANDARD": "SB_LVCMOS33"}),
index 50ced5d9b00a5bb3003cf5f605a61df7fa6235f9..24f7c330b7aab0592f48dc2a8c0db3a42c5027d7 100644 (file)
@@ -12,7 +12,8 @@ class TinyFPGABXPlatform(TinyProgrammerMixin, LatticeICE40Platform):
         ("clk16", 16e6),
     ]
     resources = [
-        Resource("clk16", 0, Pins("B2", dir="i"), extras={"IO_STANDARD": "SB_LVCMOS33"}),
+        Resource("clk16", 0, Pins("B2", dir="i"),
+                 extras={"GLOBAL": 1, "IO_STANDARD": "SB_LVCMOS33"}),
 
         Resource("user_led", 0, Pins("B3", dir="o"), extras={"IO_STANDARD": "SB_LVCMOS33"}),