return;
ses_path_t* child;
+
int i;
for (i = 0; i < path->childs->size; i++) {
scf_vector_qsort(path->childs, _ses_child_cmp);
}
-static int _topo_layers(scf_vector_t* paths, ScfEcomponent* B)
+static int __topo_path_bridges(ScfEfunction* f, ses_path_t* path)
{
- ses_path_t* child;
- ses_path_t* parent;
- ScfEpin* Bp;
- ScfEpin* Bn;
- ScfEpin* p0;
- ScfEpin* p1;
- ScfEpin* p;
+ ScfEcomponent* c0;
+ ScfEcomponent* c1;
+ ses_path_t* sp0;
+ ses_path_t* sp1;
+ ScfEpin* p0;
+ ScfEpin* p1;
+
+ int i;
+ int j;
+
+ path->bridges = scf_vector_alloc();
+ if (!path->bridges)
+ return -ENOMEM;
+
+ for (i = 0; i < path->childs->size - 1; ) {
+ sp0 = path->childs->data[i];
+
+ for (j = i + 1; j < path->childs->size; ) {
+ sp1 = path->childs->data[i];
+
+ if (sp0->parent_p0 <= sp1->parent_p0 && sp0->parent_p1 >= sp1->parent_p1) {
+ j++;
+ continue;
+ }
+
+ if (sp0->parent_p0 >= sp1->parent_p0 && sp0->parent_p1 <= sp1->parent_p1) {
+ j++;
+ continue;
+ }
+
+ p0 = sp0->pins->data[0];
+ p1 = sp1->pins->data[0];
+
+ if (SCF_EDA_PIN_IN & p0->flags)
+ goto bridge_sp1;
+
+ if (SCF_EDA_PIN_IN & p1->flags)
+ goto bridge_sp0;
+
+ c0 = f->components[p0->cid];
+ c1 = f->components[p1->cid];
+
+ if (SCF_EDA_NPN == c0->type && SCF_EDA_NPN_C == p0->id)
+ goto bridge_sp1;
+
+ if (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_C == p1->id)
+ goto bridge_sp0;
+
+ if ((SCF_EDA_Diode == c0->type && SCF_EDA_Diode_POS == p0->id)
+ || (SCF_EDA_NPN == c0->type && SCF_EDA_NPN_B == p0->id))
+ goto bridge_sp1;
+
+ if ((SCF_EDA_Diode == c1->type && SCF_EDA_Diode_POS == p1->id)
+ || (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_B == p1->id))
+ goto bridge_sp0;
+
+bridge_sp1:
+ scf_vector_del(path->childs, sp1);
+ if (scf_vector_add(path->bridges, sp1) < 0)
+ return -ENOMEM;
+ }
+
+ i++;
+ continue;
+bridge_sp0:
+ scf_vector_del(path->childs, sp0);
+ if (scf_vector_add(path->bridges, sp0) < 0)
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < path->bridges->size; i++) {
+ sp0 = path->bridges->data[i];
+
+ scf_logw("path: %d, i: %d, bridge: %d\n", path->index, i, sp0->index);
+ }
+
+ if (path->bridges->size <= 0) {
+ scf_vector_free(path->bridges);
+ path->bridges = NULL;
+ }
+
+ return 0;
+}
+
+static int _topo_path_bridges(ScfEfunction* f, ses_path_t* path)
+{
+ if (!path || !path->childs || path->childs->size <= 0)
+ return 0;
+
+ ses_path_t* child;
+
+ int i;
+
+ for (i = 0; i < path->childs->size; i++) {
+ child = path->childs->data[i];
+
+ int ret = _topo_path_bridges(f, child);
+ if (ret < 0)
+ return ret;
+ }
+
+ return __topo_path_bridges(f, path);
+}
+
+static int _topo_layers(ScfEfunction* f, scf_vector_t* paths)
+{
+ ScfEcomponent* B;
+ ses_path_t* child;
+ ses_path_t* parent;
+ ScfEpin* Bp;
+ ScfEpin* Bn;
+ ScfEpin* p0;
+ ScfEpin* p1;
+ ScfEpin* p;
int i;
int j;
int k;
+ B = f->components[0];
Bp = B->pins[SCF_EDA_Battery_POS];
Bn = B->pins[SCF_EDA_Battery_NEG];
child = paths->data[i];
_topo_path_sort(child);
+
+ _topo_path_bridges(f, child);
}
return 0;
}
}
-// _topo_print(ctx->paths);
-
- int ret = _topo_layers(ctx->paths, B);
+ int ret = _topo_layers(f, ctx->paths);
if (ret < 0)
return ret;
scf_vector_free (path->childs);
}
+ if (path->bridges) {
+ scf_vector_clear(path->bridges, ( void (*)(void*) )ses_path_free);
+ scf_vector_free (path->bridges);
+ }
+
free(path);
}
}
}
printf("\n");
- if (!path->childs)
- return;
+ if (path->childs) {
+ for (i = 0; i < path->childs->size; i++) {
+ path2 = path->childs->data[i];
+
+ printf("\033[32mchild: %d, n_diodes: %d, parent: %d, \033[0m", path2->index, path2->n_diodes, path->index);
- for (i = 0; i < path->childs->size; i++) {
- path2 = path->childs->data[i];
+ ses_path_print(path2);
+ }
+ }
- printf("\033[32mchild: %d, n_diodes: %d, parent: %d, \033[0m", path2->index, path2->n_diodes, path->index);
+ if (path->bridges) {
+ for (i = 0; i < path->bridges->size; i++) {
+ path2 = path->bridges->data[i];
- ses_path_print(path2);
+ printf("\033[32mbridge: %d, n_diodes: %d, parent: %d, \033[0m", path2->index, path2->n_diodes, path->index);
+
+ ses_path_print(path2);
+ }
}
}