def __init__(self, resources, connectors):
self.resources = OrderedDict()
self._requested = OrderedDict()
+ self._phys_reqd = OrderedDict()
self.connectors = OrderedDict()
self._conn_pins = OrderedDict()
elif isinstance(resource.ios[0], (Pins, DiffPairs)):
phys = resource.ios[0]
if isinstance(phys, Pins):
+ phys_names = phys.names
port = Record([("io", len(phys))], name=name)
if isinstance(phys, DiffPairs):
+ phys_names = phys.p.names + phys.n.names
port = Record([("p", len(phys)),
("n", len(phys))], name=name)
if dir == "-":
pin = None
else:
pin = Pin(len(phys), dir, xdr, name=name)
+
+ for phys_name in phys_names:
+ if phys_name in self._phys_reqd:
+ raise ResourceError("Resource component {} uses physical pin {}, but it "
+ "is already used by resource component {} that was "
+ "requested earlier"
+ .format(name, phys_name, self._phys_reqd[phys_name]))
+ self._phys_reqd[phys_name] = name
+
self._ports.append((resource, pin, port, attrs))
if pin is not None and resource.clock is not None:
self.cm.request("user_led", 0)
self.cm.request("user_led", 0)
+ def test_wrong_request_duplicate_physical(self):
+ self.cm.add_resources([
+ Resource("clk20", 0, Pins("H1", dir="i")),
+ ])
+ self.cm.request("clk100", 0)
+ with self.assertRaises(ResourceError,
+ msg="Resource component clk20_0 uses physical pin H1, but it is already "
+ "used by resource component clk100_0 that was requested earlier"):
+ self.cm.request("clk20", 0)
+
def test_wrong_request_with_dir(self):
with self.assertRaises(TypeError,
msg="Direction must be one of \"i\", \"o\", \"oe\", \"io\", or \"-\", "