build.res: detect physical conflicts earlier.
This is useful for two reasons:
1. nMigen can provide better error messages than the platform and
do it earlier in the build pipeline.
2. Many platforms handle diffpairs by only constraining the P pin;
the N pin is completely ignored. If this is undetected,
downstream users (human or software) can rely on this
information assuming it is correct and introduce more errors.
(Of course, this will not catch every mistake, but the most
common is a copy-paste issue, and that will handle it.)
Fixes #124.
This commit is contained in:
parent
7059cb4931
commit
b471e33d7f
2 changed files with 22 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ class ResourceManager:
|
|||
def __init__(self, resources, connectors):
|
||||
self.resources = OrderedDict()
|
||||
self._requested = OrderedDict()
|
||||
self._phys_reqd = OrderedDict()
|
||||
|
||||
self.connectors = OrderedDict()
|
||||
self._conn_pins = OrderedDict()
|
||||
|
|
@ -115,14 +116,25 @@ class ResourceManager:
|
|||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue