ses layout
authoryu.dongliang <18588496441@163.com>
Thu, 13 Jul 2023 05:51:04 +0000 (13:51 +0800)
committeryu.dongliang <18588496441@163.com>
Thu, 13 Jul 2023 05:51:04 +0000 (13:51 +0800)
ses_layout.c

index 8a4343e23b52fe208d4e6768cdc214d448ebc910..cf08c91212b58eb2a94db98a80538303246ba223 100644 (file)
@@ -38,7 +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)
@@ -48,7 +48,7 @@ int eline_cmp(const void* v0, const void* v1)
                return 1;
        if (SCF_EDA_PIN_NEG & el1->flags)
                return -1;
-
+#endif
        if (el0->n_conns < el1->n_conns)
                return 1;
 
@@ -157,6 +157,7 @@ next:
 
 int ses_lines_same_components(ScfEfunction* f)
 {
+       ScfEline* tmp;
        ScfEline* el0;
        ScfEline* el1;
        ScfEconn* ec;
@@ -228,10 +229,113 @@ int ses_lines_same_components(ScfEfunction* f)
 
        qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp);
 
+       for (i = 0; i < f->n_elines; i++) {
+               el0       = f->elines[i];
+
+               scf_loge("i: %ld, el0: %ld, n_conns: %ld, n_pins: %ld, flags: %#lx\n", i, el0->id, el0->n_conns, el0->n_pins, el0->flags);
+       }
+       printf("\n\n");
+
+       if (f->n_elines <= 2)
+               return 0;
+
+       size_t k;
+       size_t m;
+       size_t n;
+
+       el0 = f->elines[0];
+       m   = f->n_elines >> 1;
+
+       f->elines[0] = f->elines[m];
+       f->elines[m] = el0;
+       el0->n_lines = 1;
+
+       for (i = 0; i < el0->n_conns && i < 2; i++) {
+               ec =        el0->conns[i];
+
+               for (j = 0; j < f->n_elines; j++) {
+                       el1       = f->elines[j];
+
+                       if (el1->id == ec->lid)
+                               break;
+               }
+               assert(j < f->n_elines);
+
+               n = m + (i << 1) - 1;
+
+               f->elines[j] = f->elines[n];
+               f->elines[n] = el1;
+               el1->n_lines = 1;
+       }
+
+       for (n  = m - 1; n > 0; n--) {
+               el0 = f->elines[n];
+
+               el0->n_lines = 1;
+
+               if (0 == el0->n_conns)
+                       continue;
+
+               for (i = 0; i < el0->n_conns; i++) {
+                       ec =        el0->conns[i];
+
+                       for (j = 0; j < f->n_elines; j++) {
+                               el1       = f->elines[j];
+
+                               if (el1->id == ec->lid)
+                                       break;
+                       }
+                       assert(j < f->n_elines);
+
+                       if (0 == el1->n_lines)
+                               break;
+               }
+
+               if (i == el0->n_conns)
+                       continue;
+
+               f->elines[j    ] = f->elines[n - 1];
+               f->elines[n - 1] = el1;
+               el1->n_lines     = 1;
+       }
+
+       for (n  = m + 1; n < f->n_elines - 1; n++) {
+               el0 = f->elines[n];
+
+               el0->n_lines = 1;
+
+               if (0 == el0->n_conns)
+                       continue;
+
+               for (i = 0; i < el0->n_conns; i++) {
+                       ec =        el0->conns[i];
+
+                       for (j = 0; j < f->n_elines; j++) {
+                               el1       = f->elines[j];
+
+                               if (el1->id == ec->lid)
+                                       break;
+                       }
+                       assert(j < f->n_elines);
+
+                       if (0 == el1->n_lines)
+                               break;
+               }
+
+               if (i == el0->n_conns)
+                       continue;
+
+               f->elines[j    ] = f->elines[n + 1];
+               f->elines[n + 1] = el1;
+               el1->n_lines     = 1;
+       }
+
 #if 1
        for (i = 0; i < f->n_elines; i++) {
                el0       = f->elines[i];
 
+               el0->n_lines = 0;
+
                scf_loge("i: %ld, el0: %ld, n_conns: %ld, n_pins: %ld, flags: %#lx\n", i, el0->id, el0->n_conns, el0->n_pins, el0->flags);
 
                for (j = 0; j < el0->n_conns; j++) {
@@ -239,7 +343,6 @@ int ses_lines_same_components(ScfEfunction* f)
 
                        scf_logi("j: %ld, lid: %ld, n_cids: %ld\n", j, ec->lid, ec->n_cids);
                }
-
                printf("\n");
        }
 #endif
@@ -362,7 +465,7 @@ int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, u
 
                if (0 == el->n_lines) {
 
-                       int ret = __ses_layout_function(f, el, &n, d, bx, by, bw, bh);
+                       int ret = __ses_layout_function2(f, el, &n, d, bx, by, bw, bh);
                        if (ret < 0)
                                return ret;
                }