build.res: simplify emission of port constraints on individual bits.
authorwhitequark <cz@m-labs.hk>
Tue, 4 Jun 2019 08:37:52 +0000 (08:37 +0000)
committerwhitequark <cz@m-labs.hk>
Tue, 4 Jun 2019 08:39:03 +0000 (08:39 +0000)
nmigen/build/res.py
nmigen/vendor/fpga/lattice_ice40.py

index 0b32ded00704d3f8bad27d3139ce67584aee1b2f..bc388bef41cc7920b4a1e07bc71d06446ef0a4ed 100644 (file)
@@ -183,6 +183,14 @@ class ConstraintManager:
             else:
                 assert False
 
+    def iter_port_constraints_bits(self):
+        for port_name, pin_names, extras in self.iter_port_constraints():
+            if len(pin_names) == 1:
+                yield port_name, pin_names[0], extras
+            else:
+                for bit, pin_name in enumerate(pin_names):
+                    yield "{}[{}]".format(port_name, bit), pin_name, extras
+
     def iter_clock_constraints(self):
         for name, number in self.clocks.keys() & self._requested.keys():
             resource = self.resources[name, number]
index 8dc2d2b68314d2e7bef0b8bfa6772015536b195a..8434fc87e4a32849e6e6488539d31754c73e6a7a 100644 (file)
@@ -24,8 +24,9 @@ class LatticeICE40Platform(TemplatedPlatform):
         * ``synth_opts``: adds options for ``synth_ice40`` Yosys command.
         * ``script_after_read``: inserts commands after ``read_ilang`` in Yosys script.
         * ``script_after_synth``: inserts commands after ``synth_ice40`` in Yosys script.
-        * ``yosys_opts``: overrides default options (``-q``) for Yosys.
-        * ``nextpnr_opts``: overrides default options (``-q --placer heap``).
+        * ``yosys_opts``: adds extra options for Yosys.
+        * ``nextpnr_opts``: adds extra and overrides default options (``--placer heap``)
+          for nextpnr.
 
     Build products:
         * ``{{name}}.rpt``: Yosys log.
@@ -61,14 +62,8 @@ class LatticeICE40Platform(TemplatedPlatform):
         """,
         "{{name}}.pcf": r"""
             # {{autogenerated}}
-            {% for port, pins, extra in platform.iter_port_constraints() %}
-                {% if pins|count > 1 %}
-                    {% for bit in range -%}
-                        set_io {{port}}[{{bit}}] {{pins[bit]}}
-                    {% endfor %}
-                {% else -%}
-                    set_io {{port}} {{pins[0]}}
-                {% endif %}
+            {% for port_name, pin_name, extras in platform.iter_port_constraints_bits() -%}
+                set_io {{port_name}} {{pin_name}}
             {% endfor %}
         """,
         "{{name}}_pre_pack.py": r"""