From f417725b10de30a1dbf0c6024bec316cccf685f9 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 3 Jun 2019 02:54:17 +0000 Subject: [PATCH] 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`. --- examples/blinky.py | 2 +- nmigen/build/res.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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" -- 2.30.2