#include"ses_core.h"
+void __ses_npn_epr(ScfEfunction* f, ScfEpin* pe, double* r, double* jr)
+{
+ ScfEcomponent* c = f->components[pe->cid];
+ ScfEpin* pb = c->pins[SCF_EDA_NPN_B];
+ ScfEpin* pc = c->pins[SCF_EDA_NPN_C];
+
+ ses_merge_r(r, jr, pb->pr, pb->jpr, pc->pr, pc->jpr);
+}
+
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];
double r1 = 0;
double jr1 = 0;
+ scf_logd("c%ldp%ld-c%ldp%ld, p0->sr: %lg, p0->pr: %lg, p1->sr: %lg, p1->pr: %lg\n",
+ p0->cid, p0->id, p1->cid, p1->id, p0->sr, p0->pr, p1->sr, p1->pr);
+
if (SCF_EDA_NPN == c1->type) {
if (SCF_EDA_NPN_E == p1->id) {
p0 = path->pins->data[i - 1];
c0 = f->components[p0->cid];
+ double pr0 = p0->pr;
+ double jpr0 = p0->jpr;
+
if (SCF_EDA_NPN == c0->type && SCF_EDA_NPN_E == p0->id)
- p0 = path->pins->data[i - 2];
+ __ses_npn_epr(f, p0, &pr0, &jpr0);
- *r = p1->sr - r1 - p0->pr;
- *jr = p1->jsr - jr1 - p0->jpr;
+ *r = p1->sr - r1 - pr0;
+ *jr = p1->jsr - jr1 - jpr0;
} else {
*r = p1->sr;
*jr = p1->jsr;
ScfEcomponent* c0 = f->components[p0->cid];
ScfEcomponent* c1 = f->components[p1->cid];
+ scf_logd("c%ldp%ld-c%ldp%ld, p0->pr: %lg, p1->pr: %lg\n", p0->cid, p0->id, p1->cid, p1->id, p0->pr, p1->pr);
+
+ double pr1 = p1->pr;
+ double jpr1 = p1->jpr;
+
if (SCF_EDA_NPN == c1->type) {
if (SCF_EDA_NPN_E == p1->id) {
if (cp1 != p1)
p1 = path->pins->data[j - 1];
+ pr1 = p1->pr;
+ jpr1 = p1->jpr;
+
} else if (j > 0) {
p1 = path->pins->data[j - 1];
c1 = f->components[p1->cid];
+ pr1 = p1->pr;
+ jpr1 = p1->jpr;
+
if (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_E == p1->id)
- p1 = path->pins->data[j - 2];
+ __ses_npn_epr(f, p1, &pr1, &jpr1);
} else {
*r = 0;
*jr = 0;
if (SCF_EDA_NPN == c0->type) {
if (SCF_EDA_NPN_E == p0->id) {
- *r = p1->pr - p0->pr;
- *jr = p1->jpr - p0->jpr;
+ *r = pr1 - p0->pr;
+ *jr = jpr1 - p0->jpr;
} else if (i > 0) {
p0 = path->pins->data[i - 1];
c0 = f->components[p0->cid];
+ double pr0 = p0->pr;
+ double jpr0 = p0->jpr;
+
if (SCF_EDA_NPN == c0->type && SCF_EDA_NPN_E == p0->id)
- p0 = path->pins->data[i - 2];
+ __ses_npn_epr(f, p0, &pr0, &jpr0);
- *r = p1->pr - p0->pr;
- *jr = p1->jpr - p0->jpr;
+ *r = pr1 - pr0;
+ *jr = jpr1 - jpr0;
} else {
- *r = p1->pr;
- *jr = p1->jpr;
+ *r = pr1;
+ *jr = jpr1;
}
} else {
- *r = p1->pr - p0->pr;
- *jr = p1->jpr - p0->jpr;
+ *r = pr1 - p0->pr;
+ *jr = jpr1 - p0->jpr;
}
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->pr, p1->pr);
}
p->dr -= r;
p->jdr -= jr;
- scf_logd("c%ldp%ld--c%ldp%ld, v: %lg, r: %lg, p->sr: %lg, p->a: %lg, p->dr: %lg\n",
+ scf_logi("c%ldp%ld--c%ldp%ld, v: %lg, r: %lg, p->sr: %lg, p->a: %lg, p->dr: %lg\n",
p->cid, p->id, p1->cid, p1->id, v, r, p->sr, p->a, p->dr);
}
pc->v = Bp->v - v;
pc->jv = Bp->jv - jv;
- 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",
+ 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",
i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, _pr, pc->pr);
}