From 393ef8b63610fae0a0d1c697c90bfbe7e9499b25 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 24 Oct 2023 14:45:15 +0800 Subject: [PATCH] ses_path_va_transistor() --- ses_step_dc_transistor.c | 6 ++++-- ses_step_va_bridge.c | 31 +------------------------------ ses_step_va_transistor.c | 21 ++++++++++----------- ses_steps.c | 5 +++-- 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/ses_step_dc_transistor.c b/ses_step_dc_transistor.c index 6bcba87..f9a2b3c 100644 --- a/ses_step_dc_transistor.c +++ b/ses_step_dc_transistor.c @@ -83,10 +83,12 @@ static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se pe->v = le->v; c->status = SCF_EDA_Status_ON; - } else + } else { c->status = SCF_EDA_Status_OFF; - scf_loge("NPN c%ld, status: %d\n", c->id, c->status); + scf_logi("NPN c%ld, status: %d, lb->v: %lg, le->v: %lg\n", c->id, c->status, lb->v, le->v); + } + scf_loge("\033[34mNPN c%ld, status: %d\033[0m\n", c->id, c->status); } return 0; diff --git a/ses_step_va_bridge.c b/ses_step_va_bridge.c index 6cf80b9..aad2201 100644 --- a/ses_step_va_bridge.c +++ b/ses_step_va_bridge.c @@ -37,36 +37,7 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed) scf_logw("path: %d, c%ldp%ld--c%ldp%ld, v: %lg, p0->v: %lg, p1->v: %lg, n_diodes: %d\n", path->index, p0->cid, p0->id, p1->cid, p1->id, v, p0->v, p1->v, path->n_diodes); - int ret = __ses_path_va(f, path, changed); - if (ret < 0) - return ret; -#if 0 - B = f->components[0]; - Bn = B->pins[SCF_EDA_Battery_NEG]; - - for (i = 0; i < path->pins->size; i++) { - p0 = path->pins->data[i]; - - c = f->components[p0->cid]; - - if (SCF_EDA_NPN == c->type) { - if (SCF_EDA_NPN_B == p0->id) { - - p1 = c->pins[SCF_EDA_NPN_E]; - *changed += __ses_status_check(f, c, p0, p1); - } - - } else if (SCF_EDA_Diode == c->type) { - - if (SCF_EDA_Diode_POS == p0->id) { - - p1 = c->pins[SCF_EDA_Diode_NEG]; - *changed += __ses_status_check(f, c, p0, p1); - } - } - } -#endif - return 0; + return __ses_path_va(f, path, changed); } static int ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed) diff --git a/ses_step_va_transistor.c b/ses_step_va_transistor.c index b836195..11d7b6a 100644 --- a/ses_step_va_transistor.c +++ b/ses_step_va_transistor.c @@ -80,8 +80,10 @@ int __ses_status_check(ScfEfunction* f, ScfEcomponent* c, ScfEpin* pb, ScfEpin* _changed: if (SCF_EDA_NPN == c->type) { - p2 = c->pins[SCF_EDA_NPN_C]; - el = f->elines[p2->lid]; + + p2 = c->pins [SCF_EDA_NPN_C]; + el = f->elines[p2->lid]; + el->v = SCF_EDA_V_INIT; for (i = 0; i + 1 < el->n_pins; i += 2) { @@ -141,7 +143,7 @@ static int __ses_status_change(ScfEfunction* f, ScfEline* el) return changed; } -static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* changed) +static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path) { ses_path_t* parent = path->parent; ses_path_t* child; @@ -250,14 +252,12 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* chan scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, pc->dr: %lg\n\n", i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, pc->dr); - - *changed += __ses_status_change(f, el); } return 0; } -static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* changed) +static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path) { ses_path_t* child; ScfEcomponent* B; @@ -285,7 +285,7 @@ static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* change p0 = path->pins->data[0]; p1 = path->pins->data[path->pins->size - 1]; - int ret = __ses_path_va_transistor(f, path, changed); + int ret = __ses_path_va_transistor(f, path); if (ret < 0) return ret; @@ -293,7 +293,7 @@ static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* change for (j = 0; j < path->childs->size; j++) { child = path->childs->data[j]; - ret = ses_path_va_transistor(f, child, changed); + ret = ses_path_va_transistor(f, child); if (ret < 0) return ret; } @@ -306,7 +306,6 @@ static int _va_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se { ses_path_t* path; - int changed = 0; int i; for (i = 0; i < ctx->paths->size; i++) { @@ -314,14 +313,14 @@ static int _va_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se scf_logi("i: %d, path->index: %d\n", i, path->index); - int ret = ses_path_va_transistor(f, path, &changed); + int ret = ses_path_va_transistor(f, path); if (ret < 0) return ret; printf("\n"); } - return changed > 0 ? -EAGAIN : 0; + return 0; } ses_step_t ses_step_va_transistor = diff --git a/ses_steps.c b/ses_steps.c index 1416ff8..31bd711 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -30,11 +30,12 @@ static ses_step_t* ses_steps_0[] = &ses_step_dc_input, &ses_step_dc_diode, - &ses_step_dc_transistor, }; static ses_step_t* ses_steps_1[] = { + &ses_step_dc_transistor, + &ses_step_simplify, &ses_step_topo, @@ -140,7 +141,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count) return ret; int j; - for (j = 0; j < 3; j++) { + for (j = 0; j < 2; j++) { ret = __ses_steps_analyse(f, ns, i, ctx); if (-EAGAIN == ret) -- 2.25.1