ses_steps.c
authoryu.dongliang <18588496441@163.com>
Tue, 10 Oct 2023 10:15:43 +0000 (18:15 +0800)
committeryu.dongliang <18588496441@163.com>
Tue, 10 Oct 2023 10:15:43 +0000 (18:15 +0800)
ses_step_topo.c
ses_steps.c
ses_utils.c

index 7cc05cc9ea3b2d3c916293968d5b8400460d3178..6f68509a12960e206caedd0ea32f34132c1a9d20 100644 (file)
@@ -287,6 +287,9 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
                }
        }
 
+       scf_loge("ctx->paths: %p, ctx->paths->size: %d\n", ctx->paths, ctx->paths->size);
+       scf_vector_clear(ctx->paths, ( void (*)(void*) )ses_path_free);
+
        B    = f->components[0];
        el   = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
        path = NULL;
index 4e75ddbf5f2c77b24472de5787d5a59748394abb..0ed9cb7301bf3360884cd11369be4f390ac3295e 100644 (file)
@@ -23,14 +23,17 @@ extern ses_step_t   ses_step_va_balance;
 extern ses_step_t   ses_step_output;
 
 
-static ses_step_t*  ses_steps[] =
+static ses_step_t*  ses_steps_0[] =
 {
        &ses_step_battery,
 
        &ses_step_dc_input,
        &ses_step_dc_diode,
        &ses_step_dc_transistor,
+};
 
+static ses_step_t*  ses_steps_1[] =
+{
        &ses_step_simplify,
        &ses_step_topo,
 
@@ -41,41 +44,113 @@ static ses_step_t*  ses_steps[] =
        &ses_step_jr,
        &ses_step_va,
        &ses_step_va_balance,
+};
 
+static ses_step_t*  ses_steps_2[] =
+{
        &ses_step_output,
 };
 
 
+static int __ses_steps_input(ScfEfunction* f, int64_t ns, int64_t i, ses_ctx_t* ctx)
+{
+       ses_step_t* s;
+
+       int64_t j;
+
+       for (j = 0; j < sizeof(ses_steps_0) / sizeof(ses_steps_0[0]); j++) {
+               s  = ses_steps_0[j];
+
+               if (!s || !s->handler)
+                       continue;
+
+               int ret = s->handler(f, ns, i, ctx);
+               if (ret < 0) {
+                       scf_loge("analysis step '%s' ret: %d\n", s->name, ret);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+
+static int __ses_steps_output(ScfEfunction* f, int64_t ns, int64_t i, ses_ctx_t* ctx)
+{
+       ses_step_t* s;
+
+       int64_t j;
+
+       for (j = 0; j < sizeof(ses_steps_2) / sizeof(ses_steps_2[0]); j++) {
+               s  = ses_steps_2[j];
+
+               if (!s || !s->handler)
+                       continue;
+
+               int ret = s->handler(f, ns, i, ctx);
+               if (ret < 0) {
+                       scf_loge("analysis step '%s' ret: %d\n", s->name, ret);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+
+static int __ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t i, ses_ctx_t* ctx)
+{
+       ses_step_t* s;
+
+       int64_t j;
+
+       for (j = 0; j < sizeof(ses_steps_1) / sizeof(ses_steps_1[0]); j++) {
+               s  = ses_steps_1[j];
+
+               if (!s || !s->handler)
+                       continue;
+
+               int ret = s->handler(f, ns, i, ctx);
+               if (ret < 0) {
+                       scf_loge("analysis step '%s' ret: %d\n", s->name, ret);
+                       return ret;
+               }
+       }
+
+       return 0;
+}
+
 int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count)
 {
        if (!f || ns <= 0 || count < 0)
                return -EINVAL;
 
-       ses_step_t* s;
-       ses_ctx_t*  ctx = ses_ctx_alloc();
-
+       ses_ctx_t* ctx = ses_ctx_alloc();
        if (!ctx)
                return -ENOMEM;
 
        int64_t i;
-       int64_t j;
 
        for (i = 0; i < count; i++) {
 
-               for (j = 0; j < sizeof(ses_steps) / sizeof(ses_steps[0]); j++) {
-                       s  = ses_steps[j];
+               int ret = __ses_steps_input(f, ns, i, ctx);
+               if (ret < 0)
+                       return ret;
+
+               while (1) {
+                       ret = __ses_steps_analyse(f, ns, i, ctx);
 
-                       if (!s || !s->handler)
+                       if (-EAGAIN == ret)
                                continue;
 
-                       int ret = s->handler(f, ns, i, ctx);
-                       if (ret < 0) {
-                               scf_loge("analysis step '%s' ret: %d\n", s->name, ret);
+                       if (0 == ret)
+                               break;
 
-                               ses_ctx_free(ctx);
+                       if (ret < 0)
                                return ret;
-                       }
                }
+
+               ret = __ses_steps_output(f, ns, i, ctx);
+               if (ret < 0)
+                       return ret;
        }
 
        ses_ctx_free(ctx);
index bfa53a7e6e3b6c0fa78f2473f79d7aa5fb6b101d..5fa1b51ccc48e7d2eab76689e4fa802f17c0d206 100644 (file)
@@ -435,7 +435,7 @@ void ses_ctx_free(ses_ctx_t* ctx)
 {
        if (ctx) {
                if (ctx->paths) {
-                       scf_vector_clear(ctx->paths, ( void (*)(void*) )scf_vector_free);
+                       scf_vector_clear(ctx->paths, ( void (*)(void*) )ses_path_free);
                        scf_vector_free (ctx->paths);
                }