return __topo_path_bridges(f, path);
}
+static int _topo_path_completes(ScfEfunction* f, scf_vector_t* paths)
+{
+ if (!f || !paths)
+ return -EINVAL;
+
+ ses_path_t* path0;
+ ses_path_t* path1;
+
+ ScfEcomponent* B = f->components[0];
+ ScfEpin* Bp = B->pins[SCF_EDA_Battery_POS];
+ ScfEpin* Bn = B->pins[SCF_EDA_Battery_NEG];
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* p2;
+ ScfEpin* p3;
+
+ int i;
+ int j;
+
+ for (i = paths->size - 1; i >= 1; i--) {
+ path0 = paths->data[i];
+
+ p0 = path0->pins->data[0];
+ p1 = path0->pins->data[path0->pins->size - 1];
+
+ if (p1->lid != Bn->lid)
+ continue;
+
+ if (p0->lid == Bp->lid)
+ continue;
+
+ for (j = paths->size - 1; j >= 0; j--) {
+ path1 = paths->data[j];
+
+ if (path1 == path0)
+ continue;
+
+ p2 = path1->pins->data[0];
+ p3 = path1->pins->data[path1->pins->size - 1];
+
+ if (p2->lid != Bp->lid)
+ continue;
+
+ if (p3->lid == p0->lid)
+ break;
+ }
+
+ if (j > 0) {
+ scf_loge("merge path: c%ldp%ld-c%ldp%ld ... c%ldp%ld-c%ldp%ld\n",
+ p2->cid, p2->id, p3->cid, p3->id,
+ p0->cid, p0->id, p1->cid, p1->id);
+
+ for (j = 0; j < path0->pins->size; j++) {
+ p0 = path0->pins->data[j];
+
+ if (scf_vector_add(path1->pins, p0) < 0)
+ return -ENOMEM;
+ }
+
+ if (scf_vector_del(paths, path0) < 0)
+ return -1;
+
+ ses_path_free(path0);
+ path0 = NULL;
+ }
+ }
+
+ return 0;
+}
+
static int _topo_layers(ScfEfunction* f, scf_vector_t* paths)
{
ScfEcomponent* B;
ScfEpin* p;
size_t i;
- size_t j;
_topo_clear(f);
if (ret < 0)
return ret;
+ ret = _topo_path_completes(f, ctx->paths);
+ if (ret < 0)
+ return ret;
+
for (i = 0; i < ctx->paths->size; i++) {
path = ctx->paths->data[i];