#include"ses_core.h"
+void __ses_path_dr_forward(ScfEfunction* f, ses_path_t* path, int i, int j, double a)
+{
+ ScfEpin* p = path->pins->data[i];
+ ScfEpin* p1 = path->pins->data[j];
+
+ double r;
+ double jr;
+
+ int k;
+ for (k = i; k <= j; k++) {
+
+ ScfEcomponent* c;
+
+ p = path->pins->data[k];
+ c = f->components[p->cid];
+
+ if (SCF_EDA_Diode == c->type && SCF_EDA_Diode_NEG == p->id) {
+
+ ses_ui_r(&p->dr, NULL, SCF_EDA_V_Diode_ON, 0, a, 0);
+
+ p->dr -= p->r;
+
+ scf_logw("c%ldp%ld, v: %lg, r: %lg, a: %lg, dr: %lg\n", p->cid, p->id, SCF_EDA_V_Diode_ON, p->r, a, p->dr);
+
+ p1 = c->pins[SCF_EDA_Diode_POS];
+ p1->a = a;
+
+ } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == p->id) {
+
+ ses_ui_r(&p->dr, NULL, SCF_EDA_V_NPN_ON, 0, a, 0);
+
+ p->dr -= p->r;
+
+ p1 = c->pins[SCF_EDA_NPN_C];
+ p1->a = p1->hfe * a;
+ p1->aconst = 1;
+
+ scf_logw("c%ldp%ld, v: %lg, r: %lg, a: %lg, dr: %lg, c%ldp%ld->a: %lg\n",
+ p->cid, p->id, SCF_EDA_V_NPN_ON, p->r, a, p->dr, p1->cid, p1->id, p1->a);
+
+ p1 = c->pins[SCF_EDA_NPN_E];
+ p1->a = (1 + p1->hfe) * a;
+ p1->aconst = 1;
+
+ a = p1->a;
+ }
+ }
+}
+
void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double la, double* a)
{
ScfEcomponent* c;
int ret = __ses_path_va_diode(f, child);
if (ret < 0)
ses_split_i(&child->a, NULL, la, 0, child->pr, 0, r, 0);
+ else
+ goto ok;
}
- scf_logi("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, child->pr: %lg, r: %lg, child->a: %lg, el->a: %lg\n",
- j, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->pr, r, child->a, la);
+ scf_logi("k: %d, c%ldp%ld--c%ldp%ld, v: %lg, child->pr: %lg, r: %lg, child->a: %lg, el->a: %lg\n",
+ k, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->pr, r, child->a, la);
cp1->v = p1->v;
cp0->v = p0->v;
cp0->a = ca;
- c = f->components[cp1->cid];
-
- if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_E == cp1->id)
- p = child->pins->data[child->pins->size - 2];
- else
- p = cp1;
-
- ses_ui_r(&p->dr, NULL, v, 0, ca, 0);
-
- p->dr -= cp1->sr;
- p->a = ca;
+ if (child->n_diodes > 0)
+ __ses_path_dr_forward(f, child, 0, child->pins->size - 1, ca);
+ok:
cp1->sr = _sr;
cp1->pr = _pr;
- scf_logi("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, child->pr: %lg, r: %lg, cp1->a: %lg, el->a: %lg, c%ldp%ld->dr: %lg\n\n",
- j, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->pr, r, p->a, la, p->cid, p->id, p->dr);
- }
-}
-
-void __ses_path_dr_forward(ScfEfunction* f, ses_path_t* path, int i, int j, double a, double ja)
-{
- ScfEpin* p = path->pins->data[i];
- ScfEpin* p1 = path->pins->data[j];
-
- double r;
- double jr;
-
- int k;
- for (k = i; k <= j; k++) {
-
- ScfEcomponent* c;
-
- p = path->pins->data[k];
- c = f->components[p->cid];
-
- if (SCF_EDA_Diode == c->type && SCF_EDA_Diode_NEG == p->id) {
-
- ses_ui_r(&p->dr, NULL, SCF_EDA_V_Diode_ON, 0, a, 0);
-
- p->dr -= p->r;
-
- scf_logw("c%ldp%ld, v: %lg, r: %lg, a: %lg, dr: %lg\n", p->cid, p->id, SCF_EDA_V_Diode_ON, p->r, a, p->dr);
-
- p1 = c->pins[SCF_EDA_Diode_POS];
- p1->a = a;
-
- } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == p->id) {
-
- ses_ui_r(&p->dr, NULL, SCF_EDA_V_NPN_ON, 0, a, 0);
-
- p->dr -= p->r;
-
- p1 = c->pins[SCF_EDA_NPN_C];
- p1->a = p1->hfe * a;
- p1->aconst = 1;
-
- scf_logw("c%ldp%ld, v: %lg, r: %lg, a: %lg, dr: %lg, c%ldp%ld->a: %lg\n",
- p->cid, p->id, SCF_EDA_V_NPN_ON, p->r, a, p->dr, p1->cid, p1->id, p1->a);
-
- p1 = c->pins[SCF_EDA_NPN_E];
- p1->a = (1 + p1->hfe) * a;
- p1->aconst = 1;
-
- a = p1->a;
- }
+ scf_logi("k: %d, c%ldp%ld--c%ldp%ld, v: %lg, child->pr: %lg, r: %lg, child->a: %lg, cp1->a: %lg, el->a: %lg\n\n",
+ k, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->pr, r, child->a, cp1->a, la);
}
}
-void __ses_path_dr_reverse(ScfEfunction* f, ses_path_t* path, int i, int j, double a, double ja)
+void __ses_path_dr_reverse(ScfEfunction* f, ses_path_t* path, int i, int j, double a)
{
ScfEpin* p = path->pins->data[i];
ScfEpin* p1 = path->pins->data[j];
scf_loge("info->i: %d, info->j: %d, c%ldp%ld--c%ldp%ld, pi->v: %lg, pj->v: %lg, pi->a: %lg\n\n",
info->i, info->j, pi->cid, pi->id, pj->cid, pj->id, pi->v, pj->v, pi->a);
- __ses_path_dr_forward(f, path, info->i, info->j, pi->a, 0);
+ __ses_path_dr_forward(f, path, info->i, info->j, pi->a);
}
return 0;