From: yu.dongliang <18588496441@163.com> Date: Tue, 25 Jul 2023 14:06:54 +0000 (+0800) Subject: ses path X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=f09d620bf84b218b346363b619a58be8738ec132;p=ses.git ses path --- diff --git a/scf_eda_pb.h b/scf_eda_pb.h index 55f6029..e4aff68 100644 --- a/scf_eda_pb.h +++ b/scf_eda_pb.h @@ -42,6 +42,7 @@ enum { enum { SCF_EDA_Status_ON, SCF_EDA_Status_OFF, + SCF_EDA_Path_OFF, }; enum { diff --git a/ses_step_topo.c b/ses_step_topo.c index 618c6f0..cc0e5fd 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -1,7 +1,9 @@ #include"ses_core.h" -static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp) +static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, scf_vector_t** ppath) { + scf_vector_t* path = *ppath; + ScfEcomponent* c; ScfEline* el; ScfEpin* np; @@ -11,24 +13,35 @@ static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp) size_t j; if (SCF_EDA_Status_OFF == rc->status) - return 0; + return SCF_EDA_Status_OFF; if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id) - return 0; + return SCF_EDA_Path_OFF; if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id) - return 0; + return SCF_EDA_Path_OFF; + + if (!path) { + path = scf_vector_alloc(); + if (!path) + return -ENOMEM; + + *ppath = path; + } + if (scf_vector_add(path, rp) < 0) + return -ENOMEM; rp->vflag = 1; scf_logi("c%ld_p%ld, l%ld\n", rc->id, rp->id, rp->lid); + int ret = 0; + for (i = 0; i < rc->n_pins; i++) { np = rc->pins[i]; if (np->vflag) continue; - np->vflag = 1; scf_logi("c%ld_p%ld, l%ld\n", rc->id, np->id, np->lid); @@ -36,14 +49,28 @@ static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp) if (SCF_EDA_PIN_POS & el->flags) { scf_loge("pos l%ld\n\n", el->id); + + ret = SCF_EDA_Path_OFF; + np->vflag = 1; continue; } + if (scf_vector_add(path, np) < 0) + return -ENOMEM; + np->vflag = 1; + if (SCF_EDA_PIN_NEG & el->flags) { scf_loge("neg l%ld\n\n", el->id); + + if (scf_vector_add(ctx->paths, path) < 0) + return -ENOMEM; + + *ppath = NULL; return 0; } + ret = 0; + for (j = 0; j + 1 < el->n_pins; j += 2) { c = f->components[el->pins[j]]; @@ -53,19 +80,50 @@ static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp) continue; p->vflag = 1; -// scf_logi("c%ld_p%ld, l%ld\n", c->id, p->id, p->lid); - - int ret = __dfs_route(f, c, p); + ret = __dfs_path(f, c, p, ctx, ppath); if (ret < 0) return ret; + + if (SCF_EDA_Status_OFF == ret) + scf_loge("off: c%ld_p%ld, l%ld\n", p->cid, p->id, p->lid); + else if (SCF_EDA_Path_OFF == ret) { + p->vflag = 0; + scf_logw("off: c%ld_p%ld, l%ld\n", p->cid, p->id, p->lid); + } + } + + if (ret > 0) { + if (*ppath) + scf_vector_del(*ppath, np); + + if (SCF_EDA_Status_OFF == ret) + scf_loge("off: c%ld_p%ld, l%ld, *ppath: %p\n", np->cid, np->id, np->lid, *ppath); + else if (SCF_EDA_Path_OFF == ret) { + np->vflag = 0; + scf_logw("off: c%ld_p%ld, l%ld\n", np->cid, np->id, np->lid); + } } } - return 0; + if (ret > 0) { + if (*ppath) + scf_vector_del(*ppath, rp); + + if (SCF_EDA_Status_OFF == ret) + scf_loge("off: c%ld_p%ld, l%ld\n", rp->cid, rp->id, rp->lid); + else if (SCF_EDA_Path_OFF == ret) { + rp->vflag = 0; + scf_logw("off: c%ld_p%ld, l%ld\n", rp->cid, rp->id, rp->lid); + } + } + + return ret; } static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) { + scf_vector_t* path; + ScfEcomponent* c; ScfEcomponent* B; ScfEline* el; @@ -98,6 +156,8 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* } } + path = NULL; + for (i = 0; i + 1 < elp->n_pins; i += 2) { c = f->components[elp->pins[i]]; @@ -106,13 +166,25 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* if (c == B) continue; - scf_loge("i: %ld\n", i); + scf_logw("i: %ld\n", i); - __dfs_route(f, c, p); + __dfs_path(f, c, p, ctx, &path); printf("\n"); } +#if 1 + 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, j: %ld, c%ldp%ld\n", i, j, p->cid, p->id); + } + + printf("\n"); + } +#endif return 0; }