_topo_path_completes()
authoryu.dongliang <18588496441@163.com>
Sun, 12 Nov 2023 07:52:24 +0000 (15:52 +0800)
committeryu.dongliang <18588496441@163.com>
Sun, 12 Nov 2023 07:52:24 +0000 (15:52 +0800)
ses_step_topo.c

index e533a43fe8ffb3b9078dc2556650b54e75d192db..75ea62bb84d2245417cff266f8cc51cda4e08873 100644 (file)
@@ -291,6 +291,76 @@ static int _topo_path_bridges(ScfEfunction* f, ses_path_t* path)
        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;
@@ -577,7 +647,6 @@ int __ses_topo_paths(ScfEfunction* f, scf_vector_t*  paths)
        ScfEpin*         p;
 
        size_t i;
-       size_t j;
 
        _topo_clear(f);
 
@@ -631,6 +700,10 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
        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];