int ses_layout_board (ScfEboard* b);
int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count);
+int ses_paths_find_flow(ses_flow_t* flow, scf_vector_t* paths, ScfEpin* vip, ses_path_t* bridge);
+
void __ses_path_split_i(ScfEfunction* f, ses_path_t* path, int i, int j, double la, double jla, double* a, double* ja);
void __ses_path_pr (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr);
void __ses_path_sr (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr);
#include"ses_core.h"
-static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed)
+static int __ses_path_va_flow(ScfEfunction* f, ses_path_t* bridge, int* changed, scf_vector_t* paths)
{
- if (!path)
+ ses_flow_t* flow0;
+ ses_flow_t* flow1;
+
+ ScfEpin* p0;
+ ScfEpin* p1;
+
+ flow0 = ses_flow_alloc();
+ if (!flow0)
+ return -ENOMEM;
+
+ flow1 = ses_flow_alloc();
+ if (!flow1) {
+ ses_flow_free(flow0);
+ return -ENOMEM;
+ }
+
+ p0 = bridge->pins->data[0];
+ p1 = bridge->pins->data[bridge->pins->size - 1];
+
+ int ret = ses_paths_find_flow(flow0, paths, p0, bridge);
+ if (ret < 0)
+ return ret;
+
+ ret = ses_paths_find_flow(flow1, paths, p1, bridge);
+ if (ret < 0)
+ return ret;
+
+ ses_flow_print(flow0);
+ printf("\n");
+
+ ses_flow_print(flow1);
+ printf("\n");
+ return 0;
+}
+
+static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* bridge, int* changed, scf_vector_t* paths)
+{
+ if (!bridge)
return -EINVAL;
- if (path->pins->size < 2) {
+ if (bridge->pins->size < 2) {
scf_loge("\n");
return -EINVAL;
}
Bp = B->pins[SCF_EDA_Battery_POS];
Bn = B->pins[SCF_EDA_Battery_NEG];
- 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];
if (p0->lid == Bp->lid && p1->lid == Bn->lid)
return 0;
double v = p0->v - p1->v;
double jv = p0->jv - p1->jv;
- int ret = __ses_path_va(f, path, changed);
+ int ret = __ses_path_va(f, bridge, changed);
if (ret < 0)
return ret;
- scf_logw("path: %d, c%ldp%ld--c%ldp%ld, v: %lg, p0->v: %lg, p1->v: %lg, n_diodes: %d, p0->a: %lg, p1->a: %lg\n",
- path->index, p0->cid, p0->id, p1->cid, p1->id, v, p0->v, p1->v, path->n_diodes, p0->a, p1->a);
+ scf_logw("bridge: %d, c%ldp%ld--c%ldp%ld, v: %lg, p0->v: %lg, p1->v: %lg, n_diodes: %d, p0->a: %lg, p1->a: %lg\n",
+ bridge->index, p0->cid, p0->id, p1->cid, p1->id, v, p0->v, p1->v, bridge->n_diodes, p0->a, p1->a);
- return 0;
+ return __ses_path_va_flow(f, bridge, changed, paths);
}
-static int ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed)
+static int ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed, scf_vector_t* paths)
{
ses_path_t* child;
if (!path)
return -EINVAL;
- int ret = __ses_path_va_bridge(f, path, changed);
+ int ret = __ses_path_va_bridge(f, path, changed, paths);
if (ret < 0)
return ret;
for (j = 0; j < path->bridges->size; j++) {
child = path->bridges->data[j];
- ret = ses_path_va_bridge(f, child, changed);
+ ret = ses_path_va_bridge(f, child, changed, paths);
if (ret < 0)
return ret;
}
for (i = 0; i < ctx->paths->size; i++) {
path = ctx->paths->data[i];
- int ret = ses_path_va_bridge(f, path, &changed);
+ int ret = ses_path_va_bridge(f, path, &changed, ctx->paths);
if (ret < 0)
return ret;