From: yu.dongliang <18588496441@163.com> Date: Sat, 30 Sep 2023 11:03:59 +0000 (+0800) Subject: ses_pins_same_line() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=70cb38e96209774b5badd3161616399d34315f88;p=ses.git ses_pins_same_line() --- diff --git a/ses_layout.c b/ses_layout.c index 019c994..2a00d8a 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -73,6 +73,7 @@ int ses_pins_same_line(ScfEfunction* f) { ScfEcomponent* c; ScfEline* el; + ScfEline* el2; ScfEpin* p; ScfEpin* p2; @@ -142,24 +143,68 @@ int ses_pins_same_line(ScfEfunction* f) p ->c_lid = el->id; el->flags |= p->flags; next: + for (n = 0; n + 1 < p->n_tos; n += 2) { + + p2 = f->components[p->tos[n]]->pins[p->tos[n + 1]]; + + if (p2->cid > p->cid || p2->id > p->id) + break; + + el2 = f->elines[p2->lid]; + + if (el2 == el) + continue; + + if (el2->id < el->id) + SCF_XCHG(el2, el); + + for (m = 0; m + 1 < el2->n_pins; m += 2) { + p2 = f->components[el2->pins[m]]->pins[el2->pins[m + 1]]; + + if (scf_eline__add_pin(el, p2->cid, p2->id) < 0) + return -ENOMEM; + + p2->lid = el->id; + p2->c_lid = el->id; + el->flags |= p2->flags; + } + + qsort(el->pins, el->n_pins / 2, sizeof(uint64_t) * 2, epin_cmp); + + el2->n_pins = 0; + } p = NULL; } } - for (i = 0; i < f->n_elines; i++) { + for (i = 0; i < f->n_elines; ) { el = f->elines[i]; + if (0 == el->n_pins) { + scf_efunction__del_eline(f, el); + scf_eline__free(el); + continue; + } + el->c_pins = el->n_pins; -#if 1 + el->id = i; + scf_logw("line i: %ld, %p, el->flags: %#lx\n", i, el, el->flags); - for (j = 0; j + 1 < el->n_pins; j += 2) + for (j = 0; j + 1 < el->n_pins; j += 2) { + + c = f->components[el->pins[j]]; + p = c->pins [el->pins[j + 1]]; - scf_logi("pin j: %ld, cid: %ld, pid: %ld\n", j, el->pins[j], el->pins[j + 1]); + p->lid = i; + p->c_lid = i; + scf_logi("pin j: %ld, c%ldp%ld\n", j, el->pins[j], el->pins[j + 1]); + } printf("\n"); -#endif + + i++; } return 0; @@ -540,7 +585,7 @@ int ses_layout_function(ScfEfunction* f, int d) int y1 = p0->y < p1->y ? p1->y : p0->y; for (m = i + 1; m < f->n_components; m++) { - c1 = f->components[m]; + c1 = f->components[m]; for (n = 0; n < c1->n_pins - 1; n++) { p2 = c1->pins[n]; @@ -964,7 +1009,7 @@ int ses_layout_board(ScfEboard* b) return ret; } - ses_steps_analyse(f, 5, 1); +// ses_steps_analyse(f, 5, 1); x = f->x; y = f->y; diff --git a/test/main.c b/test/main.c index eaa6325..dfafc94 100644 --- a/test/main.c +++ b/test/main.c @@ -22,17 +22,17 @@ int main(int argc, char* argv[]) B->pins[SCF_EDA_Battery_NEG]->flags = SCF_EDA_PIN_NEG; B->pins[SCF_EDA_Battery_POS]->flags = SCF_EDA_PIN_POS; - EDA_INST_ADD_COMPONENT(f, D0, SCF_EDA_Diode); - EDA_INST_ADD_COMPONENT(f, T0, SCF_EDA_Transistor); - EDA_INST_ADD_COMPONENT(f, R0, SCF_EDA_Resistor); - EDA_INST_ADD_COMPONENT(f, R1, SCF_EDA_Resistor); - EDA_INST_ADD_COMPONENT(f, R2, SCF_EDA_Resistor); + EDA_INST_ADD_COMPONENT(f, D0, SCF_EDA_Diode); // 1 + EDA_INST_ADD_COMPONENT(f, T0, SCF_EDA_Transistor); // 2 + EDA_INST_ADD_COMPONENT(f, R0, SCF_EDA_Resistor); // 3 + EDA_INST_ADD_COMPONENT(f, R1, SCF_EDA_Resistor); // 4 + EDA_INST_ADD_COMPONENT(f, R2, SCF_EDA_Resistor); // 5 EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_POS, D0, SCF_EDA_Diode_POS); EDA_PIN_ADD_PIN(D0, SCF_EDA_Diode_NEG, R0, 1); EDA_PIN_ADD_PIN(R0, 0, R1, 1); EDA_PIN_ADD_PIN(R1, 0, B, SCF_EDA_Battery_NEG); -// EDA_PIN_ADD_PIN(T0, SCF_EDA_Transistor_B, R1, 1); + EDA_PIN_ADD_PIN(T0, SCF_EDA_Transistor_B, R1, 1); EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_POS, R2, 1); EDA_PIN_ADD_PIN(R2, 0, T0, SCF_EDA_Transistor_C);