_simplify_handler
authoryu.dongliang <18588496441@163.com>
Sat, 22 Jul 2023 07:08:43 +0000 (15:08 +0800)
committeryu.dongliang <18588496441@163.com>
Sat, 22 Jul 2023 07:08:43 +0000 (15:08 +0800)
ses_step_simplify.c

index d9880a1531432ae621994066ca8329163e1014ca..0bf922deb82321b438de2e5cea0e5d8f8cdc8f8b 100644 (file)
@@ -224,14 +224,51 @@ static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count)
        ScfEcomponent*   c;
        ScfEcomponent*   B;
        ScfEline*        el;
-       ScfEpin*         pb;
-       ScfEpin*         pc;
-       ScfEpin*         pe;
+       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];
+
+               if (!(SCF_EDA_PIN_IN & el->flags))
+                       continue;
+
+               if (el->v == elp->v)
+                       el2    = elp;
+               else if (el->v == eln->v)
+                       el2    = eln;
+               else
+                       continue;
+
+               for (j = 0; j + 1 < el->n_pins; j += 2) {
+
+                       c  = f->components[el->pins[j]];
+                       p  = c->pins      [el->pins[j + 1]];
+
+                       if (SCF_EDA_Status_OFF == c->status)
+                               continue;
+
+                       int ret = scf_eline__add_pin(el2, c->id, p->id);
+                       if (ret < 0)
+                               return ret;
+
+                       p->lid = el2->id;
+
+                       scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->c_lid, p->lid);
+               }
+       }
+
        _simplify_draw(f, f->x, f->y, f->w, f->h);
 
        return 0;