tmp
authoryu.dongliang <18588496441@163.com>
Wed, 26 Jul 2023 15:32:09 +0000 (23:32 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 26 Jul 2023 15:32:09 +0000 (23:32 +0800)
ses_step_dc_input.c
ses_step_topo.c

index ca39b206eb47777b618327bc4a523b3db631c485..30b9657c38bceb49642a032962114a7524562a24 100644 (file)
@@ -17,8 +17,8 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx
 
                if (SCF_EDA_PIN_IN & el->flags) {
 
-//                     el->v = (rand() & 0x1) * B->v;
-                       el->v = B->v;
+                       el->v = (rand() & 0x1) * B->v;
+//                     el->v = B->v;
 
                        scf_logw("IN el: %ld, V: %lg\n", el->id, el->v);
                }
index 3209591d27365e0ca081580493d2b70739715f0f..0843179a29780709c1cfa5e812f1526e892f9b7d 100644 (file)
@@ -2,7 +2,6 @@
 
 static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, ses_path_t** ppath)
 {
-       ses_path_t*      path = *ppath;
        ScfEcomponent*   c;
        ScfEline*        el;
        ScfEpin*         np;
@@ -10,6 +9,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
 
        size_t i;
        size_t j;
+       size_t k;
 
        if (SCF_EDA_Status_OFF == rc->status)
                return SCF_EDA_Status_OFF;
@@ -20,15 +20,13 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
        if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id)
                return SCF_EDA_Path_OFF;
 
-       if (!path) {
-               path = ses_path_alloc();
-               if (!path)
+       if (!*ppath) {
+               *ppath = ses_path_alloc();
+               if (!*ppath)
                        return -ENOMEM;
-
-               *ppath = path;
        }
 
-       if (scf_vector_add(path->pins, rp) < 0)
+       if (scf_vector_add((*ppath)->pins, rp) < 0)
                return -ENOMEM;
 
        if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != rp->id)
@@ -56,7 +54,13 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
                        continue;
                }
 
-               if (scf_vector_add(path->pins, np) < 0)
+               if (!*ppath) {
+                       *ppath = ses_path_alloc();
+                       if (!*ppath)
+                               return -ENOMEM;
+               }
+
+               if (scf_vector_add((*ppath)->pins, np) < 0)
                        return -ENOMEM;
 
                if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != np->id)
@@ -65,13 +69,11 @@ 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, path) < 0)
+                       if (scf_vector_add(ctx->paths, *ppath) < 0)
                                return -ENOMEM;
 
-                       path->type = SES_PATH_MAIN;
-
-                       for (j = 0; j < path->pins->size; j++) {
-                               p         = path->pins->data[j];
+                       for (j = 0; j < (*ppath)->pins->size; j++) {
+                               p         = (*ppath)->pins->data[j];
                                p->pflag  = 1;
                        }
 
@@ -88,8 +90,18 @@ 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);
-                               ret = SCF_EDA_Path_TO;
-                               goto end;
+
+                               if (scf_vector_add(ctx->paths, *ppath) < 0)
+                                       return -ENOMEM;
+
+                               for (k = 0; k < (*ppath)->pins->size; k++) {
+                                       p         = (*ppath)->pins->data[k];
+                                       p->pflag  = 1;
+                               }
+
+                               ret    = SCF_EDA_Path_TO;
+                               *ppath = NULL;
+                               break;
                        }
 
                        if (p->vflag)
@@ -105,10 +117,10 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
                        if (SCF_EDA_Path_OFF == ret)
                                p->vflag = 0;
                        else if (SCF_EDA_Path_TO == ret)
-                               goto end;
+                               break;
                }
 
-               if (ret > 0) {
+               if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) {
                        if (*ppath)
                                scf_vector_del((*ppath)->pins, np);
 
@@ -117,7 +129,7 @@ static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t
                }
        }
 
-       if (ret > 0) {
+       if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) {
                if (*ppath)
                        scf_vector_del((*ppath)->pins, rp);
 
@@ -195,8 +207,7 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
                        return -ENOMEM;
                }
 
-               path->type = SES_PATH_BRANCH;
-               path       = NULL;
+               path = NULL;
        }
 
        if (path) {