__ses_path_va_balance()
authoryu.dongliang <18588496441@163.com>
Tue, 10 Oct 2023 10:44:27 +0000 (18:44 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 10 Oct 2023 10:44:27 +0000 (18:44 +0800)
ses_step_simplify.c
ses_step_va_balance.c

index 9947b13109c852358e81185976cfc8a4660bbef9..20be0e1804a99d0e971a39ad8286d8e4779ac3e7 100644 (file)
@@ -33,10 +33,10 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw
        for (j = 0; j < f->n_elines; j++) {
                el =        f->elines[j];
 
-               if (el->v == B->pins[SCF_EDA_Battery_POS]->v)
+               if ((SCF_EDA_PIN_POS & el->flags) || el->v == B->pins[SCF_EDA_Battery_POS]->v)
                        cairo_set_source_rgb(cr, 1, 0, 0);
 
-               else if (el->v == B->pins[SCF_EDA_Battery_NEG]->v)
+               else if ((SCF_EDA_PIN_NEG & el->flags) || el->v == B->pins[SCF_EDA_Battery_NEG]->v)
                        cairo_set_source_rgb(cr, 0, 0, 1);
 
                else if (SCF_EDA_PIN_IN & el->flags)
index 5365b9ac8bc61362cf355bffee75acaaae455fdc..948e37e9ef33fa6b9f7d221b4adcd5cd71e6c9a9 100644 (file)
@@ -70,6 +70,7 @@ static void inline __ses_bridge_i(double* i0, double* i1, double* i2, double* i3
 static size_t __ses_line_update(ScfEfunction* f, ScfEline* el)
 {
        ScfEcomponent* c;
+       ScfEline*      el2;
        ScfEpin*       p;
        ScfEpin*       p2;
 
@@ -86,19 +87,27 @@ static size_t __ses_line_update(ScfEfunction* f, ScfEline* el)
 
                        if (SCF_EDA_Diode_POS == p->id) {
 
-                               p2 = c->pins[SCF_EDA_Diode_NEG];
+                               p2    = c->pins[SCF_EDA_Diode_NEG];
+                               el2   = f->elines[p2->lid];
+                               p2->v = el2->v;
 
                                if (p->v - p2->v < SCF_EDA_V_Diode_ON) {
                                        c->status    = SCF_EDA_Status_OFF;
                                        n++;
+
+                                       scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p->v - p2->v);
                                }
 
                        } else {
-                               p2 = c->pins[SCF_EDA_Diode_POS];
+                               p2    = c->pins[SCF_EDA_Diode_POS];
+                               el2   = f->elines[p2->lid];
+                               p2->v = el2->v;
 
                                if (p2->v - p->v < SCF_EDA_V_Diode_ON) {
                                        c->status    = SCF_EDA_Status_OFF;
                                        n++;
+
+                                       scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p2->v - p->v);
                                }
                        }
 
@@ -106,20 +115,28 @@ static size_t __ses_line_update(ScfEfunction* f, ScfEline* el)
 
                        if (SCF_EDA_Transistor_B == p->id) {
 
-                               p2 = c->pins[SCF_EDA_Transistor_E];
+                               p2    = c->pins[SCF_EDA_Transistor_E];
+                               el2   = f->elines[p2->lid];
+                               p2->v = el2->v;
 
                                if (p->v - p2->v < SCF_EDA_V_Diode_ON) {
                                        c->status    = SCF_EDA_Status_OFF;
                                        n++;
+
+                                       scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p->v - p2->v);
                                }
 
                        } else if (SCF_EDA_Transistor_E == p->id) {
 
-                               p2 = c->pins[SCF_EDA_Transistor_B];
+                               p2    = c->pins[SCF_EDA_Transistor_B];
+                               el2   = f->elines[p2->lid];
+                               p2->v = el2->v;
 
                                if (p2->v - p->v < SCF_EDA_V_Diode_ON) {
                                        c->status    = SCF_EDA_Status_OFF;
                                        n++;
+
+                                       scf_loge("c%ld off, p%ld->v: %lg, p%ld->v: %lg, diff: %lg\n", c->id, p->id, p->v, p2->id, p2->v, p2->v - p->v);
                                }
                        }
                }
@@ -193,10 +210,10 @@ static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t
                scf_loge("v0: %lg, v1: %lg, v4: %lg, v1 - v0: %lg\n", v0, v1, v4, v1 - v0);
 
                el    = f->elines[p0->lid];
-               el->v = v0;
+               el->v = v1;
 
                el    = f->elines[p1->lid];
-               el->v = v1;
+               el->v = v0;
 
                size_t n0 = __ses_line_update(f, f->elines[p0->lid]);
                size_t n1 = __ses_line_update(f, f->elines[p1->lid]);