ses_step_topo.c
authoryu.dongliang <18588496441@163.com>
Thu, 14 Sep 2023 13:50:08 +0000 (21:50 +0800)
committeryu.dongliang <18588496441@163.com>
Thu, 14 Sep 2023 13:50:08 +0000 (21:50 +0800)
ses_step_topo.c
ses_step_va_balance.c

index 24ce4d04cd50527a78525b768a217d1feed68dd8..508bb1b60d7e2176563910a03d48f560415cdfd1 100644 (file)
@@ -14,7 +14,7 @@ int _ses_path_cmp(const void* v0, const void* v1)
        return 0;
 }
 
-static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, ses_path_t** ppath)
+int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __paths, ses_path_t** ppath)
 {
        ScfEcomponent*   c;
        ScfEline*        el;
@@ -83,7 +83,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
                if (SCF_EDA_PIN_NEG & el->flags) {
                        scf_loge("neg l%ld\n\n", el->id);
 
-                       if (scf_vector_add(ctx->paths, *ppath) < 0)
+                       if (scf_vector_add(__paths, *ppath) < 0)
                                return -ENOMEM;
 
                        for (j = 0; j < (*ppath)->pins->size; j++) {
@@ -105,7 +105,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
                        if (p->pflag && p != np) {
                                scf_loge("branch: c%ld_p%ld, l%ld\n", c->id, p->id, el->id);
 
-                               if (scf_vector_add(ctx->paths, *ppath) < 0)
+                               if (scf_vector_add(__paths, *ppath) < 0)
                                        return -ENOMEM;
 
                                for (k = 0; k < (*ppath)->pins->size; k++) {
@@ -124,7 +124,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
                        if (SCF_EDA_Transistor != c->type || SCF_EDA_Transistor_E != p->id)
                                p->vflag = 1;
 
-                       ret = __dfs_path(f, c, p, ctx, ppath);
+                       ret = __dfs_path(f, c, p, __paths, ppath);
                        if (ret < 0)
                                return ret;
 
@@ -160,7 +160,7 @@ end:
        return ret;
 }
 
-static int _topo_layers(ses_ctx_t* ctx)
+static int _topo_layers(scf_vector_t* paths)
 {
        ses_path_t*      path0;
        ses_path_t*      path1;
@@ -175,13 +175,13 @@ static int _topo_layers(ses_ctx_t* ctx)
        int j;
        int k;
 
-       for (i = 0;  i   < ctx->paths->size; i++) {
-               path0        = ctx->paths->data[i];
+       for (i = 0;  i   < paths->size; i++) {
+               path0        = paths->data[i];
                path0->index = i;
        }
 
-       for (i    = ctx->paths->size - 1; i >= 1; i--) {
-               path0 = ctx->paths->data[i];
+       for (i    = paths->size - 1; i >= 1; i--) {
+               path0 = paths->data[i];
 
                assert(path0->pins->size >= 2);
 
@@ -189,7 +189,7 @@ static int _topo_layers(ses_ctx_t* ctx)
                p1   = path0->pins->data[path0->pins->size - 1];
 
                for (j    = i - 1; j >= 0; j--) {
-                       path1 = ctx->paths->data[j];
+                       path1 = paths->data[j];
 
                        int n = 0;
 
@@ -229,7 +229,7 @@ branch:
                        }
                }
 
-               if (scf_vector_del(ctx->paths, path0) < 0)
+               if (scf_vector_del(paths, path0) < 0)
                        return -1;
 
                scf_loge("path0: %d, path1: %d\n", path0->index, path1->index);
@@ -287,7 +287,7 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
 
                scf_logw("i: %ld\n", i);
 
-               int ret = __dfs_path(f, c, p, ctx, &path);
+               int ret = __dfs_path(f, c, p, ctx->paths, &path);
                if (ret < 0)
                        return ret;
 
@@ -317,7 +317,7 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
 
        scf_vector_qsort(ctx->paths, _ses_path_cmp);
 
-       int ret = _topo_layers(ctx);
+       int ret = _topo_layers(ctx->paths);
        if (ret < 0)
                return ret;
 
index b6deaf0620128cc7e3dd245ec9754dfda9bbd951..70edea655d6e718c873be9387afb01a54ae1140b 100644 (file)
@@ -80,12 +80,12 @@ int ses_paths_find_route(scf_vector_t* __route, scf_vector_t* paths, ScfEpin* p,
        return 0;
 }
 
-static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* path, scf_vector_t* route0, scf_vector_t* route1)
+static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, scf_vector_t* route0, scf_vector_t* route1)
 {
-       if (!path)
+       if (!bridge)
                return -EINVAL;
 
-       if (path->pins->size < 2) {
+       if (bridge->pins->size < 2) {
                scf_loge("\n");
                return -EINVAL;
        }
@@ -97,15 +97,15 @@ static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* path, scf_vector_t
        ScfEpin*       p0;
        ScfEpin*       p1;
        ScfEpin*       p2;
-       ScfEpin*       cp0;
-       ScfEpin*       cp1;
+       ScfEpin*       rp0;
+       ScfEpin*       rp1;
 
        int i;
        int j;
        int k;
 
-       p0 = path->pins->data[0];
-       p1 = path->pins->data[path->pins->size - 1];
+       p0  = bridge->pins->data[0];
+       p1  = bridge->pins->data[bridge->pins->size - 1];
 
        el     = f->elines[p0->lid];
        p0->v  = el->v;
@@ -115,7 +115,32 @@ static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* path, scf_vector_t
        p1->v  = el->v;
        p1->jv = el->jv;
 
-       scf_loge("p0: %lg + j%lg, p1: %lg + j%lg\n", p0->v, p0->jv, p1->v, p1->jv);
+       scf_loge("p0: %lg + j%lg, p1: %lg + j%lg, bridge->r: %lg + j%lg\n", p0->v, p0->jv, p1->v, p1->jv, bridge->r, bridge->jr);
+
+       rp0 = route0->data[0];
+       rp1 = route1->data[0];
+
+       scf_loge("rp0->pr: %lg + j%lg, rp1->pr: %lg + j%lg\n", rp0->pr, rp0->jpr, rp1->pr, rp1->jpr);
+
+       if (p0->v > p1->v) {
+
+               for (i = 0; i < bridge->pins->size; i++) {
+                       p  =        bridge->pins->data[i];
+
+                       c  = f->components[p->cid];
+
+                       if (SCF_EDA_Diode == c->type) {
+
+                               if (SCF_EDA_Diode_NEG == p->id || p0->v - p1->v < SCF_EDA_V_Diode_OFF)
+                                       c->status = SCF_EDA_Status_OFF;
+                               else
+                                       c->status = SCF_EDA_Status_ON;
+                       }
+               }
+
+       } else {
+
+       }
 
        return 0;
 }