#include"ses_core.h"
+void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, 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_Transistor == c1->type && SCF_EDA_Transistor_E == p1->id)
+ p1 = path->pins->data[j - 1];
+
+ if (SCF_EDA_Transistor == c0->type) {
+ if (i > 0) {
+ p0 = path->pins->data[i - 1];
+
+ *r = p1->pr - p0->pr;
+ *jr = p1->jpr - p0->jpr;
+ } else {
+ *r = p1->pr;
+ *jr = p1->jpr;
+ }
+ } else {
+ *r = p1->pr - p0->pr;
+ *jr = p1->jpr - p0->jpr;
+ }
+}
+
static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
{
if (!path)
ses_path_t* child;
ScfEcomponent* c;
+ ScfEcomponent* c1;
ScfEpin* p;
ScfEpin* p0;
ScfEpin* p1;
p0 = NULL;
p1 = NULL;
+ int k0;
+ int k1;
+
for (j = 0; j < path->pins->size; j++) {
p = path->pins->data[j];
if (p->lid == cp0->lid) {
p0 = p;
+ k0 = j;
break;
}
}
if (p->lid == cp1->lid) {
p1 = p;
+ k1 = j;
break;
}
}
double _r = child->r / R;
double _jr = -child->jr / R;
- c = f->components[p1->cid];
-
- if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_E == p1->id) {
- p = path->pins->data[j - 1];
-
- r = p->pr - p0->pr;
- jr = p->jpr - p0->jpr;
- } else {
- r = p1->pr - p0->pr;
- jr = p1->jpr - p0->jpr;
- }
+ __ses_path_pr(f, path, k0, k1, &r, &jr);
R = r * r + jr * jr;
r = r / R;
p = path->pins->data[j - 1];
p->pr -= dr;
p->jpr -= jdr;
+
+ scf_logw("j: %d, c%ldp%ld, p->pr: %lg + j%lg, p->sr: %lg + j%lg, dr: %lg + j%lg\n", j, p->cid, p->id, p->pr, p->jpr, p->sr, p->jsr, dr, jdr);
}
scf_logw("j: %d, c%ldp%ld, p->pr: %lg + j%lg, p->sr: %lg + j%lg, dr: %lg + j%lg\n", j, p1->cid, p1->id, p1->pr, p1->jpr, p1->sr, p1->jsr, dr, jdr);
#include"ses_core.h"
-void __ses_path_split_i(ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja)
+void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja)
{
+ ScfEcomponent* c;
ses_path_t* child;
ScfEpin* cp0;
ScfEpin* cp1;
+ ScfEpin* p;
ScfEpin* p0 = path->pins->data[i];
ScfEpin* p1 = path->pins->data[j];
double v = p0->v - p1->v;
double jv = p0->jv - p1->jv;
- double r = p1->pr - p0->pr;
- double jr = p1->jpr - p0->jpr;
+ double r;
+ double jr;
- scf_loge("c%ldp%ld--c%ldp%ld, r: %lg, p1->pr: %lg, p0->pr: %lg, p1->sr: %lg, p0->sr: %lg\n",
- p0->cid, p0->id, p1->cid, p1->id, r, p1->pr, p0->pr, p1->sr, p0->sr);
+ __ses_path_pr(f, path, i, j, &r, &jr);
+
+ scf_loge("c%ldp%ld--c%ldp%ld, r: %lg, p0->pr: %lg, p0->sr: %lg\n",
+ p0->cid, p0->id, p1->cid, p1->id, r, p0->pr, p0->sr);
int k;
for (k = 0; k < path->childs->size; k++) {
*a -= child->a;
*ja -= child->ja;
- cp1->a = child->a;
- cp1->ja = child->ja;
-
cp1->v = p1->v;
cp1->jv = p1->jv;
cp0->v = p0->v;
cp0->jv = p0->jv;
+ double ca = child->a;
+ double cja = child->ja;
+
if (child->childs)
- __ses_path_split_i(child, 0, child->pins->size - 1, child->a, child->ja, &cp1->a, &cp1->ja);
+ __ses_path_split_i(f, child, 0, child->pins->size - 1, child->a, child->ja, &ca, &cja);
+
+ cp0->a = ca;
+ cp0->ja = cja;
+
+ c = f->components[cp1->lid];
- cp0->a = cp1->a;
- cp0->ja = cp1->ja;
+ if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_E == cp1->id)
+ p = child->pins->data[child->pins->size - 2];
+ else
+ p = cp1;
- double cr;
- double jcr;
+ ses_ui_r(&p->dr, &p->jdr, v, jv, ca, cja);
- ses_ui_r(&cp1->dr, &cp1->jdr, v, jv, cp1->a, cp1->ja);
+ p->dr -= p->sr;
+ p->jdr -= p->jsr;
- cp1->dr -= cp1->sr;
- cp1->jdr -= cp1->jsr;
+ p->a = ca;
+ p->ja = cja;
scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, child->r: %lg, r: %lg, cp1->a: %lg, el->a: %lg, cp1->dr: %lg\n",
- j, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->r, r, cp1->a, la, cp1->dr);
+ j, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->r, r, p->a, la, p->dr);
}
}
pj->ja = ja;
if (path->childs)
- __ses_path_split_i(path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
+ __ses_path_split_i(f, path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, pj->v: %lg, pj->a: %lg, pr: %lg, sr: %lg\n\n",
j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr);
j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr);
if (path->childs)
- __ses_path_split_i(path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
+ __ses_path_split_i(f, path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, pj->v: %lg, pj->a: %lg, pr: %lg, sr: %lg\n\n",
j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr);
pi->ja = ja;
if (path->childs)
- __ses_path_split_i(path, 0, i, a, ja, &pi->a, &pi->ja);
+ __ses_path_split_i(f, path, 0, i, a, ja, &pi->a, &pi->ja);
__ses_path_dr_reverse(f, path, 0, i, pi->n_diodes, pi->a, pi->ja);
pi->ja = ja;
if (path->childs)
- __ses_path_split_i(path, 0, i, a, ja, &pi->a, &pi->ja);
+ __ses_path_split_i(f, path, 0, i, a, ja, &pi->a, &pi->ja);
p = c->pins[SCF_EDA_Transistor_B];