__ses_path_va_transistor()
authoryu.dongliang <18588496441@163.com>
Thu, 19 Oct 2023 12:28:08 +0000 (20:28 +0800)
committeryu.dongliang <18588496441@163.com>
Thu, 19 Oct 2023 12:28:08 +0000 (20:28 +0800)
ses_core.h
ses_step_jr.c
ses_step_va_diode.c
ses_step_va_transistor.c

index e19d6d9c00a04cad0599cb125d5b4b4086356fe6..a16ca8d114d5656aeeaf25558fb8a8ac6c08ef06 100644 (file)
@@ -114,6 +114,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count);
 
 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);
 
 static inline void vertical(int* px, int* py, int dx, int dy, int d)
 {
index 22d785f2a14355c00e364991b3cc546843eee9ea..2ada725108f8a356106744c19f9157ec54dd512c 100644 (file)
@@ -1,5 +1,46 @@
 #include"ses_core.h"
 
+void __ses_path_sr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr)
+{
+       ScfEpin*       p0 = path->pins->data[i];
+       ScfEpin*       p1 = path->pins->data[j];
+
+       ScfEcomponent* c0 = f->components[p0->cid];
+       ScfEcomponent* c1 = f->components[p1->cid];
+
+       if (SCF_EDA_NPN == c1->type) {
+
+               if (SCF_EDA_NPN_E == p1->id) {
+                       if (cp1 != p1)
+                               p1 = path->pins->data[j - 1];
+
+               } else if (j > 0)
+                       p1 = path->pins->data[j - 1];
+               else {
+                       *r  = 0;
+                       *jr = 0;
+                       return;
+               }
+       }
+
+       if (SCF_EDA_NPN == c0->type) {
+               if (i > 0) {
+                       p0 = path->pins->data[i - 1];
+
+                       *r  = p1->sr  - p0->sr;
+                       *jr = p1->jsr - p0->jsr;
+               } else {
+                       *r  = p1->sr;
+                       *jr = p1->jsr;
+               }
+       } else {
+               *r  = p1->sr  - p0->sr;
+               *jr = p1->jsr - p0->jsr;
+       }
+
+       scf_logd("c%ldp%ld-c%ldp%ld, r: %lg, p0->pr: %lg, p1->pr: %lg\n", p0->cid, p0->id, p1->cid, p1->id, *r, p0->sr, p1->sr);
+}
+
 void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr)
 {
        ScfEpin*       p0 = path->pins->data[i];
index beeffae510d40bba1804ffeb25afd77f3867bc4d..a13d1b09e50e0f889de6896a87ab40f2dfe2303b 100644 (file)
@@ -65,7 +65,7 @@ void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double
                cp0->a  = ca;
                cp0->ja = cja;
 
-               c = f->components[cp1->lid];
+               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];
index da3ecd77c899a0cdff49d9448d2995262ec42ba1..57b7912fad2f066b3f9d3bfb7a36e6155e42c905 100644 (file)
@@ -11,15 +11,15 @@ void __ses_path_dr_transistor(ScfEfunction* f, ses_path_t* path, int i, int j)
        double r;
        double jr;
 
-       __ses_path_pr(f, path, i, j, NULL, &r, &jr);
+       __ses_path_sr(f, path, i, j, NULL, &r, &jr);
 
        ses_ui_r(&p->dr, &p->jdr, v, jv, p->a, p->ja);
 
-       scf_logd("c%ldp%ld, v: %lg, r: %lg, p1->sr: %lg, p->sr: %lg, p->a: %lg, p->dr: %lg\n",
-                       p->cid, p->id, v, r, p1->sr, p->sr, p->a, p->dr);
-
        p->dr  -= r;
        p->jdr -= jr;
+
+       scf_logi("c%ldp%ld, v: %lg, r: %lg, p->sr: %lg, p->a: %lg, p->dr: %lg\n",
+                       p->cid, p->id, v, r, p->sr, p->a, p->dr);
 }
 
 static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
@@ -100,7 +100,7 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
 
                        ses_ur_i(&pc->a, &pc->ja, v, jv, _pr, _jpr);
 
-                       scf_logi("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, _pr: %lg pc->pr: %lg\n",
+                       scf_logd("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, _pr: %lg pc->pr: %lg\n",
                                        i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, _pr, pc->pr);
 
                        ses_ir_u(&v, &jv, pc->a, pc->ja, pr, jpr);
@@ -113,24 +113,20 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
                el->jv = pc->jv;
                el->a  = pc->a;
                el->ja = pc->ja;
-#if 0
-               p = path->pins->data[i - 1];
 
-               p->v   = el->v;
-               p->jv  = el->jv;
-               p->a   = el->a;
-               p->ja  = el->ja;
+               scf_logw("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, pc->dr: %lg\n",
+                               i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, pc->dr);
 
                if (path->childs)
-                       __ses_path_split_i(f, path, 0, i, el->a, el->ja, &p->a,  &p->ja);
+                       __ses_path_split_i(f, path, i, path->pins->size - 1, el->a, el->ja, &pc->a,  &pc->ja);
                else {
                        p0->a  = el->a;
                        p0->ja = el->ja;
                }
-#endif
+
                __ses_path_dr_transistor(f, path, i, path->pins->size - 1);
 
-               scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, pc->dr: %lg\n",
+               scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, pc->dr: %lg\n\n",
                                i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, pc->dr);
        }