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.

66 lines
1.8 KiB

<?xml version="1.0" encoding="utf-8"?>
<text># === LEGALIZATION ===
Legalization (or detail-placement) converts the rough global placement solution into a
legal placement solution. A legal placement must have no overlaps and cells must be properly
aligned to the rows.
from kpnr.legalizer.tetris import TetrisLegalizer
from kpnr.legalizer.densefirst import DenseFirstLegalizer
from kpnr.legalizer.annealing_legalizer import AnnealingLegalizer
importlib.reload(kpnr.legalizer.densefirst)'Start legalization.')
# 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 ='circuit_id')
if inst_id:
initial_positions[inst_id] = (pos.x, pos.y)
is_fixed ='fixed')
if is_fixed:
legalizer = DenseFirstLegalizer(row_height=row_height, x_grid_pitch=x_grid_pitch)
# Convert global placement result into legal placements.
cell_transf = legalizer.legalize(
# Update positions of the cells.
for inst_id, trans in cell_transf.items():
if inst_id in design.cell_instances_by_subcircuit_id:
design.cell_instances_by_subcircuit_id[inst_id].trans = trans
logger.warning('Cell not found: {}'.format(inst_id))'Legalization done.')</text>