From c1d179606184c88e392e43e5c863b53cc6fdea43 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Fri, 4 Apr 2025 21:18:41 +0800 Subject: [PATCH] update: check Transistor base pin 'Ib > 0' in __ses_edges_update_Ab() --- ses_node_analysis.c | 7 +++---- ses_step_dc_input.c | 25 ++++++++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ses_node_analysis.c b/ses_node_analysis.c index d9191eb..e1a198b 100644 --- a/ses_node_analysis.c +++ b/ses_node_analysis.c @@ -721,15 +721,14 @@ static int __ses_edges_update_Ab(ScfEfunction* f, scf_vector_t* edges, double* A Rb = V / Ib; } #endif - if (dI < -1e-10 - && -1e8 < Rb && Rb < 1e8) { + if (Ib > 0 && dI < -1e-10 && -1e8 < Rb && Rb < 1e8) { if (!edge->amplify_flag) { edge->amplify_flag = 1; -#if 0 +#if 1 scf_logi("edge: [%d], ", edge->index); ses_pin_print(p0); ses_pin_print(p1); - printf("[b%d], Ic: %lg, Ib: %lg, dI: %lg, Vbe: %lg, Rb: %lg\n", edge->edge_b->index, Ic, Ib, dI, Vb - Ve, Rb); + printf("[b%d], Ic: %lg, Ib: %lg, dI: %lg, Vbe: %lg, Vce: %lg, Vc: %lg, Ve: %lg, Rb: %lg\n", edge->edge_b->index, Ic, Ib, dI, Vb - Ve, Vc - Ve, Vc, Ve, Rb); #endif for (i = 0; i < N; i++) A[(n + edge->index) * N + i] = 0; diff --git a/ses_step_dc_input.c b/ses_step_dc_input.c index 736da1e..dcaa5ad 100644 --- a/ses_step_dc_input.c +++ b/ses_step_dc_input.c @@ -1,6 +1,6 @@ #include"ses_core.h" -static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx) +static int _dc_input_handler(ScfEfunction* f, int64_t ps, int64_t count, ses_ctx_t* ctx) { ScfEcomponent* B; ScfEcomponent* c; @@ -8,9 +8,12 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx ScfEline* el2; ScfEpin* p; - size_t i; - size_t j; - int k; + long i; + long j; + int k; + + int x[] = {0, 0, 1, 0, 1}; + int y[] = {1, 1, 0, 1, 0}; B = f->components[0]; @@ -22,10 +25,15 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx if (!(SCF_EDA_PIN_IN & el->flags)) continue; - k = 1 % 2; + if (SCF_EDA_PIN_IN0 & el->flags) + k = x[(count / 100) & 0x1]; + else + k = y[(count / 100) & 0x1]; + scf_logi("el->io_lid: %ld, k: %d\n", el->io_lid, k); + el2 = f->elines[B->pins[k]->lid]; - el->v = k * B->v; + el->v = el2->v; el->vconst = 1; for (j = 0; j + 1 < el->n_pins; j += 2) { @@ -33,12 +41,15 @@ static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx c = f->components[el->pins[j]]; p = c->pins [el->pins[j + 1]]; + if (p->lid != p->c_lid) + assert(0 == scf_eline__del_pin(f->elines[p->lid], c->id, p->id)); + int ret = scf_eline__add_pin(el2, c->id, p->id); if (ret < 0) return ret; + scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->lid, el2->id); p->lid = el2->id; - scf_logw("c%ld, p%ld, l%ld --> l%ld\n", c->id, p->id, p->c_lid, p->lid); } scf_logw("IN el: %ld, V: %lg\n", el->id, el->v); -- 2.25.1