From: yu.dongliang <18588496441@163.com> Date: Fri, 27 Oct 2023 14:05:36 +0000 (+0800) Subject: tmp X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=cbff0ce7a07247963bb55fedc1d079de3f0c8065;p=ses.git tmp --- diff --git a/ses_core.h b/ses_core.h index 5327c49..6ebf8c5 100644 --- a/ses_core.h +++ b/ses_core.h @@ -11,14 +11,6 @@ typedef struct ses_edge_s ses_edge_t; typedef struct ses_info_s ses_info_t; typedef struct ses_ctx_s ses_ctx_t; -struct ses_info_s -{ - int i; - int j; - int n_diodes; - int n_NPNs; -}; - struct ses_edge_s { ScfEline* el0; @@ -52,6 +44,14 @@ struct ses_flow_s #define SES_PATH_BRANCH 1 #define SES_PATH_BRIDGE 2 +struct ses_info_s +{ + int i; + int j; + int n_diodes; + int n_NPNs; +}; + struct ses_path_s { scf_vector_t* pins; diff --git a/ses_step_dc_input.c b/ses_step_dc_input.c index 5b6fb05..ea0f5ab 100644 --- a/ses_step_dc_input.c +++ b/ses_step_dc_input.c @@ -22,7 +22,7 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx if (!(SCF_EDA_PIN_IN & el->flags)) continue; - k = SCF_EDA_Battery_POS; + k = 0; el2 = f->elines[B->pins[k]->lid]; el->v = k * B->v; diff --git a/ses_step_va_diode.c b/ses_step_va_diode.c index 5dee919..0b8e444 100644 --- a/ses_step_va_diode.c +++ b/ses_step_va_diode.c @@ -202,6 +202,8 @@ void __ses_path_dr_reverse(ScfEfunction* f, ses_path_t* path, int i, int j, doub static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) { ses_path_t* child; + ses_info_t* info; + ScfEcomponent* c; ScfEline* el; ScfEpin* p; @@ -212,7 +214,6 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) int i; int j; - int k; p0 = path->pins->data[0]; p1 = path->pins->data[path->pins->size - 1]; @@ -225,181 +226,93 @@ static int __ses_path_va_diode(ScfEfunction* f, ses_path_t* path) p1->v = el->v; p1->jv = el->jv; - int i_diodes = 0; - int j_diodes = 0; - int i_NPNs = 0; - int j_NPNs = 0; - - for (i = 0; i < path->pins->size; i++) { - pi = path->pins->data[i]; - - el = f->elines [pi->lid]; - c = f->components[pi->cid]; - - if (SCF_EDA_Diode == c->type) { - i_diodes++; - continue; - } - - if (SCF_EDA_NPN != c->type) - break; + double v = p0->v - p1->v; + double jv = p0->jv - p1->jv; - if (SCF_EDA_NPN_C == pi->id) - return 0; + double r = 0; + double jr = 0; - i_NPNs++; - } - - for (j = path->pins->size - 1; j >= i; j--) { - pj = path->pins->data[j]; + double a; + double ja; - el = f->elines [pj->lid]; - c = f->components[pj->cid]; + i = 0; - if (SCF_EDA_Diode == c->type) { - j_diodes++; - continue; - } + for (j = 0; j < path->diodes->size; j++) { + info = path->diodes->data[j]; + pi = path->pins->data[i]; + pj = path->pins->data[info->i]; - if (SCF_EDA_NPN != c->type) - break; + v -= info->n_diodes * SCF_EDA_V_Diode_ON; + v -= info->n_NPNs * SCF_EDA_V_NPN_ON; - if (SCF_EDA_NPN_C == pj->id) - return 0; + r += pj->pr - pj->r - pi->pr; + jr += pj->jpr - pj->jr - pi->jpr; - j_NPNs++; - } + scf_logi("i: %d, info->i: %d, c%ldp%ld--c%ldp%ld, r: %lg, v: %lg\n", i, info->i, pi->cid, pi->id, pj->cid, pj->id, r, v); - if (j <= i) { - scf_loge("all components are Diode\n"); - return -1; + i = info->j; } - i_diodes >>= 1; - j_diodes >>= 1; - - i_NPNs >>= 1; - j_NPNs >>= 1; - - double __vi = p0->v - SCF_EDA_V_Diode_ON * i_diodes - SCF_EDA_V_NPN_ON * i_NPNs; - double __vj = p1->v + SCF_EDA_V_Diode_ON * j_diodes + SCF_EDA_V_NPN_ON * j_NPNs; - - scf_logd("i: %d, c%ldp%ld, __vi: %lg, i_diodes: %d, i_NPNs: %d\n", i, pi->cid, pi->id, __vi, i_diodes, i_NPNs); - scf_logd("j: %d, c%ldp%ld, __vj: %lg, j_diodes: %d, j_NPNs: %d\n", j, pj->cid, pj->id, __vj, j_diodes, j_NPNs); - - pi->v = __vi; - pj->v = __vj; + if (i < path->pins->size - 1) { + pi = path->pins->data[i]; - if (j < path->pins->size - 1) - pj = path->pins->data[++j]; - pj->v = __vj; + r += p1->sr - p1->r - pi->pr; + jr += p1->jsr - p1->jr - pi->jpr; - double v = pi->v - pj->v; - double jv = pi->jv - pj->jv; - - double pr = pj->pr - pj->r - pi->pr; - double jpr = pj->jpr - pj->jr - pi->jpr; - - double sr = pj->sr - pj->r - pi->sr; - double jsr = pj->jsr - pj->jr - pi->jsr; - - double a; - double ja; - - if (j == path->pins->size - 1 - && p1->sr == p1->pr - && p1->jsr == p1->jpr) - ses_ur_i(&a, &ja, v, jv, pr, jpr); - else - ses_ur_i(&a, &ja, v, jv, sr, jsr); + scf_logi("i: %d, info->i: %d, c%ldp%ld--c%ldp%ld, r: %lg, v: %lg\n", i, path->pins->size - 1, pi->cid, pi->id, p1->cid, p1->id, r, v); + } - c = f->components[pj->cid]; + ses_ur_i(&a, &ja, v, jv, r, jr); path->a = a; path->ja = ja; - scf_logd("i: %d, j: %d, c%ldp%ld--c%ldp%ld, a: %lg\n", i, j, pi->cid, pi->id, pj->cid, pj->id, a); + i = 0; - if (SCF_EDA_Diode == c->type && SCF_EDA_Diode_POS == pj->id) { + for (j = 0; j < path->diodes->size; j++) { + info = path->diodes->data[j]; + pi = path->pins->data[info->i]; + pj = path->pins->data[info->j]; - el = f->elines[pj->lid]; - el->a = a; - el->ja = ja; - el->aconst = 1; - - pj->a = a; - pj->ja = ja; - - if (path->childs) - __ses_path_split_i(f, path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja); - - scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, pj->v: %lg, pj->a: %lg, pr: %lg, sr: %lg\n\n", - j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr); - - __ses_path_dr_forward(f, path, j, path->pins->size - 1, pj->a, pj->ja); - - } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == pj->id) { - - el = f->elines[pj->lid]; - el->a = a; - el->ja = ja; - el->aconst = 1; - - pj->a = a; - pj->ja = ja; + c = f->components[pi->cid]; - if (path->childs) - __ses_path_split_i(f, path, j, path->pins->size - 1, a, ja, &pj->a, &pj->ja); + assert((SCF_EDA_Diode == c->type && SCF_EDA_Diode_POS == pi->id) + || (SCF_EDA_NPN == c->type && SCF_EDA_NPN_B == pi->id)); - scf_loge("j: %d, c%ldp%ld--c%ldp%ld, v: %lg, pj->v: %lg, pj->a: %lg, pr: %lg, sr: %lg\n\n", - j, pj->cid, pj->id, p1->cid, p1->id, v, pj->v, pj->a, pr, sr); + pi->a = a; + pi->ja = ja; - __ses_path_dr_forward(f, path, j, path->pins->size - 1, pj->a, pj->ja); - } + __ses_path_pr(f, path, i, info->i, NULL, &r, &jr); - if (i > 0) - pi = path->pins->data[--i]; - pi->v = __vi; + ses_ir_u(&v, &jv, a, ja, r, jr); - c = f->components[pi->cid]; + pi->v = p0->v - v; + pi->jv = p0->jv - jv; - if (SCF_EDA_Diode == c->type && SCF_EDA_Diode_NEG == pi->id) { + pj->v = pi->v - info->n_diodes * SCF_EDA_V_Diode_ON - info->n_NPNs * SCF_EDA_V_NPN_ON; + pj->jv = pi->jv; el = f->elines[pi->lid]; el->a = a; el->ja = ja; + el->v = pi->v; + el->jv = pi->jv; el->aconst = 1; - pi->a = a; - pi->ja = ja; - - if (path->childs) - __ses_path_split_i(f, path, 0, i, a, ja, &pi->a, &pi->ja); - - __ses_path_dr_reverse(f, path, 0, i, pi->a, pi->ja); - - scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pi->v: %lg, pi->a: %lg, pr: %lg, sr: %lg\n\n", - i, p0->cid, p0->id, pi->cid, pi->id, v, pi->v, pi->a, pr, sr); - - } else if (SCF_EDA_NPN == c->type && SCF_EDA_NPN_E == pj->id) { - - el = f->elines[pi->lid]; + el = f->elines[pj->lid]; el->a = a; el->ja = ja; + el->v = pj->v; + el->jv = pj->jv; el->aconst = 1; - pi->a = a; - pi->ja = ja; - if (path->childs) - __ses_path_split_i(f, path, 0, i, a, ja, &pi->a, &pi->ja); - - p = c->pins[SCF_EDA_NPN_B]; + __ses_path_split_i(f, path, info->i, info->j, a, ja, &pi->a, &pi->ja); - __ses_path_dr_reverse(f, path, 0, i, pi->a, pi->ja); + scf_loge("info->i: %d, info->j: %d, c%ldp%ld--c%ldp%ld, pi->v: %lg, pj->v: %lg, pi->a: %lg\n\n", + info->i, info->j, pi->cid, pi->id, pj->cid, pj->id, pi->v, pj->v, pi->a); - scf_loge("i: %d, c%ldp%ld--c%ldp%ld, v: %lg, pi->v: %lg, pi->a: %lg, pr: %lg, sr: %lg\n\n", - i, p0->cid, p0->id, pi->cid, pi->id, v, pi->v, pi->a, pr, sr); + __ses_path_dr_forward(f, path, info->i, info->j, pi->a, pi->ja); } return 0; diff --git a/ses_steps.c b/ses_steps.c index 901c5dd..177965d 100644 --- a/ses_steps.c +++ b/ses_steps.c @@ -141,7 +141,7 @@ int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count) return ret; int j; - for (j = 0; j < 2; j++) { + for (j = 0; j < 1; j++) { printf("\n\033[33m%s(), %d(), j: %d\033[0m\n", __func__, __LINE__, j); ret = __ses_steps_analyse(f, ns, i, ctx);