update: check Transistor base pin 'Ib > 0' in __ses_edges_update_Ab() master
authoryu.dongliang <18588496441@163.com>
Fri, 4 Apr 2025 13:18:41 +0000 (21:18 +0800)
committeryu.dongliang <18588496441@163.com>
Fri, 4 Apr 2025 13:18:47 +0000 (21:18 +0800)
ses_node_analysis.c
ses_step_dc_input.c

index d9191ebbca2162ab3fc78ff16b0f6e54cd1a59ed..e1a198b1e652e16a08a6cb289adc0cfe056ca0dc 100644 (file)
@@ -721,15 +721,14 @@ static int __ses_edges_update_Ab(ScfEfunction* f, scf_vector_t* edges, double* A
                                Rb = V / Ib;
                        }
 #endif
                                Rb = V / Ib;
                        }
 #endif
-                       if (dI < -1e-10
-                                       && -1e8 < Rb && Rb < 1e8) {
+                       if (Ib > 0 && dI < -1e-10 && -1e8 < Rb && Rb < 1e8) {
                                if (!edge->amplify_flag) {
                                        edge->amplify_flag = 1;
                                if (!edge->amplify_flag) {
                                        edge->amplify_flag = 1;
-#if 0
+#if 1
                                        scf_logi("edge: [%d], ", edge->index);
                                        ses_pin_print(p0);
                                        ses_pin_print(p1);
                                        scf_logi("edge: [%d], ", edge->index);
                                        ses_pin_print(p0);
                                        ses_pin_print(p1);
-                                       printf("[b%d], Ic: %lg, Ib: %lg, dI: %lg, Vbe: %lg, Rb: %lg\n", edge->edge_b->index, Ic, Ib, dI, Vb - Ve, Rb);
+                                       printf("[b%d], Ic: %lg, Ib: %lg, dI: %lg, Vbe: %lg, Vce: %lg, Vc: %lg, Ve: %lg, Rb: %lg\n", edge->edge_b->index, Ic, Ib, dI, Vb - Ve, Vc - Ve, Vc, Ve, Rb);
 #endif
                                        for (i = 0; i < N; i++)
                                                A[(n + edge->index) * N + i] = 0;
 #endif
                                        for (i = 0; i < N; i++)
                                                A[(n + edge->index) * N + i] = 0;
index 736da1ee1de8fe327ad017564194d6f0ccd292f1..dcaa5ad0298eb2b226b07a2a241be68f7938f08f 100644 (file)
@@ -1,6 +1,6 @@
 #include"ses_core.h"
 
 #include"ses_core.h"
 
-static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+static int _dc_input_handler(ScfEfunction* f, int64_t ps, int64_t count, ses_ctx_t* ctx)
 {
        ScfEcomponent*   B;
        ScfEcomponent*   c;
 {
        ScfEcomponent*   B;
        ScfEcomponent*   c;
@@ -8,9 +8,12 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx
        ScfEline*        el2;
        ScfEpin*         p;
 
        ScfEline*        el2;
        ScfEpin*         p;
 
-       size_t i;
-       size_t j;
-       int    k;
+       long i;
+       long j;
+       int  k;
+
+       int x[] = {0, 0, 1, 0, 1};
+       int y[] = {1, 1, 0, 1, 0};
 
        B = f->components[0];
 
 
        B = f->components[0];
 
@@ -22,10 +25,15 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx
                if (!(SCF_EDA_PIN_IN & el->flags))
                        continue;
 
                if (!(SCF_EDA_PIN_IN & el->flags))
                        continue;
 
-               k   = 1 % 2;
+               if (SCF_EDA_PIN_IN0 & el->flags)
+                       k = x[(count / 100) & 0x1];
+               else
+                       k = y[(count / 100) & 0x1];
+               scf_logi("el->io_lid: %ld, k: %d\n", el->io_lid, k);
+
                el2 = f->elines[B->pins[k]->lid];
 
                el2 = f->elines[B->pins[k]->lid];
 
-               el->v      = k * B->v;
+               el->v      = el2->v;
                el->vconst = 1;
 
                for (j = 0; j + 1 < el->n_pins; j += 2) {
                el->vconst = 1;
 
                for (j = 0; j + 1 < el->n_pins; j += 2) {
@@ -33,12 +41,15 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx
                        c  = f->components[el->pins[j]];
                        p  = c->pins      [el->pins[j + 1]];
 
                        c  = f->components[el->pins[j]];
                        p  = c->pins      [el->pins[j + 1]];
 
+                       if (p->lid != p->c_lid)
+                               assert(0 == scf_eline__del_pin(f->elines[p->lid], c->id, p->id));
+
                        int ret = scf_eline__add_pin(el2, c->id, p->id);
                        if (ret < 0)
                                return ret;
 
                        int ret = scf_eline__add_pin(el2, c->id, p->id);
                        if (ret < 0)
                                return ret;
 
+                       scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->lid, el2->id);
                        p->lid = el2->id;
                        p->lid = el2->id;
-                       scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->c_lid, p->lid);
                }
 
                scf_logw("IN el: %ld, V: %lg\n", el->id, el->v);
                }
 
                scf_logw("IN el: %ld, V: %lg\n", el->id, el->v);