24 from gettext
import gettext
as _
27 def __init__(self, netlist, namespace, unmangled_refdes):
52 if not isinstance(name, basestring):
59 value = component.blueprint.get_attribute(name)
79 if value
is not None and value
not in values:
83 self.
error(_(
"attribute conflict for \"%s\": %s") % (
84 name, _(
" vs. ").join(_(
"\"%s\"") % value
85 for value
in values)))
89 if default
is not KeyError:
93 assert isinstance(values[0], basestring)
99 if not isinstance(pinseq, int):
104 pin_blueprint = component.blueprint.pins_by_pinseq[pinseq]
130 self.
error(_(
"bad slot number: %s") % slot)
146 component.blueprint.get_attribute_names(search_inherited):
152 sys.stderr.write(_(
"package `%s': error: %s\n") % (self.
refdes, msg))
153 self.netlist.failed =
True
156 sys.stderr.write(_(
"package `%s': warning: %s\n") % (self.
refdes, msg))
180 if not isinstance(name, basestring):
184 for cpin
in self.
cpins:
186 value = cpin.blueprint.get_attribute(name)
206 if name ==
'pinnumber':
207 has_real_pins =
False
208 for cpin
in self.
cpins:
209 if cpin.blueprint.ob
is not None:
215 if default
is not KeyError:
221 if value
is not None and value
not in values:
225 self.
error(_(
"attribute conflict for \"%s\": %s") % (
226 name, _(
" vs. ").join(_(
"\"%s\"") % value
227 for value
in values)))
231 if default
is not KeyError:
235 assert isinstance(values[0], basestring)
239 sys.stderr.write(_(
"package `%s', pin `%s': error: %s\n") % (
240 self.package.refdes, self.
number, msg))
241 self.package.netlist.failed =
True
244 sys.stderr.write(_(
"package `%s', pin `%s': warning: %s\n") % (
245 self.package.refdes, self.
number, msg))
251 for schematic
in netlist.schematics:
252 for component
in schematic.components:
253 if component.refdes
is not None:
256 if component.is_graphical:
262 if not component.pins:
263 component.error(_(
"component has neither refdes nor pins"))
266 if not next((
True for pin
in component.pins
267 if pin.has_netattrib),
False):
270 "could not find refdes on component and "
271 "could not find net= attribute on pin"))
274 netlist.packages = []
277 for component
in netlist.components:
278 if component.blueprint.refdes
is None:
281 if flat_namespace
or component.sheet.instantiating_component
is None:
284 namespace = component.sheet
287 package = pkg_dict[namespace, component.blueprint.refdes]
289 package =
Package(netlist, namespace, component.blueprint.refdes)
290 netlist.packages.append(package)
291 pkg_dict[namespace, component.blueprint.refdes] = package
293 package.components.append(component)
295 for cpin
in component.cpins:
297 ppin = package.pins_by_number[cpin.blueprint.number]
299 ppin =
PackagePin(package, cpin.blueprint.number)
300 package.pins.append(ppin)
301 package.pins_by_number[cpin.blueprint.number] = ppin
302 ppin.cpins.append(cpin)
304 for package
in netlist.packages:
305 for ppin
in package.pins:
307 for cpin
in ppin.cpins:
308 if cpin.local_net.net
not in nets:
309 nets.append(cpin.local_net.net)
312 ppin.error(_(
"multiple nets connected to pin: %s")
313 % _(
" vs. ").join(_(
"\"%s\"") % net.name
317 for net
in netlist.nets:
324 for cpin
in net.component_pins:
325 if cpin.component.blueprint.refdes
is None:
328 or cpin.component.sheet.instantiating_component
is None:
331 namespace = cpin.component.sheet
332 ppin = pkg_dict[namespace, cpin.component.blueprint.refdes] \
333 .pins_by_number[cpin.blueprint.number]
334 if ppin
not in net.connections:
335 net.connections.append(ppin)
def get_unique_slots
Return a sorted list of unique slots used by this package.
def get_attribute
Return the value associated with attribute name on the package.
def get_all_attributes
Get attribute value(s) from a package with given refdes.
def get_all_attributes
Returns the appropriate attribute values on this pin.
def get_pin_by_pinseq
Takes a pinseq string and returns that pinseq pin of this package.
def get_attribute
Return the value associated with attribute name on the pin.
def get_slots
Return a sorted list of slots used by this package.