#include"ses_core.h"
-static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp)
+static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, scf_vector_t** ppath)
{
+ scf_vector_t* path = *ppath;
+
ScfEcomponent* c;
ScfEline* el;
ScfEpin* np;
size_t j;
if (SCF_EDA_Status_OFF == rc->status)
- return 0;
+ return SCF_EDA_Status_OFF;
if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id)
- return 0;
+ return SCF_EDA_Path_OFF;
if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id)
- return 0;
+ return SCF_EDA_Path_OFF;
+
+ if (!path) {
+ path = scf_vector_alloc();
+ if (!path)
+ return -ENOMEM;
+
+ *ppath = path;
+ }
+ if (scf_vector_add(path, rp) < 0)
+ return -ENOMEM;
rp->vflag = 1;
scf_logi("c%ld_p%ld, l%ld\n", rc->id, rp->id, rp->lid);
+ int ret = 0;
+
for (i = 0; i < rc->n_pins; i++) {
np = rc->pins[i];
if (np->vflag)
continue;
- np->vflag = 1;
scf_logi("c%ld_p%ld, l%ld\n", rc->id, np->id, np->lid);
if (SCF_EDA_PIN_POS & el->flags) {
scf_loge("pos l%ld\n\n", el->id);
+
+ ret = SCF_EDA_Path_OFF;
+ np->vflag = 1;
continue;
}
+ if (scf_vector_add(path, np) < 0)
+ return -ENOMEM;
+ np->vflag = 1;
+
if (SCF_EDA_PIN_NEG & el->flags) {
scf_loge("neg l%ld\n\n", el->id);
+
+ if (scf_vector_add(ctx->paths, path) < 0)
+ return -ENOMEM;
+
+ *ppath = NULL;
return 0;
}
+ ret = 0;
+
for (j = 0; j + 1 < el->n_pins; j += 2) {
c = f->components[el->pins[j]];
continue;
p->vflag = 1;
-// scf_logi("c%ld_p%ld, l%ld\n", c->id, p->id, p->lid);
-
- int ret = __dfs_route(f, c, p);
+ ret = __dfs_path(f, c, p, ctx, ppath);
if (ret < 0)
return ret;
+
+ if (SCF_EDA_Status_OFF == ret)
+ scf_loge("off: c%ld_p%ld, l%ld\n", p->cid, p->id, p->lid);
+ else if (SCF_EDA_Path_OFF == ret) {
+ p->vflag = 0;
+ scf_logw("off: c%ld_p%ld, l%ld\n", p->cid, p->id, p->lid);
+ }
+ }
+
+ if (ret > 0) {
+ if (*ppath)
+ scf_vector_del(*ppath, np);
+
+ if (SCF_EDA_Status_OFF == ret)
+ scf_loge("off: c%ld_p%ld, l%ld, *ppath: %p\n", np->cid, np->id, np->lid, *ppath);
+ else if (SCF_EDA_Path_OFF == ret) {
+ np->vflag = 0;
+ scf_logw("off: c%ld_p%ld, l%ld\n", np->cid, np->id, np->lid);
+ }
}
}
- return 0;
+ if (ret > 0) {
+ if (*ppath)
+ scf_vector_del(*ppath, rp);
+
+ if (SCF_EDA_Status_OFF == ret)
+ scf_loge("off: c%ld_p%ld, l%ld\n", rp->cid, rp->id, rp->lid);
+ else if (SCF_EDA_Path_OFF == ret) {
+ rp->vflag = 0;
+ scf_logw("off: c%ld_p%ld, l%ld\n", rp->cid, rp->id, rp->lid);
+ }
+ }
+
+ return ret;
}
static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
+ scf_vector_t* path;
+
ScfEcomponent* c;
ScfEcomponent* B;
ScfEline* el;
}
}
+ path = NULL;
+
for (i = 0; i + 1 < elp->n_pins; i += 2) {
c = f->components[elp->pins[i]];
if (c == B)
continue;
- scf_loge("i: %ld\n", i);
+ scf_logw("i: %ld\n", i);
- __dfs_route(f, c, p);
+ __dfs_path(f, c, p, ctx, &path);
printf("\n");
}
+#if 1
+ for (i = 0; i < ctx->paths->size; i++) {
+ path = ctx->paths->data[i];
+ for (j = 0; j < path->size; j++) {
+ p = path->data[j];
+
+ scf_logi("i: %ld, j: %ld, c%ldp%ld\n", i, j, p->cid, p->id);
+ }
+
+ printf("\n");
+ }
+#endif
return 0;
}