#include"scf_vector.h"
typedef struct ses_step_s ses_step_t;
-typedef struct ses_loop_s ses_loop_t;
typedef struct ses_edge_s ses_edge_t;
-typedef struct ses_pin_s ses_pin_t;
+typedef struct ses_ctx_s ses_ctx_t;
struct ses_edge_s
{
ScfEpin* p1;
};
-struct ses_pin_s
+struct ses_ctx_s
{
- ScfEcomponent* c;
- ScfEpin* p;
-};
-
-struct ses_loop_s
-{
- scf_vector_t* pins;
+ scf_vector_t* paths;
};
struct ses_step_s
{
const char* name;
- int (*handler)(ScfEfunction* f, int64_t ns, int64_t count);
+ int (*handler)(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx);
void* priv;
};
+ses_ctx_t* ses_ctx_alloc();
+void ses_ctx_free (ses_ctx_t* ctx);
+
+
int ses_layout_board (ScfEboard* b);
int ses_loop_function(ScfEfunction* f, scf_vector_t* loops);
int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count);
#include"ses_core.h"
-static int _battery_handler(ScfEfunction* f, int64_t ns, int64_t count)
+static int _battery_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEline* el;
#include"ses_core.h"
-static int _dc_diode_handler(ScfEfunction* f, int64_t ns, int64_t count)
+static int _dc_diode_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEcomponent* B;
#include"ses_core.h"
-static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count)
+static int _dc_input_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
ScfEcomponent* B;
ScfEline* el;
#include"ses_core.h"
-static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count)
+static int _dc_transistor_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEcomponent* B;
#include"ses_core.h"
+static int _output_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+{
+ return 0;
+}
ses_step_t ses_step_output =
{
- .name = "output",
+ .name = "output",
+ .handler = _output_handler,
};
return 0;
}
-static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count)
+static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEcomponent* B;
return 0;
}
-static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count)
+static int _va_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEcomponent* B;
#include"ses_core.h"
+static int _va_balance_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+{
+ return 0;
+}
ses_step_t ses_step_va_balance =
{
- .name = "va_balance",
+ .name = "va_balance",
+ .handler = _va_balance_handler,
};
&ses_step_output,
};
+ses_ctx_t* ses_ctx_alloc()
+{
+ ses_ctx_t* ctx = calloc(1, sizeof(ses_ctx_t));
+ if (!ctx)
+ return NULL;
+
+ ctx->paths = scf_vector_alloc();
+ if (!ctx->paths) {
+ free(ctx);
+ return NULL;
+ }
+
+ return ctx;
+}
+
+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_free (ctx->paths);
+ }
+
+ free(ctx);
+ }
+}
int ses_steps_analyse(ScfEfunction* f, int64_t ns, int64_t count)
{
return -EINVAL;
ses_step_t* s;
+ ses_ctx_t* ctx = ses_ctx_alloc();
+
+ if (!ctx)
+ return -ENOMEM;
int64_t i;
int64_t j;
if (!s || !s->handler)
continue;
- int ret = s->handler(f, ns, i);
+ int ret = s->handler(f, ns, i, ctx);
if (ret < 0) {
scf_loge("analysis step '%s' ret: %d\n", s->name, ret);
+
+ ses_ctx_free(ctx);
return ret;
}
}
}
+ ses_ctx_free(ctx);
return 0;
}