From e37e03d33c99b9189e37cde4e1c76497ebbcb2f7 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Sat, 23 Sep 2023 00:14:15 +0800 Subject: [PATCH] ses_flow_v_pos() --- ses_core.h | 3 + ses_step_va_balance.c | 6 +- ses_steps.c | 126 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 2 deletions(-) diff --git a/ses_core.h b/ses_core.h index d8fe020..61be2ef 100644 --- a/ses_core.h +++ b/ses_core.h @@ -89,6 +89,9 @@ void ses_path_print(ses_path_t* path); ses_flow_t* ses_flow_alloc(); void ses_flow_free (ses_flow_t* flow); void ses_flow_print(ses_flow_t* flow); + +void ses_flow_v_pos(ses_flow_t* flow, double a, double ja); +void ses_flow_v_neg(ses_flow_t* flow, double a, double ja); void ses_flow_jr (ses_flow_t* flow); ses_ctx_t* ses_ctx_alloc(); diff --git a/ses_step_va_balance.c b/ses_step_va_balance.c index 259cbd5..8e2a399 100644 --- a/ses_step_va_balance.c +++ b/ses_step_va_balance.c @@ -43,6 +43,7 @@ int ses_paths_find_flow(ses_flow_t* flow, scf_vector_t* paths, ScfEpin* vip, ses return 0; } + static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t* flow0, ses_flow_t* flow1) { if (!bridge || !flow0 || !flow1) @@ -96,9 +97,10 @@ static int __ses_path_va_balance(ScfEfunction* f, ses_path_t* bridge, ses_flow_t double dv; double jdv; - ses_ur_i(&a, &ja, v, jv, r, jr); + ses_ur_i(&a, &ja, v, jv, r, jr); - ses_ir_u(&dv, &jdv, a, ja, flow0->pr, flow0->jpr); + ses_flow_v_pos(flow0, a, ja); + ses_flow_v_neg(flow1, a, ja); scf_loge("r->pr: %lg + j%lg, v: %lg + j%lg, a: %lg + j%lg, dv: %lg + j%lg\n", r, jr, v, jv, a, ja, dv, jdv); diff --git a/ses_steps.c b/ses_steps.c index 0df4d78..1db1066 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -70,6 +70,132 @@ void ses_flow_free(ses_flow_t* flow) } } +void ses_flow_v_pos(ses_flow_t* flow, double a, double ja) +{ + if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip) + return; + + ses_path_t* path = flow->paths->data[flow->paths->size - 1]; + ScfEpin* vip = flow->vip; + ScfEpin* p0; + ScfEpin* p; + + double tr = flow->pr; + double jtr = flow->jpr; + + int i; + int j; + + for (i = 0; i < flow->paths->size; i++) { + path = flow->paths->data[i]; + + double v; + double jv; + + p0 = NULL; + for (j = path->pins->size - 1; j >= 0; j--) { + p = path->pins->data[j]; + + if (!p0) { + if ((j & 0x1) && p->lid == vip->lid) + p0 = p; + else + continue; + } + + double r = tr - (p0->pr - p->pr); + double jr = jtr - (p0->jpr - p->jpr); + + ses_ir_u(&v, &jv, a, ja, r, jr); + + p->v -= v; + p->jv -= jv; + + scf_logw("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg\n", p->cid, p->id, p->v, p->jv, r, jr); + break; + } + + assert(p0); + + vip = path->pins->data[0]; + tr -= p0->pr; + jtr -= p0->jpr; + + ses_ir_u(&v, &jv, a, ja, tr, jtr); + + vip->v -= v; + vip->jv -= jv; + + scf_logw("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg\n", vip->cid, vip->id, vip->v, vip->jv, tr, jtr); + } +} + +void ses_flow_v_neg(ses_flow_t* flow, double a, double ja) +{ + if (!flow || !flow->paths || flow->paths->size <= 0 || !flow->vip) + return; + + ses_path_t* path = flow->paths->data[flow->paths->size - 1]; + ScfEpin* vip = flow->vip; + ScfEpin* p0; + ScfEpin* p; + + double tr = flow->nr; + double jtr = flow->jnr; + + int i; + int j; + + for (i = 0; i < flow->paths->size; i++) { + path = flow->paths->data[i]; + + double v; + double jv; + + p0 = NULL; + for (j = 0; j < path->pins->size; j++) { + p = path->pins->data[j]; + + if (!p0) { + if (p->lid == vip->lid) + p0 = p; + else + continue; + } + + double r = tr - (p->sr - p0->pr); + double jr = jtr - (p->jsr - p0->jpr); + + if (p->sr != p->pr) + p0 = p; + + ses_ir_u(&v, &jv, a, ja, r, jr); + + p->v += v; + p->jv += jv; + + scf_loge("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg, %lg\n", p->cid, p->id, p->v, p->jv, r, jr, p->sr); + } + + assert(p0); + + vip = path->pins->data[j - 1]; + + if (vip != p0) { + + tr -= vip->sr - p0->pr; + jtr -= vip->jsr - p0->jpr; + + ses_ir_u(&v, &jv, a, ja, tr, jtr); + + vip->v += v; + vip->jv += jv; + + scf_logw("c%ldp%ld->v: %lg + j%lg, r: %lg + j%lg\n", vip->cid, vip->id, vip->v, vip->jv, tr, jtr); + } + } +} + void ses_flow_jr(ses_flow_t* flow) { if (!flow) -- 2.25.1