return 0;
}
-static void decross_mov_before(ScfEfunction* f, int d, intptr_t dst, intptr_t src)
-{
- ScfEcomponent* c;
- ScfEline* el;
- ScfEpin* p;
- ScfLine* l;
-
- intptr_t i;
- intptr_t j;
- intptr_t k;
-
- intptr_t min = dst < src ? dst : src;
- intptr_t max = dst > src ? dst : src;
-
- int y0 = f->elines[min]->lines[0]->y0;
-
- eline_mov_before(f, dst, src);
-
- for (i = min; i <= max; i++) {
- el = f->elines[i];
-
- int y = y0 + (i - min) * d;
-
- for (j = 0; j < el->n_lines; j++) {
- l = el->lines[j];
-
- l->y0 = y;
- l->y1 = y;
- }
-
- for (j = 0; j + 1 < el->n_pins; j += 2) {
-
- c = f->components[el->pins[j]];
- p = c->pins [el->pins[j + 1]];
-
- p->y = y;
- }
- }
-}
-
static int __ses_de_cross(ScfEfunction* f, int d)
{
ScfEcomponent* c;
for (j = 1; j <= N; j++)
scf_vector_add(colors, (void*)j);
- int try = 0;
- for (j = N; j >= 2; ) {
+ for (j = N; j >= 2; j--) {
int ret = ses_graph_kcolor(graph, j, colors);
if (ret < 0) {
}
}
- if (n > 0) {
- if (try > 0)
- break;
-
- ScfEcomponent* max = NULL;
-
- for (i = 0; i < graph->size; i++) {
- v = graph->data[i];
-
- c = v->data;
- if (v->color < 0 && SCF_EDA_NPN == c->type) {
-
- if (!max || max->color < c->color)
- max = c;
- }
-
- v->color = 0;
- }
-
- i = __ses_find_eline_index(f, max->pins[SCF_EDA_NPN_B]->lid);
- k = __ses_find_eline_index(f, max->pins[SCF_EDA_NPN_C]->lid);
-
- scf_logw("mov c%ld: el%ld [%ld] --> [%ld] el%ld\n\n", max->id, f->elines[k]->id, k, i, f->elines[i]->id);
-
- decross_mov_before(f, d, i, k);
-
- scf_vector_clear(graph, ( void (*)(void*) )ses_vertex_free);
-
- ret = __ses_get_crosses(f, d, graph);
- if (ret < 0)
- return ret;
-
- try++;
- continue;
- }
+ if (n > 0)
+ break;
for (i = 0; i < graph->size; i++) {
v = graph->data[i];
}
scf_vector_del(colors, (void*)j);
- j--;
}
scf_vector_clear(graph, ( void (*)(void*) )ses_vertex_free);
__ses_layout_components(f, d);
__ses_xchg_components(f, d);
+ qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id);
+
ret = __ses_de_cross(f, d);
if (ret < 0)
return ret;
- qsort(f->elines, f->n_elines, sizeof(ScfEline*), eline_cmp_id);
-
__ses_setc_xy(f, d);
__ses_layout_cx(f, d);