__ses_xchg_npn_ce()
authoryu.dongliang <18588496441@163.com>
Mon, 30 Oct 2023 10:42:01 +0000 (18:42 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 30 Oct 2023 10:42:01 +0000 (18:42 +0800)
ses_layout.c

index 3e98f3401a23b9deded33fb5f0cc76f18f4b0f59..291f0194acc47a7b8c9408937a45ef95372dc735 100644 (file)
@@ -988,6 +988,38 @@ static void __ses_layout_cx(ScfEfunction* f, int d)
        qsort(f->components, f->n_components, sizeof(ScfEcomponent*), ecomponent_cmp_id);
 }
 
+static void __ses_xchg_npn_ce(ScfEfunction* f, int d)
+{
+       ScfEcomponent* c;
+       ScfEpin*       pb;
+       ScfEpin*       pe;
+       ScfEpin*       pc;
+
+       size_t i;
+
+       for (i = 0; i < f->n_components; i++) {
+               c  =        f->components[i];
+
+               if (SCF_EDA_NPN != c->type)
+                       continue;
+
+               pb = c->pins[SCF_EDA_NPN_B];
+               pc = c->pins[SCF_EDA_NPN_C];
+               pe = c->pins[SCF_EDA_NPN_E];
+
+               if (pc->y > pe->y && pe->y > pb->y) {
+
+                       if ((c->x < 0 && pc->x > pe->x) || (c->x > 0 && pc->x < pe->x))
+                               SCF_XCHG(pc->x, pe->x);
+
+               } else if (pc->y < pe->y && pe->y < pb->y) {
+
+                       if ((c->x < 0 && pc->x > pe->x) || (c->x > 0 && pc->x < pe->x))
+                               SCF_XCHG(pc->x, pe->x);
+               }
+       }
+}
+
 int ses_layout_function(ScfEfunction* f, int d)
 {
        ScfEcomponent* c;
@@ -1018,9 +1050,10 @@ int ses_layout_function(ScfEfunction* f, int d)
        __ses_de_cross (f, d);
 
        __ses_layout_cx(f, d);
-
        __ses_xchg_cx  (f, d);
 
+       __ses_xchg_npn_ce(f, d);
+
        int mx = 0;
        int nx = INT_MIN;
        int px = INT_MAX;
@@ -1056,9 +1089,6 @@ int ses_layout_function(ScfEfunction* f, int d)
        for (i = 0; i < f->n_components; i++) {
                c  =        f->components[i];
 
-               int cx = 0;
-               int cy = 0;
-
                for (j = 0; j < c->n_pins; j++) {
                        p0 =        c->pins[j];
 
@@ -1066,15 +1096,12 @@ int ses_layout_function(ScfEfunction* f, int d)
                                p0->x -= px - nx - d;
 
                        p0->x -= mx - d;
-
-                       if (j < 2) {
-                               cx += p0->x;
-                               cy += p0->y;
-                       }
                }
 
-               c->x = cx / 2;
-               c->y = cy / 2;
+               if (c->x > 0)
+                       c->x -= px - nx - d;
+
+               c->x -= mx - d;
        }
 
        int tx0 = INT_MAX;