From 688ca0434b6cb61c5c47b2acaa1257b17ebc1789 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 6 Sep 2023 15:36:04 +0800 Subject: [PATCH] ses_path_va_diode() --- ses_step_va_diode.c | 121 ++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 67 deletions(-) diff --git a/ses_step_va_diode.c b/ses_step_va_diode.c index bcc433c..727f9ff 100644 --- a/ses_step_va_diode.c +++ b/ses_step_va_diode.c @@ -1,15 +1,52 @@ #include"ses_core.h" -static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) +static void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, ScfEpin* p1, double* a, double* ja) { - if (!path) - return -EINVAL; + ses_path_t* child; + ScfEcomponent* c; + ScfEline* el; + ScfEpin* cp; + ScfEpin* cp0; + ScfEpin* cp1; - if (path->pins->size < 2) { - scf_loge("\n"); - return -EINVAL; + double v = p0->v - p1->v; + double jv = p0->jv - p1->jv; + + double r = p1->pr - p0->pr; + double jr = p1->jpr - p0->jpr; + + el = f->elines[p0->lid]; + + int j; + for (j = 0; j < path->childs->size; j++) { + child = path->childs->data[j]; + + cp0 = child->pins->data[0]; + cp1 = child->pins->data[child->pins->size - 1]; + + if (cp0->lid != p0->lid || cp1->lid != p1->lid) + continue; + + ses_split_i(&child->a, &child->ja, el->a, el->ja, child->r, child->jr, r, jr); + + *a -= child->a; + *ja -= child->ja; + + cp0->a = child->a; + cp0->ja = child->ja; + + double cr; + double jcr; + + ses_ui_r(&cr, &jcr, v, jv, child->a, child->ja); + + scf_loge("j: %d, c%ldp%ld, v: %lg + j%lg, child->r: %lg + j%lg, child->a: %lg + j%lg, cr: %lg + j%lg\n", j, cp0->cid, cp0->id, + v, jv, child->r, child->jr, child->a, child->ja, cr, jcr); } +} +static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) +{ ses_path_t* child; ScfEcomponent* c; ScfEline* el; @@ -17,9 +54,6 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) ScfEpin* p0; ScfEpin* p1; ScfEpin* p2; - ScfEpin* cp; - ScfEpin* cp0; - ScfEpin* cp1; int i; int j; @@ -43,8 +77,6 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) double r; double jr; - scf_logi("path->type: %d\n", path->type); - for (i = 0; i < path->pins->size; i++) { p = path->pins->data[i]; @@ -74,64 +106,16 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) el->ja = ja; el->aconst = 1; - scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, r: %lg + j%lg, el->a: %lg + j%lg\n\n", i, p->cid, p->id, - v, jv, p->v, p->jv, r, jr, el->a, el->ja); - - v = p->v - p1->v; - jv = p->jv - p1->jv; - - if (path->childs) { - for (j = 0; j < path->childs->size; j++) { - child = path->childs->data[j]; - - cp0 = child->pins->data[0]; - cp1 = child->pins->data[child->pins->size - 1]; - - if (cp0->lid != p->lid || cp1->lid != p1->lid) - continue; - - ses_split_i(&child->a, &child->ja, el->a, el->ja, child->r, child->jr, r, jr); - - a -= child->a; - ja -= child->ja; - - scf_loge("j: %d, c%ldp%ld, v: %lg + j%lg, child->r: %lg + j%lg, child->a: %lg + j%lg\n\n", j, cp0->cid, cp0->id, - v, jv, child->r, child->jr, child->a, child->ja); - - cp0->a = child->a; - cp0->ja = child->ja; - - double cr; - double jcr; - - ses_ui_r(&cr, &jcr, v, jv, child->a, child->ja); - - for (k = 0; k < child->pins->size; k++) { - cp = child->pins->data[k]; - - c = f->components[cp->cid]; - - if (SCF_EDA_Diode == c->type) { - cp->dr = cr - child->r; - cp->jdr = jcr - child->jr; - break; - } - } - } - } + if (path->childs) + __ses_path_split_i(f, path, p, p1, &a, &ja); p->a = a; p->ja = ja; - } else { - v = p->v - p1->v; - jv = p->jv - p1->jv; - - ses_ur_i(&a, &ja, v, jv, p1->pr - p->pr, p1->jpr - p->jpr); + scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, r: %lg + j%lg, p->a: %lg + j%lg\n", i, p->cid, p->id, + v, jv, p->v, p->jv, r, jr, p->a, p->ja); - el->a = a; - el->ja = ja; - el->aconst = 1; + } else { } } printf("\n"); @@ -139,7 +123,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) return 0; } -static int _ses_path_va_diode(ScfEfunction* f, ses_path_t* path) +static int ses_path_va_diode(ScfEfunction* f, ses_path_t* path) { ScfEcomponent* B; ScfEpin* p0; @@ -151,6 +135,9 @@ static int _ses_path_va_diode(ScfEfunction* f, ses_path_t* path) size_t j; size_t k; + if (!path) + return -EINVAL; + if (path->pins->size < 2) { scf_loge("\n"); return -EINVAL; @@ -173,7 +160,7 @@ static int _ses_path_va_diode(ScfEfunction* f, ses_path_t* path) if (path->childs) { for (j = 0; j < path->childs->size; j++) { - ret = _ses_path_va_diode(f, path->childs->data[j]); + ret = ses_path_va_diode(f, path->childs->data[j]); if (ret < 0) return ret; } @@ -193,7 +180,7 @@ static int _va_diode_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx scf_logi("i: %ld, path->type: %d\n", i, path->type); - int ret = _ses_path_va_diode(f, path); + int ret = ses_path_va_diode(f, path); if (ret < 0) return ret; -- 2.25.1