topo
authoryu.dongliang <18588496441@163.com>
Mon, 25 Sep 2023 16:46:00 +0000 (00:46 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 25 Sep 2023 16:46:00 +0000 (00:46 +0800)
Makefile
ses_core.h
ses_step_topo.c

index 25ecfb7d15a81b3e04277ae425416f93f0584352..730e426ded9cc3e74ca602c4ad1705d8c3c7a155 100644 (file)
--- 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
index 61be2efffa573bccb3e40add1f11790cb3096393..2cef3866cab4b7d2fa9b5f3abd4b7088cb8039c5 100644 (file)
@@ -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;
index 6d04e6c86b2584687fd35dd2da84ac68c7f37627..de871c05bd168991f02ace16d734580870f2b8d7 100644 (file)
@@ -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++) {