ses_path_add()
authoryu.dongliang <18588496441@163.com>
Tue, 26 Sep 2023 14:16:42 +0000 (22:16 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 26 Sep 2023 14:16:42 +0000 (22:16 +0800)
ses_step_topo.c
ses_steps.c

index 60886fc0472c1c546cc46a24277fdd4bd9550544..7cc05cc9ea3b2d3c916293968d5b8400460d3178 100644 (file)
@@ -1,25 +1,5 @@
 #include"ses_core.h"
 
-static int _ses_path_cmp(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->n_diodes > p1->n_diodes)
-               return -1;
-
-       if (p0->n_diodes < p1->n_diodes)
-               return 1;
-
-       if (p0->pins->size > p1->pins->size)
-               return -1;
-
-       if (p0->pins->size < p1->pins->size)
-               return 1;
-
-       return 0;
-}
-
 int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __paths, ses_path_t** ppath)
 {
        ScfEcomponent*   c;
@@ -217,9 +197,12 @@ static int _topo_layers(scf_vector_t* paths)
                p0   = child->pins->data[0];
                p1   = child->pins->data[child->pins->size - 1];
 
-               for (j     = i - 1; j >= 0; j--) {
+               for (j     = paths->size - 1; j >= 0; j--) {
                        parent = paths->data[j];
 
+                       if (parent == child)
+                               continue;
+
                        int n  = 0;
 
                        for (k = 0; k < parent->pins->size; k++) {
@@ -364,8 +347,6 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
                }
        }
 
-       scf_vector_qsort(ctx->paths, _ses_path_cmp);
-
        int ret = _topo_layers(ctx->paths);
        if (ret < 0)
                return ret;
index bc221aa0438f1b75def7aa337b4ccbc1624f01bb..1afadcbbb75f3b56078b41b1ffbcd2fc1fae36c9 100644 (file)
@@ -423,8 +423,21 @@ int ses_path_add(ses_path_t* parent, ses_path_t* child)
                p0        = path->pins->data[0];
                p1        = path->pins->data[path->pins->size - 1];
 
-               if (p0->lid == cp0->lid && p1->lid == cp1->lid)
-                       return ses_path_add(path, child);
+               if (p0->lid == cp0->lid && p1->lid == cp1->lid) {
+
+                       if (child->pins->size == child->n_diodes * 2
+                         && path->pins->size  >  path->n_diodes * 2) {
+
+                               parent->childs->data[j] = child;
+                               child->parent           = parent;
+                               child->parent_p0        = path->parent_p0;
+                               child->parent_p1        = path->parent_p1;
+                               child->type             = SES_PATH_BRANCH;
+
+                               return ses_path_add(child, path);
+                       } else
+                               return ses_path_add(path, child);
+               }
        }
 
        if (scf_vector_add(parent->childs, child) < 0)