__ses_path_split_v()
authoryu.dongliang <18588496441@163.com>
Wed, 25 Oct 2023 14:36:24 +0000 (22:36 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 25 Oct 2023 14:36:24 +0000 (22:36 +0800)
ses_step_jr.c
ses_step_va.c
ses_steps.c

index 4d24f3638fe4821be036b7fc4fa494b8171fce6a..fa3d9c99118918e5a844836e325f7b79b20a61ee 100644 (file)
@@ -8,15 +8,25 @@ void __ses_path_sr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1
        ScfEcomponent* c0 = f->components[p0->cid];
        ScfEcomponent* c1 = f->components[p1->cid];
 
+       double r1  = 0;
+       double jr1 = 0;
+
        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)
+               } else if (j > 0) {
                        p1 = path->pins->data[j - 1];
-               else {
+                       c1 = f->components[p1->cid];
+
+                       if (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_E == p1->id) {
+                               p1  = path->pins->data[j];
+                               r1  = p1->r  + p1->dr;
+                               jr1 = p1->jr + p1->jdr;
+                       }
+               } else {
                        *r  = 0;
                        *jr = 0;
                        return;
@@ -27,8 +37,8 @@ void __ses_path_sr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1
                if (i > 0) {
                        p0 = path->pins->data[i - 1];
 
-                       *r  = p1->sr  - p0->pr;
-                       *jr = p1->jsr - p0->jpr;
+                       *r  = p1->sr  - r1  - p0->pr;
+                       *jr = p1->jsr - jr1 - p0->jpr;
                } else {
                        *r  = p1->sr;
                        *jr = p1->jsr;
@@ -38,7 +48,8 @@ void __ses_path_sr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1
                *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);
+       scf_logd("c%ldp%ld-c%ldp%ld, r: %lg, p0->sr: %lg, p0->pr: %lg, p1->sr: %lg, p1->pr: %lg\n",
+                       p0->cid, p0->id, p1->cid, p1->id, *r, p0->sr, p0->pr, p1->sr, p1->pr);
 }
 
 void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr)
index 21bb46496191e835f644590837d98e3d197b3198..a9d20bd6f51e9995f43406e823c5c90278c94c52 100644 (file)
@@ -78,46 +78,18 @@ static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double*
        return n;
 }
 
-static int __ses_path_split_v(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, int i, double a, double ja)
+static void __ses_path_split_v(ScfEfunction* f, ses_path_t* path, int i0, int i, double a, double ja)
 {
-       ScfEpin*       p2;
-       ScfEpin*       p  = path->pins->data[i];
-
-       ScfEcomponent* c  = f->components[p->cid];
-       double         v  = 0;
-       double         jv = 0;
-       double         r  = 0;
-       double         jr = 0;
-
-       if (SCF_EDA_NPN == c->type) {
-
-               if (SCF_EDA_NPN_E != p->id) {
-
-                       if (p != p0) {
-                               r  = p->sr  - (p->r  + p->dr ) - p0->sr;
-                               jr = p->jsr - (p->jr + p->jdr) - p0->jsr;
-                       } else {
-                               r  = 0;
-                               jr = 0;
-                       }
+       ScfEpin* p2;
+       ScfEpin* p0 = path->pins->data[i0];
+       ScfEpin* p  = path->pins->data[i];
 
-               } else if (i >= 1) {
-                       p2 = path->pins->data[i - 1];
+       double   v;
+       double   jv;
+       double   r;
+       double   jr;
 
-                       if (p2 == p0) {
-                               r  = p0->r  + p0->dr;
-                               jr = p0->jr + p0->jdr;
-                       } else {
-                               r  = p2->sr  - p0->sr;
-                               jr = p2->jsr - p0->jsr;
-                       }
-               } else
-                       return -EINVAL;
-
-       } else {
-               r  = p->sr  - p0->sr;
-               jr = p->jsr - p0->jsr;
-       }
+       __ses_path_sr(f, path, i0, i, NULL, &r, &jr);
 
        ses_ir_u(&v, &jv, a, ja, r, jr);
 
@@ -125,7 +97,6 @@ static int __ses_path_split_v(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, in
        p->jv = p0->jv - jv;
 
        scf_logd("c%ldp%ld, c%ldp%ld, a: %lg, r: %lg, v: %lg\n", p0->cid, p0->id, p->cid, p->id, a, r, v);
-       return 0;
 }
 
 int __ses_path_va(ScfEfunction* f, ses_path_t* path, int* changed)
@@ -150,7 +121,6 @@ int __ses_path_va(ScfEfunction* f, ses_path_t* path, int* changed)
 
        int i;
        int j;
-       int k;
 
        p0 = path->pins->data[0];
        p1 = path->pins->data[path->pins->size - 1];
@@ -178,29 +148,26 @@ int __ses_path_va(ScfEfunction* f, ses_path_t* path, int* changed)
        double dv  = 0;
        double jdv = 0;
 
+       int i0 = 0;
+
        for (i = 0; i < path->pins->size; i++) {
                p  =        path->pins->data[i];
 
                if (!(i & 0x1) && path->childs) {
 
-                       int ret = __ses_path_split_v(f, path, p0, i, a, ja);
-                       if (ret < 0)
-                               return ret;
+                       __ses_path_split_v(f, path, i0, i, a, ja);
 
-                       ret = __ses_path_split_a(f, path, i, &a, &ja, changed);
+                       int ret = __ses_path_split_a(f, path, i, &a, &ja, changed);
                        if (ret < 0)
                                return ret;
 
                        if (ret > 0) {
                                p0 = p;
+                               i0 = i;
                                scf_logd("i: %d, p0: c%ldp%ld\n", i, p0->cid, p0->id);
                        }
-
-               } else {
-                       int ret = __ses_path_split_v(f, path, p0, i, a, ja);
-                       if (ret < 0)
-                               return ret;
-               }
+               } else
+                       __ses_path_split_v(f, path, i0, i, a, ja);
 
                el     = f->elines[p->lid];
                el->v  = p->v;
index 80d3cefc47bb5cc116cd2cd162b710ff3367c3d8..a1469ee7be8aa7002596ce50b67d5fda1a3ed112 100644 (file)
@@ -141,7 +141,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count)
                        return ret;
 
                int j;
-               for (j = 0; j < 1; j++) {
+               for (j = 0; j < 2; j++) {
                        ret = __ses_steps_analyse(f, ns, i, ctx);
 
                        if (-EAGAIN == ret)