From 7d3ff5f03580bc1f0354175ccb43f46c500a8a5d Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 1 Nov 2023 12:43:58 +0800 Subject: [PATCH] ses_edge_alloc() --- ses_core.h | 9 ++++----- ses_layout.c | 21 ++++++++++++--------- ses_utils.c | 5 ++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ses_core.h b/ses_core.h index 0ebcb98..300e8a1 100644 --- a/ses_core.h +++ b/ses_core.h @@ -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); diff --git a/ses_layout.c b/ses_layout.c index 172069b..de5f9a0 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -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; diff --git a/ses_utils.c b/ses_utils.c index e97c3ff..07d1e39 100644 --- a/ses_utils.c +++ b/ses_utils.c @@ -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; } -- 2.25.1