Connectivity Verification in VLSI Layout Shmuel Wimer Bar Ilan Univ., School of Engineering May 2012 1 Outline • Modeling connectivity • Finding connected components in graphs – Directed graphs by DFS – Non directed graphs by UNION_FIND • Intersection of rectangles – Interval Tree – Priority search tree • Intersection of non rectilinear shapes May 2012 2 Modeling Physical Connectivity Vcc Xn Vcc OUT Xn N-diff OUT May 2012 metal1 P-diff via1 poly metal2 contact 3 Vcc Xn Vcc OUT Xn Polygon in layout and its corresponding graph vertex are labeled with net name. A short occurs when two polygons of different nets are physically connected, hence connected component has more than one label. May 2012 4 Vcc Xn OUT OUT An open occurs when a polygon is missing from layout, hence several connected component have same label. Algorithm for physical connectivity check will: 1. First construct G(V,E) by reporting pair-wise polygon intersections. 2. Then find connected components and check labeling consistency May 2012 5 • Layout polygons are labeled with net name • A connectivity graph G(V,E) is defined where vertices correspond to layout polygons. • An arc e(u,v) in E is defined for vertex pair whose corresponding polygons are intersecting and physically connected by process technology. • Consequently, every net has corresponding connected component in G(V,E), labeled uniquely by net name. • A short occurs when a connected component has more than one label. • An open occurs when two or more connected components have same label. May 2012 6 Intersection of Rectangles Given two intervals I y1, y2 and I y1, y2 , I I iff one of the following mutually exclusive conditions is satisfied: y1 y1 y2 or y1 y1 y2. Given two rectangles R x1, x2 y1, y2 and R x1, x2 y1, y2 , R R , iff x1, x2 x1, x2 and y1, y2 y1, y2 . Problem : Given a set of n isothetic rectangles Ri i 1 , report all n their pairwise intersections. May 2012 7 y1 y1 y2 y1 y1 y2 y2 y1 Solution is implemented by scan-line algiorithm. Thecondition x1, x2 x1, x2 is satisfied by definition for all rectangles currently intersected by scan-line (active rectangles). y1, y2 y1, y2 can be checked by data structures called Interval Tree or Priority Search Tree. May 2012 8 Interval Tree Introduced by McCreight 1981, Edelsbrunner 1980. We study a static version, although dynamic version is possible. Given rectangles Ri i 1 , I bi , ei i 1 are the bottom and n n top ordinates of Ri . y1 , y2 , , y2 n are the sorted ordinates. The interval tree T has a primary skeletal structure defined staticaly in memory for y1 , y2 , , y2 n , handling the set I of Ri i 1 vertical edges. n May 2012 9 T is dynamically storing a subset I active x I , called active subset. I active x is defined by scan-line position in ordinary manaer, by those of Ri i 1 it intersects at abscissa x. n w yn yn1 2 LLIST w RLIST w 5 1 2 5 3 1 4 2 May 2012 4 3 10 The root w of T has a discriminator w yn yn 1 2 and two dynamic secondary lists LLIST w and RLIST w . LLIST w stores lower ends of those I active intervals containing w , sorted in ascending order. RLIST w stores upper ends of those I active intervals containing w , sorted in descending order. Left sub-tree of w rooted at LSON w is an interval tree of y1 , y2 , left , yn and I active I I active | e I w , left are intervals I active I active whose right end fall left to w. May 2012 11 Right sub-tree of w rooted at RSON w is an interval tree of yn 1 , yn 2 , right , y2 n and I active I I active | b I w , right are intervals I active I active whose left end fall right to w. v T is calassified as active if LLIST v (and hence RLIST v ) or trees rooted at LSON v and RSON v both contain active nodes. Otherwise v is inactive. May 2012 12 I 0, 2 , 1,3 , 2,3 , 4, 7 , 5,13 , 6,9 , 8,10 , 11,12 y1 , y2 , , y13 0,1, 2,3, 4,5, 6, 7,8,9,10,11,12,13 7 8 2 7.5 3.5 11.5 5 1.5 6 9 13 5.5 9.5 11 12 0 1 2 3 8 10 4 7 0 May 2012 1 2 3 4 5 6 7 8 9 10 12 13 11 13 Properties of Interval Tree T is balanced binary tree. Its leaves are the ordered sequence y1 , y2 , , y2n . The lists LLIST v and RLIST v associated with an internal node v T must support effective insertion and deletion, hence realized by balanced binary tree. The active nodes of T are connected in a binary tree T imposed on T as a super structure. Thus, a primary node v T has two pointers LPTR v and LPTR v . If v is inactive LPTR v and RPTR v . LPTR v if the sub-tree rooted at LSON v has an active node. Similarly, RPTR v if the sub-tree rooted at RSON v has an active node. May 2012 14 7 8 2 7.5 3.5 11.5 5 1.5 6 9 13 5.5 9.5 11 12 0 1 2 3 8 10 4 7 0 May 2012 1 2 3 4 5 6 7 8 9 10 12 13 11 15 7 8 2 7.5 3.5 11.5 5 1.5 6 9 13 5.5 9.5 11 12 0 1 2 3 8 10 0 1 2 3 4 5 6 7 8 9 10 12 13 11 By definition of active nodes, all leaves of T have non-empty lists. It stems from T being binary tree that at least half of its nodes have non-empty lists. May 2012 16 Insertion and Deletion in Interval Tree Both T and all LLIST and RLIST are binary trees of depth O log 2 n . Insertion of interval b, e starts at root and traverses LSON or RSON nodes until first v* T satisfying b v* e is found. A path PIN is thus defined. May 2012 17 The lower ordinate b of b, e is inserted into LLIST v* and the upper ordinate e of b, e is inserted into RLIST v* . If v* was active T is unchanged. If it was inactive then by going upward to first active node, with constant work at node, T can be updated appropriately. Two paths PL and PR are issued from v* , ending at leaves b and e, respectively. May 2012 18 Intersections Report Intersection reports can occur with intervals allocated to nodes along PIN and intervals allocated to nodes in the sub-tree rooted at v* and bounded between PL and PR . For v PIN either e v or b v . Let e v . b, e may intersect with intervals of b , e . Since LLIST v is ascending sorted, starting at i i i b1 LLIST v intersection is reported as long as bi e. Traversal stops at first time bi e. Total work is linear in number of intersections. b v is v similar. bi b May 2012 ei e 19 Let v PL (similarly v PR ). There exist two cases. If v b, b, e may intersect with intervals of b , e . Since RLIST v is descending sorted, i i i starting at e1 RLIST v , intersection is reported as long as b ei . Traversal stops at first time b ei . Total work is linear in number of intersections. v ei bi e b Let b v. v bi b May 2012 ei e 20 b, e intersects with all intervals of LLIST v since all share v (and with RLIST v ). Intersections report is obtained by lists traversal without overhead. Consider now any right sub-tree along PL (terminating at a leaf b). Since such sub-trees are contained in left sub-tree of v* , there exists b v v* e. Hence, all intervals allocated to right sub-trees along PL must be reported. This is done efficiently by traversing only nodes of T , at least half nodes of it have non-empty lists. Consequrntly, amount of time is linear in report size. Deletion of b, e finds first v* same as insertion did and deletes b, e from LLIST v* and RLIST v* . Intersections reports are not required since insertion did it already. Update of T is in order. May 2012 21 Performance of Algorithm Storage is O n since there are 2n end points of intervals and 4n 1 nodes in T , and 2n end points at most are simultaneously stored in LLISTand RLIST . Construction of T takes O n log 2 n time at least since sorting of the 2n end points is required. May 2012 22 Intervals are inserted or deleted in time O log 2 n , including treatment of LLIST and RLIST and the maintenance of active nodes connected in T . PL and PR traversal takes O log 2 n . Less than half of visited nodes for intersection report with LLIST and RLIST are empty, and intersections of intervals are reported from LLIST and RLIST with no overhead. May 2012 23 Theorem : Given n isothetic rectangles having s intersecting pairs, interval tree algorithm reportes intersections in O n log 2 n s time, O n log 2 n pre processing time and space n . Question : Is it possible to perform better than O s n log 2 n ? Evidently, O s is mandatory (cannot perform better than report size). So can we do better than O n log 2 n ? May 2012 24 Given a set z1 , z2 , , zn R , the problem called ELEMENT_UNIQENESS is aiming at answering whether the set has two identical elements. n log 2 n is a lower bound of it. Define n rectangles Ri a, b zi , zi , and apply intersection report algorithm, which now will solve the ELEMENT_UNIQENESS problem. Consequently, no faster algorithm is possible, and interval intersection runs in n log 2 n s . May 2012 25 Priority Search Tree • Introduced by McCreight 1981 / 1985. • Transform reporting rectangle intersections into point inclusion problem. • Paradigm is scan-line, abscissa of vertical edges are sorted in ascending order {x1, x2,…, x2n}. • Vertical edges [y1, y2] are associated with opening and closing rectangle property. May 2012 26 y2 Intersection occurs if y1 y2 and y1 y2 . y2 y1 y1 Unlike Interval Tree where intersection conditions were checked explicitely, intersection problem is transformed into a point containment problem as follows. May 2012 27 Every living rectangle (i.e., it is already opened and exists in memory) is transformed into a point in 2D plane y1, y2 p, q R 2 . A newly inserted left edge y1, y2 is transformed into infinite quadrant of 2D plane, Q p, q R 2 p y2, y1 q . q New rectangle y1, y2 y1, y2 intersects with a living rectangle y1, y2 iff y2, y1 p May 2012 y1, y2 Q. 28 Priority Search Tree T is a data structure supporting queries of point containment very efficiently. T maintains p coordinates as a search tree and it is a heap for maintaining q coordinates. p coordinate must be unique for rectangles in order to maintain consistent insertion and deletion. This can be done by attaching to p the identifier (e.g., memory pointer) of its originating rectangle. q The pair p* , q* with maximal p ,q * * q is attached to the root of T . p range is then divided by a p May 2012 vertical line p const. 29 The above steps are applied recursively for the resulting left and right p sub ranges. Resulting trees are attached to LSON and RSON nodes of root T . Question : How to decide on the vertical line p const? If p* , q* is used, a data structure maned Cartesian Tree results in. It has good average performance but can be a linear list in worst case. May 2012 30 Since the entire data is known apriori, the range of p pmin , pmax is known too. Since all the values of p are distinct, bisection at median is possible. For n p, q pairs the depth of T is O log 2 n . O n successive bisections result in a stripe in q having one unit width in p. May 2012 31 m f o e a i d b j h n k g c p l A priority search tree is a heap in q and a radix search tree in p. m f a q o i d b n p e k h c j p g May 2012 l 32 Implementing Priority Search Tree As other scan-line algorithms, vertical edges are first sorted in ascending order of abscissa. Abutments are considered as intersection and therefore opening edges preceed closing ones having same abscissa. Along scan-line progression a vertical edge b, e in xy e (p,q)=(b,e) plane is translated into a point p, q in pq plane. b Denote by pE , qE = b, e the key coresponding to a currently inserted edge E b, e and by pv , qv the key of an edge stored in a node v T (recall that p is unique). May 2012 33 A node v T stores a range B v , E v of p values in pq plane. It has two sub trees rooted at LSON v and RSON v . We'll present a code for edge insertion. Deletion is more complicated and discussed briefly. See details in E. M. McCreight,"Priority search trees", SIAM J. Comput.,Vol. 14, pp. 257 - 276, 1985. Unlike segment and interval trees which are static, priority search tree is dynmic, storing only currently opened rectangles. This is an advantage for typical VLSI data (why?). Most of VLSI layout objects are relatively very small compared to chip / block size. It means that at each insertion or deletion of an edge, O are opened, consuming O May 2012 n rectangles n storage. 34 void INSERT (key pE , qE , int b, int e, node v) { while ( v ) { // heap maintenance if (qE qv ) { pE , qE v ; pv , qv pE , qE ; } m b e 2; // radix bisection if (pE m) { e m ; v LSON v ; } // left search else { b m ; v RSON v ; } // right search } allocate son node u to v ; pE , qE v ; // leaf reached LSON u RSON u ; } May 2012 35 Deletion operates in two phases. In the first finds in T the key p, q of the deleted edge by ordinary search of a radix search tree. p is compared with m b e 2. If p pv search takes left to LSON v and if p pv search takes right to RSON v . If p pv then p, q is found. A second phase starts at the node where p, q was found. "Knock out tournament" starts, at which two sons compete on the vacant key at their parent. The key of son having larger q wins. Competition proceeds with the position of the victor son, Tournament stops when a node with less than two sons is reached. This maintains the heap property of T . (Only lowest internal nodes may have single son.) May 2012 36 Reporting Intersections Report takes place prior to edge insertion. If E b, e is the edge aimed at insertion, an infinite quadrant is defined as follows: e ( p , q ) = ( e , b) b By definition, all the rectangles corresponding to nodes whose p, q keys are contained in the quadrant are intersecting with the rectangle of edge E. Exploration of these points is done by first checking whether qv qE . If test fails, it follows from heap property of T that entire subtree can be discarded (qv qE for all its nodes). May 2012 37 For a node v satisfying qv qE , a radix search in the subtree rooted at v takes place, aiming at finding all points satisfying pv , pE . Given an edge E : b, e , define pr pE ( e), pl min1i n bi and q qE ( b). void REPORT(int pl , int pr , int q, node v) { if (q qv ) { // check heap propery if (pv pl , pr ) { report intersection } m pl pr 2 ; // apply radix search if ((m pr ) and ( RSON v )) { REPORT(m, pr , q, RSON v ) } if (LSON v ) { REPORT(pl , m, q, LSON v ) } } } May 2012 38 Lemma : REPORT( pl , pr , q, root T ) correctly reports all points in quadrant , pr q, in O log 2 n k time, where k is report size. Proof : A reported point is correst. REPORT first verifies qv q, , as otherwise it returns. Satisfaction of pv , pr is also explicitely checked before reporting. Conversely, if pv , qv , pr q, it must first be approached by (q qv ) query in REPORT which implements a search in a heap, hence finding all nodes satisfying the (q qv ) query. Then the query pv , pr must be positively answered. May 2012 39 T is a heap in q and binary search tree in p, whose depth is bounded by O log 2 n . REPORT implements a radix search in , pr . Without (q qv ) query, this was an ordinary search of O log 2 n k p , where k p is the number of nodes satisfying pv , pr . (q qv ) query prevents overheads of quering wrong nodes, yielding O log 2 n k time. Q.E.D Theorem : A priority search tree for a set of n points uses O n storage and can be built in O n log 2 n time. Reporting of all points in quadrant , pr q, takes O log 2 n k time, where k is report size. May 2012 40 void FIND_ALL_INTERSECTIONS (rectangles Ri i 1 ) { n sort vertical edges of retngles in ascending order x1 , x2 , , x2 n ; set pl min1i n bi ; initialize root of priority search tree T ; for (i 1 ; i 2n ; i ) { if ( xi is openning ) { // report intersections only for openning edge REPORT_INTERSECTION (pl , ei , bi , root T ) ; INSERT ( bi , ei , bi , ei , root T ) ; } else { DELETE (bi , ei , root T ) ; } // closing edge } } May 2012 41 Layout Connectivity Graph • Geometric intersection algorithms detected pair-wise physical connectivity of polygons (labeled by net name), yielding a connectivity graph G(V,E). – V: polygons – E: physical connections • Connected components (CC) of G(V,E) represent parts of layout having same electric potential. – Short occurs when CC has more than one label – Open occurs when multiple CCs have same label May 2012 42 Disjoint Sets and Connected Components Invariants of connected component algorithm is a collection of S S1 , S2 , , Sk of dynamic sets, S k i 1 Si , Si i j S j , Every set is represented (identified) by one of its objects. S is supplamented by operations defined for every x S . MAKE_SET x creates a set of single element x. UNION x, y applies S x S y . The new set is represented by an element of either S x or S y , which are then destroyed from S . FIND_SET x returns a pointer to Sx where x belongs to. May 2012 43 What is the maximal number of UNION operations? We measure performance by n, the number of MAKE_SET operations and m, the total number of MAKE_SET, UNION and FIND_SET. void CONNECTED_COMPONENTS(graph G V , E ) { foreach (v V ) { MAKE_SET(v) } foreach (e u, v E ) { if (FIND_SET(v) FIND_SET(u )) { UNION(u, v) } } } May 2012 44 Linked-List Data Structure of Disjoint Sets a b c d a b c f g UNION ( c , f ) e f g What is run-time complexity ? MAKE_SET is O(1) FIND_SET is O(1) What about UNION ? May 2012 45 x1 x2 Xn-1 x3 xn Let CONNECTED_COMPONENT do the following sequence MAKE_SET(X1) MAKE_SET(Xn) UNION(X1,X2) UNION(Xn-1,Xn) n 2 n 2 n Average time per operation is θ(n) Question: How to improve run-time ? May 2012 46 Time is consumed in UNION for updating the pointers to set’s representative Use weighted-UNION heuristics • maintain size of set • Always merge smaller set to larger one Theorem: Given G(V,E) with |V|=n and |E|=m, finding connected components by weighted-UNION heuristics takes O(m+nlog2n) time. Proof: Pointer of vertex to the representative of its set may change log2n times at most ! Therefore, the time consumed by UNION is O(nlog2n). There are O(m) operations of MAKE_SET and FIND_SET. Q.E.D May 2012 47 Disjoint-Set Forests Sets are represented by rooted trees instead of linked lists. e e a f a b d f b c UNION ( c , f ) d g g c This by itself doesn’t improve run-time. A sequence of n-1 UNION operations may result a tree that is just a linear list. Two heuristics improve performance significantly: Union by Rank and Path Compression. May 2012 48 Similar to weighted UNION heuristics. Make the root of the deeper tree the root of the new tree (hang the shallower tree on the root of the deeper one). It requires to maintain the depth of the tree, called rank, at the root. Rank approximates the log2 of tree size. Path compression: Implemented as a part of FIND_SET. It consumes time proportional to the distance from root. It maintains set trees as shallow as possible. e FIND_SET ( b ) d b c b a May 2012 e c d a 49 Disjoint-Set Forests Implementation Associate with every node x an integer rank x , which is the longets path (edge count) to leaf in subtree rooted at x. parent x points to parent node. void MAKE_SET(node x) { parent x x ; rank x 0 ; } void UNION(node x, node y ) { LINK(FIND_SET(x) , FIND_SET(y)) } May 2012 50 Disjoint-Set Forests Implementation void LINK(node x, node y , ) { // x and y are roots, hence only their rank may change if (rank x rank y ) { parent y =x; } else { parent x =y ; if (rank x rank y ) { ++rank y } } } May 2012 51 node FIND_SET(node x) { // Check whether x is the root. If so, return it. // Otherise, it is connected directly to tree // representative (root), thus implementing path // compression. if (x parent x ) { parent x FIND_SET(parent x ); } return parent x ; } May 2012 52 FIND_SET is a two-pass process. It first goes upward to root along find path to find set representative. It then goes downward (exit of recursion) and connects to root each node along the path. Run time is almost linear in m. For proof see: Introduction to Algorithms, T.H. Cormen, C.H. Leiserson and R.L. Rivest. May 2012 53 Implementation Comments • Connectivity graph edges are not required explicitly. Instead, connected component finding algorithm is invoked into the various intersection report algorithms. May 2012 54