From 027fc3b6d747df0f0d43c671725ad752f4c3ea0a Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Mon, 16 Oct 2023 23:00:44 +0800 Subject: [PATCH] ses_layout_function() --- ses_layout.c | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/ses_layout.c b/ses_layout.c index a66fec1..3729f66 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -21,6 +21,24 @@ int epin_cmp(const void* v0, const void* v1) return 0; } +int epin_cmp_cx(const void* v0, const void* v1, void* arg) +{ + const uint64_t* t0 = v0; + const uint64_t* t1 = v1; + + ScfEfunction* f = arg; + ScfEcomponent* c0 = f->components[t0[0]]; + ScfEcomponent* c1 = f->components[t1[0]]; + + if (c0->x < c1->x) + return -1; + + if (c0->x > c1->x) + return 1; + + return 0; +} + int econn_cmp(const void* v0, const void* v1) { const ScfEconn* ec0 = *(const ScfEconn**)v0; @@ -586,7 +604,7 @@ int ses_layout_function(ScfEfunction* f, int d) } qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id); -#if 1 + for (i = 0; i < f->n_components - 1; i++) { c0 = f->components[i]; p0 = c0->pins[0]; @@ -690,7 +708,7 @@ int ses_layout_function(ScfEfunction* f, int d) next: c0 = NULL; } -#endif + int mx = 0; int nx = INT_MIN; int px = INT_MAX; @@ -745,15 +763,6 @@ next: c0->x = cx / 2; c0->y = cy / 2; - - for (j = 0; j < c0->n_pins; j++) { - p0 = c0->pins[j]; - - if (j < 2) - p0->x = c0->x; - // else - // p0->x = (c0->x * 3 + p0->x) / 4; - } } for (i = 0; i < f->n_elines; i++) { @@ -761,12 +770,28 @@ next: 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); for (j = 0; j < el0->n_pins; j += 2) { c0 = f ->components[el0->pins[j]]; p0 = c0->pins [el0->pins[j + 1]]; + int tmp = c0->x; + + if (j > 0 && c0->x < cx + d) + c0->x = cx + d; + cx = c0->x; + + for (k = 0; k < c0->n_pins; k++) { + if (k < 2) + c0->pins[k]->x = c0->x; + else + c0->pins[k]->x += c0->x - tmp; + } + if (x0 > p0->x) x0 = p0->x; @@ -853,8 +878,6 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ } } - - for (i = 0; i < b->n_functions; i++) { f = b->functions[i]; -- 2.25.1