From: yu.dongliang <18588496441@163.com> Date: Thu, 19 Oct 2023 15:24:30 +0000 (+0800) Subject: ses_step_va_transistor.c X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=c0325921fa49e9beef3b4aeab8f8f8bdadefd82b;p=ses.git ses_step_va_transistor.c --- diff --git a/ses_layout.c b/ses_layout.c index 8171d5e..2dedeb1 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -230,7 +230,7 @@ next: el->c_pins = el->n_pins; el->id = i; - scf_logw("line i: %ld, %p, el->flags: %#lx\n", i, el, el->flags); + scf_logd("line i: %ld, %p, el->flags: %#lx\n", i, el, el->flags); for (j = 0; j + 1 < el->n_pins; j += 2) { @@ -240,9 +240,9 @@ next: p->lid = i; p->c_lid = i; - scf_logi("pin j: %ld, c%ldp%ld\n", j, el->pins[j], el->pins[j + 1]); + scf_logd("pin j: %ld, c%ldp%ld\n", j, el->pins[j], el->pins[j + 1]); } - printf("\n"); +// printf("\n"); i++; } diff --git a/ses_step_va_transistor.c b/ses_step_va_transistor.c index 26cde5b..66c38ff 100644 --- a/ses_step_va_transistor.c +++ b/ses_step_va_transistor.c @@ -18,10 +18,83 @@ void __ses_path_dr_transistor(ScfEfunction* f, ses_path_t* path, int i, int j) p->dr -= r; p->jdr -= jr; - scf_logi("c%ldp%ld, v: %lg, r: %lg, p->sr: %lg, p->a: %lg, p->dr: %lg\n", + scf_logd("c%ldp%ld, v: %lg, r: %lg, p->sr: %lg, p->a: %lg, p->dr: %lg\n", p->cid, p->id, v, r, p->sr, p->a, p->dr); } +static int __ses_status_check(ScfEcomponent* c, ScfEpin* pb, ScfEpin* pe, ScfEpin* Bn) +{ + if (pe->v < SCF_EDA_V_MIN) { + pe->v = pb->v - SCF_EDA_V_Diode_ON; + + if (pe->v < Bn->v) { + pe->v = Bn->v; + c->status = SCF_EDA_Status_OFF; + } else + c->status = SCF_EDA_Status_ON; + + scf_loge("c%ld, status: %d\n", c->id, c->status); + return 1; + + } else if (pb->v - pe->v < SCF_EDA_V_Diode_ON) { + + if (c->status != SCF_EDA_Status_OFF) { + c->status = SCF_EDA_Status_OFF; + scf_loge("c%ld, status: %d\n", c->id, c->status); + return 1; + } + } else if (SCF_EDA_Status_ON != c->status) { + c->status = SCF_EDA_Status_ON; + scf_loge("c%ld, status: %d\n", c->id, c->status); + return 1; + } + + return 0; +} + +static int __ses_status_change(ScfEfunction* f, ScfEline* el) +{ + ScfEcomponent* c; + ScfEcomponent* B; + ScfEpin* Bp; + ScfEpin* Bn; + ScfEpin* p; + ScfEpin* pe; + + size_t j; + int changed = 0; + + B = f->components[0]; + Bp = B->pins[SCF_EDA_Battery_POS]; + Bn = B->pins[SCF_EDA_Battery_NEG]; + + for (j = 0; j + 1 < el->n_pins; j += 2) { + + c = f->components[el->pins[j]]; + p = c->pins [el->pins[j + 1]]; + + p->v = el->v; + + if (SCF_EDA_NPN == c->type) { + if (SCF_EDA_NPN_B == p->id) { + + pe = c->pins[SCF_EDA_NPN_E]; + changed += __ses_status_check(c, p, pe, Bn); + } + + } else if (SCF_EDA_Diode == c->type) { + + if (SCF_EDA_Diode_POS == p->id) { + + pe = c->pins[SCF_EDA_Diode_NEG]; + changed += __ses_status_check(c, p, pe, Bn); + } + } + } + + return changed; +} + static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* changed) { ses_path_t* parent = path->parent; @@ -36,13 +109,7 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* chan ScfEpin* Bn; ScfEpin* p; - ScfEpin* pb; ScfEpin* pc; - ScfEpin* pe; - - int i; - int j; - int k; B = f->components[0]; Bp = B->pins[SCF_EDA_Battery_POS]; @@ -64,10 +131,11 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* chan p1->v = el->v; p1->jv = el->jv; + int i; + for (i = 0; i < path->pins->size - 1; i++) { pc = path->pins->data[i]; - el = f->elines [pc->lid]; c = f->components[pc->cid]; if (SCF_EDA_NPN != c->type) @@ -116,6 +184,7 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* chan pc->jv = Bp->jv - jv; } + el = f->elines[pc->lid]; el->v = pc->v; el->jv = pc->jv; el->a = pc->a; @@ -135,6 +204,8 @@ 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; diff --git a/ses_steps.c b/ses_steps.c index 203a479..92534ba 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -137,7 +137,8 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count) if (ret < 0) return ret; - while (1) { + int j; + for (j = 0; j < 2; j++) { ret = __ses_steps_analyse(f, ns, i, ctx); if (-EAGAIN == ret)