size_t i;
size_t j;
size_t k;
+ size_t n;
- for (i = 0; i < f->n_components - 1; i++) {
- c0 = f->components[i];
+ do {
+ n = 0;
- int y0 = INT_MAX;
- int y1 = INT_MIN;
+ for (i = 0; i < f->n_components - 1; i++) {
+ c0 = f->components[i];
- int m = (c0->color - 1) % 2;
+ int y0 = INT_MAX;
+ int y1 = INT_MIN;
- for (k = 0; k < c0->n_pins; k++) {
- p = c0->pins[k];
+ int m = (c0->color - 1) % 2;
- if (y0 > p->y)
- y0 = p->y;
+ for (k = 0; k < c0->n_pins; k++) {
+ p = c0->pins[k];
- if (y1 < p->y)
- y1 = p->y;
- }
+ if (y0 > p->y)
+ y0 = p->y;
- if (y1 - y0 <= d)
- continue;
-
- for (j = i + 1; j < f->n_components; j++) {
- c1 = f->components[j];
+ if (y1 < p->y)
+ y1 = p->y;
+ }
- if ((c0->color != c1->color) && (0 != c1->color || c0->color > 2))
+ if (y1 - y0 <= d)
continue;
- int y2 = INT_MAX;
- int y3 = INT_MIN;
+ for (j = i + 1; j < f->n_components; j++) {
+ c1 = f->components[j];
+
+ if ((c0->color != c1->color) && (0 != c1->color || c0->color > 2))
+ continue;
- for (k = 0; k < c1->n_pins; k++) {
- p = c1->pins[k];
+ int y2 = INT_MAX;
+ int y3 = INT_MIN;
- if (y2 > p->y)
- y2 = p->y;
+ for (k = 0; k < c1->n_pins; k++) {
+ p = c1->pins[k];
- if (y3 < p->y)
- y3 = p->y;
- }
+ if (y2 > p->y)
+ y2 = p->y;
- if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) {
+ if (y3 < p->y)
+ y3 = p->y;
+ }
- if ((0 == m && c0->x > c1->x) || (1 == m && c0->x < c1->x))
- __ses_xchg_cx2(c0, c1);
+ if ((y0 <= y2 && y3 < y1) || (y0 < y2 && y3 <= y1)) {
+
+ if ((0 == m && c0->x > c1->x) || (1 == m && c0->x < c1->x)) {
+ __ses_xchg_cx2(c0, c1);
+ n++;
+ }
- } else if ((y2 <= y0 && y1 < y3) || (y2 < y0 && y1 <= y3)) {
+ } else if ((y2 <= y0 && y1 < y3) || (y2 < y0 && y1 <= y3)) {
- if ((0 == m && c0->x < c1->x) || (1 == m && c0->x > c1->x))
- __ses_xchg_cx2(c0, c1);
+ if ((0 == m && c0->x < c1->x) || (1 == m && c0->x > c1->x)) {
+ __ses_xchg_cx2(c0, c1);
+ n++;
+ }
+ }
}
}
- }
+ } while (n > 0);
}
static void __ses_layout_cx(ScfEfunction* f, int d)
}
for (j = 0; j < el->n_lines; j++)
- scf_logi("l%ld->lines[%ld]: x0: %d, x1: %d\n", el->id, j, el->lines[j]->x0, el->lines[j]->x1);
- printf("\n");
+ scf_logd("l%ld->lines[%ld]: x0: %d, x1: %d\n", el->id, j, el->lines[j]->x0, el->lines[j]->x1);
+// printf("\n");
}
f->w = tx1 + d;