tmp
authoryu.dongliang <18588496441@163.com>
Tue, 3 Oct 2023 14:45:23 +0000 (22:45 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 3 Oct 2023 14:45:23 +0000 (22:45 +0800)
ses_core.h
ses_step_jr.c
ses_step_va_diode.c
ses_step_va_transistor.c

index b82b976994c772620a9e963be8899dc9588e1010..c06f3a161137726b92f7247661c0f79f9b1360af 100644 (file)
@@ -106,7 +106,8 @@ int ses_layout_board (ScfEboard*    b);
 int ses_loop_function(ScfEfunction* f, scf_vector_t* loops);
 int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count);
 
-void __ses_path_split_i(ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja);
+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, double* r, double* jr);
 void __ses_path_dr     (ScfEpin*      p0, ScfEpin* p1, ScfEpin* p);
 
 static inline void vertical(int* px, int* py, int dx, int dy, int d)
index 14006f7cd6e1979ed56c589f16f9fb21954ee2ef..327bd8c26eb6366a5ab26a2d785f65a4e712a037 100644 (file)
@@ -1,5 +1,32 @@
 #include"ses_core.h"
 
+void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, 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_Transistor == c1->type && SCF_EDA_Transistor_E == p1->id)
+               p1 = path->pins->data[j - 1];
+
+       if (SCF_EDA_Transistor == c0->type) {
+               if (i > 0) {
+                       p0 = path->pins->data[i - 1];
+
+                       *r  = p1->pr  - p0->pr;
+                       *jr = p1->jpr - p0->jpr;
+               } else {
+                       *r  = p1->pr;
+                       *jr = p1->jpr;
+               }
+       } else {
+               *r  = p1->pr  - p0->pr;
+               *jr = p1->jpr - p0->jpr;
+       }
+}
+
 static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
 {
        if (!path)
@@ -12,6 +39,7 @@ static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
 
        ses_path_t*    child;
        ScfEcomponent* c;
+       ScfEcomponent* c1;
        ScfEpin*       p;
        ScfEpin*       p0;
        ScfEpin*       p1;
@@ -64,11 +92,15 @@ static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
                        p0  = NULL;
                        p1  = NULL;
 
+                       int k0;
+                       int k1;
+
                        for (j = 0; j < path->pins->size; j++) {
                                p  =        path->pins->data[j];
 
                                if (p->lid == cp0->lid) {
                                        p0 = p;
+                                       k0 = j;
                                        break;
                                }
                        }
@@ -81,6 +113,7 @@ static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
 
                                if (p->lid == cp1->lid) {
                                        p1 = p;
+                                       k1 = j;
                                        break;
                                }
                        }
@@ -93,17 +126,7 @@ static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
                        double _r  =  child->r  / R;
                        double _jr = -child->jr / R;
 
-                       c = f->components[p1->cid];
-
-                       if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_E == p1->id) {
-                               p  = path->pins->data[j - 1];
-
-                               r  = p->pr  - p0->pr;
-                               jr = p->jpr - p0->jpr;
-                       } else {
-                               r  = p1->pr  - p0->pr;
-                               jr = p1->jpr - p0->jpr;
-                       }
+                       __ses_path_pr(f, path, k0, k1, &r, &jr);
 
                        R  =   r * r + jr * jr;
                        r  =   r / R;
@@ -129,6 +152,8 @@ static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
                                p       = path->pins->data[j - 1];
                                p->pr  -= dr;
                                p->jpr -= jdr;
+
+                               scf_logw("j: %d, c%ldp%ld, p->pr: %lg + j%lg, p->sr: %lg + j%lg, dr: %lg + j%lg\n", j, p->cid, p->id, p->pr, p->jpr, p->sr, p->jsr, dr, jdr);
                        }
 
                        scf_logw("j: %d, c%ldp%ld, p->pr: %lg + j%lg, p->sr: %lg + j%lg, dr: %lg + j%lg\n", j, p1->cid, p1->id, p1->pr, p1->jpr, p1->sr, p1->jsr, dr, jdr);
index 86ef0fe1e473310340914032fb68e1f9cc28c7e3..771c335f4d7347c3b689fe9465b2f4e7c5440d3e 100644 (file)
@@ -1,21 +1,25 @@
 #include"ses_core.h"
 
-void __ses_path_split_i(ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja)
+void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja)
 {
+       ScfEcomponent* c;
        ses_path_t*    child;
        ScfEpin*       cp0;
        ScfEpin*       cp1;
+       ScfEpin*       p;
        ScfEpin*       p0 = path->pins->data[i];
        ScfEpin*       p1 = path->pins->data[j];
 
        double v  = p0->v   - p1->v;
        double jv = p0->jv  - p1->jv;
 
-       double r  = p1->pr  - p0->pr;
-       double jr = p1->jpr - p0->jpr;
+       double r;
+       double jr;
 
-       scf_loge("c%ldp%ld--c%ldp%ld, r: %lg, p1->pr: %lg, p0->pr: %lg, p1->sr: %lg, p0->sr: %lg\n",
-                       p0->cid, p0->id, p1->cid, p1->id, r, p1->pr, p0->pr, p1->sr, p0->sr);
+       __ses_path_pr(f, path, i, j, &r, &jr);
+
+       scf_loge("c%ldp%ld--c%ldp%ld, r: %lg, p0->pr: %lg, p0->sr: %lg\n",
+                       p0->cid, p0->id, p1->cid, p1->id, r, p0->pr, p0->sr);
 
        int k;
        for (k    = 0; k < path->childs->size; k++) {
@@ -32,31 +36,38 @@ void __ses_path_split_i(ses_path_t* path, int i, int j, double la, double jla, d
                *a  -= child->a;
                *ja -= child->ja;
 
-               cp1->a  = child->a;
-               cp1->ja = child->ja;
-
                cp1->v  = p1->v;
                cp1->jv = p1->jv;
 
                cp0->v  = p0->v;
                cp0->jv = p0->jv;
 
+               double ca  = child->a;
+               double cja = child->ja;
+
                if (child->childs)
-                       __ses_path_split_i(child, 0, child->pins->size - 1, child->a, child->ja, &cp1->a, &cp1->ja);
+                       __ses_path_split_i(f, child, 0, child->pins->size - 1, child->a, child->ja, &ca, &cja);
+
+               cp0->a  = ca;
+               cp0->ja = cja;
+
+               c = f->components[cp1->lid];
 
-               cp0->a  = cp1->a;
-               cp0->ja = cp1->ja;
+               if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_E == cp1->id)
+                       p = child->pins->data[child->pins->size - 2];
+               else
+                       p = cp1;
 
-               double cr;
-               double jcr;
+               ses_ui_r(&p->dr, &p->jdr, v, jv, ca, cja);
 
-               ses_ui_r(&cp1->dr, &cp1->jdr, v, jv, cp1->a, cp1->ja);
+               p->dr  -= p->sr;
+               p->jdr -= p->jsr;
 
-               cp1->dr  -= cp1->sr;
-               cp1->jdr -= cp1->jsr;
+               p->a    = ca;
+               p->ja   = cja;
 
                scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, child->r: %lg, r: %lg, cp1->a: %lg, el->a: %lg, cp1->dr: %lg\n",
-                               j, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->r, r, cp1->a, la, cp1->dr);
+                               j, cp0->cid, cp0->id, cp1->cid, cp1->id, v, child->r, r, p->a, la, p->dr);
        }
 }
 
@@ -312,7 +323,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                pj->ja     = ja;
 
                if (path->childs)
-                       __ses_path_split_i(path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
+                       __ses_path_split_i(f, path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
 
                scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, pj->v: %lg, pj->a: %lg, pr: %lg, sr: %lg\n\n",
                                j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr);
@@ -333,7 +344,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                                j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr);
 
                if (path->childs)
-                       __ses_path_split_i(path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
+                       __ses_path_split_i(f, path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja);
 
                scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, pj->v: %lg, pj->a: %lg, pr: %lg, sr: %lg\n\n",
                                j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr);
@@ -357,7 +368,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                pi->ja     = ja;
 
                if (path->childs)
-                       __ses_path_split_i(path, 0, i, a, ja, &pi->a, &pi->ja);
+                       __ses_path_split_i(f, path, 0, i, a, ja, &pi->a, &pi->ja);
 
                __ses_path_dr_reverse(f, path, 0, i, pi->n_diodes, pi->a, pi->ja);
 
@@ -375,7 +386,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                pi->ja     = ja;
 
                if (path->childs)
-                       __ses_path_split_i(path, 0, i, a, ja, &pi->a, &pi->ja);
+                       __ses_path_split_i(f, path, 0, i, a, ja, &pi->a, &pi->ja);
 
                p = c->pins[SCF_EDA_Transistor_B];
 
index 738c5f277250ff21c08d88734a3400053760bbbc..f75185f3cfcc7d7d7af563856a1d04d414d64282 100644 (file)
@@ -93,7 +93,7 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
                p->ja  = el->ja;
 
                if (path->childs)
-                       __ses_path_split_i(path, 0, i, el->a, el->ja, &p->a,  &p->ja);
+                       __ses_path_split_i(f, path, 0, i, el->a, el->ja, &p->a,  &p->ja);
                else {
                        p0->a  = el->a;
                        p0->ja = el->ja;