ses_step_va_transistor.c
authoryu.dongliang <18588496441@163.com>
Fri, 8 Sep 2023 12:16:33 +0000 (20:16 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 8 Sep 2023 12:16:33 +0000 (20:16 +0800)
ses_step_va_diode.c
ses_step_va_transistor.c

index 1e98b5f8c9af503db2e185981880f748959b1574..7a7ce2423047a9b9f3a2e2e96b2837c978a5cacd 100644 (file)
@@ -55,7 +55,7 @@ void __ses_path_dr(ScfEpin* p0, ScfEpin* p1, ScfEpin* p)
 
        ses_ui_r(&p->dr, &p->jdr, v, jv, p->a, p->ja);
 
-       scf_logd("c%ldp%ld, v: %lg + j%lg, r: %lg + j%lg, p->a: %lg + j%lg, p->dr: %lg + j%lg\n", p->cid, p->id,
+       scf_logw("c%ldp%ld, v: %lg + j%lg, r: %lg + j%lg, p->a: %lg + j%lg, p->dr: %lg + j%lg\n", p->cid, p->id,
                        v, jv, r, jr, p->a, p->ja, p->dr, p->jdr);
 
        p->dr  -= r;
index c2a6169fc4b0d5eec038b23d1e9c0a6253c4ce4d..e253cbd10d6403187e93a138d1fe6ef9aeb541f8 100644 (file)
@@ -7,6 +7,8 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
        ScfEline*      el;
        ScfEpin*       p0;
        ScfEpin*       p1;
+
+       ScfEpin*       p;
        ScfEpin*       pb;
        ScfEpin*       pc;
        ScfEpin*       pe;
@@ -52,6 +54,8 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
                if (SCF_EDA_Transistor_B != pb->id)
                        continue;
 
+               p   = path->pins->data[i - 1];
+
                v   = p0->v  - pb->v;
                jv  = p0->jv - pb->jv;
 
@@ -63,17 +67,30 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
 
                ses_ur_i(&el->a, &el->ja, v, jv, pr, jpr);
 
-               pb->a      = el->a;
-               pb->ja     = el->ja;
+               pb->a  = el->a;
+               pb->ja = el->ja;
+
+               p->v   = el->v;
+               p->jv  = el->jv;
+               p->a   = el->a;
+               p->ja  = el->ja;
+
                el->aconst = 1;
 
-               if (path->childs)
+               if (path->childs) {
+
+                       __ses_path_split_i(path, p0, pb, el, &p->a,  &p->ja);
                        __ses_path_split_i(path, pb, p1, el, &pb->a, &pb->ja);
 
-               __ses_path_dr(pb, p1, pb);
+               } else {
+                       p0->a  = el->a;
+                       p0->ja = el->ja;
+               }
+
+               __ses_path_dr(p, p1, pb);
 
-               scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, pb->v: %lg + j%lg, pb->a: %lg + j%lg, pr: %lg + j%lg, sr: %lg + j%lg, pb->dr: %lg + j%lg\n",
-                               i, pb->cid, pb->id, v, jv, pb->v, pb->jv, pb->a, pb->ja, pr, jpr, sr, jsr, pb->dr, pb->jdr);
+               scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg + j%lg, pb->v: %lg + j%lg, pb->a: %lg + j%lg, pr: %lg + j%lg, sr: %lg + j%lg, pb->dr: %lg + j%lg\n",
+                               i, p0->cid, p0->id, pb->cid, pb->id, v, jv, pb->v, pb->jv, pb->a, pb->ja, pr, jpr, sr, jsr, pb->dr, pb->jdr);
 
                pc     = c->pins[SCF_EDA_Transistor_C];
                pe     = c->pins[SCF_EDA_Transistor_E];
@@ -84,10 +101,82 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
                pe->a  = pc->a   + pb->a;
                pe->ja = pc->ja  + pb->ja;
 
+               pb->aconst = 1;
+               pc->aconst = 1;
+               pe->aconst = 1;
+
                scf_loge("i: %d, c%ldp%ld, pc->a: %lg + j%lg\n", i, pc->cid, pc->id, pc->a, pc->ja);
                scf_loge("i: %d, c%ldp%ld, pe->a: %lg + j%lg\n", i, pe->cid, pe->id, pe->a, pe->ja);
        }
-       printf("\n");
+
+       for (i = 1; i < path->pins->size - 1; i++) {
+               pc =        path->pins->data[i];
+
+               el = f->elines    [pc->lid];
+               c  = f->components[pc->cid];
+
+               if (SCF_EDA_Transistor != c->type)
+                       continue;
+
+               if (SCF_EDA_Transistor_C != pc->id)
+                       continue;
+
+               if (!pc->aconst)
+                       continue;
+
+               p   = path->pins->data[i - 1];
+
+               pr  = p->pr  - p0->pr;
+               jpr = p->jpr - p0->jpr;
+
+               sr  = p->sr  - p0->sr;
+               jsr = p->jsr - p0->jsr;
+
+               ses_ir_u(&v, &jv, pc->a, pc->ja, pr, jpr);
+
+               pc->v  = p0->v  - v;
+               pc->jv = p0->jv - jv;
+
+               if (pc->v < p1->v) {
+                       v     = p0->v   - p1->v;
+                       jv    = p0->jv  - p1->jv;
+
+                       pr    = p1->sr  - p0->pr;
+                       jpr   = p1->jsr - p0->jpr;
+
+                       ses_ur_i(&pc->a, &pc->ja, v, jv, pr, jpr);
+
+                       pr    = p->pr  - p0->pr;
+                       jpr   = p->jpr - p0->jpr;
+
+                       ses_ir_u(&v, &jv, pc->a, pc->ja, pr, jpr);
+
+                       pc->v  = p0->v  - v;
+                       pc->jv = p0->jv - jv;
+               }
+
+               el->v  = pc->v;
+               el->jv = pc->jv;
+               el->a  = pc->a;
+               el->ja = pc->ja;
+
+               p->v   = el->v;
+               p->jv  = el->jv;
+               p->a   = el->a;
+               p->ja  = el->ja;
+
+               if (path->childs)
+                       __ses_path_split_i(path, p0, pc, el, &p->a,  &p->ja);
+               else {
+                       p0->a  = el->a;
+                       p0->ja = el->ja;
+               }
+
+               __ses_path_dr(p, p1, pc);
+
+               scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg + j%lg, pc->v: %lg + j%lg, pc->a: %lg + j%lg, pr: %lg + j%lg, sr: %lg + j%lg, pc->dr: %lg + j%lg\n",
+                               i, p0->cid, p0->id, pc->cid, pc->id, v, jv, pc->v, pc->jv, pc->a, pc->ja, pr, jpr, sr, jsr, pc->dr, pc->jdr);
+       }
 
        return 0;
 }