ses_path_va_transistor()
authoryu.dongliang <18588496441@163.com>
Tue, 24 Oct 2023 06:45:15 +0000 (14:45 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 24 Oct 2023 06:45:15 +0000 (14:45 +0800)
ses_step_dc_transistor.c
ses_step_va_bridge.c
ses_step_va_transistor.c
ses_steps.c

index 6bcba8709f9c6ce1f316194f0af73ec979f8ca4e..f9a2b3ccf98be9746fd7dd0fb3767addedacf6a2 100644 (file)
@@ -83,10 +83,12 @@ static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se
                        pe->v = le->v;
 
                        c->status = SCF_EDA_Status_ON;
-               } else
+               } else {
                        c->status = SCF_EDA_Status_OFF;
 
-               scf_loge("NPN c%ld, status: %d\n", c->id, c->status);
+                       scf_logi("NPN c%ld, status: %d, lb->v: %lg, le->v: %lg\n", c->id, c->status, lb->v, le->v);
+               }
+               scf_loge("\033[34mNPN c%ld, status: %d\033[0m\n", c->id, c->status);
        }
 
        return 0;
index 6cf80b9795ca367dd70e483b2f8f3ef2ff4c02fb..aad2201cbbc6b628b9018e86946c78579512286d 100644 (file)
@@ -37,36 +37,7 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed)
        scf_logw("path: %d, c%ldp%ld--c%ldp%ld, v: %lg, p0->v: %lg, p1->v: %lg, n_diodes: %d\n",
                        path->index, p0->cid, p0->id, p1->cid, p1->id, v, p0->v, p1->v, path->n_diodes);
 
-       int ret = __ses_path_va(f, path, changed);
-       if (ret < 0)
-               return ret;
-#if 0
-       B  = f->components[0];
-       Bn = B->pins[SCF_EDA_Battery_NEG];
-
-       for (i = 0; i < path->pins->size; i++) {
-               p0 =        path->pins->data[i];
-
-               c = f->components[p0->cid];
-
-               if (SCF_EDA_NPN == c->type) {
-                       if (SCF_EDA_NPN_B == p0->id) {
-
-                               p1        = c->pins[SCF_EDA_NPN_E];
-                               *changed += __ses_status_check(f, c, p0, p1);
-                       }
-
-               } else if (SCF_EDA_Diode  == c->type) {
-
-                       if (SCF_EDA_Diode_POS == p0->id) {
-
-                               p1        = c->pins[SCF_EDA_Diode_NEG];
-                               *changed += __ses_status_check(f, c, p0, p1);
-                       }
-               }
-       }
-#endif
-       return 0;
+       return __ses_path_va(f, path, changed);
 }
 
 static int ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed)
index b83619557c9861dcfb4507887db612110e60bff0..11d7b6acb7128e864d279aa10e504b40f6182d5f 100644 (file)
@@ -80,8 +80,10 @@ int __ses_status_check(ScfEfunction* f, ScfEcomponent* c, ScfEpin* pb, ScfEpin*
 
 _changed:
        if (SCF_EDA_NPN == c->type) {
-               p2 = c->pins[SCF_EDA_NPN_C];
-               el = f->elines[p2->lid];
+
+               p2    = c->pins  [SCF_EDA_NPN_C];
+               el    = f->elines[p2->lid];
+               el->v = SCF_EDA_V_INIT;
 
                for (i = 0; i + 1 < el->n_pins; i += 2) {
 
@@ -141,7 +143,7 @@ static int __ses_status_change(ScfEfunction* f, ScfEline* el)
        return changed;
 }
 
-static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* changed)
+static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
 {
        ses_path_t*    parent = path->parent;
        ses_path_t*    child;
@@ -250,14 +252,12 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* chan
 
                scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pc->v: %lg, pc->a: %lg, pr: %lg, pc->dr: %lg\n\n",
                                i, p0->cid, p0->id, pc->cid, pc->id, v, pc->v, pc->a, pr, pc->dr);
-
-               *changed += __ses_status_change(f, el);
        }
 
        return 0;
 }
 
-static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* changed)
+static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
 {
        ses_path_t*    child;
        ScfEcomponent* B;
@@ -285,7 +285,7 @@ static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* change
        p0 = path->pins->data[0];
        p1 = path->pins->data[path->pins->size - 1];
 
-       int ret = __ses_path_va_transistor(f, path, changed);
+       int ret = __ses_path_va_transistor(f, path);
        if (ret < 0)
                return ret;
 
@@ -293,7 +293,7 @@ static int ses_path_va_transistor(ScfEfunction* f, ses_path_t* path, int* change
                for (j = 0; j < path->childs->size; j++) {
                        child     = path->childs->data[j];
 
-                       ret = ses_path_va_transistor(f, child, changed);
+                       ret = ses_path_va_transistor(f, child);
                        if (ret < 0)
                                return ret;
                }
@@ -306,7 +306,6 @@ static int _va_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se
 {
        ses_path_t* path;
 
-       int changed = 0;
        int i;
 
        for (i = 0; i < ctx->paths->size; i++) {
@@ -314,14 +313,14 @@ static int _va_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se
 
                scf_logi("i: %d, path->index: %d\n", i, path->index);
 
-               int ret = ses_path_va_transistor(f, path, &changed);
+               int ret = ses_path_va_transistor(f, path);
                if (ret < 0)
                        return ret;
 
                printf("\n");
        }
 
-       return changed > 0 ? -EAGAIN : 0;
+       return 0;
 }
 
 ses_step_t  ses_step_va_transistor =
index 1416ff8e1eefc8c9a11ff8adffe4c288ba63dfdb..31bd7114ba8abb0cd804b5d2ec40f18d66c2c5a1 100644 (file)
@@ -30,11 +30,12 @@ static ses_step_t*  ses_steps_0[] =
 
        &ses_step_dc_input,
        &ses_step_dc_diode,
-       &ses_step_dc_transistor,
 };
 
 static ses_step_t*  ses_steps_1[] =
 {
+       &ses_step_dc_transistor,
+
        &ses_step_simplify,
        &ses_step_topo,
 
@@ -140,7 +141,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count)
                        return ret;
 
                int j;
-               for (j = 0; j < 3; j++) {
+               for (j = 0; j < 2; j++) {
                        ret = __ses_steps_analyse(f, ns, i, ctx);
 
                        if (-EAGAIN == ret)