From: yu.dongliang <18588496441@163.com>
Date: Mon, 6 Nov 2023 05:56:04 +0000 (+0800)
Subject: __ses_de_cross()
X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=248b893fa8bb3f8343061d3b83314202fd50607a;p=ses.git

__ses_de_cross()
---

diff --git a/ses_layout.c b/ses_layout.c
index 8239358..bf2ddf5 100644
--- a/ses_layout.c
+++ b/ses_layout.c
@@ -610,7 +610,7 @@ static int __ses_layout_lines(ScfEfunction* f, int d)
 		if (!l)
 			return -ENOMEM;
 
-		l->x0 = d * abs(i - f->n_elines / 2);
+		l->x0 = d;
 		l->x1 = d + l->x0;
 		l->y0 = d + i * d;
 		l->y1 = l->y0;
@@ -943,6 +943,7 @@ static int __ses_de_cross(ScfEfunction* f, int d)
 	intptr_t N = 2;
 	intptr_t i;
 	intptr_t j;
+	intptr_t k;
 
 	int ret = __ses_get_crosses(f, d, graph);
 	if (ret < 0)
@@ -994,32 +995,30 @@ static int __ses_de_cross(ScfEfunction* f, int d)
 	colors = NULL;
 	graph  = NULL;
 
-	for (i = 0; i < f->n_elines; i++) {
-		el =        f->elines[i];
+	int x1 = 0;
 
-		qsort_r(el->pins, el->n_pins / 2, sizeof(uint64_t) * 2, epin_cmp_color, f);
+	N = j + 1;
 
-		el->lines[0]->x1 = el->lines[0]->x0 + d;
+	for (j = 1; j <= N; j++) {
 
-		for (j = 0; j + 1 < el->n_pins; j += 2) {
+		intptr_t j0 = (j - 1) / 2;
+		intptr_t j1 = (j - 1) % 2;
 
-			c  = f->components[el->pins[j]];
-			p  = c->pins      [el->pins[j + 1]];
-
-			intptr_t k = (c->color - 1) / 2;
-			intptr_t m = (c->color - 1) % 2;
+		for (i = 0; i < f->n_elines; i++) {
+			el =        f->elines[i];
 
-			while (el->n_lines <= k) {
+			if (0 == j0)
+				el->lines[0]->x1 = el->lines[0]->x0;
 
-				scf_logw("el->n_lines: %ld, k: %ld\n", el->n_lines, k);
+			else if (el->n_lines <= j0) {
 
-				l0 = el->lines[el->n_lines - 1];
+				l0 = el->lines[0];
 
 				l = malloc(sizeof(ScfLine));
 				if (!l)
 					return -ENOMEM;
 
-				l->x0 = l0->x1 + d;
+				l->x0 = x1 + d;
 				l->x1 = l->x0;
 				l->y0 = l0->y0;
 				l->y1 = l0->y1;
@@ -1030,9 +1029,21 @@ static int __ses_de_cross(ScfEfunction* f, int d)
 				}
 			}
 
-			l     = el->lines[k];
-			p->x  = l->x1 + d;
-			l->x1 = p->x;
+			for (k = 0; k + 1 < el->n_pins; k += 2) {
+
+				c  = f->components[el->pins[k]];
+				p  = c->pins      [el->pins[k + 1]];
+
+				if ((c->color - 1) / 2 != j0)
+					continue;
+
+				l     = el->lines[j0];
+				p->x  = l->x1 + d;
+				l->x1 = p->x;
+
+				if (x1 < l->x1)
+					x1 = l->x1;
+			}
 		}
 	}