From 394e95f51329cfbd7d07028b66197a6898ef7773 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sun, 12 Nov 2023 15:52:24 +0800 Subject: [PATCH] _topo_path_completes() --- ses_step_topo.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/ses_step_topo.c b/ses_step_topo.c index e533a43..75ea62b 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -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]; -- 2.25.1