From aa55aa117f1a679787da64a102298128c5336c8c Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Mon, 6 Nov 2023 15:03:21 +0800 Subject: [PATCH] tmp --- ses_layout.c | 81 +++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/ses_layout.c b/ses_layout.c index a342be4..6a3f33e 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -1118,59 +1118,68 @@ static void __ses_xchg_cx(ScfEfunction* f, int d) size_t i; size_t j; size_t k; + size_t n; - for (i = 0; i < f->n_components - 1; i++) { - c0 = f->components[i]; + do { + n = 0; - int y0 = INT_MAX; - int y1 = INT_MIN; + for (i = 0; i < f->n_components - 1; i++) { + c0 = f->components[i]; - int m = (c0->color - 1) % 2; + int y0 = INT_MAX; + int y1 = INT_MIN; - for (k = 0; k < c0->n_pins; k++) { - p = c0->pins[k]; + int m = (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; - - for (j = i + 1; j < f->n_components; j++) { - c1 = f->components[j]; + if (y1 < p->y) + y1 = p->y; + } - if ((c0->color != c1->color) && (0 != c1->color || c0->color > 2)) + if (y1 - y0 <= d) continue; - int y2 = INT_MAX; - int y3 = INT_MIN; + for (j = i + 1; j < f->n_components; j++) { + c1 = f->components[j]; + + if ((c0->color != c1->color) && (0 != c1->color || c0->color > 2)) + continue; - for (k = 0; k < c1->n_pins; k++) { - p = c1->pins[k]; + int y2 = INT_MAX; + int y3 = INT_MIN; - if (y2 > p->y) - y2 = p->y; + for (k = 0; k < c1->n_pins; k++) { + p = c1->pins[k]; - if (y3 < p->y) - y3 = p->y; - } + if (y2 > p->y) + y2 = p->y; - if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) { + if (y3 < p->y) + y3 = p->y; + } - if ((0 == m && c0->x > c1->x) || (1 == m && c0->x < c1->x)) - __ses_xchg_cx2(c0, c1); + if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) { + + if ((0 == m && c0->x > c1->x) || (1 == m && 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 == m && c0->x < c1->x) || (1 == m && c0->x > c1->x)) - __ses_xchg_cx2(c0, c1); + if ((0 == m && c0->x < c1->x) || (1 == m && c0->x > c1->x)) { + __ses_xchg_cx2(c0, c1); + n++; + } + } } } - } + } while (n > 0); } static void __ses_layout_cx(ScfEfunction* f, int d) @@ -1331,8 +1340,8 @@ int ses_layout_function(ScfEfunction* f, int d) } for (j = 0; j < el->n_lines; j++) - scf_logi("l%ld->lines[%ld]: x0: %d, x1: %d\n", el->id, j, el->lines[j]->x0, el->lines[j]->x1); - printf("\n"); + scf_logd("l%ld->lines[%ld]: x0: %d, x1: %d\n", el->id, j, el->lines[j]->x0, el->lines[j]->x1); +// printf("\n"); } f->w = tx1 + d; -- 2.25.1