tmp
authoryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 08:04:08 +0000 (16:04 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 11 Jul 2023 08:04:08 +0000 (16:04 +0800)
ses_layout.c

index 8282334dc493c7e968ea0c328d4c3135dfdfdb26..b79ba46fadc47dd7d9b8016dd025fdbee7f823a1 100644 (file)
@@ -39,6 +39,16 @@ int eline_cmp(const void* v0, const void* v1)
        const ScfEline* el0 = *(const ScfEline**)v0;
        const ScfEline* el1 = *(const ScfEline**)v1;
 
+       if (SCF_EDA_PIN_POS == el0->flags)
+               return -1;
+       if (SCF_EDA_PIN_NEG == el0->flags)
+               return 1;
+
+       if (SCF_EDA_PIN_POS == el1->flags)
+               return 1;
+       if (SCF_EDA_PIN_NEG == el1->flags)
+               return -1;
+
        if (el0->n_conns < el1->n_conns)
                return 1;
 
@@ -101,8 +111,14 @@ int ses_pins_same_line(ScfEfunction* f)
                                        else {
                                                if (scf_eline__add_pin(el, p->cid, p->id) < 0)
                                                        return -ENOMEM;
-                                               p->lid = el->id;
-
+                                               p ->lid = el->id;
+
+                                               if (SCF_EDA_Battery == c->type) {
+                                                       if (SCF_EDA_Battery_POS == p->id)
+                                                               el->flags = SCF_EDA_PIN_POS;
+                                                       else
+                                                               el->flags = SCF_EDA_PIN_NEG;
+                                               }
                                                goto next;
                                        }
                                }
@@ -120,7 +136,14 @@ int ses_pins_same_line(ScfEfunction* f)
 
                        if (scf_eline__add_pin(el, p->cid, p->id) < 0)
                                return -ENOMEM;
-                       p->lid = el->id;
+                       p ->lid = el->id;
+
+                       if (SCF_EDA_Battery == c->type) {
+                               if (SCF_EDA_Battery_POS == p->id)
+                                       el->flags = SCF_EDA_PIN_POS;
+                               else
+                                       el->flags = SCF_EDA_PIN_NEG;
+                       }
 next:
                        p = NULL;
                }
@@ -130,7 +153,7 @@ next:
        for (i = 0; i < f->n_elines; i++) {
                el        = f->elines[i];
 
-               scf_logw("line i: %ld, %p\n", i, el);
+               scf_logw("line i: %ld, %p, el->flags: %#lx\n", i, el, el->flags);
 
                for (j = 0; j + 1 < el->n_pins; j += 2)
 
@@ -219,7 +242,7 @@ int ses_lines_same_components(ScfEfunction* f)
        for (i = 0; i < f->n_elines; i++) {
                el0       = f->elines[i];
 
-               scf_loge("i: %ld, el0: %ld, n_conns: %ld, n_pins: %ld\n", i, el0->id, el0->n_conns, el0->n_pins);
+               scf_loge("i: %ld, el0: %ld, n_conns: %ld, n_pins: %ld, flags: %#lx\n", i, el0->id, el0->n_conns, el0->n_pins, el0->flags);
 
                for (j = 0; j < el0->n_conns; j++) {
                        ec        = el0->conns[j];
@@ -259,7 +282,11 @@ int __ses_layout_function2(ScfEfunction* f, ScfEline* el, size_t* pn, uint32_t d
                if (!l)
                        return -ENOMEM;
 
-               l->x0 = bx;
+               if (SCF_EDA_PIN_NEG == el->flags || SCF_EDA_PIN_POS == el->flags)
+                       l->x0 = bx;
+               else
+                       l->x0 = bx + d;
+
                l->y0 = by + (n + j) * d;
                l->y1 = l->y0;
 
@@ -303,11 +330,6 @@ int __ses_layout_function(ScfEfunction* f, ScfEline* el, size_t* pn, uint32_t d,
 
                        if (el2->id == ec->lid && 0 == el2->n_lines) {
 
-                               int diff = 10 + rand() % 20;
-
-                               bx += diff;
-                               bw -= diff;
-
                                ret = __ses_layout_function(f, el2, pn, d, bx, by, bw, bh);
                                if (ret < 0)
                                        return ret;
@@ -350,11 +372,6 @@ int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, u
                        int ret = __ses_layout_function(f, el, &n, d, bx, by, bw, bh);
                        if (ret < 0)
                                return ret;
-
-                       int diff = 10 + rand() % 20;
-
-                       bx += diff;
-                       bw -= diff;
                }
        }
        scf_logi("f->x: %d, f->y: %d, f->w: %d, f->h: %d\n", f->x, f->y, f->w, f->h);