Skip to content

Commit

Permalink
Set blockage rate for clock straps to 0.99 to distinguish it from rec…
Browse files Browse the repository at this point in the history
…tilinear blockages.

Adding macro to boundary spacing blockages to outside of the rectilinear blockages.

PiperOrigin-RevId: 651107644
Change-Id: I466ad579fa6efa61e0f37f8fde4369e799cac793
  • Loading branch information
esonghori authored and copybara-github committed Jul 10, 2024
1 parent f1f88a1 commit ff17281
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 11 deletions.
56 changes: 47 additions & 9 deletions circuit_training/environment/placement_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def extract_attribute_from_comments(


def get_blockages_from_comments(
filenames: Union[str, List[str]]
filenames: Union[str, List[str]],
) -> Optional[List[List[float]]]:
"""Returns list of blockages if they exist in the file's comments section."""
for filename in filenames:
Expand Down Expand Up @@ -233,8 +233,8 @@ def create_placement_cost(
blockages: List of blockages.
fixed_macro_names_regex: A list of macro names regex that should be fixed in
the placement.
legacy_congestion_grid: If set, use the placement grid size for
congestion grid.
legacy_congestion_grid: If set, use the placement grid size for congestion
grid.
Returns:
A PlacementCost object.
Expand Down Expand Up @@ -572,8 +572,9 @@ def extract_blockages_from_file(
raise ValueError(
f'Illegal blockage ury {ury} > canvas height {canvas_height}'
)
# Set 1.0 blockage rate so no macros or stdcells are allowed.
blockages.append([llx, lly, urx, ury, 1.0])
# Set 0.99 blockage rate so no macros or stdcells are allowed.
# 1.0 is reserved for rectilinear blockages.
blockages.append([llx, lly, urx, ury, 0.99])
except IOError:
logging.error('Could not read file %s', filename)
return blockages
Expand Down Expand Up @@ -734,18 +735,19 @@ def create_blockages_by_spacing_constraints(
canvas_height: float,
macro_boundary_x_spacing: float = 0,
macro_boundary_y_spacing: float = 0,
rectilinear_blockages: Optional[List[List[float]]] = None,
) -> List[List[float]]:
"""Create blockages using macro-to-boundary spacing constraints."""
blockages = []
# Not macro overlap but allow stedcells to be placed within.
blockage_rate = 0.1
if macro_boundary_x_spacing:
assert 0 < macro_boundary_x_spacing <= canvas_width
# Left horizontal
# Left vertical
blockages.append(
[0, 0, macro_boundary_x_spacing, canvas_height, blockage_rate]
)
# Right horizontal
# Right vertical
blockages.append([
canvas_width - macro_boundary_x_spacing,
0,
Expand All @@ -755,16 +757,52 @@ def create_blockages_by_spacing_constraints(
])
if macro_boundary_y_spacing:
assert 0 < macro_boundary_y_spacing <= canvas_height
# Bottom vertical
# Bottom horizontal
blockages.append(
[0, 0, canvas_width, macro_boundary_y_spacing, blockage_rate]
)
# Top vertical
# Top horizontal
blockages.append([
0,
canvas_height - macro_boundary_y_spacing,
canvas_width,
canvas_height,
blockage_rate,
])
for rectilinear_blockage in rectilinear_blockages or []:
minx, miny, maxx, maxy, _ = rectilinear_blockage
if macro_boundary_x_spacing:
# Left Vertical
blockages.append([
max(minx - macro_boundary_x_spacing, 0),
max(miny - macro_boundary_y_spacing, 0),
minx,
min(maxy + macro_boundary_y_spacing, canvas_height),
blockage_rate,
])
# Right Vertical
blockages.append([
maxx,
max(miny - macro_boundary_y_spacing, 0),
min(maxx + macro_boundary_x_spacing, canvas_width),
min(maxy + macro_boundary_y_spacing, canvas_height),
blockage_rate,
])
if macro_boundary_y_spacing:
# Bottom horizental
blockages.append([
max(minx - macro_boundary_x_spacing, 0),
max(miny - macro_boundary_y_spacing, 0),
min(maxx + macro_boundary_x_spacing, canvas_width),
miny,
blockage_rate,
])
# Top horizental
blockages.append([
max(minx - macro_boundary_x_spacing, 0),
maxy,
min(maxx + macro_boundary_x_spacing, canvas_width),
min(maxy + macro_boundary_y_spacing, canvas_height),
blockage_rate,
])
return blockages
15 changes: 15 additions & 0 deletions circuit_training/environment/placement_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,21 @@ def test_blockage_with_spacing_constraints(self):
]
self.assertEqual(blockages, expected_blockages)

blockages = placement_util.create_blockages_by_spacing_constraints(
10, 20, 1, 2, [(0, 0, 3, 3, 1.0)]
)
expected_blockages = [
[0, 0, 1, 20, 0.1],
[9, 0, 10, 20, 0.1],
[0, 0, 10, 2, 0.1],
[0, 18, 10, 20, 0.1],
[0, 0, 0, 5, 0.1],
[3, 0, 4, 5, 0.1],
[0, 0, 4, 0, 0.1],
[0, 3, 4, 5, 0.1],
]
self.assertEqual(blockages, expected_blockages)


if __name__ == '__main__':
test_utils.main()
11 changes: 9 additions & 2 deletions circuit_training/grouping/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ def add_blockage(
"""
blockage_file = FLAGS.blockage_file

w, h = plc.get_canvas_width_height()
if blockage_file:
w, h = plc.get_canvas_width_height()
blockages = placement_util.extract_blockages_from_file(blockage_file, w, h)
for blockage in blockages:
logging.info('Blockage: %s', blockage)
Expand All @@ -456,8 +456,15 @@ def add_blockage(
macro_boundary_x_spacing = FLAGS.macro_boundary_x_spacing
macro_boundary_y_spacing = FLAGS.macro_boundary_y_spacing
if macro_boundary_x_spacing or macro_boundary_y_spacing:
rectilinear_blockages = [
blockage for blockage in plc.get_blockages() if blockage[4] >= 1.0
]
blockages = placement_util.create_blockages_by_spacing_constraints(
w, h, macro_boundary_x_spacing, macro_boundary_y_spacing
w,
h,
macro_boundary_x_spacing,
macro_boundary_y_spacing,
rectilinear_blockages,
)
for blockage in blockages:
logging.info('Macro-to-boundary spacing blockage: %s', blockage)
Expand Down

0 comments on commit ff17281

Please sign in to comment.