ses_step_topo.c
authoryu.dongliang <18588496441@163.com>
Tue, 25 Jul 2023 12:10:47 +0000 (20:10 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 25 Jul 2023 12:10:47 +0000 (20:10 +0800)
Makefile
ses_step_topo.c [new file with mode: 0644]
ses_step_va.c
ses_steps.c

index cbd33639b73599260c51b3692f018bb3bef1d05c..5b3ab32e4a1048236736bf20a2ec8daf6dd1ed1e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,8 @@ CFILES += ses_step_dc_diode.c
 CFILES += ses_step_dc_transistor.c
 
 CFILES += ses_step_simplify.c
+CFILES += ses_step_topo.c
+
 CFILES += ses_step_va.c 
 CFILES += ses_step_va_balance.c
 CFILES += ses_step_output.c
diff --git a/ses_step_topo.c b/ses_step_topo.c
new file mode 100644 (file)
index 0000000..618c6f0
--- /dev/null
@@ -0,0 +1,124 @@
+#include"ses_core.h"
+
+static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp)
+{
+       ScfEcomponent*   c;
+       ScfEline*        el;
+       ScfEpin*         np;
+       ScfEpin*         p;
+
+       size_t i;
+       size_t j;
+
+       if (SCF_EDA_Status_OFF == rc->status)
+               return 0;
+
+       if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id)
+               return 0;
+
+       if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id)
+               return 0;
+
+       rp->vflag = 1;
+
+       scf_logi("c%ld_p%ld, l%ld\n", rc->id, rp->id, rp->lid);
+
+       for (i = 0; i < rc->n_pins; i++) {
+               np =        rc->pins[i];
+
+               if (np->vflag)
+                       continue;
+               np->vflag = 1;
+
+               scf_logi("c%ld_p%ld, l%ld\n", rc->id, np->id, np->lid);
+
+               el = f->elines[np->lid];
+
+               if (SCF_EDA_PIN_POS & el->flags) {
+                       scf_loge("pos l%ld\n\n", el->id);
+                       continue;
+               }
+
+               if (SCF_EDA_PIN_NEG & el->flags) {
+                       scf_loge("neg l%ld\n\n", el->id);
+                       return 0;
+               }
+
+               for (j = 0; j + 1 < el->n_pins; j += 2) {
+
+                       c  = f->components[el->pins[j]];
+                       p  = c->pins      [el->pins[j + 1]];
+
+                       if (p->vflag)
+                               continue;
+                       p->vflag = 1;
+
+//                     scf_logi("c%ld_p%ld, l%ld\n", c->id, p->id, p->lid);
+
+                       int ret = __dfs_route(f, c, p);
+                       if (ret < 0)
+                               return ret;
+               }
+       }
+
+       return 0;
+}
+
+static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+{
+       ScfEcomponent*   c;
+       ScfEcomponent*   B;
+       ScfEline*        el;
+       ScfEline*        el2;
+       ScfEline*        elp;
+       ScfEline*        eln;
+       ScfEpin*         p;
+
+       size_t i;
+       size_t j;
+       size_t k;
+
+       B = f->components[0];
+
+       elp = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
+       eln = f->elines[B->pins[SCF_EDA_Battery_NEG]->lid];
+
+       for (i = 0; i < f->n_elines; i++) {
+               el        = f->elines[i];
+               el->vflag = 0;
+       }
+
+       for (i = 0; i < f->n_components; i++) {
+               c         = f->components[i];
+               c->vflag  = 0;
+
+               for (j = 0; j < c->n_pins; j++) {
+                       p         = c->pins[j];
+                       p->vflag  = 0;
+               }
+       }
+
+       for (i = 0; i + 1 < elp->n_pins; i += 2) {
+
+               c  = f->components[elp->pins[i]];
+               p  = c->pins      [elp->pins[i + 1]];
+
+               if (c == B)
+                       continue;
+
+               scf_loge("i: %ld\n", i);
+
+               __dfs_route(f, c, p);
+
+               printf("\n");
+       }
+
+       return 0;
+}
+
+ses_step_t  ses_step_topo =
+{
+       .name    = "topo",
+
+       .handler = _topo_handler,
+};
index aa90f19c811628f53c4f841b45583f3e1972c297..c5df06d86f7716e446ba2b4fc7a46cc861562f71 100644 (file)
@@ -1,69 +1,5 @@
 #include"ses_core.h"
 
-static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp)
-{
-       ScfEcomponent*   c;
-       ScfEline*        el;
-       ScfEpin*         np;
-       ScfEpin*         p;
-
-       size_t i;
-       size_t j;
-
-       if (SCF_EDA_Status_OFF == rc->status)
-               return 0;
-
-       if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id)
-               return 0;
-
-       if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id)
-               return 0;
-
-       rp->vflag = 1;
-
-       scf_logi("c%ld_p%ld, l%ld\n", rc->id, rp->id, rp->lid);
-
-       for (i = 0; i < rc->n_pins; i++) {
-               np =        rc->pins[i];
-
-               if (np->vflag)
-                       continue;
-               np->vflag = 1;
-
-               scf_logi("c%ld_p%ld, l%ld\n", rc->id, np->id, np->lid);
-
-               el = f->elines[np->lid];
-
-               if (SCF_EDA_PIN_POS & el->flags) {
-                       scf_loge("pos l%ld\n\n", el->id);
-                       continue;
-               }
-
-               if (SCF_EDA_PIN_NEG & el->flags) {
-                       scf_loge("neg l%ld\n\n", el->id);
-                       return 0;
-               }
-
-               for (j = 0; j + 1 < el->n_pins; j += 2) {
-
-                       c  = f->components[el->pins[j]];
-                       p  = c->pins      [el->pins[j + 1]];
-
-                       if (p->vflag)
-                               continue;
-                       p->vflag = 1;
-
-//                     scf_logi("c%ld_p%ld, l%ld\n", c->id, p->id, p->lid);
-
-                       int ret = __dfs_route(f, c, p);
-                       if (ret < 0)
-                               return ret;
-               }
-       }
-
-       return 0;
-}
-
 static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
 {
        ScfEcomponent*   c;
@@ -80,39 +16,6 @@ static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ct
 
        B = f->components[0];
 
-       elp = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
-       eln = f->elines[B->pins[SCF_EDA_Battery_NEG]->lid];
-
-       for (i = 0; i < f->n_elines; i++) {
-               el        = f->elines[i];
-               el->vflag = 0;
-       }
-
-       for (i = 0; i < f->n_components; i++) {
-               c         = f->components[i];
-               c->vflag  = 0;
-
-               for (j = 0; j < c->n_pins; j++) {
-                       p         = c->pins[j];
-                       p->vflag  = 0;
-               }
-       }
-
-       for (i = 0; i + 1 < elp->n_pins; i += 2) {
-
-               c  = f->components[elp->pins[i]];
-               p  = c->pins      [elp->pins[i + 1]];
-
-               if (c == B)
-                       continue;
-
-               scf_loge("i: %ld\n", i);
-
-               __dfs_route(f, c, p);
-
-               printf("\n");
-       }
-
        return 0;
 }
 
index 7e19bb82c03a181bb758003ed46942bb2985f500..62a0b2b5bc4e1f31be9a1b70481a1fe7df312938 100644 (file)
@@ -12,6 +12,7 @@ extern ses_step_t   ses_step_dc_transistor;
 //extern ses_step_t   ses_step_ac_diode;
 
 extern ses_step_t   ses_step_simplify;
+extern ses_step_t   ses_step_topo;
 extern ses_step_t   ses_step_va;
 extern ses_step_t   ses_step_va_balance;
 
@@ -27,6 +28,7 @@ static ses_step_t*  ses_steps[] =
        &ses_step_dc_transistor,
 
        &ses_step_simplify,
+       &ses_step_topo,
        &ses_step_va,
        &ses_step_va_balance,