本文整理汇总了Python中group.Group.parent方法的典型用法代码示例。如果您正苦于以下问题:Python Group.parent方法的具体用法?Python Group.parent怎么用?Python Group.parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group.Group
的用法示例。
在下文中一共展示了Group.parent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_parent
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import parent [as 别名]
def create_parent(child, forceOptimizer, debug):
"""
DESCRIPTION: builds recursive the parents of the groupe, which containts the block
when the algo reached the last parent, it will add them to the main group
PARAMETER: child The group which need a parent
STATE: finish
"""
if debug:
print "create parent for child:", child.group_id
group_id = child.group_id[: len(child.group_id) - 1] # remove the last ID
if debug:
print "parents ID:", group_id
group = search_group(group_id, forceOptimizer) # check if the group allready exists
if group is None: # create a new group if needed
group = Group(group_id)
forceOptimizer.groups.append(group)
if debug:
print "Parent not exist, create a new Group"
group.add_child(child)
child.parent = group
# check the connection to important pins
group.connected_gnd = 0
group.connected_vcc = 0
group.connected_out = 0
group.connected_inp = 0
for c in group.childs:
group.connected_gnd += c.connected_gnd
group.connected_vcc += c.connected_vcc
group.connected_out += c.connected_out
group.connected_inp += c.connected_inp
group.connected_parent_east = group.connected_out
group.connected_parent_south = group.connected_gnd
group.connected_parent_north = group.connected_vcc
# if group has parents create them
if len(group_id) > 1:
create_parent(group, forceOptimizer, debug)
# else add group to main group
else:
forceOptimizer.group_main.add_child(group)
group.parent = forceOptimizer.group_main
示例2: create_groups
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import parent [as 别名]
def create_groups(forceOptimizer, debug=False):
'''
DESCRIPTION: Create the groups and add them to the list: groups
STATE: finish
'''
if debug:
print ""
print "============="
print "Create Groups"
print "============="
print ""
#go through all blocks in circuit
for block in forceOptimizer.blocks:
group_id = block.groups # the lowest group get all IDs
if debug:
pins = ""
for p in block.pins.values():
pins += " " + p.net
print "Block: ", block.name, " Group ID", group_id, "Pins:", pins
group = search_group(group_id,forceOptimizer) # check if the group allready exists
if group is None: # create a new group if needed
if debug:
print ("Create a new Group with ID", group_id)
group = Group(group_id)
forceOptimizer.groups.append(group)
if block.name.startswith('i'):
group.block_north.add(block);
group.block_west.add(block)
#add the block to the low level group
group.add_block(block)
#if group has parents create them
if len(group.group_id) > 1:
create_parent(group, forceOptimizer, debug)
#else add group to main group
else:
forceOptimizer.group_main.add_child(group)
group.parent = forceOptimizer.group_main
示例3: insert
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import parent [as 别名]
def insert(self, index, item):
""" Insert an item into the manager at the specified index.
The item can be:-
1) A 'Group' instance.
In which case the group is inserted into the manager's list of
groups.
2) A string.
In which case a 'Group' instance is created with that Id, and then
inserted into the manager's list of groups.
3) An 'ActionManagerItem' instance.
In which case the item is inserted into the manager's default
group.
"""
# 1) The item is a 'Group' instance.
if isinstance(item, Group):
group = item
# Insert the group into the manager.
group.parent = self
self._groups.insert(index, item)
# 2) The item is a string.
elif isinstance(item, basestring):
# Create a group with that Id.
group = Group(id=item)
# Insert the group into the manager.
group.parent = self
self._groups.insert(index, group)
# 3) The item is an 'ActionManagerItem' instance.
else:
# Find the default group.
group = self._get_default_group()
# Insert the item into the default group.
group.insert(index, item)
return group
示例4: create_groups
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import parent [as 别名]
def create_groups(forceOptimizer, debug=False):
"""
DESCRIPTION: Create the groups and add them to the list: groups
STATE: finish
"""
if debug:
print ""
print "============="
print "Create Groups"
print "============="
print ""
# go through all blocks in circuit
for block in forceOptimizer.blocks:
group_id = block.groups # the lowest group get all IDs
pins = ""
for p in block.pins.values():
pins += " " + p.net
if debug:
print "Block: ", block.name, " Group ID", group_id, "Pins:", pins
group = search_group(group_id, forceOptimizer) # check if the group allready exists
if group is None: # create a new group if needed
if debug:
print ("Create a new Group with ID", group_id)
group = Group(group_id)
forceOptimizer.groups.append(group)
if block.name.startswith("i"):
group.block_north.add(block)
group.block_west.add(block)
# check the connection to important pins
for p in block.pins.values():
for pin in forceOptimizer.pins_south:
if p.net.lower().startswith(pin):
group.connected_gnd += 1
group.block_south.add(block)
for pin in forceOptimizer.pins_north:
if p.net.lower().startswith(pin):
group.connected_vcc += 1
group.block_north.add(block)
for pin in forceOptimizer.pins_east:
if p.net.lower().startswith(pin):
group.connected_out += 1
group.block_east.add(block)
for pin in forceOptimizer.pins_west:
if p.net.lower().startswith(pin):
group.block_west.add(block)
if p.net.lower().startswith("in"):
group.connected_inp
if group.connected_out > 0:
group.connected_parent_east += group.connected_out
if group.connected_gnd > 0:
group.connected_parent_south += group.connected_gnd
if group.connected_vcc > 0:
group.connected_parent_north += group.connected_vcc
# add the block to the low level group
group.add_block(block)
# if group has parents create them
if len(group_id) > 1:
create_parent(group, forceOptimizer, debug)
# else add group to main group
else:
forceOptimizer.group_main.add_child(group)
group.parent = forceOptimizer.group_main
示例5: find_special_groups
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import parent [as 别名]
def find_special_groups(forceOptimizer, debug):
new_groups = []
new_level = 0
for group in forceOptimizer.groups:
if len(group.blocks):
bias_blocks = []
in_blocks = []
for block in group.blocks:
for pin in block.pins.values():
if pin.net.startswith("vbias"):
bias_blocks.append(block)
break
if pin.net.startswith("in"):
in_blocks.append(block)
'''
if len(bias_blocks) < len(group.blocks) and len(bias_blocks):
new_group_id = group.group_id[:]
new_group_id.append(len(group.childs))
new_group = Group(new_group_id)
if new_group not in new_groups:
new_level = len(new_group_id)
new_groups.append(new_group)
new_group.parent = group
group.childs.append(new_group)
new_group.is_bias_connected = True
for block in bias_blocks:
block.groups = new_group_id
group.blocks.remove(block)
new_group.blocks.add(block)
if len(in_blocks) and len(in_blocks)< len(group.blocks):
new_group_id = group.group_id[:]
new_group_id.append(len(group.childs))
new_group = Group(new_group_id)
if new_group not in new_groups:
new_level = len(new_group_id)
new_groups.append(new_group)
new_group.parent = group
group.childs.append(new_group)
for block in in_blocks:
block.groups = new_group_id
group.blocks.remove(block)
new_group.blocks.add(block)
'''
if len(bias_blocks) < len(group.blocks) and len(bias_blocks):
new_group_id = group.parent.group_id[:]
new_group_id.append(len(group.parent.childs))
new_group = Group(new_group_id)
if new_group not in new_groups:
new_groups.append(new_group)
new_group.parent = group.parent
group.parent.childs.append(new_group)
new_group.is_bias_connected = True
for block in bias_blocks:
block.groups = new_group_id
group.blocks.remove(block)
new_group.blocks.add(block)
if len(in_blocks) and len(in_blocks)< len(group.blocks):
new_group_id = group.parent.group_id[:]
new_group_id.append(len(group.parent.childs))
new_group = Group(new_group_id)
if new_group not in new_groups:
new_groups.append(new_group)
new_group.parent = group.parent
group.parent.childs.append(new_group)
new_group.is_bias_connected = True
for block in in_blocks:
block.groups = new_group_id
group.blocks.remove(block)
new_group.blocks.add(block)
if new_level:
for group in forceOptimizer.groups:
if len(group.group_id) == new_level - 1:
if len(group.blocks):
new_group_id = group.group_id[:]
new_group_id.append(len(group.childs))
new_group = Group(new_group_id)
if new_group not in new_groups:
#.........这里部分代码省略.........