From: yu.dongliang <18588496441@163.com> Date: Thu, 19 Oct 2023 12:28:08 +0000 (+0800) Subject: __ses_path_va_transistor() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=bb00ad38928459052f8a74a04efeeecc885c3fe8;p=ses.git __ses_path_va_transistor() --- diff --git a/ses_core.h b/ses_core.h index e19d6d9..a16ca8d 100644 --- a/ses_core.h +++ b/ses_core.h @@ -114,6 +114,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); static inline void vertical(int* px, int* py, int dx, int dy, int d) { diff --git a/ses_step_jr.c b/ses_step_jr.c index 22d785f..2ada725 100644 --- a/ses_step_jr.c +++ b/ses_step_jr.c @@ -1,5 +1,46 @@ #include"ses_core.h" +void __ses_path_sr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr) +{ + ScfEpin* p0 = path->pins->data[i]; + ScfEpin* p1 = path->pins->data[j]; + + ScfEcomponent* c0 = f->components[p0->cid]; + ScfEcomponent* c1 = f->components[p1->cid]; + + if (SCF_EDA_NPN == c1->type) { + + if (SCF_EDA_NPN_E == p1->id) { + if (cp1 != p1) + p1 = path->pins->data[j - 1]; + + } else if (j > 0) + p1 = path->pins->data[j - 1]; + else { + *r = 0; + *jr = 0; + return; + } + } + + if (SCF_EDA_NPN == c0->type) { + if (i > 0) { + p0 = path->pins->data[i - 1]; + + *r = p1->sr - p0->sr; + *jr = p1->jsr - p0->jsr; + } else { + *r = p1->sr; + *jr = p1->jsr; + } + } else { + *r = p1->sr - p0->sr; + *jr = p1->jsr - p0->jsr; + } + + scf_logd("c%ldp%ld-c%ldp%ld, r: %lg, p0->pr: %lg, p1->pr: %lg\n", p0->cid, p0->id, p1->cid, p1->id, *r, p0->sr, p1->sr); +} + void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr) { ScfEpin* p0 = path->pins->data[i]; diff --git a/ses_step_va_diode.c b/ses_step_va_diode.c index beeffae..a13d1b0 100644 --- a/ses_step_va_diode.c +++ b/ses_step_va_diode.c @@ -65,7 +65,7 @@ void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double cp0->a = ca; cp0->ja = cja; - c = f->components[cp1->lid]; + c = f->components[cp1->cid]; if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_E == cp1->id) p = child->pins->data[child->pins->size - 2]; diff --git a/ses_step_va_transistor.c b/ses_step_va_transistor.c index da3ecd7..57b7912 100644 --- a/ses_step_va_transistor.c +++ b/ses_step_va_transistor.c @@ -11,15 +11,15 @@ void __ses_path_dr_transistor(ScfEfunction* f, ses_path_t* path, int i, int j) double r; double jr; - __ses_path_pr(f, path, i, j, NULL, &r, &jr); + __ses_path_sr(f, path, i, j, NULL, &r, &jr); ses_ui_r(&p->dr, &p->jdr, v, jv, p->a, p->ja); - scf_logd("c%ldp%ld, v: %lg, r: %lg, p1->sr: %lg, p->sr: %lg, p->a: %lg, p->dr: %lg\n", - p->cid, p->id, v, r, p1->sr, p->sr, p->a, p->dr); - 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", + p->cid, p->id, v, r, p->sr, p->a, p->dr); } static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path) @@ -100,7 +100,7 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path) ses_ur_i(&pc->a, &pc->ja, v, jv, _pr, _jpr); - scf_logi("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, _pr: %lg pc->pr: %lg\n", + scf_logd("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, _pr: %lg pc->pr: %lg\n", i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, _pr, pc->pr); ses_ir_u(&v, &jv, pc->a, pc->ja, pr, jpr); @@ -113,24 +113,20 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path) el->jv = pc->jv; el->a = pc->a; el->ja = pc->ja; -#if 0 - p = path->pins->data[i - 1]; - p->v = el->v; - p->jv = el->jv; - p->a = el->a; - p->ja = el->ja; + scf_logw("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, pc->dr: %lg\n", + i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, pc->dr); if (path->childs) - __ses_path_split_i(f, path, 0, i, el->a, el->ja, &p->a, &p->ja); + __ses_path_split_i(f, path, i, path->pins->size - 1, el->a, el->ja, &pc->a, &pc->ja); else { p0->a = el->a; p0->ja = el->ja; } -#endif + __ses_path_dr_transistor(f, path, i, path->pins->size - 1); - scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, pc->dr: %lg\n", + 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); }