return 0;
}
-static int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, ses_ctx_t* ctx, ses_path_t** ppath)
+int __dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __paths, ses_path_t** ppath)
{
ScfEcomponent* c;
ScfEline* el;
if (SCF_EDA_PIN_NEG & el->flags) {
scf_loge("neg l%ld\n\n", el->id);
- if (scf_vector_add(ctx->paths, *ppath) < 0)
+ if (scf_vector_add(__paths, *ppath) < 0)
return -ENOMEM;
for (j = 0; j < (*ppath)->pins->size; j++) {
if (p->pflag && p != np) {
scf_loge("branch: c%ld_p%ld, l%ld\n", c->id, p->id, el->id);
- if (scf_vector_add(ctx->paths, *ppath) < 0)
+ if (scf_vector_add(__paths, *ppath) < 0)
return -ENOMEM;
for (k = 0; k < (*ppath)->pins->size; k++) {
if (SCF_EDA_Transistor != c->type || SCF_EDA_Transistor_E != p->id)
p->vflag = 1;
- ret = __dfs_path(f, c, p, ctx, ppath);
+ ret = __dfs_path(f, c, p, __paths, ppath);
if (ret < 0)
return ret;
return ret;
}
-static int _topo_layers(ses_ctx_t* ctx)
+static int _topo_layers(scf_vector_t* paths)
{
ses_path_t* path0;
ses_path_t* path1;
int j;
int k;
- for (i = 0; i < ctx->paths->size; i++) {
- path0 = ctx->paths->data[i];
+ for (i = 0; i < paths->size; i++) {
+ path0 = paths->data[i];
path0->index = i;
}
- for (i = ctx->paths->size - 1; i >= 1; i--) {
- path0 = ctx->paths->data[i];
+ for (i = paths->size - 1; i >= 1; i--) {
+ path0 = paths->data[i];
assert(path0->pins->size >= 2);
p1 = path0->pins->data[path0->pins->size - 1];
for (j = i - 1; j >= 0; j--) {
- path1 = ctx->paths->data[j];
+ path1 = paths->data[j];
int n = 0;
}
}
- if (scf_vector_del(ctx->paths, path0) < 0)
+ if (scf_vector_del(paths, path0) < 0)
return -1;
scf_loge("path0: %d, path1: %d\n", path0->index, path1->index);
scf_logw("i: %ld\n", i);
- int ret = __dfs_path(f, c, p, ctx, &path);
+ int ret = __dfs_path(f, c, p, ctx->paths, &path);
if (ret < 0)
return ret;
scf_vector_qsort(ctx->paths, _ses_path_cmp);
- int ret = _topo_layers(ctx);
+ int ret = _topo_layers(ctx->paths);
if (ret < 0)
return ret;
return 0;
}
-static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* path, scf_vector_t* route0, scf_vector_t* route1)
+static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, scf_vector_t* route0, scf_vector_t* route1)
{
- if (!path)
+ if (!bridge)
return -EINVAL;
- if (path->pins->size < 2) {
+ if (bridge->pins->size < 2) {
scf_loge("\n");
return -EINVAL;
}
ScfEpin* p0;
ScfEpin* p1;
ScfEpin* p2;
- ScfEpin* cp0;
- ScfEpin* cp1;
+ ScfEpin* rp0;
+ ScfEpin* rp1;
int i;
int j;
int k;
- p0 = path->pins->data[0];
- p1 = path->pins->data[path->pins->size - 1];
+ p0 = bridge->pins->data[0];
+ p1 = bridge->pins->data[bridge->pins->size - 1];
el = f->elines[p0->lid];
p0->v = el->v;
p1->v = el->v;
p1->jv = el->jv;
- scf_loge("p0: %lg + j%lg, p1: %lg + j%lg\n", p0->v, p0->jv, p1->v, p1->jv);
+ scf_loge("p0: %lg + j%lg, p1: %lg + j%lg, bridge->r: %lg + j%lg\n", p0->v, p0->jv, p1->v, p1->jv, bridge->r, bridge->jr);
+
+ rp0 = route0->data[0];
+ rp1 = route1->data[0];
+
+ scf_loge("rp0->pr: %lg + j%lg, rp1->pr: %lg + j%lg\n", rp0->pr, rp0->jpr, rp1->pr, rp1->jpr);
+
+ if (p0->v > p1->v) {
+
+ for (i = 0; i < bridge->pins->size; i++) {
+ p = bridge->pins->data[i];
+
+ c = f->components[p->cid];
+
+ if (SCF_EDA_Diode == c->type) {
+
+ if (SCF_EDA_Diode_NEG == p->id || p0->v - p1->v < SCF_EDA_V_Diode_OFF)
+ c->status = SCF_EDA_Status_OFF;
+ else
+ c->status = SCF_EDA_Status_ON;
+ }
+ }
+
+ } else {
+
+ }
return 0;
}