{
const ScfEline* el0 = *(const ScfEline**)v0;
const ScfEline* el1 = *(const ScfEline**)v1;
-#if 0
- 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;
-#endif
if (el0->n_conns < el1->n_conns)
return 1;
return 0;
}
+int eline_cmp_id(const void* v0, const void* v1)
+{
+ const ScfEline* el0 = *(const ScfEline**)v0;
+ const ScfEline* el1 = *(const ScfEline**)v1;
+
+ if (el0->id < el1->id)
+ return -1;
+
+ if (el0->id > el1->id)
+ return 1;
+
+ return 0;
+}
+
int ses_pins_same_line(ScfEfunction* f)
{
ScfEcomponent* c;
}
}
+ for (i = 0; i < f->n_elines; i++) {
+ el0 = f->elines[i];
+
+ for (m = 0; m + 3 < el0->n_pins; m += 2) {
+
+ c0 = f->components[el0->pins[m]];
+
+ if (2 != c0->n_pins)
+ continue;
+
+ p0 = c0->pins[ el0->pins[m + 1]];
+ p1 = c0->pins[!el0->pins[m + 1]];
+
+ for (n = 2; n + 1 < el0->n_pins; n += 2) {
+
+ c1 = f->components[el0->pins[n]];
+ if (2 != c1->n_pins)
+ continue;
+
+ p2 = c1->pins[ el0->pins[n + 1]];
+ p3 = c1->pins[!el0->pins[n + 1]];
+
+ if ((p1->y < p0->y && p3->y < p0->y)
+ || (p1->y > p0->y && p3->y > p0->y)) {
+
+ if ((p0->x > p2->x && p1->x < p3->x)
+ || (p0->x < p2->x && p1->x > p3->x))
+ SCF_XCHG(p0->x, p2->x);
+ }
+ }
+ }
+ }
+
int mx = 0;
for (i = 0; i < f->n_components - 1; i++) {
}
}
- for (i = 0; i < f->n_elines; i++) {
- el0 = f->elines[i];
-
- el0->lines[0]->x1 -= mx - d;
-
- for (m = 0; m + 3 < el0->n_pins; m += 2) {
-
- c0 = f->components[el0->pins[m]];
-
- if (2 != c0->n_pins)
- continue;
-
- p0 = c0->pins[ el0->pins[m + 1]];
- p1 = c0->pins[!el0->pins[m + 1]];
-
- for (n = 2; n + 1 < el0->n_pins; n += 2) {
-
- c1 = f->components[el0->pins[n]];
- if (2 != c1->n_pins)
- continue;
-
- p2 = c1->pins[ el0->pins[n + 1]];
- p3 = c1->pins[!el0->pins[n + 1]];
-
- if ((p1->y < p0->y && p3->y < p0->y)
- || (p1->y > p0->y && p3->y > p0->y)) {
-
- if (p0->x > 0 && p1->x > 0 && p2->x > 0 && p3->x > 0) {
-
- if ((p0->x > p2->x && p1->x < p3->x)
- || (p0->x < p2->x && p1->x > p3->x))
- SCF_XCHG(p0->x, p2->x);
-
- } else if (p0->x < 0 && p1->x < 0 && p2->x < 0 && p3->x < 0) {
- }
- }
- }
- }
- }
+ qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id);
for (i = 0; i < f->n_components; i++) {
c0 = f->components[i];
p0->x -= mx - d;
+ el0 = f->elines[p0->lid];
+
+ if (el0->lines[0]->x1 < p0->x)
+ el0->lines[0]->x1 = p0->x;
+
+ if (c0->id == 11)
+ scf_loge("p0->x: %d, p0->lid: %ld, el0->id: %ld, el0->x1: %d\n", p0->x, p0->lid, el0->id, el0->lines[0]->x1);
+
cx += p0->x;
cy += p0->y;
}