From 10e7765340c3f932f996c283baadfe6213f532fb Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Mon, 30 Oct 2023 19:01:55 +0800 Subject: [PATCH] __ses_xchg_cx() --- ses_layout.c | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/ses_layout.c b/ses_layout.c index 291f019..18490bc 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -860,25 +860,30 @@ static void __ses_xchg_cx(ScfEfunction* f, int d) { ScfEcomponent* c0; ScfEcomponent* c1; - ScfEpin* p0; - ScfEpin* p1; - ScfEpin* p2; - ScfEpin* p3; + ScfEpin* p; size_t i; size_t j; + size_t k; for (i = 0; i < f->n_components - 1; i++) { c0 = f->components[i]; - p0 = c0->pins[0]; - p1 = c0->pins[1]; + int y0 = INT_MAX; + int y1 = INT_MIN; - if (p0->y - p1->y <= d && p0->y - p1->y >= -d) - continue; + for (k = 0; k < c0->n_pins; k++) { + p = c0->pins[k]; + + if (y0 > p->y) + y0 = p->y; - int y0 = p0->y < p1->y ? p0->y : p1->y; - int y1 = p0->y < p1->y ? p1->y : p0->y; + if (y1 < p->y) + y1 = p->y; + } + + if (y1 - y0 <= d) + continue; for (j = i + 1; j < f->n_components; j++) { c1 = f->components[j]; @@ -886,20 +891,29 @@ static void __ses_xchg_cx(ScfEfunction* f, int d) if ((c0->x < 0 && c1->x > 0) || (c0->x > 0 && c1->x < 0)) continue; - p2 = c1->pins[0]; - p3 = c1->pins[1]; + int y2 = INT_MAX; + int y3 = INT_MIN; + + for (k = 0; k < c1->n_pins; k++) { + p = c1->pins[k]; - if (p2->y - p3->y <= d && p2->y - p3->y >= -d) + if (y2 > p->y) + y2 = p->y; + + if (y3 < p->y) + y3 = p->y; + } + + if (y3 - y2 <= d) continue; - int y2 = p2->y < p3->y ? p2->y : p3->y; - int y3 = p2->y < p3->y ? p3->y : p2->y; + if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) { - if (y0 < y2 && y3 < y1) { if ((c0->x < 0 && c0->x > c1->x) || (c0->x > 0 && c0->x < c1->x)) __ses_xchg_cx2(c0, c1); - } else if (y2 < y0 && y1 < y3) { + } else if ((y2 <= y0 && y1 < y3) || (y2 < y0 && y1 <= y3)) { + if ((c0->x < 0 && c0->x < c1->x) || (c0->x > 0 && c0->x > c1->x)) __ses_xchg_cx2(c0, c1); } -- 2.25.1