build.res: if not specified, request resource #0.
authorwhitequark <cz@m-labs.hk>
Mon, 3 Jun 2019 02:54:17 +0000 (02:54 +0000)
committerwhitequark <cz@m-labs.hk>
Mon, 3 Jun 2019 02:54:17 +0000 (02:54 +0000)
This markedly differs from oMigen system, which would request
consecutive resources. The difference is deliberate; most resources
are singular, so it does not matter for them, and for resources where
it does matter, which pins are requested should not depend on order
of execution of `platform.request`.

examples/blinky.py
nmigen/build/res.py

index a41bab36d875cf157d09cbe0027e2598c5be551a..3e9cc023b8481c1355a92ffb8e321ebe35704aa9 100644 (file)
@@ -4,7 +4,7 @@ from nmigen.vendor.ice40_hx1k_blink_evn import *
 
 class Blinky(Elaboratable):
     def elaborate(self, platform):
-        clk3p3   = platform.request("clk3p3", 0)
+        clk3p3   = platform.request("clk3p3")
         user_led = platform.request("user_led", 0)
         counter  = Signal(20)
 
index 9376f006764ba8e1c9b29917f87ae0db79d355f7..44aa8fbd4fd2985ea69e7eabae9853b1976572d7 100644 (file)
@@ -49,13 +49,13 @@ class ConstraintManager:
                                   .format(resource.name, resource.number, other / 1e6))
         self.clocks[resource.name, resource.number] = frequency
 
-    def lookup(self, name, number):
+    def lookup(self, name, number=0):
         if (name, number) not in self.resources:
             raise NameError("Resource {}#{} does not exist"
                             .format(name, number))
         return self.resources[name, number]
 
-    def request(self, name, number, dir=None, xdr=None):
+    def request(self, name, number=0, *, dir=None, xdr=None):
         resource = self.lookup(name, number)
         if (resource.name, resource.number) in self.requested:
             raise ConstraintError("Resource {}#{} has already been requested"