elines-> x1
authoryu.dongliang <18588496441@163.com>
Sun, 16 Jul 2023 07:46:53 +0000 (15:46 +0800)
committeryu.dongliang <18588496441@163.com>
Sun, 16 Jul 2023 07:46:53 +0000 (15:46 +0800)
ses_layout.c

index b4853bbde52b68b12db453fad12062b2f2a57d91..7943aec4ad10463744f463e92c97b36243aff7db 100644 (file)
@@ -38,17 +38,7 @@ int eline_cmp(const void* v0, const void* v1)
 {
        const ScfEline* el0 = *(const ScfEline**)v0;
        const ScfEline* el1 = *(const ScfEline**)v1;
-#if 0
-       if (SCF_EDA_PIN_POS & el0->flags)
-               return -1;
-       if (SCF_EDA_PIN_NEG & el0->flags)
-               return 1;
 
-       if (SCF_EDA_PIN_POS & el1->flags)
-               return 1;
-       if (SCF_EDA_PIN_NEG & el1->flags)
-               return -1;
-#endif
        if (el0->n_conns < el1->n_conns)
                return 1;
 
@@ -64,6 +54,20 @@ int eline_cmp(const void* v0, const void* v1)
        return 0;
 }
 
+int eline_cmp_id(const void* v0, const void* v1)
+{
+       const ScfEline* el0 = *(const ScfEline**)v0;
+       const ScfEline* el1 = *(const ScfEline**)v1;
+
+       if (el0->id < el1->id)
+               return -1;
+
+       if (el0->id > el1->id)
+               return 1;
+
+       return 0;
+}
+
 int ses_pins_same_line(ScfEfunction* f)
 {
        ScfEcomponent* c;
@@ -472,6 +476,39 @@ int ses_layout_function(ScfEfunction* f, int d)
                }
        }
 
+       for (i = 0; i < f->n_elines; i++) {
+               el0       = f->elines[i];
+
+               for (m = 0; m + 3 < el0->n_pins; m += 2) {
+
+                       c0 = f->components[el0->pins[m]];
+
+                       if (2 != c0->n_pins)
+                               continue;
+
+                       p0 = c0->pins[ el0->pins[m + 1]];
+                       p1 = c0->pins[!el0->pins[m + 1]];
+
+                       for (n = 2; n + 1 < el0->n_pins; n += 2) {
+
+                               c1 = f->components[el0->pins[n]];
+                               if (2 != c1->n_pins)
+                                       continue;
+
+                               p2 = c1->pins[ el0->pins[n + 1]];
+                               p3 = c1->pins[!el0->pins[n + 1]];
+
+                               if ((p1->y < p0->y && p3->y < p0->y)
+                                               || (p1->y > p0->y && p3->y > p0->y)) {
+
+                                       if ((p0->x > p2->x && p1->x < p3->x)
+                                                       || (p0->x < p2->x && p1->x > p3->x))
+                                               SCF_XCHG(p0->x, p2->x);
+                               }
+                       }
+               }
+       }
+
        int mx = 0;
 
        for (i = 0; i < f->n_components - 1; i++) {
@@ -539,45 +576,7 @@ int ses_layout_function(ScfEfunction* f, int d)
                }
        }
 
-       for (i = 0; i < f->n_elines; i++) {
-               el0       = f->elines[i];
-
-               el0->lines[0]->x1 -= mx - d;
-
-               for (m = 0; m + 3 < el0->n_pins; m += 2) {
-
-                       c0 = f->components[el0->pins[m]];
-
-                       if (2 != c0->n_pins)
-                               continue;
-
-                       p0 = c0->pins[ el0->pins[m + 1]];
-                       p1 = c0->pins[!el0->pins[m + 1]];
-
-                       for (n = 2; n + 1 < el0->n_pins; n += 2) {
-
-                               c1 = f->components[el0->pins[n]];
-                               if (2 != c1->n_pins)
-                                       continue;
-
-                               p2 = c1->pins[ el0->pins[n + 1]];
-                               p3 = c1->pins[!el0->pins[n + 1]];
-
-                               if ((p1->y < p0->y && p3->y < p0->y)
-                                               || (p1->y > p0->y && p3->y > p0->y)) {
-
-                                       if (p0->x > 0 && p1->x > 0 && p2->x > 0 && p3->x > 0) {
-
-                                               if ((p0->x > p2->x && p1->x < p3->x)
-                                                               || (p0->x < p2->x && p1->x > p3->x))
-                                                       SCF_XCHG(p0->x, p2->x);
-
-                                       } else if (p0->x < 0 && p1->x < 0 && p2->x < 0 && p3->x < 0) {
-                                       }
-                               }
-                       }
-               }
-       }
+       qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id);
 
        for (i = 0; i < f->n_components; i++) {
                c0 =        f->components[i];
@@ -590,6 +589,14 @@ int ses_layout_function(ScfEfunction* f, int d)
 
                        p0->x -= mx - d;
 
+                       el0 = f->elines[p0->lid];
+
+                       if (el0->lines[0]->x1 < p0->x)
+                               el0->lines[0]->x1 = p0->x;
+
+                       if (c0->id == 11)
+                               scf_loge("p0->x: %d, p0->lid: %ld, el0->id: %ld, el0->x1: %d\n", p0->x, p0->lid, el0->id, el0->lines[0]->x1);
+
                        cx += p0->x;
                        cy += p0->y;
                }