NPN
authoryu.dongliang <18588496441@163.com>
Wed, 18 Oct 2023 07:35:01 +0000 (15:35 +0800)
committeryu.dongliang <18588496441@163.com>
Wed, 18 Oct 2023 07:35:01 +0000 (15:35 +0800)
scf_eda_pb.c
scf_eda_pb.h
ses_layout.c
ses_step_dc_transistor.c
ses_step_jr.c
ses_step_simplify.c
ses_step_topo.c
ses_step_va.c
ses_step_va_balance.c
ses_step_va_diode.c
ses_step_va_transistor.c

index c5ec14c6a7ed75d52129530b6f658b26abe5ff85..601a7a8457f519f88c980a5ca950dfe032a7bc57 100644 (file)
@@ -11,7 +11,8 @@ static int component_pins[SCF_EDA_Components_NB] =
        2, // SCF_EDA_Inductor
 
        SCF_EDA_Diode_NB,
-       SCF_EDA_Transistor_NB,
+       SCF_EDA_NPN_NB,
+       SCF_EDA_PNP_NB,
 };
 
 static scf_edata_t  component_datas[] =
@@ -26,11 +27,15 @@ static scf_edata_t  component_datas[] =
 
 static scf_edata_t  pin_datas[] =
 {
-       {SCF_EDA_None,       0,                   0,  0, 0,         0, 0,    0,    0, 0},
+       {SCF_EDA_None,  0,                    0,  0, 0, 0, 0,    0,    0, 0},
+
+       {SCF_EDA_Diode, 0, SCF_EDA_Diode_NEG, 0, 0,  750, 0,    0,    0, 0},
+
+       {SCF_EDA_NPN,   0, SCF_EDA_NPN_B,     0, 0,  750, 0,    0,    0, 0},
+       {SCF_EDA_NPN,   0, SCF_EDA_NPN_C,     0, 0,  100, 0,    0,    0, 100},
 
-       {SCF_EDA_Diode,      0, SCF_EDA_Diode_NEG,    0, 0,       750, 0,    0,    0, 0},
-       {SCF_EDA_Transistor, 0, SCF_EDA_Transistor_B, 0, 0,       750, 0,    0,    0, 0},
-       {SCF_EDA_Transistor, 0, SCF_EDA_Transistor_C, 0, 0,       750, 0,    0,    0, 100},
+       {SCF_EDA_PNP,   0, SCF_EDA_PNP_B,     0, 0,  750, 0,    0,    0, 0},
+       {SCF_EDA_PNP,   0, SCF_EDA_PNP_C,     0, 0,  100, 0,    0,    0, 100},
 };
 
 static scf_edata_t* _pin_find_data(const uint64_t type, const uint64_t model, const uint64_t pid)
index 21fc713c02832691cd98fbb10b8b26cc6fa41088..5fdb4bae060af6be267b568f666fa1dfd031d66a 100644 (file)
@@ -12,7 +12,8 @@ enum {
        SCF_EDA_Inductor,
 
        SCF_EDA_Diode,
-       SCF_EDA_Transistor,
+       SCF_EDA_NPN,
+       SCF_EDA_PNP,
 
        SCF_EDA_Components_NB,
 };
@@ -51,10 +52,17 @@ enum {
 };
 
 enum {
-       SCF_EDA_Transistor_B,
-       SCF_EDA_Transistor_E,
-       SCF_EDA_Transistor_C,
-       SCF_EDA_Transistor_NB,
+       SCF_EDA_NPN_B,
+       SCF_EDA_NPN_E,
+       SCF_EDA_NPN_C,
+       SCF_EDA_NPN_NB,
+};
+
+enum {
+       SCF_EDA_PNP_B,
+       SCF_EDA_PNP_E,
+       SCF_EDA_PNP_C,
+       SCF_EDA_PNP_NB,
 };
 
 typedef struct {
index c3e593eab3ca24c5a1818e397191faf32fef43eb..46403dc5cb54189350d13333d6250428e129b37d 100644 (file)
@@ -1125,10 +1125,10 @@ int ses_layout_draw(ScfEboard* b, uint32_t bx, uint32_t by, uint32_t bw, uint32_
                                        cairo_rel_line_to(cr, -dx0 * 2,    -dy0 * 2);
                                        break;
 
-                               case SCF_EDA_Transistor:
-                                       pb = c->pins[SCF_EDA_Transistor_B];
-                                       pc = c->pins[SCF_EDA_Transistor_C];
-                                       pe = c->pins[SCF_EDA_Transistor_E];
+                               case SCF_EDA_NPN:
+                                       pb = c->pins[SCF_EDA_NPN_B];
+                                       pc = c->pins[SCF_EDA_NPN_C];
+                                       pe = c->pins[SCF_EDA_NPN_E];
 
                                        vertical(&dx0, &dy0, c->x - pb->x, c->y - pb->y,  8);
                                        forward (&dx3, &dy3, c->x - pb->x, c->y - pb->y,  8);
index 794610e3fdcccc6e364e501b2aa0af4d519b0fc2..92fb61efe4903127e918f2ec8eb1c58cb6aa79b1 100644 (file)
@@ -23,12 +23,12 @@ static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se
        for (i = 0; i < f->n_components; i++) {
                c  =        f->components[i];
 
-               if (SCF_EDA_Transistor != c->type)
+               if (SCF_EDA_NPN != c->type)
                        continue;
 
-               pb = c->pins[SCF_EDA_Transistor_B];
-               pc = c->pins[SCF_EDA_Transistor_C];
-               pe = c->pins[SCF_EDA_Transistor_E];
+               pb = c->pins[SCF_EDA_NPN_B];
+               pc = c->pins[SCF_EDA_NPN_C];
+               pe = c->pins[SCF_EDA_NPN_E];
 
                lb = f->elines[pb->lid];
                le = f->elines[pe->lid];
@@ -62,7 +62,7 @@ static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se
 
                        if (le->v == Bn->v) {
                                if (lb->v == Bp->v) {
-                                       scf_loge("Transistor c%ld, short connected\n", c->id);
+                                       scf_loge("NPN c%ld, short connected\n", c->id);
                                        return -EINVAL;
                                }
 
@@ -79,7 +79,7 @@ static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, se
                } else
                        c->status = SCF_EDA_Status_OFF;
 
-               scf_loge("Transistor c%ld, status: %d\n", c->id, c->status);
+               scf_loge("NPN c%ld, status: %d\n", c->id, c->status);
        }
 
        return 0;
index 612d91a8e42b1aa29d713c1146d17b2d12fd4786..5d2161d85e580f39a3ee93ad11fb989bab54317e 100644 (file)
@@ -8,16 +8,16 @@ void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1
        ScfEcomponent* c0 = f->components[p0->cid];
        ScfEcomponent* c1 = f->components[p1->cid];
 
-       if (SCF_EDA_Transistor == c1->type) {
+       if (SCF_EDA_NPN == c1->type) {
 
-               if (SCF_EDA_Transistor_E == p1->id) {
+               if (SCF_EDA_NPN_E == p1->id) {
                        if (cp1 != p1)
                                p1 = path->pins->data[j - 1];
                } else
                        p1 = path->pins->data[j - 1];
        }
 
-       if (SCF_EDA_Transistor == c0->type) {
+       if (SCF_EDA_NPN == c0->type) {
                if (i > 0) {
                        p0 = path->pins->data[i - 1];
 
@@ -154,7 +154,7 @@ static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
 
                        c  = f->components[p1->cid];
 
-                       if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_E == p1->id && cp1 != p1) {
+                       if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_E == p1->id && cp1 != p1) {
 
                                p       = path->pins->data[j - 1];
                                p->pr  -= dr;
index faa31b51ac5f0bb6fda564cb3b8fa83d8ba17feb..e021f9a0832bba6f41d422e6c6975d63e47d2575 100644 (file)
@@ -72,7 +72,7 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw
        for (j = 0; j < f->n_components; j++) {
                c  =        f->components[j];
 
-               if ((SCF_EDA_Diode == c->type || SCF_EDA_Transistor == c->type)
+               if ((SCF_EDA_Diode == c->type || SCF_EDA_NPN == c->type)
                                && SCF_EDA_Status_OFF == c->status)
                        continue;
 
@@ -189,10 +189,10 @@ static int _simplify_draw(ScfEfunction* f, uint32_t bx, uint32_t by, uint32_t bw
                                cairo_rel_line_to(cr, -dx0 * 2,    -dy0 * 2);
                                break;
 
-                       case SCF_EDA_Transistor:
-                               pb = c->pins[SCF_EDA_Transistor_B];
-                               pc = c->pins[SCF_EDA_Transistor_C];
-                               pe = c->pins[SCF_EDA_Transistor_E];
+                       case SCF_EDA_NPN:
+                               pb = c->pins[SCF_EDA_NPN_B];
+                               pc = c->pins[SCF_EDA_NPN_C];
+                               pe = c->pins[SCF_EDA_NPN_E];
 
                                vertical(&dx0, &dy0, c->x - pb->x, c->y - pb->y,  8);
                                forward (&dx3, &dy3, c->x - pb->x, c->y - pb->y,  8);
index 2cb0dd679d91b487f98ecb77ce4a133f3037b955..d4700dcbc88ded5b21ad2de1aa271632a6982ba7 100644 (file)
@@ -17,7 +17,7 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __
        if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id)
                return SCF_EDA_Path_OFF;
 
-       if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E == rp->id)
+       if (SCF_EDA_NPN == rc->type && SCF_EDA_NPN_E == rp->id)
                return SCF_EDA_Path_OFF;
 
        if (!*ppath) {
@@ -29,7 +29,7 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __
        if (scf_vector_add((*ppath)->pins, rp) < 0)
                return -ENOMEM;
 
-       if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != rp->id)
+       if (SCF_EDA_NPN != rc->type || SCF_EDA_NPN_E != rp->id)
                rp->vflag = 1;
 
        scf_logi("c%ld_p%ld, l%ld, vflag: %d, pflag: %d\n", rp->cid, rp->id, rp->lid, rp->vflag, rp->pflag);
@@ -42,7 +42,7 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __
                if (np->vflag)
                        continue;
 
-               if (SCF_EDA_Transistor == rc->type && SCF_EDA_Transistor_E != np->id)
+               if (SCF_EDA_NPN == rc->type && SCF_EDA_NPN_E != np->id)
                        continue;
 
                scf_logi("c%ld_p%ld, l%ld, vflag: %d, pflag: %d\n", np->cid, np->id, np->lid, np->vflag, np->pflag);
@@ -65,7 +65,7 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __
                if (scf_vector_add((*ppath)->pins, np) < 0)
                        return -ENOMEM;
 
-               if (SCF_EDA_Transistor != rc->type || SCF_EDA_Transistor_E != np->id)
+               if (SCF_EDA_NPN != rc->type || SCF_EDA_NPN_E != np->id)
                        np->vflag = 1;
 
                if (SCF_EDA_PIN_NEG & el->flags) {
@@ -111,7 +111,7 @@ int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __
                        if (p->vflag)
                                continue;
 
-                       if (SCF_EDA_Transistor != c->type || SCF_EDA_Transistor_E != p->id)
+                       if (SCF_EDA_NPN != c->type || SCF_EDA_NPN_E != p->id)
                                p->vflag = 1;
 
                        ret = __dfs_path(f, c, p, __paths, ppath);
@@ -264,10 +264,10 @@ static int topo_epin_cmp(const void* v0, const void* v1, void* arg)
        ScfEcomponent*  c0 = f->components[p0[0]];
        ScfEcomponent*  c1 = f->components[p1[0]];
 
-       if (SCF_EDA_Diode == c0->type || (SCF_EDA_Transistor == c0->type && SCF_EDA_Transistor_B == p0[1]))
+       if (SCF_EDA_Diode == c0->type || (SCF_EDA_NPN == c0->type && SCF_EDA_NPN_B == p0[1]))
                return -1;
 
-       if (SCF_EDA_Diode == c1->type || (SCF_EDA_Transistor == c1->type && SCF_EDA_Transistor_B == p1[1]))
+       if (SCF_EDA_Diode == c1->type || (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_B == p1[1]))
                return 1;
 
        return 0;
@@ -373,8 +373,8 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
 
                        c  = f->components[p->cid];
 
-                       if ((SCF_EDA_Diode      == c->type && SCF_EDA_Diode_NEG    == p->id)
-                        || (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_B == p->id))
+                       if ((SCF_EDA_Diode == c->type && SCF_EDA_Diode_NEG == p->id)
+                        || (SCF_EDA_NPN   == c->type && SCF_EDA_NPN_B     == p->id))
                                path->n_diodes++;
 
                        p->n_diodes = path->n_diodes;
index 97c75026b0ddb82ad5ebcb2ba768a6a59589e362..917f09945347f2d6e7c65a813c9f998ae2932d87 100644 (file)
@@ -91,9 +91,9 @@ static int __ses_path_split_v(ScfEfunction* f, ses_path_t* path, ScfEpin* p0, in
        double         r  = 0;
        double         jr = 0;
 
-       if (SCF_EDA_Transistor == c->type) {
+       if (SCF_EDA_NPN == c->type) {
 
-               if (SCF_EDA_Transistor_B == p->id || SCF_EDA_Transistor_C == p->id) {
+               if (SCF_EDA_NPN_B == p->id || SCF_EDA_NPN_C == p->id) {
 
                        r  = p->sr  - (p->r  + p->dr ) - p0->sr;
                        jr = p->jsr - (p->jr + p->jdr) - p0->jsr;
index 948e37e9ef33fa6b9f7d221b4adcd5cd71e6c9a9..a85ea451b601633c4a043a05ff05adf2d35e9035 100644 (file)
@@ -111,11 +111,11 @@ static size_t __ses_line_update(ScfEfunction* f, ScfEline* el)
                                }
                        }
 
-               } else if (SCF_EDA_Transistor == c->type) {
+               } else if (SCF_EDA_NPN == c->type) {
 
-                       if (SCF_EDA_Transistor_B == p->id) {
+                       if (SCF_EDA_NPN_B == p->id) {
 
-                               p2    = c->pins[SCF_EDA_Transistor_E];
+                               p2    = c->pins[SCF_EDA_NPN_E];
                                el2   = f->elines[p2->lid];
                                p2->v = el2->v;
 
@@ -126,9 +126,9 @@ static size_t __ses_line_update(ScfEfunction* f, ScfEline* el)
                                        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) {
+                       } else if (SCF_EDA_NPN_E == p->id) {
 
-                               p2    = c->pins[SCF_EDA_Transistor_B];
+                               p2    = c->pins[SCF_EDA_NPN_B];
                                el2   = f->elines[p2->lid];
                                p2->v = el2->v;
 
index 9735a0566cf0e42925805f9329299443028fa9d4..35c67b9afb85f4db65eb97710792beafbb25d31b 100644 (file)
@@ -60,7 +60,7 @@ void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double
 
                c = f->components[cp1->lid];
 
-               if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_E == cp1->id)
+               if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_E == cp1->id)
                        p = child->pins->data[child->pins->size - 2];
                else
                        p = cp1;
@@ -115,7 +115,7 @@ void __ses_path_dr_forward(ScfEfunction* f, ses_path_t* path, int i, int j, int
                        p1->a  = a;
                        p1->ja = ja;
 
-               } else if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_B == p->id) {
+               } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == p->id) {
 
                        ses_ui_r(&p->dr, &p->jdr, v, jv, a, ja);
 
@@ -124,12 +124,12 @@ void __ses_path_dr_forward(ScfEfunction* f, ses_path_t* path, int i, int j, int
 
                        scf_logw("c%ldp%ld, v: %lg, r: %lg, a: %lg, dr: %lg, n_diodes: %d\n", p->cid, p->id, v, p->r, a, p->dr, n_diodes);
 
-                       p1     = c->pins[SCF_EDA_Transistor_C];
+                       p1     = c->pins[SCF_EDA_NPN_C];
                        p1->a  = p1->hfe * a;
                        p1->ja = p1->hfe * ja;
                        p1->aconst = 1;
 
-                       p1     = c->pins[SCF_EDA_Transistor_E];
+                       p1     = c->pins[SCF_EDA_NPN_E];
                        p1->a  = (1 + p1->hfe) * a;
                        p1->ja = (1 + p1->hfe) * ja;
                        p1->aconst = 1;
@@ -177,14 +177,14 @@ void __ses_path_dr_reverse(ScfEfunction* f, ses_path_t* path, int i, int j, int
                        p1->a  = a;
                        p1->ja = ja;
 
-               } else if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_B == p->id) {
+               } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == p->id) {
 
-                       p1     = c->pins[SCF_EDA_Transistor_E];
+                       p1     = c->pins[SCF_EDA_NPN_E];
                        p1->a  = a;
                        p1->ja = ja;
                        p1->aconst = 1;
 
-                       p1  = c->pins[SCF_EDA_Transistor_C];
+                       p1  = c->pins[SCF_EDA_NPN_C];
 
                        a  /= (1 + p1->hfe);
                        ja /= (1 + p1->hfe);
@@ -244,10 +244,10 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                if (SCF_EDA_Diode == c->type)
                        continue;
 
-               if (SCF_EDA_Transistor != c->type)
+               if (SCF_EDA_NPN != c->type)
                        break;
 
-               if (SCF_EDA_Transistor_C == pi->id)
+               if (SCF_EDA_NPN_C == pi->id)
                        return 0;
        }
 
@@ -266,10 +266,10 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                if (SCF_EDA_Diode == c->type)
                        continue;
 
-               if (SCF_EDA_Transistor != c->type)
+               if (SCF_EDA_NPN != c->type)
                        break;
 
-               if (SCF_EDA_Transistor_C == pj->id)
+               if (SCF_EDA_NPN_C == pj->id)
                        return 0;
        }
 
@@ -320,7 +320,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
 
                __ses_path_dr_forward(f, path, j, path->pins->size - 1, path->n_diodes - pj->n_diodes, pj->a, pj->ja);
 
-       } else if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_B == pj->id) {
+       } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == pj->id) {
 
                el         = f->elines[pj->lid];
                el->a      = a;
@@ -365,7 +365,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pi->v: %lg, pi->a: %lg, pr: %lg, sr: %lg\n\n",
                                i, p0->cid, p0->id, pi->cid, pi->id, v, pi->v, pi->a, pr, sr);
 
-       } else if (SCF_EDA_Transistor == c->type && SCF_EDA_Transistor_E == pj->id) {
+       } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_E == pj->id) {
 
                el         = f->elines[pi->lid];
                el->a      = a;
@@ -378,7 +378,7 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path)
                if (path->childs)
                        __ses_path_split_i(f, path, 0, i, a, ja, &pi->a, &pi->ja);
 
-               p = c->pins[SCF_EDA_Transistor_B];
+               p = c->pins[SCF_EDA_NPN_B];
 
                __ses_path_dr_reverse(f, path, 0, i, p->n_diodes, pi->a, pi->ja);
 
index bf07c0302a28962c88b6aeb841cef42ea9c5dfb8..7b5d1e47be110f859a20b334f453260bcfba95a6 100644 (file)
@@ -64,10 +64,10 @@ static int __ses_path_va_transistor(ScfEfunction* f, ses_path_t* path)
                el = f->elines    [pc->lid];
                c  = f->components[pc->cid];
 
-               if (SCF_EDA_Transistor != c->type)
+               if (SCF_EDA_NPN != c->type)
                        continue;
 
-               if (SCF_EDA_Transistor_C != pc->id)
+               if (SCF_EDA_NPN_C != pc->id)
                        continue;
 
                if (!pc->aconst)