__ses_xchg_cx()
authoryu.dongliang <18588496441@163.com>
Mon, 30 Oct 2023 11:01:55 +0000 (19:01 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 30 Oct 2023 11:01:55 +0000 (19:01 +0800)
ses_layout.c

index 291f0194acc47a7b8c9408937a45ef95372dc735..18490bcb6b2a959aa92a18cdff6bfc8a6148d2e0 100644 (file)
@@ -860,25 +860,30 @@ static void __ses_xchg_cx(ScfEfunction* f, int d)
 {
        ScfEcomponent* c0;
        ScfEcomponent* c1;
-       ScfEpin*       p0;
-       ScfEpin*       p1;
-       ScfEpin*       p2;
-       ScfEpin*       p3;
+       ScfEpin*       p;
 
        size_t i;
        size_t j;
+       size_t k;
 
        for (i = 0; i < f->n_components - 1; i++) {
                c0 =        f->components[i];
 
-               p0 =  c0->pins[0];
-               p1 =  c0->pins[1];
+               int y0 = INT_MAX;
+               int y1 = INT_MIN;
 
-               if (p0->y - p1->y <= d && p0->y - p1->y >= -d)
-                       continue;
+               for (k = 0; k < c0->n_pins; k++) {
+                       p  =        c0->pins[k];
+
+                       if (y0 > p->y)
+                               y0 = p->y;
 
-               int y0 = p0->y < p1->y ? p0->y : p1->y;
-               int y1 = p0->y < p1->y ? p1->y : p0->y;
+                       if (y1 < p->y)
+                               y1 = p->y;
+               }
+
+               if (y1 - y0 <= d)
+                       continue;
 
                for (j = i + 1; j < f->n_components; j++) {
                        c1 =            f->components[j];
@@ -886,20 +891,29 @@ static void __ses_xchg_cx(ScfEfunction* f, int d)
                        if ((c0->x < 0 && c1->x > 0) || (c0->x > 0 && c1->x < 0))
                                continue;
 
-                       p2 =  c1->pins[0];
-                       p3 =  c1->pins[1];
+                       int y2 = INT_MAX;
+                       int y3 = INT_MIN;
+
+                       for (k = 0; k < c1->n_pins; k++) {
+                               p  =        c1->pins[k];
 
-                       if (p2->y - p3->y <= d && p2->y - p3->y >= -d)
+                               if (y2 > p->y)
+                                       y2 = p->y;
+
+                               if (y3 < p->y)
+                                       y3 = p->y;
+                       }
+
+                       if (y3 - y2 <= d)
                                continue;
 
-                       int y2 = p2->y < p3->y ? p2->y : p3->y;
-                       int y3 = p2->y < p3->y ? p3->y : p2->y;
+                       if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) {
 
-                       if (y0 < y2 && y3 < y1) {
                                if ((c0->x < 0 && c0->x > c1->x) || (c0->x > 0 && c0->x < c1->x))
                                        __ses_xchg_cx2(c0, c1);
 
-                       } else if (y2 < y0 && y1 < y3) {
+                       } else if ((y2 <= y0 && y1 < y3) || (y2 < y0 && y1 <= y3)) {
+
                                if ((c0->x < 0 && c0->x < c1->x) || (c0->x > 0 && c0->x > c1->x))
                                        __ses_xchg_cx2(c0, c1);
                        }