N = v->edges->size;
}
- scf_vector_t* paths = scf_vector_alloc();
- int ret = __ses_topo_paths(f, paths);
- if (ret < 0)
- return ret;
-
for (j = N; j >= 1; j--) {
for (i = 1; i <= j; i++)
scf_vector_free(colors);
}
+int epath_cmp_pins(const void* v0, const void* v1)
+{
+ const ses_path_t* p0 = *(const ses_path_t**)v0;
+ const ses_path_t* p1 = *(const ses_path_t**)v1;
+
+ if (p0->pins->size > p1->pins->size)
+ return -1;
+
+ if (p0->pins->size < p1->pins->size)
+ return 1;
+ return 0;
+}
+
+static int __ses_layout_lines4(ScfEfunction* f)
+{
+ scf_vector_t* paths;
+ ses_path_t* Bpath;
+ ses_path_t* path;
+
+ ScfEcomponent* B;
+ ScfEline* el;
+ ScfEpin* Bp;
+ ScfEpin* p;
+
+ intptr_t i;
+ intptr_t j;
+ intptr_t k;
+
+ paths = scf_vector_alloc();
+ if (!paths)
+ return -ENOMEM;
+
+ int ret = __ses_topo_paths(f, paths);
+ if (ret < 0)
+ goto end;
+
+ scf_vector_qsort(paths, epath_cmp_pins);
+
+ B = f->components[0];
+ Bp = B->pins[SCF_EDA_Battery_POS];
+
+ for (i = 0; i < paths->size; i++) {
+ Bpath = paths->data[i];
+
+ p = Bpath->pins->data[0];
+ if (p->lid == Bp->lid)
+ break;
+ }
+
+ if (i >= paths->size)
+ goto end;
+
+ 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]);
+ }
+
+ p = Bpath->pins->data[j - 1];
+ k = __ses_find_eline_index(f, p->lid);
+ SCF_XCHG(f->elines[k], f->elines[j / 2 + 1]);
+
+ ret = 0;
+end:
+ scf_vector_clear(paths, ( void (*)(void*) )ses_path_free);
+ scf_vector_free(paths);
+ return ret;
+}
+
static int __ses_layout_lines2(ScfEfunction* f)
{
ScfEline* tmp;
if (f->n_elines <= 2)
return 0;
- __ses_layout_lines3(f);
+ __ses_layout_lines4(f);
#if 1
for (i = 0; i < f->n_elines; i++) {
f->w = 0;
f->h = 0;
- qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp);
+// qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp);
int ret = __ses_layout_lines(f, d);
if (ret < 0)