From: yu.dongliang <18588496441@163.com> Date: Tue, 18 Jul 2023 10:14:51 +0000 (+0800) Subject: ses loop X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=ec61cefa635c1a089d9728fcead3a77fdce42e0e;p=ses.git ses loop --- diff --git a/scf_eda.pb-c.c b/scf_eda.pb-c.c index fccdbe6..70d1464 100644 --- a/scf_eda.pb-c.c +++ b/scf_eda.pb-c.c @@ -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, diff --git a/scf_eda.pb-c.h b/scf_eda.pb-c.h index 15b3352..9f24e0d 100644 --- a/scf_eda.pb-c.h +++ b/scf_eda.pb-c.h @@ -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 diff --git a/scf_eda.proto b/scf_eda.proto index 420fa1c..beb5a0e 100644 --- a/scf_eda.proto +++ b/scf_eda.proto @@ -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 diff --git a/ses_core.h b/ses_core.h index 7a33ef4..cecc74b 100644 --- a/ses_core.h +++ b/ses_core.h @@ -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; }; diff --git a/ses_layout.c b/ses_layout.c index 2d299a4..d48964e 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -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); diff --git a/ses_loop.c b/ses_loop.c index aea5e6c..1a67213 100644 --- a/ses_loop.c +++ b/ses_loop.c @@ -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; }