From: yu.dongliang <18588496441@163.com> Date: Tue, 26 Sep 2023 14:16:42 +0000 (+0800) Subject: ses_path_add() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=26443205ff75de0e3703fac03a852f9c62ee66eb;p=ses.git ses_path_add() --- diff --git a/ses_step_topo.c b/ses_step_topo.c index 60886fc..7cc05cc 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -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; diff --git a/ses_steps.c b/ses_steps.c index bc221aa..1afadcb 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -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)