From f89a2ad0d962474f132fb06e0a46e15d13204000 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sun, 23 Jul 2023 18:27:06 +0800 Subject: [PATCH] ses_step_va.c --- ses_step_simplify.c | 1 + ses_step_va.c | 119 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 1 deletion(-) diff --git a/ses_step_simplify.c b/ses_step_simplify.c index 0bf922d..598380d 100644 --- a/ses_step_simplify.c +++ b/ses_step_simplify.c @@ -271,6 +271,7 @@ static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count) _simplify_draw(f, f->x, f->y, f->w, f->h); + printf("\n"); return 0; } diff --git a/ses_step_va.c b/ses_step_va.c index 3f21a46..cde11fd 100644 --- a/ses_step_va.c +++ b/ses_step_va.c @@ -1,8 +1,125 @@ #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) +{ + 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_va = { - .name = "va", + .name = "va", + + .handler = _va_handler, }; -- 2.25.1