ses loop
authoryu.dongliang <18588496441@163.com>
Tue, 18 Jul 2023 10:14:51 +0000 (18:14 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 18 Jul 2023 10:14:51 +0000 (18:14 +0800)
scf_eda.pb-c.c
scf_eda.pb-c.h
scf_eda.proto
ses_core.h
ses_layout.c
ses_loop.c

index fccdbe631969b489be9f0a6319eab9ef392ccef7..70d1464ab78e0aa12f5dcbc033be590c9749d50d 100644 (file)
@@ -578,7 +578,7 @@ const ProtobufCMessageDescriptor scf_econn__descriptor =
   (ProtobufCMessageInit) scf_econn__init,
   NULL,NULL,NULL    /* reserved[123] */
 };
-static const ProtobufCFieldDescriptor scf_eline__field_descriptors[6] =
+static const ProtobufCFieldDescriptor scf_eline__field_descriptors[7] =
 {
   {
     "id",
@@ -617,8 +617,20 @@ static const ProtobufCFieldDescriptor scf_eline__field_descriptors[6] =
     0,NULL,NULL    /* reserved1,reserved2, etc */
   },
   {
-    "conns",
+    "dfo",
     4,
+    PROTOBUF_C_LABEL_REQUIRED,
+    PROTOBUF_C_TYPE_INT64,
+    0,   /* quantifier_offset */
+    offsetof(ScfEline, dfo),
+    NULL,
+    NULL,
+    0,             /* flags */
+    0,NULL,NULL    /* reserved1,reserved2, etc */
+  },
+  {
+    "conns",
+    5,
     PROTOBUF_C_LABEL_REPEATED,
     PROTOBUF_C_TYPE_MESSAGE,
     offsetof(ScfEline, n_conns),
@@ -630,7 +642,7 @@ static const ProtobufCFieldDescriptor scf_eline__field_descriptors[6] =
   },
   {
     "lines",
-    5,
+    6,
     PROTOBUF_C_LABEL_REPEATED,
     PROTOBUF_C_TYPE_MESSAGE,
     offsetof(ScfEline, n_lines),
@@ -642,7 +654,7 @@ static const ProtobufCFieldDescriptor scf_eline__field_descriptors[6] =
   },
   {
     "vflag",
-    6,
+    7,
     PROTOBUF_C_LABEL_REQUIRED,
     PROTOBUF_C_TYPE_BOOL,
     0,   /* quantifier_offset */
@@ -654,17 +666,18 @@ static const ProtobufCFieldDescriptor scf_eline__field_descriptors[6] =
   },
 };
 static const unsigned scf_eline__field_indices_by_name[] = {
-  3,   /* field[3] = conns */
+  4,   /* field[4] = conns */
+  3,   /* field[3] = dfo */
   2,   /* field[2] = flags */
   0,   /* field[0] = id */
-  4,   /* field[4] = lines */
+  5,   /* field[5] = lines */
   1,   /* field[1] = pins */
-  5,   /* field[5] = vflag */
+  6,   /* field[6] = vflag */
 };
 static const ProtobufCIntRange scf_eline__number_ranges[1 + 1] =
 {
   { 1, 0 },
-  { 0, 6 }
+  { 0, 7 }
 };
 const ProtobufCMessageDescriptor scf_eline__descriptor =
 {
@@ -674,7 +687,7 @@ const ProtobufCMessageDescriptor scf_eline__descriptor =
   "ScfEline",
   "",
   sizeof(ScfEline),
-  6,
+  7,
   scf_eline__field_descriptors,
   scf_eline__field_indices_by_name,
   1,  scf_eline__number_ranges,
index 15b3352fa51b48a41cbc3f5a9530dae31b4f3eee..9f24e0d4eda49b2ed3ee691abafebd182a3ebdf7 100644 (file)
@@ -80,6 +80,7 @@ struct  _ScfEline
   size_t n_pins;
   uint64_t *pins;
   uint64_t flags;
+  int64_t dfo;
   size_t n_conns;
   ScfEconn **conns;
   size_t n_lines;
@@ -88,7 +89,7 @@ struct  _ScfEline
 };
 #define SCF_ELINE__INIT \
  { PROTOBUF_C_MESSAGE_INIT (&scf_eline__descriptor) \
-    , 0, 0,NULL, 0, 0,NULL, 0,NULL, 0 }
+    , 0, 0,NULL, 0, 0, 0,NULL, 0,NULL, 0 }
 
 
 struct  _ScfEcomponent
index 420fa1c71a12f854aec2dd8cbd1c3fed56a9b83e..beb5a0e25edd4f2bd0b414d9b8be8c0fdf5d56d3 100644 (file)
@@ -33,9 +33,10 @@ message scf_eline
        required uint64    id    = 1;
        repeated uint64    pins  = 2;
        required uint64    flags = 3;
-       repeated scf_econn conns = 4;
-       repeated scf_line  lines = 5;
-       required bool      vflag = 6;
+       required int64     dfo   = 4;
+       repeated scf_econn conns = 5;
+       repeated scf_line  lines = 6;
+       required bool      vflag = 7;
 }
 
 message scf_ecomponent
index 7a33ef4da88aee1428effe7832552706252475ac..cecc74b50d99af88d74f4e7291dac61245aaa094 100644 (file)
@@ -10,10 +10,11 @@ typedef struct ses_pin_s     ses_pin_t;
 
 struct ses_edge_s
 {
-       ScfEcomponent* c0;
-       ScfEpin*       p0;
+       ScfEline*      el0;
+       ScfEline*      el1;
 
-       ScfEcomponent* c1;
+       ScfEcomponent* c;
+       ScfEpin*       p0;
        ScfEpin*       p1;
 };
 
index 2d299a4ef4c78b95302f0bba577160418b22d28c..d48964ef69d563eb1c44de43c7ad185a40888dec 100644 (file)
@@ -785,11 +785,11 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_
                        }
 
                        uint8_t text[64];
-                       snprintf(text, sizeof(text) - 1, "%ld", el->id);
+                       snprintf(text, sizeof(text) - 1, "%ld_%ld", el->id, el->dfo);
 
                        cairo_select_font_face(cr, "Georgia", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
                        cairo_set_font_size   (cr, 24);
-                       cairo_move_to         (cr, l->x0 - 20, l->y0 + 5);
+                       cairo_move_to         (cr, l->x0 - 40, l->y0 + 5);
                        cairo_show_text       (cr, text);
 
                        cairo_stroke(cr);
index aea5e6c7efc901668aa5698c28463aba724b0c82..1a6721381b8e180d16ebe654371bea45b3b10d2c 100644 (file)
@@ -1,10 +1,11 @@
 #include"ses_core.h"
 
-static int __ses_dfs_tree(ScfEfunction* f, ScfEcomponent* root, scf_vector_t* edges, int64_t* total)
+static int __ses_dfs_tree(ScfEfunction* f, ScfEline* root, scf_vector_t* edges, int64_t* total)
 {
     ScfEcomponent* c;
-    ScfEpin*       p;
-    ScfEpin*       rp;
+    ScfEline*      el;
+    ScfEpin*       p0;
+    ScfEpin*       p1;
 
        ses_edge_t*    e;
 
@@ -13,41 +14,46 @@ static int __ses_dfs_tree(ScfEfunction* f, ScfEcomponent* root, scf_vector_t* ed
 
        root->vflag = 1;
 
-       for (i = 0; i < root->n_pins; i++) {
-               rp =        root->pins[i];
+       for (i = 0; i + 1 < root->n_pins; i += 2) {
 
-               if (rp->vflag)
+               c  = f->components[root->pins[i]];
+               p0 = c->pins      [root->pins[i + 1]];
+
+               if (p0->vflag)
                        continue;
-               rp->vflag = 1;
+               p0->vflag = 1;
+
+               for (j = 0; j < c->n_pins; j++) {
+                       p1 =        c->pins[j];
 
-               for (j = 0; j + 1 < rp->n_tos; j += 2) {
+                       if (p1->vflag)
+                               continue;
+                       p1->vflag = 1;
 
-                       c  = f->components[rp->tos[j]];
-                       p  = c->pins      [rp->tos[j + 1]];
+                       el = f->elines[p1->lid];
 
-                       if (c->vflag || p->vflag)
+                       if (el->vflag)
                                continue;
+                       el->vflag = 1;
 
                        e = malloc(sizeof(ses_edge_t));
                        if (!e)
                                return -ENOMEM;
 
-                       e->c0 = root;
-                       e->p0 = rp;
+                       e->c   = c;
+                       e->p0  = p0;
+                       e->p1  = p1;
 
-                       e->c1 = c;
-                       e->p1 = p;
+                       e->el0 = root;
+                       e->el1 = el;
 
-                       c->vflag = 1;
-                       p->vflag = 1;
-
-                       scf_loge("c%ld_p%ld -- l%ld --> c%ld_p%ld\n", root->id, rp->id, rp->lid, c->id, p->id);
+                       scf_loge("l%ld --- c%ld_p%ld_p%ld --> l%ld\n", root->id, c->id, p0->id, p1->id, el->id);
 
                        int ret = scf_vector_add(edges, e);
                        if ( ret < 0)
                                return ret;
 
-                       ret = __ses_dfs_tree(f, c, edges, total);
+                       ret = __ses_dfs_tree(f, el, edges, total);
                        if ( ret < 0)
                                return ret;
                }
@@ -61,10 +67,11 @@ static int __ses_dfs_tree(ScfEfunction* f, ScfEcomponent* root, scf_vector_t* ed
 
 int ses_loop_function(ScfEfunction* f, scf_vector_t* loops)
 {
-       if (!f || !loops || f->n_components < 2)
+       if (!f || !loops || f->n_elines < 2)
                return -EINVAL;
 
        ScfEcomponent* c;
+       ScfEline*      el;
        ScfEpin*       p;
 
        scf_vector_t*  edges = scf_vector_alloc();
@@ -75,7 +82,7 @@ int ses_loop_function(ScfEfunction* f, scf_vector_t* loops)
        size_t j;
        size_t k;
 
-       int64_t total = f->n_components;
+       int64_t total = f->n_elines;
 
        for (i = 0; i < f->n_components; i++) {
                c         = f->components[i];
@@ -87,10 +94,11 @@ int ses_loop_function(ScfEfunction* f, scf_vector_t* loops)
                }
        }
 
-       c = f->components[0];
-
-       c->pins[SCF_EDA_Battery_NEG]->vflag = 1;
+       for (i = 0; i < f->n_elines; i++) {
+               el        = f->elines[i];
+               el->vflag = 0;
+       }
 
-       __ses_dfs_tree(f, c, edges, &total);
+       __ses_dfs_tree(f, f->elines[0], edges, &total);
        return 0;
 }