From: whitequark Date: Mon, 3 Jun 2019 02:54:17 +0000 (+0000) Subject: build.res: if not specified, request resource #0. X-Git-Tag: locally_working~223 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f417725b10de30a1dbf0c6024bec316cccf685f9;p=nmigen.git build.res: if not specified, request resource #0. 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`. --- diff --git a/examples/blinky.py b/examples/blinky.py index a41bab3..3e9cc02 100644 --- a/examples/blinky.py +++ b/examples/blinky.py @@ -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) diff --git a/nmigen/build/res.py b/nmigen/build/res.py index 9376f00..44aa8fb 100644 --- a/nmigen/build/res.py +++ b/nmigen/build/res.py @@ -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"