From 7f2c6f66499172f149a3c1984fc4f238252978e7 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 15 Nov 2023 19:44:45 +0800 Subject: [PATCH] ses_step_va_bridge.c --- ses_core.h | 2 ++ ses_step_va_bridge.c | 63 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/ses_core.h b/ses_core.h index 26f2d16..3878abc 100644 --- a/ses_core.h +++ b/ses_core.h @@ -115,6 +115,8 @@ void ses_ctx_free (ses_ctx_t* ctx); 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); diff --git a/ses_step_va_bridge.c b/ses_step_va_bridge.c index e4feaf2..216b2ee 100644 --- a/ses_step_va_bridge.c +++ b/ses_step_va_bridge.c @@ -1,11 +1,48 @@ #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; } @@ -21,8 +58,8 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed) 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; @@ -38,17 +75,17 @@ static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed) 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; @@ -57,7 +94,7 @@ static int ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed) 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; @@ -65,7 +102,7 @@ static int ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed) 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; } @@ -84,7 +121,7 @@ static int _va_bridge_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ct 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; -- 2.25.1