ses_edge_alloc()
authoryu.dongliang <18588496441@163.com>
Wed, 1 Nov 2023 04:43:58 +0000 (12:43 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 1 Nov 2023 04:43:58 +0000 (12:43 +0800)
ses_core.h
ses_layout.c
ses_utils.c

index 0ebcb98aed7f594cc6f27516a35d49de3508812e..300e8a1f7459ea4e94e6c0ffe32758835b5b62ca 100644 (file)
@@ -13,10 +13,9 @@ typedef struct ses_ctx_s     ses_ctx_t;
 
 struct ses_edge_s
 {
-       scf_vector_t*  crosses;
+       ScfEcomponent* c;
 
-       ScfEpin*       p0;
-       ScfEpin*       p1;
+       scf_vector_t*  crosses;
 };
 
 struct ses_flow_s
@@ -117,8 +116,8 @@ void        ses_flow_v_pos(ses_flow_t* flow, double a, double ja);
 void        ses_flow_v_neg(ses_flow_t* flow, double a, double ja);
 void        ses_flow_jr   (ses_flow_t* flow);
 
-ses_edge_t* ses_edge_alloc(ScfEpin*    p0, ScfEpin* p1);
-void        ses_edge_free (ses_edge_t* edge);
+ses_edge_t* ses_edge_alloc(ScfEcomponent* c);
+void        ses_edge_free (ses_edge_t*    edge);
 
 ses_ctx_t*  ses_ctx_alloc();
 void        ses_ctx_free (ses_ctx_t* ctx);
index 172069b25ad1f8cfbc6c2dae2bf3d47c3f23b6b0..de5f9a0f3a0df4fc4c0fbf7db8adaa6930379585 100644 (file)
@@ -721,18 +721,18 @@ static inline int edge_cmp(const void* v0, const void* v1)
        const ses_edge_t* edge0 = v0;
        const ses_edge_t* edge1 = v1;
 
-       if (edge0->p0 == edge1->p0 && edge0->p1 == edge1->p1)
+       if (edge0->c == edge1->c)
                return 0;
        return -1;
 }
 
-static inline ses_edge_t* __ses_edge_add(scf_vector_t* edges, ScfEpin* p0, ScfEpin* p1)
+static inline ses_edge_t* __ses_edge_add(scf_vector_t* edges, ScfEcomponent* c)
 {
-       ses_edge_t  tmp  = {NULL, p0, p1};
+       ses_edge_t  tmp  = {c, NULL};
        ses_edge_t* edge = scf_vector_find_cmp(edges, &tmp, edge_cmp);
 
        if (!edge) {
-               edge = ses_edge_alloc(p0, p1);
+               edge = ses_edge_alloc(c);
                if (!edge)
                        return NULL;
 
@@ -811,11 +811,11 @@ static int __ses_get_crosses(ScfEfunction* f, int d, scf_vector_t* edges)
 
                                                        if ((y0 < y2 && y2 < y1 && y1 < y3) || (y2 < y0 && y0 < y3 && y3 < y1)) {
 
-                                                               edge0 = __ses_edge_add(edges, p0, p1);
+                                                               edge0 = __ses_edge_add(edges, c0);
                                                                if (!edge0)
                                                                        return -ENOMEM;
 
-                                                               edge1 = __ses_edge_add(edges, p2, p3);
+                                                               edge1 = __ses_edge_add(edges, c1);
                                                                if (!edge1)
                                                                        return -ENOMEM;
 
@@ -828,9 +828,12 @@ static int __ses_get_crosses(ScfEfunction* f, int d, scf_vector_t* edges)
                                                                        if (scf_vector_add(edge1->crosses, edge0) < 0)
                                                                                return -ENOMEM;
                                                                }
+                                                               goto next;
                                                        }
                                                }
                                        }
+next:
+                                       c1 = NULL;
                                }
                        }
                }
@@ -844,12 +847,12 @@ static int __ses_get_crosses(ScfEfunction* f, int d, scf_vector_t* edges)
        for (i = 0; i < edges->size; i++) {
                edge0     = edges->data[i];
 
-               scf_logw("i: %ld, c%ldp%ld--c%ldp%ld\n", i, edge0->p0->cid, edge0->p0->id, edge0->p1->cid, edge0->p1->id);
+               scf_logw("c%ld\n", edge0->c->id);
 
                for (j = 0; j < edge0->crosses->size; j++) {
                        edge1     = edge0->crosses->data[j];
 
-                       scf_logi("j: %ld, c%ldp%ld--c%ldp%ld\n", j, edge1->p0->cid, edge1->p0->id, edge1->p1->cid, edge1->p1->id);
+                       scf_logi("j: %ld, c%ld\n", j, edge1->c->id);
                }
                printf("\n");
 
@@ -1639,7 +1642,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;
index e97c3fff86bf2007d7c63b50e3ec052ab0265305..07d1e39c2c2b83ddebc1b7ccb5949377a87ae7d3 100644 (file)
@@ -1,6 +1,6 @@
 #include"ses_core.h"
 
-ses_edge_t* ses_edge_alloc(ScfEpin* p0, ScfEpin* p1)
+ses_edge_t* ses_edge_alloc(ScfEcomponent* c)
 {
        ses_edge_t* edge = calloc(1, sizeof(ses_edge_t));
        if (!edge)
@@ -12,8 +12,7 @@ ses_edge_t* ses_edge_alloc(ScfEpin* p0, ScfEpin* p1)
                return NULL;
        }
 
-       edge->p0 = p0;
-       edge->p1 = p1;
+       edge->c = c;
        return edge;
 }