Esempio n. 1
0
def legalize_floorplan(
    curr_v2s: Dict[Vertex, Slot],
    slot_manager: SlotManager,
    grouping_constraints: List[List[Vertex]],
    pre_assignments: Dict[Vertex, Slot],
    partition_order: List[Dir],
    init_usage_ratio: float = 0.7,
    limit_increase_step: float = 0.01,
    max_usage_ratio: float = 0.85,
) -> Optional[Dict[Vertex, Slot]]:
    """
  the iterative partitioning process may result in some slots being overused
  Re-assign some of the Vertices from the overused slots to the under-used slots
  """
    # if a slot is empty, it is not included in v2s
    all_leaf_slots = slot_manager.getLeafSlotsAfterPartition(partition_order)

    curr_limit = init_usage_ratio
    while 1:
        if curr_limit > max_usage_ratio:
            _logger.info(
                f'Fail to legalize under the cut threhold {max_usage_ratio}')
            return {}

        new_v2s = get_legalized_v2s(curr_v2s, grouping_constraints,
                                    all_leaf_slots, pre_assignments,
                                    curr_limit)
        if new_v2s:
            _logger.info(
                f'Legalization succeeded with target usage limit {curr_limit}')
            return new_v2s
        else:
            curr_limit += limit_increase_step
Esempio n. 2
0
def _get_slot_by_idx_closure(
  slot_manager: SlotManager
) -> Callable[[int, int, int], Slot]:
  # slot_group = [slot_000, slot_001, \
  #               slot_010, slot_011, \
  #               slot_100, slot_101, \
  #               slot_110, slot_111 ]

  # must not change order!
  partition_order = [Dir.horizontal, Dir.horizontal, Dir.vertical]
  all_leaf_slots = slot_manager.getLeafSlotsAfterPartition(partition_order)
  slr_slots = slot_manager.getLeafSlotsAfterPartition([Dir.horizontal, Dir.horizontal])

  # include both whole-slr slots and half-slr slots
  def func_get_slot_by_idx(y1, y2, x):
    if x != -1:
      idx = y1 * 4 + y2 * 2 + x
      return all_leaf_slots[idx]
    else:
      idx = y1 * 2 + y2
      return slr_slots[idx]

  return func_get_slot_by_idx
Esempio n. 3
0
def _get_slot_by_idx_closure(
        slot_manager: SlotManager) -> Callable[[int, int], Slot]:
    # slot_group = [slot_00, slot_01, \
    #               slot_10, slot_11, \

    # must not change order!
    partition_order = [Dir.horizontal, Dir.horizontal]
    all_leaf_slots = slot_manager.getLeafSlotsAfterPartition(partition_order)

    def func_get_slot_by_idx(y1, y2):
        idx = y1 * 2 + y2
        return all_leaf_slots[idx]

    return func_get_slot_by_idx
Esempio n. 4
0
def get_four_way_partition_slots(slot_manager: SlotManager) -> List[Slot]:
    """ get all the eight slots after eight-way partition
  """
    partition_order = [Dir.horizontal, Dir.horizontal]
    return slot_manager.getLeafSlotsAfterPartition(partition_order)