qsort(f->components, f->n_components, sizeof(ScfEcomponent*), ecomponent_cmp_id);
}
+static void __ses_xchg_npn_ce(ScfEfunction* f, int d)
+{
+ ScfEcomponent* c;
+ ScfEpin* pb;
+ ScfEpin* pe;
+ ScfEpin* pc;
+
+ size_t i;
+
+ for (i = 0; i < f->n_components; i++) {
+ c = f->components[i];
+
+ if (SCF_EDA_NPN != c->type)
+ continue;
+
+ pb = c->pins[SCF_EDA_NPN_B];
+ pc = c->pins[SCF_EDA_NPN_C];
+ pe = c->pins[SCF_EDA_NPN_E];
+
+ if (pc->y > pe->y && pe->y > pb->y) {
+
+ if ((c->x < 0 && pc->x > pe->x) || (c->x > 0 && pc->x < pe->x))
+ SCF_XCHG(pc->x, pe->x);
+
+ } else if (pc->y < pe->y && pe->y < pb->y) {
+
+ if ((c->x < 0 && pc->x > pe->x) || (c->x > 0 && pc->x < pe->x))
+ SCF_XCHG(pc->x, pe->x);
+ }
+ }
+}
+
int ses_layout_function(ScfEfunction* f, int d)
{
ScfEcomponent* c;
__ses_de_cross (f, d);
__ses_layout_cx(f, d);
-
__ses_xchg_cx (f, d);
+ __ses_xchg_npn_ce(f, d);
+
int mx = 0;
int nx = INT_MIN;
int px = INT_MAX;
for (i = 0; i < f->n_components; i++) {
c = f->components[i];
- int cx = 0;
- int cy = 0;
-
for (j = 0; j < c->n_pins; j++) {
p0 = c->pins[j];
p0->x -= px - nx - d;
p0->x -= mx - d;
-
- if (j < 2) {
- cx += p0->x;
- cy += p0->y;
- }
}
- c->x = cx / 2;
- c->y = cy / 2;
+ if (c->x > 0)
+ c->x -= px - nx - d;
+
+ c->x -= mx - d;
}
int tx0 = INT_MAX;