From 738eed0e60963199a8e47141e7d89078fafe159a Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Tue, 26 Sep 2023 00:46:00 +0800 Subject: [PATCH] topo --- Makefile | 2 +- ses_core.h | 2 +- ses_step_topo.c | 28 ++++++++++++++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 25ecfb7..730e426 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ CFILES += ses_step_va.c CFILES += ses_step_va_balance.c CFILES += ses_step_output.c -CFLAGS += -g +CFLAGS += -g -D_GNU_SOURCE CFLAGS += -I./ LDFLAGS += -lm diff --git a/ses_core.h b/ses_core.h index 61be2ef..2cef386 100644 --- a/ses_core.h +++ b/ses_core.h @@ -1,8 +1,8 @@ #ifndef SES_CORE_H #define SES_CORE_H -#include"scf_eda_pb.h" #include"scf_vector.h" +#include"scf_eda_pb.h" typedef struct ses_step_s ses_step_t; typedef struct ses_path_s ses_path_t; diff --git a/ses_step_topo.c b/ses_step_topo.c index 6d04e6c..de871c0 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -108,7 +108,7 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __ c = f->components[el->pins[j]]; p = c->pins [el->pins[j + 1]]; - if (p->pflag && p != np) { + if (p->pflag && p != np && *ppath) { scf_loge("branch: c%ld_p%ld, l%ld\n", c->id, p->id, el->id); if (scf_vector_add(__paths, *ppath) < 0) @@ -119,9 +119,8 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __ p->pflag = 1; } - ret = SCF_EDA_Path_TO; *ppath = NULL; - break; + continue; } if (p->vflag) @@ -136,8 +135,6 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __ if (SCF_EDA_Path_OFF == ret) p->vflag = 0; - else if (SCF_EDA_Path_TO == ret) - break; } if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) { @@ -162,7 +159,6 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __ scf_loge("off: c%ld_p%ld, l%ld\n", rp->cid, rp->id, rp->lid); } -end: return ret; } @@ -252,6 +248,24 @@ branch: return 0; } +static int topo_epin_cmp(const void* v0, const void* v1, void* arg) +{ + ScfEfunction* f = arg; + const uint64_t* p0 = v0; + const uint64_t* p1 = v1; + + ScfEcomponent* c0 = f->components[p0[0]]; + ScfEcomponent* c1 = f->components[p1[0]]; + + if (SCF_EDA_Diode == c0->type || (SCF_EDA_Transistor == c0->type && SCF_EDA_Transistor_B == p0[1])) + return -1; + + if (SCF_EDA_Diode == c1->type || (SCF_EDA_Transistor == c1->type && SCF_EDA_Transistor_B == p1[1])) + return 1; + + return 0; +} + static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) { ses_path_t* path; @@ -266,6 +280,8 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* for (i = 0; i < f->n_elines; i++) { el = f->elines[i]; el->vflag = 0; + + qsort_r(el->pins, el->n_pins / 2, sizeof(uint64_t) * 2, topo_epin_cmp, f); } for (i = 0; i < f->n_components; i++) { -- 2.25.1