return 0;
}
+static int _topo_diodes(ScfEfunction* f, ses_path_t* path)
+{
+ ses_info_t* info = NULL;
+ ScfEcomponent* c;
+ ScfEpin* p;
+
+ int i;
+
+ for (i = 0; i < path->pins->size; i++) {
+ p = path->pins->data[i];
+
+ c = f->components[p->cid];
+
+ if (SCF_EDA_Diode == c->type) {
+
+ if (!info) {
+ info = calloc(1, sizeof(ses_info_t));
+ if (!info)
+ return -ENOMEM;
+
+ info->i = i;
+ }
+
+ if (SCF_EDA_Diode_NEG == p->id) {
+ info->n_diodes++;
+ path->n_diodes++;
+ }
+ continue;
+ }
+
+ if (SCF_EDA_NPN == c->type) {
+
+ if (SCF_EDA_NPN_B == p->id) {
+ if (!info) {
+ info = calloc(1, sizeof(ses_info_t));
+ if (!info)
+ return -ENOMEM;
+
+ info->i = i;
+ }
+
+ info->n_NPNs++;
+ path->n_diodes++;
+ continue;
+ } else if (SCF_EDA_NPN_E == p->id)
+ continue;
+ }
+
+ if (info) {
+ info->j = i - 1;
+
+ if (scf_vector_add(path->diodes, info) < 0) {
+ free(info);
+ return -ENOMEM;
+ }
+
+ info = NULL;
+ }
+ }
+
+ if (info) {
+ info->j = i - 1;
+
+ if (scf_vector_add(path->diodes, info) < 0) {
+ free(info);
+ return -ENOMEM;
+ }
+
+ info = NULL;
+ }
+
+ return 0;
+}
+
static int _topo_print(scf_vector_t* paths)
{
ses_path_t* path;
for (i = 0; i < ctx->paths->size; i++) {
path = ctx->paths->data[i];
- path->n_diodes = 0;
-
- for (j = 0; j < path->pins->size; j++) {
- p = path->pins->data[j];
+ scf_vector_clear(path->diodes, ( void (*)(void*) )free);
- c = f->components[p->cid];
-
- if ((SCF_EDA_Diode == c->type && SCF_EDA_Diode_NEG == p->id)
- || (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == p->id))
- path->n_diodes++;
-
- p->n_diodes = path->n_diodes;
- }
+ int ret = _topo_diodes(f, path);
+ if (ret < 0)
+ return ret;
}
int ret = _topo_layers(f, ctx->paths);
int i;
if (!path->parent)
- printf("\033[31mpath: %d, n_diodes: %d, \033[0m", path->index, path->n_diodes);
+ printf("\033[31mpath : %d, n_diodes: %d, diodes->size: %d, \033[0m", path->index, path->n_diodes, path->diodes->size);
for (i = 0; i < path->pins->size; i++) {
p = path->pins->data[i];
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);
+ printf("\033[32mchild : %d, n_diodes: %d, diodes->size: %d, parent: %d, \033[0m", path2->index, path2->n_diodes, path2->diodes->size, path->index);
ses_path_print(path2);
}
for (i = 0; i < path->bridges->size; i++) {
path2 = path->bridges->data[i];
- printf("\033[33mbridge: %d, n_diodes: %d, parent: %d, \033[0m", path2->index, path2->n_diodes, path->index);
+ printf("\033[33mbridge: %d, n_diodes: %d, diodes->size: %d, parent: %d, \033[0m", path2->index, path2->n_diodes, path2->diodes->size, path->index);
ses_path_print(path2);
}