1 / 37

Applications Crossing Distribution

Applications Crossing Distribution. Problem: start with a routing channel with n pins on both the top and bottom of the channel. See next slide. n = 10. Routing region in slide is the shaded area. Also have a permutation C of the numbers [1,2,3,…, n ].

lali
Download Presentation

Applications Crossing Distribution

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ApplicationsCrossing Distribution • Problem: start with a routing channel with n pins on both the top and bottom of the channel. • See next slide. n = 10. • Routing region in slide is the shaded area. • Also have a permutation C of the numbers [1,2,3,…,n]. • Must connect pin i on top to pin Cion bottom • The n wires needed are numbered left to right, 1 through n. • Wire i connects top pin i to bottom pin Ci. Wire i is to the left of wire j iff i < j.

  2. ApplicationsCrossing Distribution • Crossings of wires are undesirable. Require insulators. • Crossings given by pair (i,j) where i and j are the two wires that cross. • To avoid duplicates, require that i < j. Note that (9,10) is same as (10,9). • Wires i and j cross iff Ci > Cj.

  3. ApplicationsCrossing Distribution • Let ki be the number of pairs (i, j), i < j such that wires i and j cross. • Recall that wire i is the wire that connects top pin i to bottom pin Ci. • In the example, k9 = 1, k10 = 0, and k6 = 0 (since no wires with top pin greater than 6 that crosses with wire with top pin 6). • See next figure.

  4. ApplicationsCrossing Distribution • Total crossings K found by adding all of the individual crossings ki. • This example: K = 22. • Since kicounts the crossings of wire i only with wires to its right, kigives the number of right-side crossings of wire i. • The crossing problem: want to balance the routing complexity in the top and lower halves of the channel. • Require that each half have approximately the same number of crossings, ie, top must have floor of K/2 crossings, bottom must have ceiling K/2.

  5. ApplicationsCrossing Distribution • Connections in top half given by permutation: A = [1,4,6,3,7,2,9,5,10,8] • Top pin i connects to center pin Ai. • Connections in bottom half given by: B = [8,1,2,7,3,4,5,6,9,10] • Center pin i is connected to bottom pin Bi.

  6. ApplicationsCrossing Distribution • Note that Ci = Bai • This equality is necessary to accomplish the connections given by Ci . • Now need algorithms to compute the permutations A and B so that the top half of the channel has floor K/2 crossings where K is the total number of crossings.

  7. Crossing DistributionAlgorithm crossingsNeeded = K/2 crossingList = ( ) While we need more crossings (in upper half): Scan pins from right, ie, look at pins n, n-1, n-2 etc. look at the current pin i’s k number, ki if crossingsNeeded - ki > 0 put i in the kith position in the list else let c = crossingsNeeded - ki put i in the c th position in the list end while Now add remaining wires (1,2,…) to the beginning of the list. These wires will not cross any other wires in the upper half.

  8. Crossing DistributionExample Each index into theX represents a pin in the bottom of the top channel. The entry in theX represents the top pin that will connect To the pin represented by the index. Example: (10, 9) means top pin 10 connects To middle pin 0 and top pin 9 connects to Middle pin 1. Upper pins are always in order, ie, 9 10 in the upper channel Current List Total Upper Crossings (theX) Crossings Needed (10) 0 11 (10,9) 1 10

  9. 9 10 0 1 Crossing Example Current List Total Upper Crossings (theX) Crossings Needed (10) 0 11 (10,9) 1 10 (8,10,9) 1 10 (8,10,7,9) 3 8

  10. Crossing Example Current List Total Upper Crossings (theX) Crossings Needed (8,10,7,9) 3 8 (6,8,10,7,9) 3 8 (6,8,5,10,7,9) 5 6 7 8 9 10 0 1 2 3 5 6 7 8 9 10 0 1 2 3 4 5

  11. Crossing Example Current List Total Upper Crossings (theX) Crossings Needed (6,4,8,5,10,7,9) 6 5 (6,4,8,3,5,10,7,9) 9 2 4 5 6 7 8 9 10 0 1 2 3 4 5 6 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7

  12. Crossing Example 2 has k2=6, but we only need 2 more Crossings, so enter 2 in index 2. Current List Total Upper Crossings (theX) Crossings Needed (6,4,2,8,3,5,10,7,9) 11 0 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8

  13. Crossing Example No more crossings needed, so add remaining indexes in order Current List Total Upper Crossings (theX) Crossings Needed (1,6,4,2,8,3,5,10,7,9) 11 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9

  14. Crossing Example • Now must convert theX to A A[theX[i]] = i theX =(1,6,4,2,8,3,5,10,7,9) A[theX[1]] = 1, A[1] = 1. So pin 1 on top connects to pin 1 in the middle of the channel. A[theX[2]] = 2, A[6] = 2. So pin 6 on top connects to pin 2 in the middle of the channel. A[theX[3]] = 3, A[4] = 3. So pin 4 on top connects to pin 3 in the middle of the channel.

  15. Crossing Example A[theX[i]] = I theX =(1,6,4,2,8,3,5,10,7,9) A[theX[4]] = 4, A[2] = 4. So pin 2 on top connects to pin 4 in the middle of the channel. A[theX[10]] = 10, A[9] = 10. So pin 9 on top connects to pin 10 in the middle of the channel. 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

  16. Crossing Example • Now must create the B array using theX array and the C array (which is given) B[i] = C[theX[i]]

  17. 6 7 8 9 10 10 9 10 0 1 2 3 4 0 0 1 5 6 7 8 9 10 0 1 2 3 4 5 Crossing DistributionAlgorithm Why does this algorithm work? putting a pin in the ith position makes it cross i other pins, but doesn’t affect pins already added: Crossing list = (6,8,10,7,9) Where k9 = 1 so crossingList = (10,9) Where k5 = 2 so Crossing list = (6,8,10,7,9)

  18. 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 Crossing DistributionAlgorithm In below example, k5 = 2. So wire 5 can cross up to 2 wires that are larger than it. putting 5 into position 2 of the crossing List will guarantee that it crosses exactly two wires (since two wires are connected to lower pins 0 and 1). smaller pins (like pins 1,2,3,4) that are added to the left of 5 in the list will not affect the k number of pin 5 since their wire number is less than 5 and k only counts wires j, j > 5. Where k5 = 2 so Crossing list = (6,8,10,7,9) Crossing list = (6,8,10,7,9)

  19. Crossing DistributionAlgorithm Why does this algorithm work? All wires not added to theX array will cross in the lower half of the channel.

  20. Crossing DistributionComplexity • Time needed to insert an element into a linear list: O(n) (or O(log n) expected time if use an indexed BST as a linear list) • So while loop takes O(n2) (or O(nlogn)). • Remainder of code takes O(n) • Time to compute theK and the k[i]s is O(n2)

  21. Indexed BSTComputing Crossing Numbers Examine pins in order n, n-1, … Put the value Ci into the BST when wire i is examined Use leftSize nodes that begin with value 1 for a leaf The value ki is the sum of leftSize values for every node that we traverse to the right child when placing wire i into the BST. leftSize Ci Pin number

  22. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 1 1 6 6 10 10 1 l0 9 • Add rightmost wire (10). k10=0, leftmost of a leaf = 1. Label node with C10=6. • Add wire 9. It’s C9=10, so node goes to right of node 6. Since go to the right of node 6, it crosses pin 10 (who represents node 6) so k9=1. Its leftSize = 1 since it’s a leaf.

  23. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 2 6 10 1 1 3 l0 8 9 Next insert wire 8. C8=3, so goes to the left of node 6. Leaf gets leftSize=1. k8=0 since it does not go to the right of any node.

  24. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 2 6 10 1 2 3 l0 8 9 1 9 7 Next insert wire 7. C7=9, so goes to the right of node 6 and then the left of node 10. Leaf gets leftSize=1. LeftSize of node 10 goes to 2. k7=2 since goes to right of node 6 who has leftsize = 2. Means that wire 7 has 2 wires that connect to pins to the left of its connecting pin (ie 2 pins greater than it that it crosses).

  25. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 3 6 10 2 2 3 l0 8 9 1 1 1 9 6 7 Next insert wire 6. C6=1, so goes to the left of node 6 and then the left of node 3. Leaf gets leftSize=1. LeftSize of node 6 goes to 3 and the leafsize of node 6 goes to 3. k6=0 since does not go to the right of any node.

  26. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 4 6 10 2 2 3 l0 8 9 1 1 1 1 5 9 6 7 5 Next insert wire 5. C5=5, so goes to the left of node 6 and then the right of node 3. Leaf gets leftSize=2 because it goes right of node 3. LeftSize of node 6 goes to 4. k5= 2 since goes to right of node 3.

  27. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 5 6 10 3 2 3 l0 8 9 1 1 1 1 5 9 6 7 5 1 2 4 Next insert wire 4. C4=2, so goes to the left of node 6, the left of node 3 and the right of node 1. Leaf gets leftSize=1. LeftSize of node 2 goes to 3, of node 6 to 5. k4=1 since went to right of node 1.

  28. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 6 6 10 3 2 3 l0 8 9 1 2 1 1 5 9 6 7 5 1 1 4 2 3 4 Next insert wire 3. C4=4, so goes to the left of node 6, the right of node 3 and the left of node 1. Leaf gets leftSize=1. LeftSize of node 6 goes to 6, of node 5 to 2. k3=3 since went to right of node 3.

  29. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 6 6 10 3 3 3 l0 8 9 1 2 2 1 5 9 6 7 5 1 1 1 4 7 2 3 2 4 Next insert wire 2. C2=7, so goes to the right of node 6, the left of node 10 and the left of node 9. Leaf gets leftSize=1. LeftSize of node 10 goes to 3, of node 9 to 2. k2=6 since went to right of node 6.

  30. Computing Crossing Numbers C=[8,7,4,2,5,1,9,3,10,6] 6 6 10 3 4 3 l0 8 9 1 2 3 1 5 9 6 7 5 1 1 1 4 1 7 2 3 2 1 4 8 Next insert wire 1. C1=8, so goes to the right of node 6, the left of node 10, the left of node 9 and the right of node 7. Leaf gets leftSize=1. LeftSize of node 10 goes to 4, of node 9 to 3. k1=7 since went to right of nodes 6 and 7.

  31. Computing Crossing Numbers Complexity • Time needed to examine wire i and compute ki is O(h) where h is the current height of tree. • All ki’s can be computed in O(nlog n) expected time • Previous algorithm to compute A using a iBST was O(nlog n). • To list elements in order of rank, do an inorder traversal. Takes O(nlog n).

More Related