From b9de1818a6365a48167c469623142903084ac87c Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Mon, 6 Nov 2023 15:55:27 +0800 Subject: [PATCH] __ses_xchg_cx() --- ses_layout.c | 99 ++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/ses_layout.c b/ses_layout.c index 0042dd2..da7a3a5 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -1120,8 +1120,6 @@ static void __ses_xchg_cx(ScfEfunction* f, int d) size_t k; size_t n; - k = 0; - for (i = 0; i < f->n_components - 1; i++) { c0 = f->components[i]; @@ -1154,72 +1152,75 @@ static void __ses_xchg_cx(ScfEfunction* f, int d) } } - for (i = 0; i < f->n_components - 1; i++) { - c0 = f->components[i]; + do { + n = 0; - int y0 = INT_MAX; - int y1 = INT_MIN; - int m0 = 0; - int n0 = 0; + for (i = 0; i < f->n_components - 1; i++) { + c0 = f->components[i]; - if (c0->color > 0) { - m0 = (c0->color - 1) / 2; - n0 = (c0->color - 1) % 2; - } + int y0 = INT_MAX; + int y1 = INT_MIN; + int m0 = 0; + int n0 = 0; - for (k = 0; k < c0->n_pins; k++) { - p = c0->pins[k]; + if (c0->color > 0) { + m0 = (c0->color - 1) / 2; + n0 = (c0->color - 1) % 2; + } - if (y0 > p->y) - y0 = p->y; + for (k = 0; k < c0->n_pins; k++) { + p = c0->pins[k]; - if (y1 < p->y) - y1 = p->y; - } + if (y0 > p->y) + y0 = p->y; - if (y1 - y0 <= d) - continue; + if (y1 < p->y) + y1 = p->y; + } - for (j = i + 1; j < f->n_components; j++) { - c1 = f->components[j]; + for (j = i + 1; j < f->n_components; j++) { + c1 = f->components[j]; - int y2 = INT_MAX; - int y3 = INT_MIN; - int m1 = 0; - int n1 = 0; + int y2 = INT_MAX; + int y3 = INT_MIN; + int m1 = 0; + int n1 = 0; - if (c1->color > 0) { - m1 = (c1->color - 1) / 2; - n1 = (c1->color - 1) % 2; - } - - if (m0 != m1 || n0 != n1) - continue; + if (c1->color > 0) { + m1 = (c1->color - 1) / 2; + n1 = (c1->color - 1) % 2; + } - scf_logi("c%ld <--> c%ld, color: %ld, %ld, cx: %d, %d\n", c0->id, c1->id, c0->color, c1->color, c0->x, c1->x); + if (m0 != m1 || n0 != n1) + continue; - for (k = 0; k < c1->n_pins; k++) { - p = c1->pins[k]; + for (k = 0; k < c1->n_pins; k++) { + p = c1->pins[k]; - if (y2 > p->y) - y2 = p->y; + if (y2 > p->y) + y2 = p->y; - if (y3 < p->y) - y3 = p->y; - } + if (y3 < p->y) + y3 = p->y; + } - if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) { + if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) { - if ((0 == n0 && c0->x > c1->x) || (1 == n0 && c0->x < c1->x)) - __ses_xchg_cx2(c0, c1); + if ((0 == n0 && c0->x > c1->x) || (1 == n0 && c0->x < c1->x)) { + __ses_xchg_cx2(c0, c1); + n++; + } - } else if ((y2 <= y0 && y1 < y3) || (y2 < y0 && y1 <= y3)) { + } else if ((y2 <= y0 && y1 < y3) || (y2 < y0 && y1 <= y3)) { - if ((0 == n0 && c0->x < c1->x) || (1 == n0 && c0->x > c1->x)) - __ses_xchg_cx2(c0, c1); + if ((0 == n0 && c0->x < c1->x) || (1 == n0 && c0->x > c1->x)) { + __ses_xchg_cx2(c0, c1); + n++; + } + } } } - } + } while (n > 0); } static void __ses_layout_cx(ScfEfunction* f, int d) -- 2.25.1