From: yu.dongliang <18588496441@163.com> Date: Mon, 16 Oct 2023 16:16:36 +0000 (+0800) Subject: __ses_layout_components() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=1ad842da8d4f66a857cdb81973361b9a57084a06;p=ses.git __ses_layout_components() --- diff --git a/ses_layout.c b/ses_layout.c index 3729f66..5dbbf52 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -418,56 +418,47 @@ int ses_lines_same_components(ScfEfunction* f) return 0; } -int ses_layout_function(ScfEfunction* f, int d) +int __ses_layout_lines(ScfEfunction* f, int d) { - ScfEcomponent* c0; - ScfEcomponent* c1; - ScfEline* el0; - ScfEline* el1; - ScfEline* el2; - - ScfEconn* ec; - ScfLine* l0; - ScfLine* l1; - ScfLine* l2; - - ScfEpin* p0; - ScfEpin* p1; - ScfEpin* p2; - ScfEpin* p3; - - size_t i; - size_t j; - size_t k; - size_t m; - size_t n; - size_t q; + ScfEline* el; + ScfLine* l; - f->x = 0; - f->y = 0; - f->w = 0; - f->h = 0; + size_t i; for (i = 0; i < f->n_elines; i++) { - el0 = f->elines[i]; + el = f->elines[i]; - l0 = malloc(sizeof(ScfLine)); - if (!l0) + l = malloc(sizeof(ScfLine)); + if (!l) return -ENOMEM; - l0->x0 = d * abs(i - f->n_elines / 2); - l0->x1 = d + l0->x0; - l0->y0 = d + i * d; - l0->y1 = l0->y0; + l->x0 = d * abs(i - f->n_elines / 2); + l->x1 = d + l->x0; + l->y0 = d + i * d; + l->y1 = l->y0; - if (scf_eline__add_line(el0, l0) < 0) { - free(l0); + if (scf_eline__add_line(el, l) < 0) { + free(l); return -ENOMEM; } - if (f->h < l0->y0) - f->h = l0->y0; + if (f->h < l->y0) + f->h = l->y0; } +} + +void __ses_layout_components(ScfEfunction* f, int d) +{ + ScfEcomponent* c; + ScfEline* el0; + ScfEline* el1; + ScfEpin* p0; + ScfEpin* p1; + + size_t i; + size_t j; + size_t m; + size_t n; for (i = 0; i < f->n_elines - 1; i++) { el0 = f->elines[i]; @@ -487,10 +478,10 @@ int ses_layout_function(ScfEfunction* f, int d) n += 2; else { - c0 = f->components[el0->pins[m]]; + c = f->components[el0->pins[m]]; - p0 = c0->pins[el0->pins[m + 1]]; - p1 = c0->pins[el1->pins[n + 1]]; + p0 = c->pins[el0->pins[m + 1]]; + p1 = c->pins[el1->pins[n + 1]]; p0->x = el0->lines[0]->x1 + j * d + 10 + rand() % d; p1->x = el1->lines[0]->x1 + j * d + 10 + rand() % d; @@ -518,8 +509,8 @@ int ses_layout_function(ScfEfunction* f, int d) for (m = 0; m + 1 < el0->n_pins; m += 2) { - c0 = f->components[el0->pins[m]]; - p0 = c0->pins[el0->pins[m + 1]]; + c = f->components[el0->pins[m]]; + p0 = c->pins [el0->pins[m + 1]]; if (0 == p0->x) { @@ -533,6 +524,43 @@ int ses_layout_function(ScfEfunction* f, int d) } } } +} + +int ses_layout_function(ScfEfunction* f, int d) +{ + ScfEcomponent* c0; + ScfEcomponent* c1; + ScfEline* el0; + ScfEline* el1; + ScfEline* el2; + + ScfEconn* ec; + ScfLine* l0; + ScfLine* l1; + ScfLine* l2; + + ScfEpin* p0; + ScfEpin* p1; + ScfEpin* p2; + ScfEpin* p3; + + size_t i; + size_t j; + size_t k; + size_t m; + size_t n; + size_t q; + + f->x = 0; + f->y = 0; + f->w = 0; + f->h = 0; + + int ret = __ses_layout_lines(f, d); + if (ret < 0) + return ret; + + __ses_layout_components(f, d); for (i = 0; i < f->n_elines; i++) { el0 = f->elines[i];