From 3bf113a7adb2e8d79089deb7a9c80784377ae100 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 17 Oct 2023 00:44:48 +0800 Subject: [PATCH] ses_layout_function() --- ses_layout.c | 130 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 53 deletions(-) diff --git a/ses_layout.c b/ses_layout.c index 5dbbf52..d9ecdb2 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -418,7 +418,7 @@ int ses_lines_same_components(ScfEfunction* f) return 0; } -int __ses_layout_lines(ScfEfunction* f, int d) +static int __ses_layout_lines(ScfEfunction* f, int d) { ScfEline* el; ScfLine* l; @@ -447,7 +447,7 @@ int __ses_layout_lines(ScfEfunction* f, int d) } } -void __ses_layout_components(ScfEfunction* f, int d) +static void __ses_layout_components(ScfEfunction* f, int d) { ScfEcomponent* c; ScfEline* el0; @@ -526,19 +526,11 @@ void __ses_layout_components(ScfEfunction* f, int d) } } -int ses_layout_function(ScfEfunction* f, int d) +static void __ses_xchg_components(ScfEfunction* f, int d) { ScfEcomponent* c0; ScfEcomponent* c1; - ScfEline* el0; - ScfEline* el1; - ScfEline* el2; - - ScfEconn* ec; - ScfLine* l0; - ScfLine* l1; - ScfLine* l2; - + ScfEline* el; ScfEpin* p0; ScfEpin* p1; ScfEpin* p2; @@ -551,24 +543,13 @@ int ses_layout_function(ScfEfunction* f, int d) size_t n; size_t q; - f->x = 0; - f->y = 0; - f->w = 0; - f->h = 0; - - int ret = __ses_layout_lines(f, d); - if (ret < 0) - return ret; - - __ses_layout_components(f, d); - for (i = 0; i < f->n_elines; i++) { - el0 = f->elines[i]; + el = f->elines[i]; - for (m = 0; m + 3 < el0->n_pins; m += 2) { + for (m = 0; m + 3 < el->n_pins; m += 2) { - c0 = f->components[el0->pins[m]]; - p0 = c0->pins [el0->pins[m + 1]]; + c0 = f->components[el->pins[m]]; + p0 = c0->pins [el->pins[m + 1]]; for (j = 0; j < c0->n_pins; j++) { p1 = c0->pins[j]; @@ -576,10 +557,10 @@ int ses_layout_function(ScfEfunction* f, int d) if (p1 == p0) continue; - for (n = 2; n + 1 < el0->n_pins; n += 2) { + for (n = 2; n + 1 < el->n_pins; n += 2) { - c1 = f->components[el0->pins[n]]; - p2 = c1->pins [el0->pins[n + 1]]; + c1 = f->components[el->pins[n]]; + p2 = c1->pins [el->pins[n + 1]]; for (k = 0; k < c1->n_pins; k++) { p3 = c1->pins[k]; @@ -630,8 +611,23 @@ int ses_layout_function(ScfEfunction* f, int d) } } } +} - qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id); +static void __ses_de_cross(ScfEfunction* f, int d) +{ + ScfEcomponent* c0; + ScfEcomponent* c1; + ScfEpin* p0; + ScfEpin* p1; + ScfEpin* p2; + ScfEpin* p3; + + size_t i; + size_t j; + size_t k; + size_t m; + size_t n; + size_t q; for (i = 0; i < f->n_components - 1; i++) { c0 = f->components[i]; @@ -736,16 +732,44 @@ int ses_layout_function(ScfEfunction* f, int d) next: c0 = NULL; } +} + +int ses_layout_function(ScfEfunction* f, int d) +{ + ScfEcomponent* c; + ScfEline* el; + ScfEpin* p0; + ScfEpin* p1; + + size_t i; + size_t j; + size_t k; + + f->x = 0; + f->y = 0; + f->w = 0; + f->h = 0; + + int ret = __ses_layout_lines(f, d); + if (ret < 0) + return ret; + + __ses_layout_components(f, d); + __ses_xchg_components(f, d); + + qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id); + + __ses_de_cross(f, d); int mx = 0; int nx = INT_MIN; int px = INT_MAX; for (i = 0; i < f->n_components; i++) { - c0 = f->components[i]; + c = f->components[i]; - for (j = 0; j < c0->n_pins; j++) { - p0 = c0->pins[j]; + for (j = 0; j < c->n_pins; j++) { + p0 = c->pins[j]; if (p0->x < 0) { if (mx > p0->x) @@ -770,13 +794,13 @@ next: scf_loge("mx: %d, nx: %d, px: %d\n", mx, nx, px); for (i = 0; i < f->n_components; i++) { - c0 = f->components[i]; + c = f->components[i]; int cx = 0; int cy = 0; - for (j = 0; j < c0->n_pins; j++) { - p0 = c0->pins[j]; + for (j = 0; j < c->n_pins; j++) { + p0 = c->pins[j]; if (p0->x > 0) p0->x -= px - nx - d; @@ -789,35 +813,35 @@ next: } } - c0->x = cx / 2; - c0->y = cy / 2; + c->x = cx / 2; + c->y = cy / 2; } for (i = 0; i < f->n_elines; i++) { - el0 = f->elines[i]; + el = f->elines[i]; int x0 = INT_MAX; int x1 = 0; int cx = 0; - qsort_r(el0->pins, el0->n_pins / 2, sizeof(uint64_t) * 2, epin_cmp_cx, f); + qsort_r(el->pins, el->n_pins / 2, sizeof(uint64_t) * 2, epin_cmp_cx, f); - for (j = 0; j < el0->n_pins; j += 2) { + for (j = 0; j < el->n_pins; j += 2) { - c0 = f ->components[el0->pins[j]]; - p0 = c0->pins [el0->pins[j + 1]]; + c = f->components[el->pins[j]]; + p0 = c->pins [el->pins[j + 1]]; - int tmp = c0->x; + int tmp = c->x; - if (j > 0 && c0->x < cx + d) - c0->x = cx + d; - cx = c0->x; + if (j > 0 && c->x < cx + d) + c->x = cx + d; + cx = c->x; - for (k = 0; k < c0->n_pins; k++) { + for (k = 0; k < c->n_pins; k++) { if (k < 2) - c0->pins[k]->x = c0->x; + c->pins[k]->x = c->x; else - c0->pins[k]->x += c0->x - tmp; + c->pins[k]->x += c->x - tmp; } if (x0 > p0->x) @@ -827,8 +851,8 @@ next: x1 = p0->x; } - el0->lines[0]->x0 = x0; - el0->lines[0]->x1 = x1; + el->lines[0]->x0 = x0; + el->lines[0]->x1 = x1; } f->w -= mx - 3 * d + px - nx; -- 2.25.1