#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];
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)
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);
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);
}