tmp
authoryu.dongliang <18588496441@163.com>
Tue, 5 Sep 2023 09:53:20 +0000 (17:53 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 5 Sep 2023 09:53:20 +0000 (17:53 +0800)
ses_step_va.c

index d78d97d09789a241e28f94fc16f25a103ccf5c53..e696effa1b01beab926cf57a5372579e5b1d160d 100644 (file)
@@ -2,6 +2,20 @@
 
 int _ses_path_cmp(const void* v0, const void* v1);
 
+static inline void __ses_ur_i(double* a, double* ja, double v, double jv, double r, double jr)
+{
+       double R  = r * r + jr * jr;
+
+       *a  = ( v * r + jv * jr) / R;
+       *ja = (jv * r -  v * jr) / R;
+}
+
+static inline void __ses_ir_u(double* v, double* jv, double a, double ja, double r, double jr)
+{
+       *v  =  a * r  - ja * jr;
+       *jv = ja * r  +  a * jr;
+}
+
 static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
 {
        if (!path)
@@ -154,11 +168,13 @@ static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
        ScfEpin*       p;
        ScfEpin*       p0;
        ScfEpin*       p1;
+       ScfEpin*       p2;
        ScfEpin*       cp0;
        ScfEpin*       cp1;
 
        int i;
        int j;
+       int k;
 
        p0 = path->pins->data[0];
        p1 = path->pins->data[path->pins->size - 1];
@@ -171,13 +187,12 @@ static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
        p1->v  = el->v;
        p1->jv = el->jv;
 
-       double R  = path->r * path->r + path->jr * path->jr;
-
        double v  = p0->v  - p1->v;
        double jv = p0->jv - p1->jv;
+       double a  = 0;
+       double ja = 0;
 
-       double a  = ( v * path->r + jv * path->jr) / R;
-       double ja = (jv * path->r -  v * path->jr) / R;
+       __ses_ur_i(&a, &ja, v, jv, path->r, path->jr);
 
        scf_loge("path: %d, v: %lg + j%lg, r: %lg + j%lg, a: %lg + j%lg\n", path->index, v, jv, path->r, path->jr, a, ja);
 
@@ -189,8 +204,51 @@ static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
        for (i = 0; i < path->pins->size; i++) {
                p  =        path->pins->data[i];
 
-               v      =  a * p->pr - ja * p->jpr;
-               jv     = ja * p->pr +  a * p->jpr;
+               if (path->childs) {
+                       for (j    = 0; j < path->childs->size; j++) {
+                               child =        path->childs->data[j];
+
+                               cp0 = child->pins->data[0];
+                               cp1 = child->pins->data[child->pins->size - 1];
+
+                               if (p->lid != cp0->lid)
+                                       continue;
+
+                               for (k = i + 1; k < path->pins->size; k++) {
+                                       p2 =            path->pins->data[k];
+
+                                       if (p2->lid == cp1->lid)
+                                               break;
+                               }
+
+                               if (k >= path->pins->size)
+                                       return -EINVAL;
+
+                               double _r  = p2->pr  - p->pr;
+                               double _jr = p2->jpr - p->jpr;
+
+                               double _v  = 0;
+                               double _jv = 0;
+                               double _a  = 0;
+                               double _ja = 0;
+
+                               __ses_ir_u(&_v, &_jv,  a,  ja,       _r,       _jr);
+                               __ses_ur_i(&_a, &_ja, _v, _jv, child->r, child->jr);
+
+                               el     = f->elines[p2->lid];
+                               el->v  = p->v  - _v;
+                               el->jv = p->jv - _jv;
+
+//                             int ret = __ses_path_va(f, child);
+//                             if (ret < 0)
+//                                     return ret;
+
+                               a  -= _a;
+                               ja -= _ja;
+                       }
+               }
+
+               __ses_ir_u(&v, &jv, a, ja, p->sr, p->jsr);
 
                p->v   = p0->v  - v;
                p->jv  = p0->jv - jv;
@@ -210,15 +268,14 @@ static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
                        dv  -= p->v;
                        jdv -= p->jv;
 
-                       R     =    r * r +  jr * jr;
-                       p->a  = ( dv * r + jdv * jr) / R;
-                       p->ja = (jdv * r -  dv * jr) / R;
+                       __ses_ur_i(&p->a, &p->ja, dv, jdv, r, jr);
 
                        scf_loge("i: %d, c%ldp%ld, v: %lg + j%lg, p->v: %lg + j%lg, dv: %lg + j%lg, r: %lg + j%lg, a: %lg + j%lg\n\n", i, p->cid, p->id,
                                        v, jv, p->v, p->jv, dv, jdv, r, jr, p->a, p->ja);
 
-                       r  = 0;
-                       jr = 0;
+                       r   = 0;
+                       jr  = 0;
+
                } else {
                        dv  = p->v;
                        jdv = p->jv;
@@ -228,18 +285,6 @@ static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
        }
        printf("\n");
 
-       if (path->childs) {
-
-               for (i    = path->childs->size - 1; i >= 0; i--) {
-                       child = path->childs->data[i];
-
-                       int ret = __ses_path_va(f, child);
-                       if (ret < 0)
-                               return ret;
-
-               }
-       }
-
        return 0;
 }