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[] =
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)
SCF_EDA_Inductor,
SCF_EDA_Diode,
- SCF_EDA_Transistor,
+ SCF_EDA_NPN,
+ SCF_EDA_PNP,
SCF_EDA_Components_NB,
};
};
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 {
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);
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];
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;
}
} 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;
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];
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;
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;
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);
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) {
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);
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);
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) {
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);
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;
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;
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;
}
}
- } 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;
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;
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;
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);
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;
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);
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;
}
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;
}
__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;
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;
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);
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)