From: yu.dongliang <18588496441@163.com> Date: Mon, 30 Oct 2023 10:03:45 +0000 (+0800) Subject: ses_layout_function() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=93c0668dd1ce545bdbb52b6590e41b4af5f32920;p=ses.git ses_layout_function() --- diff --git a/ses_layout.c b/ses_layout.c index 635e659..511fa49 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -843,6 +843,8 @@ static inline void __ses_xchg_cx2(ScfEcomponent* c0, ScfEcomponent* c1) SCF_XCHG(c0->x, c1->x); + scf_logw("c%ld <--> c%ld\n", c0->id, c1->id); + for (i = 0; i < c0->n_pins; i++) { p = c0->pins[i]; @@ -862,7 +864,7 @@ static inline void __ses_xchg_cx2(ScfEcomponent* c0, ScfEcomponent* c1) } } -static inline void __ses_xchg_cx(ScfEfunction* f, int d) +static void __ses_xchg_cx(ScfEfunction* f, int d) { ScfEcomponent* c0; ScfEcomponent* c1; @@ -913,6 +915,87 @@ static inline void __ses_xchg_cx(ScfEfunction* f, int d) } } +static void __ses_layout_cx(ScfEfunction* f, int d) +{ + ScfEcomponent* c; + ScfEcomponent* c2; + ScfEline* el; + ScfEline* el2; + ScfEpin* p0; + ScfEpin* p1; + + size_t i; + size_t j; + size_t k; + + for (i = 0; i < f->n_components; i++) { + c = f->components[i]; + + p0 = c->pins[0]; + p1 = c->pins[1]; + + c->x = (p0->x + p1->x) / 2; + c->y = (p0->y + p1->y) / 2; + } + + for (i = 0; i < f->n_elines; i++) { + el = f->elines[i]; + + int cx = 0; + + qsort_r(el->pins, el->n_pins / 2, sizeof(uint64_t) * 2, epin_cmp_cx, f); + + for (j = 0; j < el->n_pins; j += 2) { + + c = f->components[el->pins[j]]; + p0 = c->pins [el->pins[j + 1]]; + + int tmp = c->x; + + if (j > 0) { + if (c->x < cx + d) + c->x = cx + d; + } + cx = c->x; + + for (k = 0; k < c->n_pins; k++) { + p1 = c->pins[k]; + + if (k < 2) + p1->x = c->x; + else + p1->x += c->x - tmp; + } + } + } + + qsort(f->components, f->n_components, sizeof(ScfEcomponent*), ecomponent_cmp_cx); + for (i = 1; i < f->n_components; i++) { + c = f->components[i]; + c2 = f->components[i - 1]; + + int tmp = c->x; + + if (c->x > c2->x + d) + c->x = c2->x + d; + + if (c->x < c2->x + d / 2) + c->x = c2->x + d / 2; + + for (k = 0; k < c->n_pins; k++) { + p1 = c->pins[k]; + + if (k < 2) + p1->x = c->x; + else { + p1->x += c->x - tmp; +// p1->x = (c->x * 3 + p1->x) / 4; + } + } + } + qsort(f->components, f->n_components, sizeof(ScfEcomponent*), ecomponent_cmp_id); +} + int ses_layout_function(ScfEfunction* f, int d) { ScfEcomponent* c; @@ -940,7 +1023,11 @@ int ses_layout_function(ScfEfunction* f, int d) qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id); - __ses_de_cross(f, d); + __ses_de_cross (f, d); + + __ses_layout_cx(f, d); + + __ses_xchg_cx (f, d); int mx = 0; int nx = INT_MIN; @@ -998,70 +1085,9 @@ int ses_layout_function(ScfEfunction* f, int d) c->y = cy / 2; } - for (i = 0; i < f->n_elines; i++) { - el = f->elines[i]; - - int cx = 0; - - qsort_r(el->pins, el->n_pins / 2, sizeof(uint64_t) * 2, epin_cmp_cx, f); - - for (j = 0; j < el->n_pins; j += 2) { - - c = f->components[el->pins[j]]; - p0 = c->pins [el->pins[j + 1]]; - - int tmp = c->x; - - if (j > 0 && c->x < cx + d) - c->x = cx + d; - cx = c->x; - - for (k = 0; k < c->n_pins; k++) { - p1 = c->pins[k]; - - if (k < 2) - p1->x = c->x; - else - p1->x += c->x - tmp; - } - } - } - int tx0 = INT_MAX; int tx1 = 0; - qsort(f->components, f->n_components, sizeof(ScfEcomponent*), ecomponent_cmp_cx); - for (i = 1; i < f->n_components; i++) { - c = f->components[i]; - c2 = f->components[i - 1]; - - int tmp = c->x; - - if (c->x > c2->x + d) - c->x = c2->x + d; - - if (c->x < c2->x + d / 2) - c->x = c2->x + d / 2; - - for (k = 0; k < c->n_pins; k++) { - p1 = c->pins[k]; - - if (k < 2) - p1->x = c->x; - else { - p1->x += c->x - tmp; -// p1->x = (c->x * 3 + p1->x) / 4; - } - - if (tx0 > p1->x) - tx0 = p1->x; - - if (tx1 < p1->x) - tx1 = p1->x; - } - } - qsort(f->components, f->n_components, sizeof(ScfEcomponent*), ecomponent_cmp_id); - for (i = 0; i < f->n_elines; i++) { el = f->elines[i]; @@ -1082,6 +1108,12 @@ int ses_layout_function(ScfEfunction* f, int d) el->lines[0]->x0 = x0; el->lines[0]->x1 = x1; + + if (tx0 > x0) + tx0 = x0; + + if (tx1 < x1) + tx1 = x1; } f->w = tx1 + d;