tmp
authoryu.dongliang <18588496441@163.com>
Thu, 16 Nov 2023 05:08:43 +0000 (13:08 +0800)
committeryu.dongliang <18588496441@163.com>
Thu, 16 Nov 2023 05:08:43 +0000 (13:08 +0800)
ses_step_va_bridge.c

index 50f640dfbbaed39f2e9c2957956efe5b2b8d0719..4c83cebe113fb8ecf39eb1de1cbf08ef6d639b4c 100644 (file)
@@ -1,6 +1,6 @@
 #include"ses_core.h"
 
-int __ses_flow_va_pos(ScfEfunction* f, ses_flow_t* flow, double a_bridge, double ja_bridge)
+int __ses_flow_a_pos(ScfEfunction* f, ses_flow_t* flow, double a_bridge, double ja_bridge)
 {
        if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip)
                return -EINVAL;
@@ -46,6 +46,9 @@ int __ses_flow_va_pos(ScfEfunction* f, ses_flow_t* flow, double a_bridge, double
                        p->v  -= v;
                        p->jv -= jv;
 
+                       f->elines[p->lid]->v  = p->v;
+                       f->elines[p->lid]->jv = p->jv;
+
                        scf_logw("c%ldp%ld->v: %lg, r: %lg\n", p->cid, p->id, p->v, r);
                        break;
                }
@@ -63,13 +66,102 @@ int __ses_flow_va_pos(ScfEfunction* f, ses_flow_t* flow, double a_bridge, double
                vip->v  -= v;
                vip->jv -= jv;
 
+               f->elines[vip->lid]->v  = vip->v;
+               f->elines[vip->lid]->jv = vip->jv;
+
                scf_logw("c%ldp%ld->v: %lg, r: %lg\n", vip->cid, vip->id, vip->v, tr);
        }
 
        return 0;
 }
 
-int __ses_flow_va_neg(ScfEfunction* f, ses_flow_t* flow, double a_bridge, double ja_bridge)
+int __ses_flow_v_neg(ScfEfunction* f, ses_flow_t* flow, double dv_vip, double djv_vip)
+{
+       if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip)
+               return -EINVAL;
+
+       ses_path_t* path = flow->paths->data[flow->paths->size - 1];
+       ScfEpin*    vip  = flow->vip;
+       ScfEpin*    p0;
+       ScfEpin*    p;
+
+       double tr  = flow->neg_r;
+       double jtr = flow->neg_jr;
+
+       double da;
+       double dja;
+
+       int i;
+       int j;
+
+       ses_ur_i(&da, &dja, dv_vip, djv_vip, tr, jtr);
+
+       for (i   = 0; i < flow->paths->size; i++) {
+               path =        flow->paths->data[i];
+
+               double v;
+               double jv;
+
+               double r;
+               double jr;
+
+               int j0 = -1;
+               for (j = 0; j < path->pins->size; j++) {
+                       p  =        path->pins->data[j];
+
+                       if (j0 < 0) {
+                               if (p->lid == vip->lid)
+                                       j0 = j;
+                               else
+                                       continue;
+                       }
+
+                       __ses_path_pr(f, path, j0, j, NULL, &r, &jr);
+
+                       r  = tr  - r;
+                       jr = jtr - jr;
+
+                       if (p->sr != p->pr)
+                               j0 = j;
+
+                       ses_ir_u(&v, &jv, da, dja, r, jr);
+
+                       p->v  += v;
+                       p->jv += jv;
+
+                       f->elines[p->lid]->v  = p->v;
+                       f->elines[p->lid]->jv = p->jv;
+
+                       scf_loge("c%ldp%ld->v: %lg, r: %lg, %lg\n", p->cid, p->id, p->v, r, p->sr);
+               }
+
+               assert(p0);
+
+               vip = path->pins->data[j - 1];
+
+               if (j - 1 != j0) {
+
+                       __ses_path_sr(f, path, j0, j, NULL, &r, &jr);
+
+                       tr  -= r;
+                       jtr -= jr;
+
+                       ses_ir_u(&v, &jv, da, dja, r, jr);
+
+                       vip->v  += v;
+                       vip->jv += jv;
+
+                       f->elines[vip->lid]->v  = vip->v;
+                       f->elines[vip->lid]->jv = vip->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);
+               }
+       }
+
+       return 0;
+}
+
+int __ses_flow_a_neg(ScfEfunction* f, ses_flow_t* flow, double a_bridge, double ja_bridge)
 {
        if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip)
                return -EINVAL;
@@ -204,7 +296,7 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* bridge, int* change
        fp0   = fpath->pins->data[0];
        fp1   = fpath->pins->data[fpath->pins->size - 1];
 
-       scf_logw("flow vip: c%ldp%ld->a: %lg, fp0: c%ldp%ld->a: %lg, fp1: c%ldp%ld->a: %lg\n",
+       scf_logw("flow vip: c%ldp%ld->a: %lg, fp0: c%ldp%ld->a: %lg, fp1: c%ldp%ld->a: %lg\n\n",
                        flow->vip->cid, flow->vip->id, flow->vip->a, fp0->cid, fp0->id, fp0->a, fp1->cid, fp1->id, fp1->a);
 
        double da  = 0;
@@ -215,7 +307,10 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* bridge, int* change
 
        double Eta = 0.001;
 
+       int k = 0;
        do {
+               scf_logw("k: %d, ****************\n", k);
+
                ret = __ses_path_va(f, bridge, changed);
                if (ret < 0)
                        return ret;
@@ -228,17 +323,25 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* bridge, int* change
 
                scf_loge("da: %lg, a: %lg\n", da, a);
 
-               ret = __ses_flow_va_pos(f, flow, a, ja);
+               double dv  = flow->vip->v;
+               double djv = flow->vip->jv;
+
+               ret = __ses_flow_a_pos(f, flow, a, ja);
                if (ret < 0)
                        return ret;
-               scf_logi("----------------\n\n");
 
-               ret = __ses_flow_va_neg(f, flow, a, ja);
+               dv  = flow->vip->v  - dv;
+               djv = flow->vip->jv - djv;
+
+               scf_logi("dv: %lg, ----------------\n", dv);
+
+               ret = __ses_flow_v_neg(f, flow, a, ja);
                if (ret < 0)
                        return ret;
-               scf_logw("****************\n\n");
+               printf("\n");
 
-       } while (0);
+               k++;
+       } while (k < 3);
 
        scf_logw("bridge: %d, c%ldp%ld--c%ldp%ld, v: %lg, p0->v: %lg, p1->v: %lg, n_diodes: %d, p0->a: %lg, p1->a: %lg\n",
                        bridge->index, p0->cid, p0->id, p1->cid, p1->id, v, p0->v, p1->v, bridge->n_diodes, p0->a, p1->a);