CFILES += ses_step_va_diode.c
CFILES += ses_step_va_transistor.c
CFILES += ses_step_va.c
+CFILES += ses_step_va_bridge.c
CFILES += ses_step_va_balance.c
CFILES += ses_step_output.c
void __ses_path_sr (ScfEfunction* f, ses_path_t* path, int i, int j, ScfEpin* cp1, double* r, double* jr);
int __ses_path_pos (ScfEfunction* f, ScfEline* el);
int __ses_path_neg (ScfEfunction* f, ScfEline* el);
+int __ses_path_va (ScfEfunction* f, ses_path_t* path);
static inline void vertical(int* px, int* py, int dx, int dy, int d)
{
int _ses_path_cmp(const void* v0, const void* v1);
-static int __ses_path_va(ScfEfunction* f, ses_path_t* path);
-
static int __ses_path_split_a(ScfEfunction* f, ses_path_t* path, int i, double* a, double *ja)
{
ses_path_t* child;
r = p->sr - (p->r + p->dr ) - p0->sr;
jr = p->jsr - (p->jr + p->jdr) - p0->jsr;
+ scf_logi("c%ldp%ld-c%ldp%ld, p->sr: %lg, p->r: %lg, p->dr: %lg, p0->sr: %lg\n",
+ p0->cid, p0->id, p->cid, p->id, p->sr, p->r, p->dr, p0->sr);
+
} else if (i >= 1) {
p2 = path->pins->data[i - 1];
p->v = p0->v - v;
p->jv = p0->jv - jv;
- scf_logd("c%ldp%ld, c%ldp%ld, a: %lg, r: %lg, v: %lg\n", p0->cid, p0->id, p->cid, p->id, a, r, v);
+ scf_logi("c%ldp%ld, c%ldp%ld, a: %lg, r: %lg, v: %lg\n", p0->cid, p0->id, p->cid, p->id, a, r, v);
return 0;
}
-static int __ses_path_va(ScfEfunction* f, ses_path_t* path)
+int __ses_path_va(ScfEfunction* f, ses_path_t* path)
{
if (!path)
return -EINVAL;
for (i = 0; i < ctx->paths->size; i++) {
path = ctx->paths->data[i];
- scf_logi("i: %d, path->type: %d\n", i, path->type);
+ scf_logi("i: %d, path->index: %d\n", i, path->index);
if (path->pins->size < 2) {
scf_loge("\n");
--- /dev/null
+#include"ses_core.h"
+
+static int __ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed)
+{
+ if (!path)
+ return -EINVAL;
+
+ if (path->pins->size < 2) {
+ scf_loge("\n");
+ return -EINVAL;
+ }
+
+ ses_path_t* child;
+ ScfEcomponent* c;
+ ScfEline* el;
+ ScfEpin* p0;
+ ScfEpin* p1;
+
+ p0 = path->pins->data[0];
+ p1 = path->pins->data[path->pins->size - 1];
+
+ el = f->elines[p0->lid];
+ p0->v = el->v;
+ p0->jv = el->jv;
+
+ el = f->elines[p1->lid];
+ p1->v = el->v;
+ p1->jv = el->jv;
+
+ double v = p0->v - p1->v;
+ double jv = p0->jv - p1->jv;
+
+ scf_logw("path: %d, c%ldp%ld--c%ldp%ld, v: %lg, p0->v: %lg, p1->v: %lg, n_diodes: %d\n",
+ path->index, p0->cid, p0->id, p1->cid, p1->id, v, p0->v, p1->v, path->n_diodes);
+
+ int ret = __ses_path_va(f, path);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int ses_path_va_bridge(ScfEfunction* f, ses_path_t* path, int* changed)
+{
+ ses_path_t* child;
+
+ size_t j;
+
+ if (!path)
+ return -EINVAL;
+
+ if (path->bridges) {
+ for (j = 0; j < path->bridges->size; j++) {
+ child = path->bridges->data[j];
+
+ int ret = __ses_path_va_bridge(f, child, changed);
+ if (ret < 0)
+ return ret;
+
+ ret = ses_path_va_bridge(f, child, changed);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int _va_bridge_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+{
+ ses_path_t* path;
+
+ int changed = 0;
+ int i;
+
+ for (i = 0; i < ctx->paths->size; i++) {
+ path = ctx->paths->data[i];
+
+ int ret = ses_path_va_bridge(f, path, &changed);
+ if (ret < 0)
+ return ret;
+
+ printf("\n");
+ }
+
+ return changed > 0 ? -EAGAIN : 0;
+}
+
+ses_step_t ses_step_va_bridge =
+{
+ .name = "va_bridge",
+
+ .handler = _va_bridge_handler,
+};
extern ses_step_t ses_step_va_diode;
extern ses_step_t ses_step_va_transistor;
extern ses_step_t ses_step_va;
+extern ses_step_t ses_step_va_bridge;
extern ses_step_t ses_step_va_balance;
extern ses_step_t ses_step_output;
#if 1
&ses_step_jr,
&ses_step_va,
+ &ses_step_va_bridge,
&ses_step_va_balance,
#endif
};