From cb0fb9df9b040711c88881dfda1cd646fca7368a Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 8 Nov 2023 00:27:47 +0800 Subject: [PATCH] tmp --- ses_layout.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 4 deletions(-) diff --git a/ses_layout.c b/ses_layout.c index b891df0..131efaf 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -537,6 +537,20 @@ int epath_cmp_pins(const void* v0, const void* v1) return 0; } +static inline void eline_mov_before(ScfEfunction* f, intptr_t dst, intptr_t src) +{ + ScfEline* el = f->elines[src]; + intptr_t i; + + for (i = src + 1; i < f->n_elines; i++) + f->elines[i - 1] = f->elines[i]; + + for (i = f->n_elines - 1; i > dst; i--) + f->elines[i] = f->elines[i - 1]; + + f->elines[dst] = el; +} + static int __ses_layout_lines4(ScfEfunction* f) { scf_vector_t* paths; @@ -546,11 +560,14 @@ static int __ses_layout_lines4(ScfEfunction* f) ScfEcomponent* B; ScfEline* el; ScfEpin* Bp; + ScfEpin* Bn; ScfEpin* p; intptr_t i; intptr_t j; intptr_t k; + intptr_t n; + intptr_t __n; paths = scf_vector_alloc(); if (!paths) @@ -564,6 +581,7 @@ static int __ses_layout_lines4(ScfEfunction* f) B = f->components[0]; Bp = B->pins[SCF_EDA_Battery_POS]; + Bn = B->pins[SCF_EDA_Battery_NEG]; for (i = 0; i < paths->size; i++) { Bpath = paths->data[i]; @@ -579,13 +597,60 @@ static int __ses_layout_lines4(ScfEfunction* f) for (j = 0; j < Bpath->pins->size; j += 2) { p = Bpath->pins->data[j]; - k = __ses_find_eline_index(f, p->lid); - SCF_XCHG(f->elines[k], f->elines[j / 2]); + n = __ses_find_eline_index(f, p->lid); + SCF_XCHG(f->elines[n], f->elines[j / 2]); } p = Bpath->pins->data[j - 1]; - k = __ses_find_eline_index(f, p->lid); - SCF_XCHG(f->elines[k], f->elines[j / 2 + 1]); + n = __ses_find_eline_index(f, p->lid); + SCF_XCHG(f->elines[n], f->elines[j / 2 + 1]); + + for (i = 0; i < paths->size; i++) { + path = paths->data[i]; + + if (path == Bpath) + continue; + + __n = __ses_find_eline_index(f, Bn->lid); + + for (j = path->pins->size - 1; j > 0; j -= 2) { + p = path->pins->data[j]; + + for (k = Bpath->pins->size - 1; k >= 0; k--) { + Bp = Bpath->pins->data[k]; + + if (p->lid == Bp->lid) { + __n = __ses_find_eline_index(f, Bp->lid); + break; + } + } + + if (k < 0) { + n = __ses_find_eline_index(f, p->lid); + + eline_mov_before(f, __n, n); + __n = n; + } + } + + p = path->pins->data[0]; + + for (k = Bpath->pins->size - 1; k >= 0; k--) { + Bp = Bpath->pins->data[k]; + + if (p->lid == Bp->lid) { + __n = __ses_find_eline_index(f, Bp->lid); + break; + } + } + + if (k < 0) { + n = __ses_find_eline_index(f, p->lid); + + eline_mov_before(f, __n, n); + __n = n; + } + } ret = 0; end: -- 2.25.1