From: yu.dongliang <18588496441@163.com> Date: Wed, 18 Oct 2023 07:35:01 +0000 (+0800) Subject: NPN X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=f5de5ead86e31b1b810d6d63c2a34e6446627848;p=ses.git NPN --- diff --git a/scf_eda_pb.c b/scf_eda_pb.c index c5ec14c..601a7a8 100644 --- a/scf_eda_pb.c +++ b/scf_eda_pb.c @@ -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) diff --git a/scf_eda_pb.h b/scf_eda_pb.h index 21fc713..5fdb4ba 100644 --- a/scf_eda_pb.h +++ b/scf_eda_pb.h @@ -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 { diff --git a/ses_layout.c b/ses_layout.c index c3e593e..46403dc 100644 --- a/ses_layout.c +++ b/ses_layout.c @@ -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); diff --git a/ses_step_dc_transistor.c b/ses_step_dc_transistor.c index 794610e..92fb61e 100644 --- a/ses_step_dc_transistor.c +++ b/ses_step_dc_transistor.c @@ -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; diff --git a/ses_step_jr.c b/ses_step_jr.c index 612d91a..5d2161d 100644 --- a/ses_step_jr.c +++ b/ses_step_jr.c @@ -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; diff --git a/ses_step_simplify.c b/ses_step_simplify.c index faa31b5..e021f9a 100644 --- a/ses_step_simplify.c +++ b/ses_step_simplify.c @@ -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); diff --git a/ses_step_topo.c b/ses_step_topo.c index 2cb0dd6..d4700dc 100644 --- a/ses_step_topo.c +++ b/ses_step_topo.c @@ -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; diff --git a/ses_step_va.c b/ses_step_va.c index 97c7502..917f099 100644 --- a/ses_step_va.c +++ b/ses_step_va.c @@ -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; diff --git a/ses_step_va_balance.c b/ses_step_va_balance.c index 948e37e..a85ea45 100644 --- a/ses_step_va_balance.c +++ b/ses_step_va_balance.c @@ -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; diff --git a/ses_step_va_diode.c b/ses_step_va_diode.c index 9735a05..35c67b9 100644 --- a/ses_step_va_diode.c +++ b/ses_step_va_diode.c @@ -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); diff --git a/ses_step_va_transistor.c b/ses_step_va_transistor.c index bf07c03..7b5d1e4 100644 --- a/ses_step_va_transistor.c +++ b/ses_step_va_transistor.c @@ -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)