ScfEboard* b = scf_eboard__unpack(NULL, len, pb);
- ses_layout_board(b, 0, 0, 100, 100);
+ ses_layout_board(b, 0, 0, 30, 160);
#if 0
size_t i;
size_t j;
}
#endif
- scf_eboard__free_unpacked(b, NULL);
+// scf_eboard__free_unpacked(b, NULL);
return 0;
}
return 0;
}
+int econn_cmp(const void* v0, const void* v1)
+{
+ const ScfEconn* ec0 = *(const ScfEconn**)v0;
+ const ScfEconn* ec1 = *(const ScfEconn**)v1;
+
+ if (ec0->n_cids < ec1->n_cids)
+ return 1;
+
+ if (ec0->n_cids > ec1->n_cids)
+ return -1;
+
+ return 0;
+}
+
int eline_cmp(const void* v0, const void* v1)
{
const ScfEline* el0 = *(const ScfEline**)v0;
ec = NULL;
}
+
+ qsort(el0->conns, el0->n_conns, sizeof(ScfEconn*), econn_cmp);
}
if (ec) {
int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh)
{
ScfEline* el;
+ ScfEline* el2;
ScfEconn* ec;
+ ScfLine* l;
- size_t i;
- size_t j;
+ uint32_t w;
+ uint32_t h;
+ size_t i;
+ size_t j;
+ size_t k;
+ size_t m;
+ size_t n;
+
+ f->x = bx;
+ f->y = by;
+ n = 0;
+
+ for (i = 0; i < f->n_elines; i++) {
+ el = f->elines[i];
+
+ w = el->n_pins * d;
+
+ if (w <= bw)
+ n++;
+ else
+ n += (w + bw - 1) / bw;
+ }
+
+ f->h = n * d;
+
+ if (f->h > bh) {
+ scf_loge("board's height too small, f->n_elines: %ld, n: %ld, f->h: %d, bh: %d\n", f->n_elines, n, f->h, bh);
+ return -EINVAL;
+ }
+
+ n = (n + 1) >> 1;
+ m = 0;
for (i = 0; i < f->n_elines; i++) {
el = f->elines[i];
+ w = el->n_pins * d;
+ k = (w + bw - 1) / bw;
+ m += k;
+
+ if (m < n)
+ h = (n - m % n) * d;
+ else
+ h = (n + m % n) * d;
+
+ for (j = 0; j < k; j++) {
+
+ l = malloc(sizeof(ScfLine));
+ if (!l)
+ return -ENOMEM;
+
+ l->x0 = bx;
+ l->y0 = by + h - j * d;
+ l->x1 = l->x0 + w;
+ l->y1 = l->y0;
+
+ scf_logi("el i: %ld, j: %ld, h: %d y0: %d, w: %d, bw: %d\n", i, j, h, l->y0, w, bw);
+
+ if (scf_eline__add_line(el, l) < 0) {
+ free(l);
+ return -ENOMEM;
+ }
+ }
+
+ printf("\n");
}
return 0;
ses_pins_same_line(f);
ses_lines_same_components(f);
+
+ ses_layout_function(f, 5, x + 20, y + 20, w - 20, h - 20);
}
- ses_layout_draw();
+// ses_layout_draw();
return 0;
}