#include"ses_core.h"
-static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
+static void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, ScfEpin* p1, double* a, double* ja)
{
- if (!path)
- return -EINVAL;
+ ses_path_t* child;
+ ScfEcomponent* c;
+ ScfEline* el;
+ ScfEpin* cp;
+ ScfEpin* cp0;
+ ScfEpin* cp1;
- if (path->pins->size < 2) {
- scf_loge("\n");
- return -EINVAL;
+ double v = p0->v - p1->v;
+ double jv = p0->jv - p1->jv;
+
+ double r = p1->pr - p0->pr;
+ double jr = p1->jpr - p0->jpr;
+
+ el = f->elines[p0->lid];
+
+ int j;
+ 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 (cp0->lid != p0->lid || cp1->lid != p1->lid)
+ continue;
+
+ ses_split_i(&child->a, &child->ja, el->a, el->ja, child->r, child->jr, r, jr);
+
+ *a -= child->a;
+ *ja -= child->ja;
+
+ cp0->a = child->a;
+ cp0->ja = child->ja;
+
+ double cr;
+ double jcr;
+
+ ses_ui_r(&cr, &jcr, v, jv, child->a, child->ja);
+
+ scf_loge("j: %d, c%ldp%ld, v: %lg + j%lg, child->r: %lg + j%lg, child->a: %lg + j%lg, cr: %lg + j%lg\n", j, cp0->cid, cp0->id,
+ v, jv, child->r, child->jr, child->a, child->ja, cr, jcr);
}
+}
+static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
+{
ses_path_t* child;
ScfEcomponent* c;
ScfEline* el;
ScfEpin* p0;
ScfEpin* p1;
ScfEpin* p2;
- ScfEpin* cp;
- ScfEpin* cp0;
- ScfEpin* cp1;
int i;
int j;
double r;
double jr;
- scf_logi("path->type: %d\n", path->type);
-
for (i = 0; i < path->pins->size; i++) {
p = path->pins->data[i];
el->ja = ja;
el->aconst = 1;
- scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, r: %lg + j%lg, el->a: %lg + j%lg\n\n", i, p->cid, p->id,
- v, jv, p->v, p->jv, r, jr, el->a, el->ja);
-
- v = p->v - p1->v;
- jv = p->jv - p1->jv;
-
- if (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 (cp0->lid != p->lid || cp1->lid != p1->lid)
- continue;
-
- ses_split_i(&child->a, &child->ja, el->a, el->ja, child->r, child->jr, r, jr);
-
- a -= child->a;
- ja -= child->ja;
-
- scf_loge("j: %d, c%ldp%ld, v: %lg + j%lg, child->r: %lg + j%lg, child->a: %lg + j%lg\n\n", j, cp0->cid, cp0->id,
- v, jv, child->r, child->jr, child->a, child->ja);
-
- cp0->a = child->a;
- cp0->ja = child->ja;
-
- double cr;
- double jcr;
-
- ses_ui_r(&cr, &jcr, v, jv, child->a, child->ja);
-
- for (k = 0; k < child->pins->size; k++) {
- cp = child->pins->data[k];
-
- c = f->components[cp->cid];
-
- if (SCF_EDA_Diode == c->type) {
- cp->dr = cr - child->r;
- cp->jdr = jcr - child->jr;
- break;
- }
- }
- }
- }
+ if (path->childs)
+ __ses_path_split_i(f, path, p, p1, &a, &ja);
p->a = a;
p->ja = ja;
- } else {
- v = p->v - p1->v;
- jv = p->jv - p1->jv;
-
- ses_ur_i(&a, &ja, v, jv, p1->pr - p->pr, p1->jpr - p->jpr);
+ scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, r: %lg + j%lg, p->a: %lg + j%lg\n", i, p->cid, p->id,
+ v, jv, p->v, p->jv, r, jr, p->a, p->ja);
- el->a = a;
- el->ja = ja;
- el->aconst = 1;
+ } else {
}
}
printf("\n");
return 0;
}
-static int _ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
+static int ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
{
ScfEcomponent* B;
ScfEpin* p0;
size_t j;
size_t k;
+ if (!path)
+ return -EINVAL;
+
if (path->pins->size < 2) {
scf_loge("\n");
return -EINVAL;
if (path->childs) {
for (j = 0; j < path->childs->size; j++) {
- ret = _ses_path_va_diode(f, path->childs->data[j]);
+ ret = ses_path_va_diode(f, path->childs->data[j]);
if (ret < 0)
return ret;
}
scf_logi("i: %ld, path->type: %d\n", i, path->type);
- int ret = _ses_path_va_diode(f, path);
+ int ret = ses_path_va_diode(f, path);
if (ret < 0)
return ret;