ses_layout_function()
authoryu.dongliang <18588496441@163.com>
Sat, 30 Sep 2023 14:10:14 +0000 (22:10 +0800)
committeryu.dongliang <18588496441@163.com>
Sat, 30 Sep 2023 14:10:14 +0000 (22:10 +0800)
ses_layout.c

index d73bf245e3a4dbafaa9464c89e3a0d83829f3fb5..92b578be66fcdf79760991fea7d61fe42c3e9ccf 100644 (file)
@@ -572,8 +572,6 @@ int ses_layout_function(ScfEfunction* f, int d)
 
        qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id);
 
-       int mx = 0;
-
        for (i = 0; i < f->n_components - 1; i++) {
                c0 =        f->components[i];
 
@@ -606,31 +604,19 @@ int ses_layout_function(ScfEfunction* f, int d)
 
                                                        if (y0 < y2 && y2 < y1 && y1 < y3) {
 
-                                                               if (p0->x > 0) {
+                                                               if (p0->x > 0)
                                                                        p0->x = -p0->x;
-                                                                       if (mx > p0->x)
-                                                                               mx = p0->x;
-                                                               }
 
-                                                               if (p1->x > 0) {
+                                                               if (p1->x > 0)
                                                                        p1->x = -p1->x;
-                                                                       if (mx > p1->x)
-                                                                               mx = p1->x;
-                                                               }
 
                                                        } else if (y2 < y0 && y0 < y3 && y3 < y1) {
 
-                                                               if (p2->x > 0) {
+                                                               if (p2->x > 0)
                                                                        p2->x = -p2->x;
-                                                                       if (mx > p2->x)
-                                                                               mx = p2->x;
-                                                               }
 
-                                                               if (p3->x > 0) {
+                                                               if (p3->x > 0)
                                                                        p3->x = -p3->x;
-                                                                       if (mx > p3->x)
-                                                                               mx = p3->x;
-                                                               }
                                                        }
                                                }
                                        }
@@ -698,6 +684,38 @@ next:
                c0 = NULL;
        }
 
+       int mx = 0;
+       int nx = INT_MIN;
+       int px = INT_MAX;
+
+       for (i = 0; i < f->n_components; i++) {
+               c0 =        f->components[i];
+
+               for (j = 0; j < c0->n_pins; j++) {
+                       p0 =        c0->pins[j];
+
+                       if (p0->x < 0) {
+                               if (mx > p0->x)
+                                       mx = p0->x;
+
+                               if (nx < p0->x)
+                                       nx = p0->x;
+
+                       } else {
+                               if (px > p0->x)
+                                       px = p0->x;
+                       }
+               }
+       }
+
+       if (INT_MIN == nx)
+               nx = 0;
+
+       if (INT_MAX == px)
+               px = 0;
+
+       scf_loge("mx: %d, nx: %d, px: %d\n", mx, nx, px);
+
        for (i = 0; i < f->n_components; i++) {
                c0 =        f->components[i];
 
@@ -707,6 +725,9 @@ next:
                for (j = 0; j < c0->n_pins; j++) {
                        p0 =        c0->pins[j];
 
+                       if (p0->x > 0)
+                               p0->x -= px - nx - d;
+
                        p0->x -= mx - d;
 
                        if (j < 2) {
@@ -744,7 +765,7 @@ next:
                el0->lines[0]->x1 = x1;
        }
 
-       f->w -= mx - d * 2;
+       f->w -= mx - 3 * d + px - nx;
        f->h += d;
 
        scf_loge("f->x: %d, y: %d, w: %d, h: %d\n", f->x, f->y, f->w, f->h);