From b281d87b67d3cc9ae9f4f39cfd322397f9b6fac1 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 26 Jul 2023 23:07:50 +0800 Subject: [PATCH] branch path --- ses_step_topo.c | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/ses_step_topo.c b/ses_step_topo.c index 257d82a..3209591 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -1,9 +1,8 @@ #include"ses_core.h" -static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, scf_vector_t** ppath) +static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, ses_path_t** ppath) { - scf_vector_t* path = *ppath; - + ses_path_t* path = *ppath; ScfEcomponent* c; ScfEline* el; ScfEpin* np; @@ -22,14 +21,14 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t return SCF_EDA_Path_OFF; if (!path) { - path = scf_vector_alloc(); + path = ses_path_alloc(); if (!path) return -ENOMEM; *ppath = path; } - if (scf_vector_add(path, rp) < 0) + if (scf_vector_add(path->pins, rp) < 0) return -ENOMEM; if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != rp->id) @@ -57,7 +56,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t continue; } - if (scf_vector_add(path, np) < 0) + if (scf_vector_add(path->pins, np) < 0) return -ENOMEM; if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != np->id) @@ -69,8 +68,10 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t if (scf_vector_add(ctx->paths, path) < 0) return -ENOMEM; - for (j = 0; j < path->size; j++) { - p = path->data[j]; + path->type = SES_PATH_MAIN; + + for (j = 0; j < path->pins->size; j++) { + p = path->pins->data[j]; p->pflag = 1; } @@ -109,7 +110,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t if (ret > 0) { if (*ppath) - scf_vector_del(*ppath, np); + scf_vector_del((*ppath)->pins, np); if (SCF_EDA_Path_OFF == ret) np->vflag = 0; @@ -118,7 +119,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t if (ret > 0) { if (*ppath) - scf_vector_del(*ppath, rp); + scf_vector_del((*ppath)->pins, rp); if (SCF_EDA_Path_OFF == ret) { rp->vflag = 0; @@ -135,24 +136,14 @@ end: static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) { - scf_vector_t* path; - + ses_path_t* path; ScfEcomponent* c; ScfEcomponent* B; ScfEline* el; - ScfEline* el2; - ScfEline* elp; - ScfEline* eln; ScfEpin* p; size_t i; size_t j; - size_t k; - - B = f->components[0]; - - elp = f->elines[B->pins[SCF_EDA_Battery_POS]->lid]; - eln = f->elines[B->pins[SCF_EDA_Battery_NEG]->lid]; for (i = 0; i < f->n_elines; i++) { el = f->elines[i]; @@ -166,15 +157,18 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* for (j = 0; j < c->n_pins; j++) { p = c->pins[j]; p->vflag = 0; + p->pflag = 0; } } + B = f->components[0]; + el = f->elines[B->pins[SCF_EDA_Battery_POS]->lid]; path = NULL; - for (i = 0; i + 1 < elp->n_pins; i += 2) { + for (i = 0; i + 1 < el->n_pins; i += 2) { - c = f->components[elp->pins[i]]; - p = c->pins [elp->pins[i + 1]]; + c = f->components[el->pins[i]]; + p = c->pins [el->pins[i + 1]]; if (c == B) continue; @@ -191,20 +185,22 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* continue; if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) { - scf_vector_clear(path, NULL); + ses_path_free(path); + path = NULL; continue; } if (scf_vector_add(ctx->paths, path) < 0) { - scf_vector_free(path); + ses_path_free(path); return -ENOMEM; } - path = NULL; + path->type = SES_PATH_BRANCH; + path = NULL; } if (path) { - scf_vector_free(path); + ses_path_free(path); path = NULL; } @@ -212,8 +208,10 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* for (i = 0; i < ctx->paths->size; i++) { path = ctx->paths->data[i]; - for (j = 0; j < path->size; j++) { - p = path->data[j]; + scf_logi("i: %ld, path->type: %d\n", i, path->type); + + for (j = 0; j < path->pins->size; j++) { + p = path->pins->data[j]; scf_logi("i: %ld, j: %ld, c%ldp%ld\n", i, j, p->cid, p->id); } -- 2.25.1