Simple framework for physical chip design (place & route) based on KLayout.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
1.4 KiB

<?xml version="1.0" encoding="utf-8"?>
<klayout-macro>
<description/>
<version/>
<category>pymacros</category>
<prolog/>
<epilog/>
<doc/>
<autorun>false</autorun>
<autorun-early>false</autorun-early>
<shortcut/>
<show-in-menu>false</show-in-menu>
<group-name/>
<menu-path/>
<interpreter>python</interpreter>
<dsl-interpreter-name/>
<text># === PLACEMENT ===
logger.info('Start global placement.')
# Get initial positions from the layout.
fixed_circuits = set()
fixed_circuits.update({n for n in fixed_positions})
initial_positions = dict()
for inst in design.top_cell.each_inst():
pos = inst.trans.disp
inst_id = inst.property('circuit_id')
initial_positions[inst_id] = (pos.x, pos.y)
is_fixed = inst.property('fixed')
if is_fixed:
fixed_circuits.add(inst_id)
#placer = QuadraticPlacer()
placer = QuadraticDensityPlacer(density_penalty=8000)
global_positions = placer.place(design.top_circuit,
design.core_area,
shapes=cell_shapes,
positions=fixed_positions, # Initial positions.
fixed_circuits=fixed_circuits)
# Update positions of the cells.
for inst_id, (x, y) in global_positions.items():
trans = db.Trans(int(x), int(y))
if inst_id in design.cell_instances_by_subcircuit_id:
design.cell_instances_by_subcircuit_id[inst_id].trans = trans
logger.info('Global placement done.')</text>
</klayout-macro>