__ses_path_va()
authoryu.dongliang <18588496441@163.com>
Mon, 23 Oct 2023 15:13:55 +0000 (23:13 +0800)
committeryu.dongliang <18588496441@163.com>
Mon, 23 Oct 2023 15:13:55 +0000 (23:13 +0800)
ses_core.h
ses_step_va.c
ses_step_va_bridge.c
ses_steps.c

index 99850950f066dceb0d66b354908a50da96ba6c7a..aa357f025450dd22ac85b63480a8cd09ba81b211 100644 (file)
@@ -117,7 +117,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count);
 void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja);
 void __ses_path_pr     (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr);
 void __ses_path_sr     (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr);
-int  __ses_path_va     (ScfEfunction* f, ses_path_t* path);
+int  __ses_path_va     (ScfEfunction* f, ses_path_t* path, int *changed);
 int  __ses_path_pos    (ScfEfunction* f, ScfEline*   el);
 int  __ses_path_neg    (ScfEfunction* f, ScfEline*   el);
 
index 1905e2712de736dc073635c016018b5208496ec8..21bb46496191e835f644590837d98e3d197b3198 100644 (file)
@@ -2,7 +2,7 @@
 
 int _ses_path_cmp(const void* v0, const void* v1);
 
-static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja)
+static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja, int* changed)
 {
        ses_path_t*    child;
 
@@ -67,7 +67,7 @@ static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double*
                scf_loge("child: %d, c%ldp%ld, c%ldp%ld, p->v: %lg, el->v: %lg, _v: %lg\n",
                                child->index, p->cid, p->id, p2->cid, p2->id, p->v, el->v, _v);
 
-               int ret = __ses_path_va(f, child);
+               int ret = __ses_path_va(f, child, changed);
                if (ret < 0)
                        return ret;
 
@@ -128,7 +128,7 @@ static int __ses_path_split_v(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, in
        return 0;
 }
 
-int __ses_path_va(ScfEfunction* f, ses_path_t* path)
+int __ses_path_va(ScfEfunction* f, ses_path_t* path, int* changed)
 {
        if (!path)
                return -EINVAL;
@@ -187,7 +187,7 @@ int __ses_path_va(ScfEfunction* f, ses_path_t* path)
                        if (ret < 0)
                                return ret;
 
-                       ret = __ses_path_split_a(f, path, i, &a, &ja);
+                       ret = __ses_path_split_a(f, path, i, &a, &ja, changed);
                        if (ret < 0)
                                return ret;
 
@@ -238,9 +238,25 @@ int __ses_path_va(ScfEfunction* f, ses_path_t* path)
                        scf_loge("path: %d, i: %d, c%ldp%ld, p->v: %lg, dv: %lg, r: %lg, p->a: %lg, a: %lg, p->pr: %lg\n\n", path->index, i, p->cid, p->id,
                                        p->v, dv, r, p->a, a, p->pr);
 
+                       if (SCF_EDA_Diode == c->type) {
+
+                               if (SCF_EDA_Diode_NEG == p->id) {
+                                       p2 = path->pins->data[i - 1];
+                                       *changed += __ses_status_check(f, c, p2, p);
+                               }
+
+                       } else if (SCF_EDA_NPN == c->type) {
+
+                               if (SCF_EDA_NPN_E == p->id) {
+                                       p2 = path->pins->data[i - 1];
+
+                                       if (SCF_EDA_NPN_B == p2->id)
+                                               *changed += __ses_status_check(f, c, p2, p);
+                               }
+                       }
+
                        r   = 0;
                        jr  = 0;
-
                } else {
                        dv  = p->v;
                        jdv = p->jv;
@@ -268,6 +284,7 @@ static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ct
 
        printf("\n*******************\n");
 
+       int changed = 0;
        int i;
 
        for (i = 0; i < ctx->paths->size; i++) {
@@ -286,14 +303,14 @@ static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ct
                if (p0->lid != Bp->lid || p1->lid != Bn->lid)
                        continue;
 
-               int ret = __ses_path_va(f, path);
+               int ret = __ses_path_va(f, path, &changed);
                if (ret < 0)
                        return ret;
 
                printf("\n");
        }
 
-       return 0;
+       return changed > 0 ? -EAGAIN : 0;
 }
 
 ses_step_t  ses_step_va =
index 2354fa4cb5b508caca4dc619dc42f50c201ac9a6..6cf80b9795ca367dd70e483b2f8f3ef2ff4c02fb 100644 (file)
@@ -37,10 +37,10 @@ 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);
+       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];
 
@@ -65,7 +65,7 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed)
                        }
                }
        }
-
+#endif
        return 0;
 }
 
index 897dbc4af9162aea5c49251027ae4a30790b27b5..1416ff8e1eefc8c9a11ff8adffe4c288ba63dfdb 100644 (file)
@@ -140,7 +140,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count)
                        return ret;
 
                int j;
-               for (j = 0; j < 1; j++) {
+               for (j = 0; j < 3; j++) {
                        ret = __ses_steps_analyse(f, ns, i, ctx);
 
                        if (-EAGAIN == ret)