tmp
authoryu.dongliang <18588496441@163.com>
Tue, 7 Nov 2023 16:27:47 +0000 (00:27 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 7 Nov 2023 16:27:47 +0000 (00:27 +0800)
ses_layout.c

index b891df0dd6ba599e2e195f29d8316c87d24143e1..131efaf3e33c4713613ccb6c1d124f037c87c7ef 100644 (file)
@@ -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: