ses_flow_v_pos()
authoryu.dongliang <18588496441@163.com>
Fri, 22 Sep 2023 16:14:15 +0000 (00:14 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 22 Sep 2023 16:14:15 +0000 (00:14 +0800)
ses_core.h
ses_step_va_balance.c
ses_steps.c

index d8fe0205cccdcb0e48cad55d797c39ff2da805a2..61be2efffa573bccb3e40add1f11790cb3096393 100644 (file)
@@ -89,6 +89,9 @@ void        ses_path_print(ses_path_t* path);
 ses_flow_t* ses_flow_alloc();
 void        ses_flow_free (ses_flow_t* flow);
 void        ses_flow_print(ses_flow_t* flow);
+
+void        ses_flow_v_pos(ses_flow_t* flow, double a, double ja);
+void        ses_flow_v_neg(ses_flow_t* flow, double a, double ja);
 void        ses_flow_jr   (ses_flow_t* flow);
 
 ses_ctx_t*  ses_ctx_alloc();
index 259cbd5c96f55abb026df2510d654cd8ab1b6ea4..8e2a399df9e781f1fa869d1813272003ab36f211 100644 (file)
@@ -43,6 +43,7 @@ int ses_paths_find_flow(ses_flow_t* flow, scf_vector_t* paths, ScfEpin* vip, ses
        return 0;
 }
 
+
 static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t* flow0, ses_flow_t* flow1)
 {
        if (!bridge || !flow0 || !flow1)
@@ -96,9 +97,10 @@ static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t
                double dv;
                double jdv;
 
-               ses_ur_i(&a, &ja, v, jv, r, jr);
+               ses_ur_i(&a,  &ja,  v, jv,         r, jr);
 
-               ses_ir_u(&dv, &jdv, a, ja, flow0->pr, flow0->jpr);
+               ses_flow_v_pos(flow0, a, ja);
+               ses_flow_v_neg(flow1, a, ja);
 
                scf_loge("r->pr: %lg + j%lg, v: %lg + j%lg, a: %lg + j%lg, dv: %lg + j%lg\n", r, jr, v, jv, a, ja, dv, jdv);
 
index 0df4d78869e6468ada01136c3000b1b8ea1c35e5..1db1066618f035e06d615e8839d1593cf850a3c6 100644 (file)
@@ -70,6 +70,132 @@ void ses_flow_free(ses_flow_t* flow)
        }
 }
 
+void ses_flow_v_pos(ses_flow_t* flow, double a, double ja)
+{
+       if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip)
+               return;
+
+       ses_path_t* path = flow->paths->data[flow->paths->size - 1];
+       ScfEpin*    vip  = flow->vip;
+       ScfEpin*    p0;
+       ScfEpin*    p;
+
+       double tr  = flow->pr;
+       double jtr = flow->jpr;
+
+       int i;
+       int j;
+
+       for (i   = 0; i < flow->paths->size; i++) {
+               path =        flow->paths->data[i];
+
+               double v;
+               double jv;
+
+               p0 = NULL;
+               for (j = path->pins->size - 1; j >= 0; j--) {
+                       p  = path->pins->data[j];
+
+                       if (!p0) {
+                               if ((j & 0x1) && p->lid == vip->lid)
+                                       p0 = p;
+                               else
+                                       continue;
+                       }
+
+                       double r  = tr  - (p0->pr  - p->pr);
+                       double jr = jtr - (p0->jpr - p->jpr);
+
+                       ses_ir_u(&v, &jv, a, ja, r, jr);
+
+                       p->v  -= v;
+                       p->jv -= jv;
+
+                       scf_logw("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg\n", p->cid, p->id, p->v, p->jv, r, jr);
+                       break;
+               }
+
+               assert(p0);
+
+               vip  = path->pins->data[0];
+               tr  -= p0->pr;
+               jtr -= p0->jpr;
+
+               ses_ir_u(&v, &jv, a, ja, tr, jtr);
+
+               vip->v  -= v;
+               vip->jv -= jv;
+
+               scf_logw("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg\n", vip->cid, vip->id, vip->v, vip->jv, tr, jtr);
+       }
+}
+
+void ses_flow_v_neg(ses_flow_t* flow, double a, double ja)
+{
+       if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip)
+               return;
+
+       ses_path_t* path = flow->paths->data[flow->paths->size - 1];
+       ScfEpin*    vip  = flow->vip;
+       ScfEpin*    p0;
+       ScfEpin*    p;
+
+       double tr  = flow->nr;
+       double jtr = flow->jnr;
+
+       int i;
+       int j;
+
+       for (i   = 0; i < flow->paths->size; i++) {
+               path =        flow->paths->data[i];
+
+               double v;
+               double jv;
+
+               p0 = NULL;
+               for (j = 0; j < path->pins->size; j++) {
+                       p  =        path->pins->data[j];
+
+                       if (!p0) {
+                               if (p->lid == vip->lid)
+                                       p0 = p;
+                               else
+                                       continue;
+                       }
+
+                       double r  = tr  - (p->sr  - p0->pr);
+                       double jr = jtr - (p->jsr - p0->jpr);
+
+                       if (p->sr != p->pr)
+                               p0 = p;
+
+                       ses_ir_u(&v, &jv, a, ja, r, jr);
+
+                       p->v  += v;
+                       p->jv += jv;
+
+                       scf_loge("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg, %lg\n", p->cid, p->id, p->v, p->jv, r, jr, p->sr);
+               }
+
+               assert(p0);
+
+               vip = path->pins->data[j - 1];
+
+               if (vip != p0) {
+
+                       tr  -= vip->sr  - p0->pr;
+                       jtr -= vip->jsr - p0->jpr;
+
+                       ses_ir_u(&v, &jv, a, ja, tr, jtr);
+
+                       vip->v  += v;
+                       vip->jv += jv;
+
+                       scf_logw("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg\n", vip->cid, vip->id, vip->v, vip->jv, tr, jtr);
+               }
+       }
+}
+
 void ses_flow_jr(ses_flow_t* flow)
 {
        if (!flow)