From: yu.dongliang <18588496441@163.com> Date: Mon, 10 Jul 2023 07:17:12 +0000 (+0800) Subject: ses layout X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=2fbad6c979e3836d585691125e49edd88683909f;p=ses.git ses layout --- diff --git a/ses_layout.c b/ses_layout.c index e46bba4..05b772e 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -232,6 +232,86 @@ int ses_lines_same_components(ScfEfunction* f) return 0; } +int __ses_layout_function2(ScfEfunction* f, ScfEline* el, size_t* pn, uint32_t d, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh) +{ + ScfLine* l; + + uint32_t w = el->n_pins * d; + size_t m = (w + bw - 1) / bw; + size_t n = *pn; + uint32_t h = (n + m) * d; + size_t j; + + if (h > bh) { + scf_loge("board's height too small, h: %d, bh: %d\n", h, bh); + return -EINVAL; + } + + if (f->w < w) + f->w = w; + f->h = h; + + for (j = 0; j < m; j++) { + + l = malloc(sizeof(ScfLine)); + if (!l) + return -ENOMEM; + + l->x0 = bx; + l->y0 = by + (n + j) * d; + l->y1 = l->y0; + + if (w > bw) { + l->x1 = l->x0 + bw; + w -= bw; + } else + l->x1 = l->x0 + w; + + scf_logi("el->id: %ld, j: %ld, n: %ld, y0: %d, x1: %d\n", el->id, j, n, l->y0, l->x1); + + if (scf_eline__add_line(el, l) < 0) { + free(l); + return -ENOMEM; + } + } + + printf("\n"); + + *pn += m; + return 0; +} + +int __ses_layout_function(ScfEfunction* f, ScfEline* el, size_t* pn, uint32_t d, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh) +{ + ScfEline* el2; + ScfEconn* ec; + + size_t i; + size_t j; + + int ret = __ses_layout_function2(f, el, pn, d, bx, by, bw, bh); + if (ret < 0) + return ret; + + for (i = 0; i < el->n_conns; i++) { + ec = el->conns[i]; + + for (j = 0; j < f->n_elines; j++) { + el2 = f->elines[j]; + + if (el2->id == ec->lid && 0 == el2->n_lines) { + + ret = __ses_layout_function(f, el2, pn, d, bx, by, bw, bh); + if (ret < 0) + return ret; + break; + } + } + } + + return 0; +} + int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh) { ScfEline* el; @@ -257,46 +337,12 @@ int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, u for (i = 0; i < f->n_elines; i++) { el = f->elines[i]; - w = el->n_pins * d; - m = (w + bw - 1) / bw; - h = (n + m) * d; - - if (h > bh) { - scf_loge("board's height too small, h: %d, bh: %d\n", h, bh); - return -EINVAL; - } - - if (f->w < w) - f->w = w; - f->h = h; - - for (j = 0; j < m; j++) { - - l = malloc(sizeof(ScfLine)); - if (!l) - return -ENOMEM; - - l->x0 = bx; - l->y0 = by + (n + j) * d; - l->y1 = l->y0; - - if (w > bw) { - l->x1 = l->x0 + bw; - w -= bw; - } else - l->x1 = l->x0 + w; + if (0 == el->n_lines) { - scf_logi("i: %ld, el->id: %ld, j: %ld, n: %ld, y0: %d, x1: %d\n", i, el->id, j, n, l->y0, l->x1); - - if (scf_eline__add_line(el, l) < 0) { - free(l); - return -ENOMEM; - } + int ret = __ses_layout_function(f, el, &n, d, bx, by, bw, bh); + if (ret < 0) + return ret; } - - printf("\n"); - - n += m; } scf_logi("f->x: %d, f->y: %d, f->w: %d, f->h: %d\n", f->x, f->y, f->w, f->h);