From: yu.dongliang <18588496441@163.com> Date: Fri, 10 Nov 2023 05:16:27 +0000 (+0800) Subject: __ses_de_cross() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=831f9e2af6e12dd1dc82a8889851719f8211affe;p=ses.git __ses_de_cross() --- diff --git a/ses_layout.c b/ses_layout.c index b2fd915..b02d422 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -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;