From 17dcea6ba7aeab6235e1030802cd75e556163fe1 Mon Sep 17 00:00:00 2001
From: "yu.dongliang" <18588496441@163.com>
Date: Mon, 13 Nov 2023 12:13:50 +0800
Subject: [PATCH] __topo_path_diodes()

---
 ses_step_jr.c   | 11 +++++++----
 ses_step_topo.c | 12 ++++++++----
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/ses_step_jr.c b/ses_step_jr.c
index 2ce1961..4e2dfb3 100644
--- a/ses_step_jr.c
+++ b/ses_step_jr.c
@@ -60,9 +60,13 @@ void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1
 			if (cp1 != p1)
 				p1 = path->pins->data[j - 1];
 
-		} else if (j > 0)
+		} else if (j > 0) {
 			p1 = path->pins->data[j - 1];
-		else {
+			c1 = f->components[p1->cid];
+
+			if (SCF_EDA_NPN == c1->type && SCF_EDA_NPN_E == p1->id)
+				p1 = path->pins->data[j - 2];
+		} else {
 			*r  = 0;
 			*jr = 0;
 			return;
@@ -92,8 +96,7 @@ void __ses_path_pr(ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1
 		*r  = p1->pr  - p0->pr;
 		*jr = p1->jpr - p0->jpr;
 	}
-
-	scf_logd("c%ldp%ld-c%ldp%ld, r: %lg, p0->pr: %lg, p1->pr: %lg\n", p0->cid, p0->id, p1->cid, p1->id, *r, p0->pr, p1->pr);
+	scf_loge("c%ldp%ld-c%ldp%ld, r: %lg, p0->pr: %lg, p1->pr: %lg\n", p0->cid, p0->id, p1->cid, p1->id, *r, p0->pr, p1->pr);
 }
 
 static int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
diff --git a/ses_step_topo.c b/ses_step_topo.c
index fc959c1..af5a4bd 100644
--- a/ses_step_topo.c
+++ b/ses_step_topo.c
@@ -499,8 +499,10 @@ static int __topo_path_diodes(ScfEfunction* f, ses_path_t* path)
 			if (SCF_EDA_Diode_NEG == p->id) {
 				info->n_diodes++;
 
-				if (__ses_branch_exist(path, i))
+				if (__ses_branch_exist(path, i)) {
+					j = i;
 					goto _add;
+				}
 			}
 			continue;
 		}
@@ -521,16 +523,18 @@ static int __topo_path_diodes(ScfEfunction* f, ses_path_t* path)
 
 			} else if (SCF_EDA_NPN_E == p->id) {
 
-				if (__ses_branch_exist(path, i))
+				if (__ses_branch_exist(path, i)) {
+					j = i;
 					goto _add;
-
+				}
 				continue;
 			}
 		}
 
+		j = i - 1;
 _add:
 		if (info) {
-			info->j = i - 1;
+			info->j = j;
 
 			if (scf_vector_add(path->diodes, info) < 0) {
 				free(info);
-- 
2.25.1