void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja);
void __ses_path_pr (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr);
void __ses_path_sr (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr);
-int __ses_path_va (ScfEfunction* f, ses_path_t* path);
+int __ses_path_va (ScfEfunction* f, ses_path_t* path, int *changed);
int __ses_path_pos (ScfEfunction* f, ScfEline* el);
int __ses_path_neg (ScfEfunction* f, ScfEline* el);
int _ses_path_cmp(const void* v0, const void* v1);
-static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja)
+static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja, int* changed)
{
ses_path_t* child;
scf_loge("child: %d, c%ldp%ld, c%ldp%ld, p->v: %lg, el->v: %lg, _v: %lg\n",
child->index, p->cid, p->id, p2->cid, p2->id, p->v, el->v, _v);
- int ret = __ses_path_va(f, child);
+ int ret = __ses_path_va(f, child, changed);
if (ret < 0)
return ret;
return 0;
}
-int __ses_path_va(ScfEfunction* f, ses_path_t* path)
+int __ses_path_va(ScfEfunction* f, ses_path_t* path, int* changed)
{
if (!path)
return -EINVAL;
if (ret < 0)
return ret;
- ret = __ses_path_split_a(f, path, i, &a, &ja);
+ ret = __ses_path_split_a(f, path, i, &a, &ja, changed);
if (ret < 0)
return ret;
scf_loge("path: %d, i: %d, c%ldp%ld, p->v: %lg, dv: %lg, r: %lg, p->a: %lg, a: %lg, p->pr: %lg\n\n", path->index, i, p->cid, p->id,
p->v, dv, r, p->a, a, p->pr);
+ if (SCF_EDA_Diode == c->type) {
+
+ if (SCF_EDA_Diode_NEG == p->id) {
+ p2 = path->pins->data[i - 1];
+ *changed += __ses_status_check(f, c, p2, p);
+ }
+
+ } else if (SCF_EDA_NPN == c->type) {
+
+ if (SCF_EDA_NPN_E == p->id) {
+ p2 = path->pins->data[i - 1];
+
+ if (SCF_EDA_NPN_B == p2->id)
+ *changed += __ses_status_check(f, c, p2, p);
+ }
+ }
+
r = 0;
jr = 0;
-
} else {
dv = p->v;
jdv = p->jv;
printf("\n*******************\n");
+ int changed = 0;
int i;
for (i = 0; i < ctx->paths->size; i++) {
if (p0->lid != Bp->lid || p1->lid != Bn->lid)
continue;
- int ret = __ses_path_va(f, path);
+ int ret = __ses_path_va(f, path, &changed);
if (ret < 0)
return ret;
printf("\n");
}
- return 0;
+ return changed > 0 ? -EAGAIN : 0;
}
ses_step_t ses_step_va =
scf_logw("path: %d, c%ldp%ld--c%ldp%ld, v: %lg, p0->v: %lg, p1->v: %lg, n_diodes: %d\n",
path->index, p0->cid, p0->id, p1->cid, p1->id, v, p0->v, p1->v, path->n_diodes);
- int ret = __ses_path_va(f, path);
+ int ret = __ses_path_va(f, path, changed);
if (ret < 0)
return ret;
-
+#if 0
B = f->components[0];
Bn = B->pins[SCF_EDA_Battery_NEG];
}
}
}
-
+#endif
return 0;
}