From: yu.dongliang <18588496441@163.com> Date: Fri, 27 Oct 2023 07:27:56 +0000 (+0800) Subject: _topo_diodes() X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=b60cafbcf429c23f51cc9dfa8eb8b06bc64ffc3a;p=ses.git _topo_diodes() --- diff --git a/ses_core.h b/ses_core.h index d640ac2..5327c49 100644 --- a/ses_core.h +++ b/ses_core.h @@ -16,7 +16,7 @@ struct ses_info_s int i; int j; int n_diodes; - int n_PNPs; + int n_NPNs; }; struct ses_edge_s diff --git a/ses_step_topo.c b/ses_step_topo.c index 3365ac6..5719038 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -392,6 +392,80 @@ static int topo_epin_cmp(const void* v0, const void* v1, void* arg) 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; @@ -481,19 +555,11 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* 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); diff --git a/ses_utils.c b/ses_utils.c index eb444d2..b098854 100644 --- a/ses_utils.c +++ b/ses_utils.c @@ -351,7 +351,7 @@ void ses_path_print(ses_path_t* path) 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]; @@ -364,7 +364,7 @@ void ses_path_print(ses_path_t* path) 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); } @@ -374,7 +374,7 @@ void ses_path_print(ses_path_t* path) 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); }