gfn.gym.helpers.chip_design.utils¶
A collection of non-prod utility functions for placement.
All the dependencies in this files should be non-prod.
Attributes¶
Functions¶
|
|
|
Returns the RL cost and info. |
|
Create blockages using macro-to-boundary spacing constraints. |
|
Creates a placement_cost object. |
|
|
|
Parses the files' comments section, tries to extract the attribute. |
|
Reads blockage information from a given file. |
|
Parses the file's comments section, tries to extract canvas/grid sizes. |
|
A placement schedule that uses force directed method. |
|
Fix macro locations given a list of macro name regex strings. |
|
Find all ports and fix their coordinates. |
|
Returns list of blockages if they exist in the file's comments section. |
Returns all macros' orientations in a dict. |
|
|
Returns all node grid locations (macros and stdcells) in a dict. |
Returns the list of nodes (macros and stdcells) ordered by area. |
|
|
Returns number of each type of nodes in the netlist. |
Returns all node x,y coordinates (canvas) in a dict. |
|
|
Returns an ordering of node indices according to the specified mode. |
|
Yields node indices closest to the start_grid_index. |
|
Places the nodes to legal positions snapping to grid cells. |
|
|
|
Yields the index of a node of certain types. |
|
Coordinate descent over macro orientations. |
|
Places a node (legally) closest to the given location. |
|
Reads the node order from a file. |
|
|
|
|
|
Saves the node order to a file. |
|
Saves the placement file with some information in the comments section. |
Module Contents¶
- gfn.gym.helpers.chip_design.utils.COST_COMPONENTS = ['wirelength', 'congestion', 'density']¶
- gfn.gym.helpers.chip_design.utils.ORIENTATIONS = ['N', 'S', 'E', 'W', 'FN', 'FS', 'FE', 'FW']¶
- gfn.gym.helpers.chip_design.utils._proxy_cost(plc, wirelength_weight, density_weight, congestion_weight)¶
- Parameters:
wirelength_weight (float)
density_weight (float)
congestion_weight (float)
- Return type:
float
- gfn.gym.helpers.chip_design.utils.cost_info_function(plc, done, infeasible_state=False, wirelength_weight=1.0, density_weight=1.0, congestion_weight=0.5)¶
Returns the RL cost and info.
- Parameters:
done (bool)
infeasible_state (bool)
wirelength_weight (float)
density_weight (float)
congestion_weight (float)
- Return type:
tuple[float, dict[str, float]]
- gfn.gym.helpers.chip_design.utils.create_blockages_by_spacing_constraints(canvas_width, canvas_height, macro_boundary_x_spacing=0, macro_boundary_y_spacing=0, rectilinear_blockages=None)¶
Create blockages using macro-to-boundary spacing constraints.
- Parameters:
canvas_width (float)
canvas_height (float)
macro_boundary_x_spacing (float)
macro_boundary_y_spacing (float)
rectilinear_blockages (Optional[List[List[float]]])
- Return type:
List[List[float]]
- gfn.gym.helpers.chip_design.utils.create_placement_cost(netlist_file, init_placement, overlap_threshold=0.004, congestion_smooth_range=5, macro_macro_x_spacing=0.1, macro_macro_y_spacing=0.1, boundary_check=False, horizontal_routes_per_micron=70.33, vertical_routes_per_micron=74.51, macro_horizontal_routing_allocation=51.79, macro_vertical_routing_allocation=51.79, routes_per_congestion_grid=1000, blockages=None, fixed_macro_names_regex=None, legacy_congestion_grid=False, singularity_image=None)¶
Creates a placement_cost object.
- Parameters:
netlist_file (str)
init_placement (str)
overlap_threshold (float)
congestion_smooth_range (int)
macro_macro_x_spacing (float)
macro_macro_y_spacing (float)
boundary_check (bool)
horizontal_routes_per_micron (float)
vertical_routes_per_micron (float)
macro_horizontal_routing_allocation (float)
macro_vertical_routing_allocation (float)
routes_per_congestion_grid (int)
blockages (Optional[List[List[float]]])
fixed_macro_names_regex (Optional[List[str]])
legacy_congestion_grid (bool)
singularity_image (Optional[str])
- Return type:
- gfn.gym.helpers.chip_design.utils.disconnect_high_fanout_nets(plc, max_allowed_fanouts=500)¶
- Parameters:
max_allowed_fanouts (int)
- Return type:
None
- gfn.gym.helpers.chip_design.utils.extract_attribute_from_comments(attribute, filenames)¶
Parses the files’ comments section, tries to extract the attribute.
- Parameters:
attribute (str)
filenames (List[str])
- Return type:
Optional[str]
- gfn.gym.helpers.chip_design.utils.extract_blockages_from_file(filename, canvas_width, canvas_height)¶
Reads blockage information from a given file.
- Parameters:
filename (str)
canvas_width (float)
canvas_height (float)
- Return type:
Optional[List[List[float]]]
- gfn.gym.helpers.chip_design.utils.extract_sizes_from_comments(filenames)¶
Parses the file’s comments section, tries to extract canvas/grid sizes.
- Parameters:
filenames (List[str])
- Return type:
Tuple[Optional[float], Optional[float], Optional[int], Optional[int]]
- gfn.gym.helpers.chip_design.utils.fd_placement_schedule(plc, num_steps=(100, 100, 100), io_factor=1.0, move_distance_factors=(1.0, 1.0, 1.0), attract_factor=(100.0, 0.001, 1e-05), repel_factor=(0.0, 1000000.0, 10000000.0), use_current_loc=False, move_macros=False)¶
A placement schedule that uses force directed method.
- Parameters:
num_steps (Tuple[int, Ellipsis])
io_factor (float)
move_distance_factors (Tuple[float, Ellipsis])
attract_factor (Tuple[float, Ellipsis])
repel_factor (Tuple[float, Ellipsis])
use_current_loc (bool)
move_macros (bool)
- Return type:
None
- gfn.gym.helpers.chip_design.utils.fix_macros_by_regex(plc, macro_regex_str_list)¶
Fix macro locations given a list of macro name regex strings.
- Parameters:
macro_regex_str_list (List[str])
- gfn.gym.helpers.chip_design.utils.fix_port_coordinates(plc)¶
Find all ports and fix their coordinates.
- Parameters:
- Return type:
None
- gfn.gym.helpers.chip_design.utils.get_blockages_from_comments(filenames)¶
Returns list of blockages if they exist in the file’s comments section.
- Parameters:
filenames (Union[str, List[str]])
- Return type:
Optional[List[List[float]]]
- gfn.gym.helpers.chip_design.utils.get_macro_orientations(plc)¶
Returns all macros’ orientations in a dict.
- Parameters:
- Return type:
Dict[int, int]
- gfn.gym.helpers.chip_design.utils.get_node_locations(plc)¶
Returns all node grid locations (macros and stdcells) in a dict.
- Parameters:
- Return type:
Dict[int, int]
- gfn.gym.helpers.chip_design.utils.get_node_ordering_by_size(plc)¶
Returns the list of nodes (macros and stdcells) ordered by area.
- Parameters:
- Return type:
List[int]
- gfn.gym.helpers.chip_design.utils.get_node_type_counts(plc)¶
Returns number of each type of nodes in the netlist.
- Parameters:
- Return type:
Dict[str, int]
- gfn.gym.helpers.chip_design.utils.get_node_xy_coordinates(plc)¶
Returns all node x,y coordinates (canvas) in a dict.
- Parameters:
- Return type:
Dict[int, Tuple[float, float]]
- gfn.gym.helpers.chip_design.utils.get_ordered_node_indices(mode, plc, seed=111, node_order_file='', exclude_fixed_nodes=True)¶
Returns an ordering of node indices according to the specified mode.
- Parameters:
mode (str)
seed (int)
node_order_file (str)
exclude_fixed_nodes (bool)
- Return type:
List[int]
- gfn.gym.helpers.chip_design.utils.grid_locations_near(plc, start_grid_index)¶
Yields node indices closest to the start_grid_index.
- Parameters:
start_grid_index (int)
- Return type:
Iterator[int]
- gfn.gym.helpers.chip_design.utils.legalize_placement(plc)¶
Places the nodes to legal positions snapping to grid cells.
- Parameters:
- Return type:
bool
- gfn.gym.helpers.chip_design.utils.make_blockage_text(plc)¶
- Parameters:
- Return type:
str
- gfn.gym.helpers.chip_design.utils.nodes_of_types(plc, type_list)¶
Yields the index of a node of certain types.
- Parameters:
type_list (List[str])
- Return type:
Iterator[int]
- gfn.gym.helpers.chip_design.utils.optimize_orientations(plc, wirelength_weight=1.0, density_weight=1.0, congestion_weight=0.5, max_iterations=2)¶
Coordinate descent over macro orientations.
For each macro, tries all 8 orientations and greedily picks the one that minimizes the proxy cost. Repeats for
max_iterationssweeps (convergence is typically reached in 1-2).- Parameters:
wirelength_weight (float)
density_weight (float)
congestion_weight (float)
max_iterations (int)
- Return type:
None
- gfn.gym.helpers.chip_design.utils.place_near(plc, node_index, location)¶
Places a node (legally) closest to the given location.
- Parameters:
node_index (int)
location (int)
- Return type:
bool
- gfn.gym.helpers.chip_design.utils.read_node_order_file(plc, node_order_file)¶
Reads the node order from a file.
- Parameters:
node_order_file (str)
- Return type:
List[int]
- gfn.gym.helpers.chip_design.utils.restore_macro_orientations(plc, macro_orientations)¶
- Parameters:
macro_orientations (Dict[int, int])
- Return type:
None
- gfn.gym.helpers.chip_design.utils.restore_node_xy_coordinates(plc, node_coords)¶
- Parameters:
node_coords (Dict[int, Tuple[float, float]])
- Return type:
None
- gfn.gym.helpers.chip_design.utils.save_node_order_file(plc, node_order, node_order_file)¶
Saves the node order to a file.
- Parameters:
node_order (List[int])
node_order_file (str)
- Return type:
None
- gfn.gym.helpers.chip_design.utils.save_placement(plc, filename, user_comments='')¶
Saves the placement file with some information in the comments section.
- Parameters:
filename (str)
user_comments (str)
- Return type:
None