From a1358c24146bb63fa991adbe0c23b4555e6c08a1 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sun, 12 Nov 2023 17:03:53 +0800 Subject: [PATCH] _topo_path_completes() --- ses_step_topo.c | 93 +++++++++++++++++++++++++++++++++++++++++-------- ses_steps.c | 2 +- 2 files changed, 79 insertions(+), 16 deletions(-) diff --git a/ses_step_topo.c b/ses_step_topo.c index 75ea62b..58f0da3 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -291,6 +291,38 @@ static int _topo_path_bridges(ScfEfunction* f, ses_path_t* path) return __topo_path_bridges(f, path); } +static int __topo_path_xchg(ses_path_t* path0, int k0, ses_path_t* path1, int k1) +{ + ScfEpin* p; + + int i; + + for (i = 0; i + k0 < path0->pins->size && i + k1 < path1->pins->size; i++) + SCF_XCHG(path0->pins->data[i + k0], path1->pins->data[i + k1]); + + while (i + k0 < path0->pins->size) { + p = path0->pins->data[i + k0]; + + if (scf_vector_del(path0->pins, p) < 0) + return -1; + + if (scf_vector_add(path1->pins, p) < 0) + return -ENOMEM; + } + + while (i + k1 < path1->pins->size) { + p = path1->pins->data[i + k1]; + + if (scf_vector_del(path1->pins, p) < 0) + return -1; + + if (scf_vector_add(path0->pins, p) < 0) + return -ENOMEM; + } + + return 0; +} + static int _topo_path_completes(ScfEfunction* f, scf_vector_t* paths) { if (!f || !paths) @@ -306,9 +338,11 @@ static int _topo_path_completes(ScfEfunction* f, scf_vector_t* paths) ScfEpin* p1; ScfEpin* p2; ScfEpin* p3; + ScfEpin* p; int i; int j; + int k; for (i = paths->size - 1; i >= 1; i--) { path0 = paths->data[i]; @@ -334,27 +368,56 @@ static int _topo_path_completes(ScfEfunction* f, scf_vector_t* paths) if (p2->lid != Bp->lid) continue; - if (p3->lid == p0->lid) - break; - } + if (p3->lid == Bn->lid) + continue; - 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 (k = path1->pins->size - 1; k >= 0; k -= 2) { + p = path1->pins->data[k]; - for (j = 0; j < path0->pins->size; j++) { - p0 = path0->pins->data[j]; + if (p->lid == p1->lid) + break; + } - if (scf_vector_add(path1->pins, p0) < 0) - return -ENOMEM; + if (k > 0) { + scf_loge("merge path: c%ldp%ld-c%ldp%ld ... c%ldp%ld-c%ldp%ld\n", + p2->cid, p2->id, p->cid, p->id, + p0->cid, p0->id, p1->cid, p1->id); + + int ret = __topo_path_xchg(path0, 0, path1, k + 1); + if (ret < 0) + return ret; + + if (path0->pins->size <= 0) { + scf_loge("free path0: %d\n", path0->index); + ses_path_free(path0); + path0 = NULL; + } + break; + } + + for (k = 0; k < path0->pins->size; k += 2) { + p = path0->pins->data[k]; + + if (p->lid == p3->lid) + break; } - if (scf_vector_del(paths, path0) < 0) - return -1; + if (k < path0->pins->size) { + 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, + p ->cid, p ->id, p1->cid, p1->id); - ses_path_free(path0); - path0 = NULL; + int ret = __topo_path_xchg(path0, k, path1, path1->pins->size); + if (ret < 0) + return ret; + + if (path0->pins->size <= 0) { + scf_loge("free path0: %d\n", path0->index); + ses_path_free(path0); + path0 = NULL; + } + break; + } } } diff --git a/ses_steps.c b/ses_steps.c index 204bbab..3797568 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -39,11 +39,11 @@ static ses_step_t* ses_steps_1[] = // &ses_step_simplify, &ses_step_topo, +#if 0 &ses_step_jr, &ses_step_va_diode, &ses_step_va_transistor, -#if 1 &ses_step_jr, &ses_step_va, &ses_step_va_bridge, -- 2.25.1