#include"ses_core.h"
+static int __dfs_route(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp)
+{
+ ScfEcomponent* c;
+ ScfEline* el;
+ ScfEpin* np;
+ ScfEpin* p;
+
+ size_t i;
+ size_t j;
+
+ if (SCF_EDA_Status_OFF == rc->status)
+ return 0;
+
+ if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id)
+ return 0;
+
+ if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id)
+ return 0;
+
+ rp->vflag = 1;
+
+ scf_logi("c%ld_p%ld, l%ld\n", rc->id, rp->id, rp->lid);
+
+ 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);
+
+ el = f->elines[np->lid];
+
+ if (SCF_EDA_PIN_POS & el->flags) {
+ scf_loge("pos l%ld\n\n", el->id);
+ continue;
+ }
+
+ if (SCF_EDA_PIN_NEG & el->flags) {
+ scf_loge("neg l%ld\n\n", el->id);
+ return 0;
+ }
+
+ for (j = 0; j + 1 < el->n_pins; j += 2) {
+
+ c = f->components[el->pins[j]];
+ p = c->pins [el->pins[j + 1]];
+
+ if (p->vflag)
+ 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);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count)
+{
+ ScfEcomponent* c;
+ ScfEcomponent* B;
+ ScfEline* el;
+ ScfEline* el2;
+ ScfEline* elp;
+ ScfEline* eln;
+ ScfEpin* p;
+
+ size_t i;
+ size_t j;
+ size_t k;
+
+ B = f->components[0];
+
+ elp = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
+ eln = f->elines[B->pins[SCF_EDA_Battery_NEG]->lid];
+
+ for (i = 0; i < f->n_elines; i++) {
+ el = f->elines[i];
+ el->vflag = 0;
+ }
+
+ for (i = 0; i < f->n_components; i++) {
+ c = f->components[i];
+ c->vflag = 0;
+
+ for (j = 0; j < c->n_pins; j++) {
+ p = c->pins[j];
+ p->vflag = 0;
+ }
+ }
+
+ for (i = 0; i + 1 < elp->n_pins; i += 2) {
+
+ c = f->components[elp->pins[i]];
+ p = c->pins [elp->pins[i + 1]];
+
+ if (c == B)
+ continue;
+
+ scf_loge("i: %ld\n", i);
+
+ __dfs_route(f, c, p);
+
+ printf("\n");
+ }
+
+ return 0;
+}
ses_step_t ses_step_va =
{
- .name = "va",
+ .name = "va",
+
+ .handler = _va_handler,
};