From: yu.dongliang <18588496441@163.com> Date: Mon, 10 Jul 2023 10:36:14 +0000 (+0800) Subject: ses layout X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=7b795094be2c0057977fdedcccd2b14d40a2d480;p=ses.git ses layout --- diff --git a/main.c b/main.c index 2c881dc..17d4ce1 100644 --- a/main.c +++ b/main.c @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) ScfEboard* b = scf_eboard__unpack(NULL, len, pb); - ses_layout_board(b, 0, 0, 200, 200); + ses_layout_board(b, 0, 0, 400, 400); #if 0 size_t i; size_t j; diff --git a/ses_layout.c b/ses_layout.c index d4af27d..6381934 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -361,44 +361,37 @@ 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]; - uint32_t sum = 0; + for (j = 0; j + 1 < el->n_pins; j += 2) { - for (j = 0; j < el->n_conns; j++) { - ec = el->conns[j]; + uint64_t cid = el->pins[j]; + uint64_t pid = el->pins[j + 1]; - el2 = NULL; - for (k = 0; k < f->n_elines; k++) { - el2 = f->elines[k]; - - if (el2->id == ec->lid) - break; - } + scf_logi("j: %ld, cid: %ld, pid: %ld\n", j, cid, pid); - assert(k < f->n_elines); - uint32_t dis = UINT_MAX; + ScfEcomponent* c = f->components[cid]; + ScfEpin* p = NULL; - for (k = 0; k < el->n_lines; k++) { - l = el->lines[k]; + assert(c->id == cid); - for (m = 0; m < el2->n_lines; m++) { - l2 = el2->lines[m]; + for (k = 0; k < c->n_pins; k++) { + p = c->pins[k]; - uint32_t dis2; + if (p->id == pid) + break; + p = NULL; + } + assert(p); - if (l->y0 < l2->y0) - dis2 = l2->y0 - l->y0; - else - dis2 = l->y0 - l2->y0; + m = j * d / f->w; + assert(m < el->n_lines); - if (dis > dis2) - dis = dis2; - } - } + l = el->lines[m]; + m = j * d % f->w; + assert(m < l->x1); - sum += dis; + p->x = l->x1 - m; + p->y = l->y0; } - - scf_logi("el->id: %ld, sum: %d\n", el->id, sum); } return 0; @@ -406,8 +399,10 @@ int ses_layout_function(ScfEfunction* f, uint32_t d, uint32_t bx, uint32_t by, u int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh) { + ScfEcomponent* c; ScfEfunction* f; ScfEline* el; + ScfEpin* p; ScfLine* l; cairo_surface_t* surface; @@ -416,7 +411,7 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, bx + bw, by + bh); cr = cairo_create (surface); - cairo_set_line_width(cr, 1); + cairo_set_line_width(cr, 2); cairo_set_source_rgb(cr, 1, 1, 1); cairo_rectangle (cr, 0, 0, bx + bw, by + bh); cairo_fill(cr); @@ -426,15 +421,11 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ size_t j; size_t k; - double colors[5][3] = + double lcolors[3][3] = { - {0, 1, 0}, - {1, 0, 1}, - {1, 1, 0}, + {1, 0.5, 0}, {0, 1, 1}, - - {1, 0.5, 0.5}, }; for (i = 0; i < b->n_functions; i++) { @@ -443,9 +434,9 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ for (j = 0; j < f->n_elines; j++) { el = f->elines[j]; - double red = colors[j % 5][0]; - double green = colors[j % 5][1]; - double blue = colors[j % 5][2]; + double red = lcolors[j % 3][0]; + double green = lcolors[j % 3][1]; + double blue = lcolors[j % 3][2]; cairo_set_source_rgb(cr, red, green, blue); @@ -459,6 +450,42 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_ } } + double ccolors[3][3] = + { + {1, 0, 0}, + {0, 1, 0}, + {0, 0, 1}, + }; + + for (i = 0; i < b->n_functions; i++) { + f = b->functions[i]; + + for (j = 0; j < f->n_components; j++) { + c = f->components[j]; + + double red = ccolors[j % 3][0]; + double green = ccolors[j % 3][1]; + double blue = ccolors[j % 3][2]; + + cairo_set_source_rgb(cr, red, green, blue); + + scf_logw("j: %ld, c->id: %ld, n_pins: %ld, ", j, c->id, c->n_pins); + + for (k = 0; k < c->n_pins; k++) { + p = c->pins[k]; + + printf("p[%ld]: %d,%d, ", k, p->x, p->y); + + if (0 == k) + cairo_move_to(cr, p->x, p->y); + else + cairo_line_to(cr, p->x, p->y); + } + printf("\n"); + } + cairo_stroke(cr); + } + cairo_surface_write_to_png(surface, "./a.png"); cairo_destroy(cr); @@ -483,7 +510,11 @@ int ses_layout_board(ScfEboard* b, uint32_t x, uint32_t y, uint32_t w, uint32_t ses_lines_same_components(f); - ses_layout_function(f, 5, x + 20, y + 20, w - 20, h - 20); + int ret = ses_layout_function(f, 25, x + 30, y + 30, w - 40, h - 40); + if (ret < 0) { + scf_loge("\n"); + return ret; + } } ses_layout_draw(b, x, y, w, h);