__ses_de_cross()
authoryu.dongliang <18588496441@163.com>
Fri, 10 Nov 2023 05:16:27 +0000 (13:16 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 10 Nov 2023 05:16:27 +0000 (13:16 +0800)
ses_layout.c

index b2fd915afb20bf45cc9ffd48063f95c0b15d6edf..b02d42253945e6e19f2928d4193dfd25b49bda7c 100644 (file)
@@ -1170,10 +1170,10 @@ static int __ses_de_cross(ScfEfunction* f, int d)
                N = v->edges->size + 1;
        }
 
-       for (j = N; j >= 1; j--) {
+       for (j = 1; j <= N; j++)
+               scf_vector_add(colors, (void*)j);
 
-               for (i = 1; i <= j; i++)
-                       scf_vector_add(colors, (void*)i);
+       for (j = N; j >= 2; j--) {
 
                int ret = ses_graph_kcolor(graph, j, colors);
                if (ret < 0) {
@@ -1200,19 +1200,61 @@ static int __ses_de_cross(ScfEfunction* f, int d)
                        v->color = 0;
                }
 
-               scf_vector_clear(colors, NULL);
+               scf_vector_del(colors, (void*)j);
        }
 
        scf_vector_clear(graph, ( void (*)(void*) )ses_vertex_free);
        scf_vector_free(graph);
+       graph = NULL;
+
+       N = j + 1;
+       scf_vector_add(colors, (void*)N);
+       scf_vector_add(colors, (void*)0);
+
+       for (i = 0; i < f->n_elines; i++) {
+               el =        f->elines[i];
+
+               for (j = 0; j < colors->size; j++)
+                       colors->data[j] = NULL;
+
+               for (j = 0; j + 1 < el->n_pins; j += 2) {
+                       c  = f->components[el->pins[j]];
+
+                       ++colors->data[c->color];
+               }
+
+               intptr_t _j = 0;
+               intptr_t _n = (intptr_t)colors->data[_j];
+
+               if (_n > 1)
+                       continue;
+
+               for (j = 1; j < colors->size; j++) {
+
+                       if (_n < (intptr_t)colors->data[j]) {
+                               _n = (intptr_t)colors->data[j];
+                               _j = j;
+                       }
+               }
+
+               if (0 == _j)
+                       continue;
+
+               for (j = 0; j + 1 < el->n_pins; j += 2) {
+                       c  = f->components[el->pins[j]];
+
+                       if (0 == c->color) {
+                               scf_loge("c%ld->color: %ld --> %ld\n", c->id, c->color, _j);
+                               c->color = _j;
+                       }
+               }
+       }
+
        scf_vector_free(colors);
        colors = NULL;
-       graph  = NULL;
 
        int x1 = 0;
 
-       N = j + 1;
-
        for (j = 1; j <= N; j++) {
 
                intptr_t j0 = (j - 1) / 2;