Grt delete segments
Fixes #5254. A Secure CI run is associated with this PR
Segment Cover Pin Refactoring
Function GlobalRouter::segmentCoversPin() to check if a given segment covers a given pin. GlobalRouter::netIsCovered() was refactored to include this function and also raise an error if a given Net has no driver pin.
Net Graph Support and Delete Route
For this task it was pertinent to have segments of a net be represented as a graph assigning which connects to which. For this purpose a parent_segment_ vector was created. This models the net as a tree rooted on the net driver, the vector gives the parent of each segment in this tree. The root is its own parent. The indexing follows the same indexing found on the routes_[dbnet] vector. A function Net::getSegmentGraph() was added to return the graph formatted as a vector of vectors where graph[node] = {all nodes connected to it}. This function is not currently in use but might be useful in other tasks. A Net::deleteRoute() function was added that receives an index and a GRoute. It erases the element in the corresponding index from the GRoute and updated the parent_segment_ vector. The function GlobarlRouter::deleteSegment() was added to delete a segment from a net and also release the usage from the respective DCells.
Useless Segment Deletion
This is the main part of the task, all functions before are auxiliary to this part. In time complexity s is for number of segments, p for number of pins and d for deleted segments. The function GlobalRouter::shrinkNetRoute() was implemented to delete this segments. Following are the steps taken to do so:
Pin Coverage and root detection O(p*s)
Every pair of segment and pin is iterated through, given a complexity of O(p*s). Every segment is assigned a boolean value indicating whether it contains a pin. The segment containing the driver is assigned as the root.
Build Net Graph O(s²)
A function GlobalRouter::buildNetGraph() as implemented to build a graph of the segments. It iterates through every pair of segments checking if they connect. If so and edge in the graph is created. The time complexity is O(s²).
BFS to create a tree O(s)
With the graph a breadth first search is done to create a tree rooted in the driver representing the net. A vector containing the number of children a node has in the tree was also created. At the end of the process the Net parent_segments_ is set to the tree created.
Useless Routes Pruning O(s)
A set containing segments that will be deleted is created A queue with all the leafs is created and iterated though. if a leaf (no children) is marked as not covering a pin it is added to the segments for deletion. The number of children of its parent is decreased and if this turns it into a leaf the parent is added to the queue. At the end of the process every leaf of the tree will cover a pin
Deleting Useless Segments O(s*d)
Every element in the set is deleted from the Net. Since it is a vector deletion it costs O(n) for every element deleted, resulting in a O(s*d) time complexity.
UpdateDirtyNets Refactoring
Some oversights were found during debugging. The following changes were done to deal with corner cases:
- GlobalRouter::updateDirtyNets() will not call **GlobalRouter::shrinkNetRoutes()**for nets with less than 2 pins
- During pin reallocation checks, the layer is now considered, therefore grt::RoutePt is used during comparisons instead of odb::Point, this changed the way GlobalRouter::pinPositionsChanged() and GlobalRouter::newPinOnGrid() check for pin position.
Metrics update
Some metrics and tcl checks were updated to conform with the changes
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"