int _ses_path_cmp(const void* v0, const void* v1);
+static int __ses_path_va(ScfEfunction* f, ses_path_t* path);
+
+static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja)
+{
+ ses_path_t* child;
+ ScfEline* el;
+ ScfEpin* p;
+ ScfEpin* p2;
+ ScfEpin* cp0;
+ ScfEpin* cp1;
+
+ int j;
+ int k;
+
+ p = path->pins->data[i];
+
+ for (j = 0; j < path->childs->size; j++) {
+ child = path->childs->data[j];
+
+ cp0 = child->pins->data[0];
+ cp1 = child->pins->data[child->pins->size - 1];
+
+ if (p->lid != cp0->lid)
+ continue;
+
+ for (k = i + 1; k < path->pins->size; k++) {
+ p2 = path->pins->data[k];
+
+ if (p2->lid == cp1->lid)
+ break;
+ }
+
+ if (k >= path->pins->size) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ double _r = p2->pr - p->pr;
+ double _jr = p2->jpr - p->jpr;
+
+ double _v = 0;
+ double _jv = 0;
+ double _a = 0;
+ double _ja = 0;
+
+ ses_ir_u(&_v, &_jv, *a, *ja, _r, _jr);
+
+ scf_logw("child: %d, c%ldp%ld, c%ldp%ld, _v: %lg + j%lg, a: %lg + j%lg, _r: %lg + j%lg, p->pr: %lg + j%lg, p->dr: %lg + j%lg, p2->pr: %lg + j%lg\n",
+ child->index, p->cid, p->id, p2->cid, p2->id, _v, _jv, *a, *ja, _r, _jr, p->pr, p->jpr, p->dr, p->jdr, p2->pr, p2->jpr);
+
+ ses_ur_i(&_a, &_ja, _v, _jv, child->r, child->jr);
+
+ *a -= _a;
+ *ja -= _ja;
+
+ el = f->elines[p2->lid];
+ el->v = p->v - _v;
+ el->jv = p->jv - _jv;
+
+ scf_loge("child: %d, c%ldp%ld, c%ldp%ld, p->v: %lg + j%lg, el->v: %lg + j%lg, _v: %lg + j%lg\n",
+ child->index, p->cid, p->id, p2->cid, p2->id, p->v, p->jv, el->v, el->jv, _v, _jv);
+
+ int ret = __ses_path_va(f, child);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int __ses_path_split_v(ScfEfunction* f, ses_path_t* path, int i, double a, double ja)
+{
+ ScfEpin* p2;
+ ScfEpin* p0 = path->pins->data[0];
+ ScfEpin* p = path->pins->data[i];
+
+ ScfEcomponent* c = f->components[p->cid];
+ double v = 0;
+ double jv = 0;
+
+ if (SCF_EDA_Transistor == c->type) {
+
+ if (SCF_EDA_Transistor_B == p->id || SCF_EDA_Transistor_C == p->id)
+ ses_ir_u(&v, &jv, a, ja, p->sr - (p->r + p->dr), p->jsr - (p->jr + p->jdr));
+
+ else if (i >= 1) {
+ p2 = path->pins->data[i - 1];
+
+ ses_ir_u(&v, &jv, a, ja, p2->sr, p2->jsr);
+ } else
+ return -EINVAL;
+
+ } else
+ ses_ir_u(&v, &jv, a, ja, p->sr, p->jsr);
+
+ p->v = p0->v - v;
+ p->jv = p0->jv - jv;
+
+ return 0;
+}
+
static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
{
if (!path)
p = path->pins->data[i];
if (!(i & 0x1) && path->childs) {
- for (j = 0; j < path->childs->size; j++) {
- child = path->childs->data[j];
-
- cp0 = child->pins->data[0];
- cp1 = child->pins->data[child->pins->size - 1];
-
- if (p->lid != cp0->lid)
- continue;
-
- for (k = i + 1; k < path->pins->size; k++) {
- p2 = path->pins->data[k];
-
- if (p2->lid == cp1->lid)
- break;
- }
-
- if (k >= path->pins->size)
- return -EINVAL;
- double _r = p2->pr - p->pr;
- double _jr = p2->jpr - p->jpr;
-
- double _v = 0;
- double _jv = 0;
- double _a = 0;
- double _ja = 0;
-
- ses_ir_u(&_v, &_jv, a, ja, _r, _jr);
-
- scf_logw("child: %d, c%ldp%ld, c%ldp%ld, _v: %lg + j%lg, a: %lg + j%lg, _r: %lg + j%lg, p->pr: %lg + j%lg, p->dr: %lg + j%lg, p2->pr: %lg + j%lg\n",
- child->index, p->cid, p->id, p2->cid, p2->id, _v, _jv, a, ja, _r, _jr, p->pr, p->jpr, p->dr, p->jdr, p2->pr, p2->jpr);
-
- ses_ur_i(&_a, &_ja, _v, _jv, child->r, child->jr);
-
- a -= _a;
- ja -= _ja;
-
- el = f->elines[p2->lid];
- el->v = p->v - _v;
- el->jv = p->jv - _jv;
-
- scf_loge("child: %d, c%ldp%ld, c%ldp%ld, p->v: %lg + j%lg, el->v: %lg + j%lg, _v: %lg + j%lg\n",
- child->index, p->cid, p->id, p2->cid, p2->id, p->v, p->jv, el->v, el->jv, _v, _jv);
-
- int ret = __ses_path_va(f, child);
- if (ret < 0)
- return ret;
- }
+ int ret = __ses_path_split_a(f, path, i, &a, &ja);
+ if (ret < 0)
+ return ret;
}
- c = f->components[p->cid];
-
- if (SCF_EDA_Transistor == c->type) {
-
- if (SCF_EDA_Transistor_B == p->id || SCF_EDA_Transistor_C == p->id)
- ses_ir_u(&v, &jv, a, ja, p->sr - (p->r + p->dr), p->jsr - (p->jr + p->jdr));
- else {
- if (i < 1) {
- scf_loge("\n");
- return -EINVAL;
- }
-
- p2 = path->pins->data[i - 1];
-
- ses_ir_u(&v, &jv, a, ja, p2->sr, p2->jsr);
- }
- } else
- ses_ir_u(&v, &jv, a, ja, p->sr, p->jsr);
-
- p->v = p0->v - v;
- p->jv = p0->jv - jv;
+ int ret = __ses_path_split_v(f, path, i, a, ja);
+ if (ret < 0)
+ return ret;
el = f->elines[p->lid];
el->v = p->v;
jr += p->jr + p->jdr;
if (i & 0x1) {
+ c = f->components[p->cid];
r += c->r;
jr += c->jr;