ses_step_va.c
authoryu.dongliang <18588496441@163.com>
Sun, 23 Jul 2023 10:27:06 +0000 (18:27 +0800)
committeryu.dongliang <18588496441@163.com>
Sun, 23 Jul 2023 10:27:06 +0000 (18:27 +0800)
ses_step_simplify.c
ses_step_va.c

index 0bf922deb82321b438de2e5cea0e5d8f8cdc8f8b..598380d3828b1f342ae49f15af9ef5bebea0a163 100644 (file)
@@ -271,6 +271,7 @@ static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count)
 
        _simplify_draw(f, f->x, f->y, f->w, f->h);
 
+       printf("\n");
        return 0;
 }
 
index 3f21a46366940fa873c121b6edbe5e3f13df9ab3..cde11fde1d44c68abb92a79c8c380fc7e453404a 100644 (file)
@@ -1,8 +1,125 @@
 #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)
+{
+       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_va =
 {
-       .name = "va",
+       .name    = "va",
+
+       .handler = _va_handler,
 
 };