From 23475ff28f40e296b943da09ffcc3e8aedc98f5b Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 25 Jul 2023 20:10:47 +0800 Subject: [PATCH] ses_step_topo.c --- Makefile | 2 + ses_step_topo.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++ ses_step_va.c | 97 ------------------------------------- ses_steps.c | 2 + 4 files changed, 128 insertions(+), 97 deletions(-) create mode 100644 ses_step_topo.c diff --git a/Makefile b/Makefile index cbd3363..5b3ab32 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,8 @@ CFILES += ses_step_dc_diode.c CFILES += ses_step_dc_transistor.c CFILES += ses_step_simplify.c +CFILES += ses_step_topo.c + CFILES += ses_step_va.c CFILES += ses_step_va_balance.c CFILES += ses_step_output.c diff --git a/ses_step_topo.c b/ses_step_topo.c new file mode 100644 index 0000000..618c6f0 --- /dev/null +++ b/ses_step_topo.c @@ -0,0 +1,124 @@ +#include"ses_core.h" + +static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp) +{ + ScfEcomponent* c; + ScfEline* el; + ScfEpin* np; + ScfEpin* p; + + size_t i; + size_t j; + + if (SCF_EDA_Status_OFF == rc->status) + return 0; + + if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id) + return 0; + + if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id) + return 0; + + rp->vflag = 1; + + scf_logi("c%ld_p%ld, l%ld\n", rc->id, rp->id, rp->lid); + + 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); + + el = f->elines[np->lid]; + + if (SCF_EDA_PIN_POS & el->flags) { + scf_loge("pos l%ld\n\n", el->id); + continue; + } + + if (SCF_EDA_PIN_NEG & el->flags) { + scf_loge("neg l%ld\n\n", el->id); + return 0; + } + + for (j = 0; j + 1 < el->n_pins; j += 2) { + + c = f->components[el->pins[j]]; + p = c->pins [el->pins[j + 1]]; + + if (p->vflag) + 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); + if (ret < 0) + return ret; + } + } + + return 0; +} + +static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) +{ + 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]; + el->vflag = 0; + } + + for (i = 0; i < f->n_components; i++) { + c = f->components[i]; + c->vflag = 0; + + for (j = 0; j < c->n_pins; j++) { + p = c->pins[j]; + p->vflag = 0; + } + } + + for (i = 0; i + 1 < elp->n_pins; i += 2) { + + c = f->components[elp->pins[i]]; + p = c->pins [elp->pins[i + 1]]; + + if (c == B) + continue; + + scf_loge("i: %ld\n", i); + + __dfs_route(f, c, p); + + printf("\n"); + } + + return 0; +} + +ses_step_t ses_step_topo = +{ + .name = "topo", + + .handler = _topo_handler, +}; diff --git a/ses_step_va.c b/ses_step_va.c index aa90f19..c5df06d 100644 --- a/ses_step_va.c +++ b/ses_step_va.c @@ -1,69 +1,5 @@ #include"ses_core.h" -static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp) -{ - ScfEcomponent* c; - ScfEline* el; - ScfEpin* np; - ScfEpin* p; - - size_t i; - size_t j; - - if (SCF_EDA_Status_OFF == rc->status) - return 0; - - if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id) - return 0; - - if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id) - return 0; - - rp->vflag = 1; - - scf_logi("c%ld_p%ld, l%ld\n", rc->id, rp->id, rp->lid); - - 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); - - el = f->elines[np->lid]; - - if (SCF_EDA_PIN_POS & el->flags) { - scf_loge("pos l%ld\n\n", el->id); - continue; - } - - if (SCF_EDA_PIN_NEG & el->flags) { - scf_loge("neg l%ld\n\n", el->id); - return 0; - } - - for (j = 0; j + 1 < el->n_pins; j += 2) { - - c = f->components[el->pins[j]]; - p = c->pins [el->pins[j + 1]]; - - if (p->vflag) - 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); - if (ret < 0) - return ret; - } - } - - return 0; -} - static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) { ScfEcomponent* c; @@ -80,39 +16,6 @@ static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ct 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]; - el->vflag = 0; - } - - for (i = 0; i < f->n_components; i++) { - c = f->components[i]; - c->vflag = 0; - - for (j = 0; j < c->n_pins; j++) { - p = c->pins[j]; - p->vflag = 0; - } - } - - for (i = 0; i + 1 < elp->n_pins; i += 2) { - - c = f->components[elp->pins[i]]; - p = c->pins [elp->pins[i + 1]]; - - if (c == B) - continue; - - scf_loge("i: %ld\n", i); - - __dfs_route(f, c, p); - - printf("\n"); - } - return 0; } diff --git a/ses_steps.c b/ses_steps.c index 7e19bb8..62a0b2b 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -12,6 +12,7 @@ extern ses_step_t ses_step_dc_transistor; //extern ses_step_t ses_step_ac_diode; extern ses_step_t ses_step_simplify; +extern ses_step_t ses_step_topo; extern ses_step_t ses_step_va; extern ses_step_t ses_step_va_balance; @@ -27,6 +28,7 @@ static ses_step_t* ses_steps[] = &ses_step_dc_transistor, &ses_step_simplify, + &ses_step_topo, &ses_step_va, &ses_step_va_balance, -- 2.25.1