From: yu.dongliang <18588496441@163.com> Date: Mon, 23 Oct 2023 15:13:55 +0000 (+0800) Subject: __ses_path_va() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=3df2d6571f7a7150850211aa8b94c5a148bfd316;p=ses.git __ses_path_va() --- diff --git a/ses_core.h b/ses_core.h index 9985095..aa357f0 100644 --- a/ses_core.h +++ b/ses_core.h @@ -117,7 +117,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count); void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja); void __ses_path_pr (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr); void __ses_path_sr (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr); -int __ses_path_va (ScfEfunction* f, ses_path_t* path); +int __ses_path_va (ScfEfunction* f, ses_path_t* path, int *changed); int __ses_path_pos (ScfEfunction* f, ScfEline* el); int __ses_path_neg (ScfEfunction* f, ScfEline* el); diff --git a/ses_step_va.c b/ses_step_va.c index 1905e27..21bb464 100644 --- a/ses_step_va.c +++ b/ses_step_va.c @@ -2,7 +2,7 @@ int _ses_path_cmp(const void* v0, const void* v1); -static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja) +static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja, int* changed) { ses_path_t* child; @@ -67,7 +67,7 @@ static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* scf_loge("child: %d, c%ldp%ld, c%ldp%ld, p->v: %lg, el->v: %lg, _v: %lg\n", child->index, p->cid, p->id, p2->cid, p2->id, p->v, el->v, _v); - int ret = __ses_path_va(f, child); + int ret = __ses_path_va(f, child, changed); if (ret < 0) return ret; @@ -128,7 +128,7 @@ static int __ses_path_split_v(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, in return 0; } -int __ses_path_va(ScfEfunction* f, ses_path_t* path) +int __ses_path_va(ScfEfunction* f, ses_path_t* path, int* changed) { if (!path) return -EINVAL; @@ -187,7 +187,7 @@ int __ses_path_va(ScfEfunction* f, ses_path_t* path) if (ret < 0) return ret; - ret = __ses_path_split_a(f, path, i, &a, &ja); + ret = __ses_path_split_a(f, path, i, &a, &ja, changed); if (ret < 0) return ret; @@ -238,9 +238,25 @@ int __ses_path_va(ScfEfunction* f, ses_path_t* path) scf_loge("path: %d, i: %d, c%ldp%ld, p->v: %lg, dv: %lg, r: %lg, p->a: %lg, a: %lg, p->pr: %lg\n\n", path->index, i, p->cid, p->id, p->v, dv, r, p->a, a, p->pr); + if (SCF_EDA_Diode == c->type) { + + if (SCF_EDA_Diode_NEG == p->id) { + p2 = path->pins->data[i - 1]; + *changed += __ses_status_check(f, c, p2, p); + } + + } else if (SCF_EDA_NPN == c->type) { + + if (SCF_EDA_NPN_E == p->id) { + p2 = path->pins->data[i - 1]; + + if (SCF_EDA_NPN_B == p2->id) + *changed += __ses_status_check(f, c, p2, p); + } + } + r = 0; jr = 0; - } else { dv = p->v; jdv = p->jv; @@ -268,6 +284,7 @@ static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ct printf("\n*******************\n"); + int changed = 0; int i; for (i = 0; i < ctx->paths->size; i++) { @@ -286,14 +303,14 @@ static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ct if (p0->lid != Bp->lid || p1->lid != Bn->lid) continue; - int ret = __ses_path_va(f, path); + int ret = __ses_path_va(f, path, &changed); if (ret < 0) return ret; printf("\n"); } - return 0; + return changed > 0 ? -EAGAIN : 0; } ses_step_t ses_step_va = diff --git a/ses_step_va_bridge.c b/ses_step_va_bridge.c index 2354fa4..6cf80b9 100644 --- a/ses_step_va_bridge.c +++ b/ses_step_va_bridge.c @@ -37,10 +37,10 @@ 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); + 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]; @@ -65,7 +65,7 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed) } } } - +#endif return 0; } diff --git a/ses_steps.c b/ses_steps.c index 897dbc4..1416ff8 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -140,7 +140,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count) return ret; int j; - for (j = 0; j < 1; j++) { + for (j = 0; j < 3; j++) { ret = __ses_steps_analyse(f, ns, i, ctx); if (-EAGAIN == ret)