update node analysis, scf_pack.c, rename ses_step_simplify.c --> ses_step_draw.c...
authoryu.dongliang <18588496441@163.com>
Sun, 23 Jun 2024 11:17:41 +0000 (19:17 +0800)
committeryu.dongliang <18588496441@163.com>
Sun, 23 Jun 2024 11:17:41 +0000 (19:17 +0800)
34 files changed:
Makefile
cpk/Makefile [new file with mode: 0644]
cpk/add_gate.c [new file with mode: 0644]
cpk/and_gate.c [new file with mode: 0644]
cpk/nand.c [new file with mode: 0644]
cpk/nand.cpk [new file with mode: 0644]
cpk/nor.c [new file with mode: 0644]
cpk/nor.cpk [new file with mode: 0644]
cpk/not.c [new file with mode: 0644]
cpk/not.cpk [new file with mode: 0644]
cpk/or_gate.c [new file with mode: 0644]
examples/add.cpk
examples/add2.cpk
examples/and.cpk
examples/colpitts_oscillator.cpk [deleted file]
examples/or.cpk
examples/pnp_oscillator.cpk [deleted file]
examples/sin_oscillator.cpk
examples/sub.cpk
main.c
pack/main.c
pack/scf_pack.c
pack/scf_pack.h
scf_eda_pack.c
scf_eda_pack.h
ses_core.h
ses_layout.c
ses_node_analysis.c
ses_step_draw.c [moved from ses_step_simplify.c with 67% similarity]
ses_step_jr.c
ses_step_output.c
ses_step_topo.c
ses_steps.c
test/Makefile

index 952b8f2fd07a2437726c3b9756f73b3fe5962d62..be7e53030bfb1874511aadab2b6de7aef5b3794f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ CFILES += ses_step_open.c
 CFILES += ses_step_va_nodes.c
 
 CFILES += ses_step_output.c
-CFILES += ses_step_simplify.c
+CFILES += ses_step_draw.c
 
 CFLAGS += -g -D_GNU_SOURCE
 CFLAGS += -I./
diff --git a/cpk/Makefile b/cpk/Makefile
new file mode 100644 (file)
index 0000000..bcf56ea
--- /dev/null
@@ -0,0 +1,20 @@
+#CFILES += nand.c
+#CFILES += nor.c
+#CFILES += not.c
+CFILES += and_gate.c
+#CFILES += or_gate.c
+#CFILES += add_gate.c
+CFILES += ../scf_eda_pack.c
+CFILES += ../pack/scf_pack.c
+
+CFLAGS += -g
+CFLAGS += -I../
+CFLAGS += -I../pack
+
+LDFLAGS += -lcairo -lm -lgsl -lgslcblas
+
+all:
+       gcc $(CFLAGS) $(CFILES) $(LDFLAGS)
+
+clean:
+       rm *.o
diff --git a/cpk/add_gate.c b/cpk/add_gate.c
new file mode 100644 (file)
index 0000000..4868d60
--- /dev/null
@@ -0,0 +1,73 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+       ScfEcomponent* B;
+
+       ScfEcomponent* NAND0;
+       ScfEcomponent* NOR0;
+       ScfEcomponent* NOR1;
+       ScfEcomponent* NOT0;
+
+       ScfEfunction*  f;
+       ScfEboard*     b;
+
+       b = scf_eboard__alloc();
+       f = scf_efunction__alloc("add_gate");
+
+       EDA_INST_ADD_COMPONENT(f, B,  SCF_EDA_Battery);
+
+       B->pins[SCF_EDA_Battery_NEG]->flags = SCF_EDA_PIN_NEG;
+       B->pins[SCF_EDA_Battery_POS]->flags = SCF_EDA_PIN_POS;
+
+       EDA_INST_ADD_COMPONENT(f, NAND0, SCF_EDA_NAND);
+       EDA_INST_ADD_COMPONENT(f, NOT0,  SCF_EDA_NOT);
+       EDA_INST_ADD_COMPONENT(f, NOR0,  SCF_EDA_NOR);
+       EDA_INST_ADD_COMPONENT(f, NOR1,  SCF_EDA_NOR);
+
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_POS,  NAND0, SCF_EDA_NAND_POS);
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_NEG,  NAND0, SCF_EDA_NAND_NEG);
+
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_POS,  NOR0,  SCF_EDA_NOR_POS);
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_NEG,  NOR0,  SCF_EDA_NOR_NEG);
+
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_POS,  NOR1,  SCF_EDA_NOR_POS);
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_NEG,  NOR1,  SCF_EDA_NOR_NEG);
+
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_POS,  NOT0,  SCF_EDA_NOT_POS);
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_NEG,  NOT0,  SCF_EDA_NOT_NEG);
+
+       EDA_PIN_ADD_PIN(NAND0, SCF_EDA_NAND_OUT,     NOT0,  SCF_EDA_NOT_IN);
+
+       EDA_PIN_ADD_PIN(NOT0,  SCF_EDA_NOT_OUT,      NOR1,  SCF_EDA_NOR_IN0);
+       EDA_PIN_ADD_PIN(NOR0,  SCF_EDA_NOR_OUT,      NOR1,  SCF_EDA_NOR_IN1);
+
+       EDA_PIN_ADD_PIN(NAND0, SCF_EDA_NAND_IN0,     NOR0,  SCF_EDA_NOR_IN0);
+       EDA_PIN_ADD_PIN(NAND0, SCF_EDA_NAND_IN1,     NOR0,  SCF_EDA_NOR_IN1);
+
+       NAND0->pins[SCF_EDA_NAND_IN0]->flags = SCF_EDA_PIN_IN | SCF_EDA_PIN_IN0;
+       NAND0->pins[SCF_EDA_NAND_IN1]->flags = SCF_EDA_PIN_IN;
+
+       NOR1->pins[SCF_EDA_NOR_OUT]->flags   = SCF_EDA_PIN_OUT;
+
+       scf_logi("\n");
+       scf_eboard__add_function(b, f);
+
+       int      len = 0;
+       uint8_t* buf = NULL;
+
+       ScfEboard_pack(b, &buf, &len);
+       ScfEboard_free(b);
+       b = NULL;
+
+       FILE* fp = fopen("./add_gate.cpk", "wb");
+       if (!fp)
+               return -EINVAL;
+
+       fwrite(buf, len, 1, fp);
+       fclose(fp);
+       return 0;
+}
diff --git a/cpk/and_gate.c b/cpk/and_gate.c
new file mode 100644 (file)
index 0000000..26ddfc9
--- /dev/null
@@ -0,0 +1,63 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+       ScfEcomponent* B;
+
+       ScfEcomponent* NAND0;
+       ScfEcomponent* NOT0;
+       ScfEcomponent* R0;
+       ScfEcomponent* R1;
+
+       ScfEfunction*  f;
+       ScfEboard*     b;
+
+       b = scf_eboard__alloc();
+       f = scf_efunction__alloc("and_gate");
+
+       EDA_INST_ADD_COMPONENT(f, B,  SCF_EDA_Battery);
+       EDA_INST_ADD_COMPONENT(f, R0, SCF_EDA_Resistor);
+       EDA_INST_ADD_COMPONENT(f, R1, SCF_EDA_Resistor);
+
+       B->pins[SCF_EDA_Battery_NEG]->flags = SCF_EDA_PIN_NEG;
+       B->pins[SCF_EDA_Battery_POS]->flags = SCF_EDA_PIN_POS;
+
+       EDA_INST_ADD_COMPONENT(f, NAND0, SCF_EDA_NAND);
+       EDA_INST_ADD_COMPONENT(f, NOT0,  SCF_EDA_NOT);
+
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_POS,  NAND0, SCF_EDA_NAND_POS);
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_NEG,  NAND0, SCF_EDA_NAND_NEG);
+
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_POS,  NOT0,  SCF_EDA_NOT_POS);
+       EDA_PIN_ADD_PIN(B,     SCF_EDA_Battery_NEG,  NOT0,  SCF_EDA_NOT_NEG);
+
+       EDA_PIN_ADD_PIN(NAND0, SCF_EDA_NAND_OUT,     NOT0,  SCF_EDA_NOT_IN);
+
+       EDA_PIN_ADD_PIN(R0,    0,                    NAND0, SCF_EDA_NAND_IN0);
+       EDA_PIN_ADD_PIN(R1,    0,                    NAND0, SCF_EDA_NAND_IN1);
+
+       R0->pins[1]->flags = SCF_EDA_PIN_IN | SCF_EDA_PIN_IN0;
+       R1->pins[1]->flags = SCF_EDA_PIN_IN;
+
+       NOT0->pins[SCF_EDA_NOT_OUT]->flags = SCF_EDA_PIN_OUT;
+
+       scf_eboard__add_function(b, f);
+
+       uint8_t* buf = NULL;
+       long     len = 0;
+
+       ScfEboard_pack(b, &buf, &len);
+       ScfEboard_free(b);
+       b = NULL;
+
+       FILE* fp = fopen("./and_gate.cpk", "wb");
+       if (!fp)
+               return -EINVAL;
+
+       fwrite(buf, len, 1, fp);
+       fclose(fp);
+       return 0;
+}
diff --git a/cpk/nand.c b/cpk/nand.c
new file mode 100644 (file)
index 0000000..f2b7a01
--- /dev/null
@@ -0,0 +1,46 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+       ScfEcomponent* B;
+
+       ScfEcomponent* R0;
+       ScfEcomponent* T0;
+       ScfEcomponent* T1;
+
+       ScfEfunction*  f;
+
+       f = scf_efunction__alloc("nand.cpk");
+
+       EDA_INST_ADD_COMPONENT(f, R0, SCF_EDA_Resistor);
+       EDA_INST_ADD_COMPONENT(f, T0, SCF_EDA_NPN);
+       EDA_INST_ADD_COMPONENT(f, T1, SCF_EDA_NPN);
+
+       EDA_PIN_ADD_PIN(R0, 0,             T0, SCF_EDA_NPN_C);
+       EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_E, T1, SCF_EDA_NPN_C);
+
+       R0->pins[1]->flags             = SCF_EDA_PIN_POS;
+       T1->pins[SCF_EDA_NPN_E]->flags = SCF_EDA_PIN_NEG;
+
+       T0->pins[SCF_EDA_NPN_B]->flags = SCF_EDA_PIN_IN | SCF_EDA_PIN_IN0;
+       T1->pins[SCF_EDA_NPN_B]->flags = SCF_EDA_PIN_IN;
+       R0->pins[0]->flags             = SCF_EDA_PIN_OUT;
+
+       int      len = 0;
+       uint8_t* buf = NULL;
+
+       ScfEfunction_pack(f, &buf, &len);
+       ScfEfunction_free(f);
+       f = NULL;
+
+       FILE* fp = fopen("./nand.cpk", "wb");
+       if (!fp)
+               return -EINVAL;
+
+       fwrite(buf, len, 1, fp);
+       fclose(fp);
+       return 0;
+}
diff --git a/cpk/nand.cpk b/cpk/nand.cpk
new file mode 100644 (file)
index 0000000..b80fcfa
Binary files /dev/null and b/cpk/nand.cpk differ
diff --git a/cpk/nor.c b/cpk/nor.c
new file mode 100644 (file)
index 0000000..8c1f63c
--- /dev/null
+++ b/cpk/nor.c
@@ -0,0 +1,47 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+       ScfEcomponent* B;
+
+       ScfEcomponent* R0;
+       ScfEcomponent* T0;
+       ScfEcomponent* T1;
+
+       ScfEfunction*  f;
+
+       f = scf_efunction__alloc("nor.cpk");
+
+       EDA_INST_ADD_COMPONENT(f, R0, SCF_EDA_Resistor);
+       EDA_INST_ADD_COMPONENT(f, T0, SCF_EDA_NPN);
+       EDA_INST_ADD_COMPONENT(f, T1, SCF_EDA_NPN);
+
+       EDA_PIN_ADD_PIN(R0, 0,             T0, SCF_EDA_NPN_C);
+       EDA_PIN_ADD_PIN(R0, 0,             T1, SCF_EDA_NPN_C);
+       EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_E, T1, SCF_EDA_NPN_E);
+
+       R0->pins[1]->flags             = SCF_EDA_PIN_POS;
+       T0->pins[SCF_EDA_NPN_E]->flags = SCF_EDA_PIN_NEG;
+
+       T0->pins[SCF_EDA_NPN_B]->flags = SCF_EDA_PIN_IN | SCF_EDA_PIN_IN0;
+       T1->pins[SCF_EDA_NPN_B]->flags = SCF_EDA_PIN_IN;
+       R0->pins[0]->flags             = SCF_EDA_PIN_OUT;
+
+       int      len = 0;
+       uint8_t* buf = NULL;
+
+       ScfEfunction_pack(f, &buf, &len);
+       ScfEfunction_free(f);
+       f = NULL;
+
+       FILE* fp = fopen("./nor.cpk", "wb");
+       if (!fp)
+               return -EINVAL;
+
+       fwrite(buf, len, 1, fp);
+       fclose(fp);
+       return 0;
+}
diff --git a/cpk/nor.cpk b/cpk/nor.cpk
new file mode 100644 (file)
index 0000000..9fc5bc8
Binary files /dev/null and b/cpk/nor.cpk differ
diff --git a/cpk/not.c b/cpk/not.c
new file mode 100644 (file)
index 0000000..a2d622a
--- /dev/null
+++ b/cpk/not.c
@@ -0,0 +1,42 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+       ScfEcomponent* B;
+
+       ScfEcomponent* R0;
+       ScfEcomponent* T0;
+
+       ScfEfunction*  f;
+
+       f = scf_efunction__alloc("not.cpk");
+
+       EDA_INST_ADD_COMPONENT(f, R0, SCF_EDA_Resistor);
+       EDA_INST_ADD_COMPONENT(f, T0, SCF_EDA_NPN);
+
+       EDA_PIN_ADD_PIN(R0, 0, T0, SCF_EDA_NPN_C);
+
+       R0->pins[1]->flags             = SCF_EDA_PIN_POS;
+       T0->pins[SCF_EDA_NPN_E]->flags = SCF_EDA_PIN_NEG;
+
+       T0->pins[SCF_EDA_NPN_B]->flags = SCF_EDA_PIN_IN | SCF_EDA_PIN_IN0;
+       R0->pins[0]->flags             = SCF_EDA_PIN_OUT;
+
+       int      len = 0;
+       uint8_t* buf = NULL;
+
+       ScfEfunction_pack(f, &buf, &len);
+       ScfEfunction_free(f);
+       f = NULL;
+
+       FILE* fp = fopen("./not.cpk", "wb");
+       if (!fp)
+               return -EINVAL;
+
+       fwrite(buf, len, 1, fp);
+       fclose(fp);
+       return 0;
+}
diff --git a/cpk/not.cpk b/cpk/not.cpk
new file mode 100644 (file)
index 0000000..f74503d
Binary files /dev/null and b/cpk/not.cpk differ
diff --git a/cpk/or_gate.c b/cpk/or_gate.c
new file mode 100644 (file)
index 0000000..2641657
--- /dev/null
@@ -0,0 +1,56 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+       ScfEcomponent* B;
+
+       ScfEcomponent* NOR0;
+       ScfEcomponent* NOT0;
+
+       ScfEfunction*  f;
+       ScfEboard*     b;
+
+       b = scf_eboard__alloc();
+       f = scf_efunction__alloc("or_gate");
+
+       EDA_INST_ADD_COMPONENT(f, B,  SCF_EDA_Battery);
+
+       B->pins[SCF_EDA_Battery_NEG]->flags = SCF_EDA_PIN_NEG;
+       B->pins[SCF_EDA_Battery_POS]->flags = SCF_EDA_PIN_POS;
+
+       EDA_INST_ADD_COMPONENT(f, NOR0, SCF_EDA_NOR);
+       EDA_INST_ADD_COMPONENT(f, NOT0, SCF_EDA_NOT);
+
+       EDA_PIN_ADD_PIN(B,    SCF_EDA_Battery_POS, NOR0, SCF_EDA_NAND_POS);
+       EDA_PIN_ADD_PIN(B,    SCF_EDA_Battery_NEG, NOR0, SCF_EDA_NAND_NEG);
+
+       EDA_PIN_ADD_PIN(B,    SCF_EDA_Battery_POS, NOT0, SCF_EDA_NOT_POS);
+       EDA_PIN_ADD_PIN(B,    SCF_EDA_Battery_NEG, NOT0, SCF_EDA_NOT_NEG);
+
+       EDA_PIN_ADD_PIN(NOR0, SCF_EDA_NOR_OUT,     NOT0, SCF_EDA_NOT_IN);
+
+       NOR0->pins[SCF_EDA_NOR_IN0]->flags = SCF_EDA_PIN_IN | SCF_EDA_PIN_IN0;
+       NOR0->pins[SCF_EDA_NOR_IN1]->flags = SCF_EDA_PIN_IN;
+
+       NOT0->pins[SCF_EDA_NOT_OUT]->flags = SCF_EDA_PIN_OUT;
+
+       scf_eboard__add_function(b, f);
+
+       int      len = 0;
+       uint8_t* buf = NULL;
+
+       ScfEboard_pack(b, &buf, &len);
+       ScfEboard_free(b);
+       b = NULL;
+
+       FILE* fp = fopen("./or_gate.cpk", "wb");
+       if (!fp)
+               return -EINVAL;
+
+       fwrite(buf, len, 1, fp);
+       fclose(fp);
+       return 0;
+}
index f549b6accb3faa6f52e312a195ed74332f03dc08..ad32f5061b8ad2c55302396f605016a8791e98d8 100644 (file)
Binary files a/examples/add.cpk and b/examples/add.cpk differ
index 30cbeebf6375b4c7a8c0f63e539d5a95c86ef01d..ae8ca9aa82ed41b209a0da9463b64acda7155b47 100644 (file)
Binary files a/examples/add2.cpk and b/examples/add2.cpk differ
index 4cfa6984d812c7c5ee6c0ebc5cb4129c5aa310b4..717e76d4bebb0889739ad2958d4820de3954c6d0 100644 (file)
Binary files a/examples/and.cpk and b/examples/and.cpk differ
diff --git a/examples/colpitts_oscillator.cpk b/examples/colpitts_oscillator.cpk
deleted file mode 100644 (file)
index 4d1e411..0000000
Binary files a/examples/colpitts_oscillator.cpk and /dev/null differ
index c52c94575adef2b87c06c78d0f8d63b5e790fa1c..a861ebd124931f1a2da9e0bc458cea2ba4923012 100644 (file)
Binary files a/examples/or.cpk and b/examples/or.cpk differ
diff --git a/examples/pnp_oscillator.cpk b/examples/pnp_oscillator.cpk
deleted file mode 100644 (file)
index 62dc959..0000000
Binary files a/examples/pnp_oscillator.cpk and /dev/null differ
index 25cb122aff1f8b05b02288e083b2877f68692506..ddeef15c536b97182b845c924d9c062b5c9df318 100644 (file)
Binary files a/examples/sin_oscillator.cpk and b/examples/sin_oscillator.cpk differ
index b64b29046e55f2a78cd5ea24da856a6a2e302722..aea4f8909d3ac6a128af4debd569d811f37655b1 100644 (file)
Binary files a/examples/sub.cpk and b/examples/sub.cpk differ
diff --git a/main.c b/main.c
index 1a848f53aed897c00c75bd6c6ca2ae609dd57052..8d9aa7bc2615d8b48615665fc1c78f4f5ce33a0f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -56,62 +56,55 @@ int main(int argc, char* argv[])
                return -EINVAL;
        }
 
-       FILE* fp = fopen(argv[1], "rb");
-       if (!fp) {
-               scf_loge("fopen '%s' error\n", argv[1]);
-               return -EINVAL;
-       }
+       ScfEcomponent* c;
+       ScfEfunction*  f;
+       ScfEboard*     b  = NULL;
+       ScfEdata*      ed = NULL;
 
-       fseek(fp, 0, SEEK_END);
+       uint8_t* buf = NULL;
 
-       int len = ftell(fp);
+       long len = scf_pack_read(&buf, argv[1]);
        if (len < 0) {
-               scf_loge("pb len: %d\n", len);
-               return -EINVAL;
+               scf_loge("scf_pack_read error: %ld\n", len);
+               return len;
        }
 
-       uint8_t* pb = calloc(1, len);
-       if (!pb) {
-               scf_loge("malloc error\n");
-               return -ENOMEM;
+       long ret = ScfEboard_unpack(&b, buf, len);
+       if (ret < 0) {
+               scf_loge("ScfEboard__unpack error: %ld\n", ret);
+               return ret;
        }
 
-       fseek(fp, 0, SEEK_SET);
+       free(buf);
+       buf = NULL;
 
-       if (fread(pb, 1, len, fp) != len) {
-               scf_loge("fread error\n");
-               return -ENOMEM;
-       }
+       long i;
+       long j;
 
-       fclose(fp);
-       fp = NULL;
+       for (i = 0; i < b->n_functions; i++) {
+               f  =        b->functions[i];
 
-       ScfEcomponent* c;
-       ScfEfunction*  f;
-       ScfEboard*     b = NULL;
+               for (j = 0; j < f->n_components; j++) {
+                       c  =        f->components[j];
 
-       int ret = ScfEboard_unpack(&b, pb, len);
-       if (ret < 0) {
-               scf_loge("ScfEboard__unpack error: %d\n", ret);
-               return ret;
+                       ed = scf_ecomponent__find_data(c->type, c->model);
+                       if (ed)
+                               c->ops = ed->ops;
+               }
        }
-
 //     print_board(b);
 #if 1
        ses_layout_board(b, 100);
 
-       size_t i;
-
        for (i = 0; i < b->n_functions; i++) {
                f  =        b->functions[i];
 
                printf("f: %s\n", f->name);
 
-               ses_steps_analyse(f, 100, 3);
+//             ses_steps_analyse(f, 100, 1);
        }
 #endif
 
        ScfEboard_free(b);
-       free(pb);
        return 0;
 }
index 7b6abb817097f481f73a98df8c6fb51382d929b6..82e503b76a0ef183b658e2ebaad5dd19154005dd 100644 (file)
@@ -38,7 +38,7 @@ int main()
        printf("z0: %p, z1: %p\n", z0, z1);
 
        uint8_t* buf = NULL;
-       int      len = 0;
+       long     len = 0;
 
        B_pack(&b, &buf, &len);
 
index 1d440fe5a5aa0919d424470f691124330d4d4467..e49ead736e11a9dcdb6bdcb6aec3fc79509abc5a 100644 (file)
@@ -1,12 +1,12 @@
 #include"scf_pack.h"
 
-int __scf_pack_one_index(uint8_t* pack, uint64_t u, int shift)
+long __scf_pack_one_index(uint8_t* pack, uint64_t u, long shift)
 {
-       int max  = -1;
-       int bits = 1u << shift;
-       int i;
-       int j;
-       int k;
+       long max  = -1;
+       long bits = 1u << shift;
+       long i;
+       long j;
+       long k;
 
        j = 0;
        k = 3;
@@ -61,15 +61,15 @@ int __scf_pack_one_index(uint8_t* pack, uint64_t u, int shift)
        return j + 1;
 }
 
-int __scf_pack_byte_map(uint8_t* pack, uint64_t u, int shift)
+long __scf_pack_byte_map(uint8_t* pack, uint64_t u, long shift)
 {
        uint8_t* p = (uint8_t*)&u;
        uint8_t map = 0;
 
-       int bytes = 1u << shift >> 3;
-       int i;
-       int j;
-       int k;
+       long bytes = 1u << shift >> 3;
+       long i;
+       long j;
+       long k;
 
        pack[0] |= 0x4;
        j = 0;
@@ -101,12 +101,12 @@ int __scf_pack_byte_map(uint8_t* pack, uint64_t u, int shift)
        return j + 1;
 }
 
-int __scf_pack2(uint8_t* pack, uint64_t u, int shift)
+long __scf_pack2(uint8_t* pack, uint64_t u, long shift)
 {
-       int sum  = 0;
-       int not  = 0;
-       int bits = 1u << shift;
-       int i;
+       long sum  = 0;
+       long not  = 0;
+       long bits = 1u << shift;
+       long i;
 
        for (i = 0; i < bits; i++) {
                if (u & (1ull << i))
@@ -135,13 +135,13 @@ int __scf_pack2(uint8_t* pack, uint64_t u, int shift)
        return __scf_pack_byte_map(pack, u, shift);
 }
 
-int __scf_unpack2(void* p, int shift, const uint8_t* buf, int len)
+long __scf_unpack2(void* p, long shift, const uint8_t* buf, long len)
 {
-       int bits = 1u << shift;
-       int max  = -1;
-       int i;
-       int j;
-       int k;
+       long bits = 1u << shift;
+       long max  = -1;
+       long i;
+       long j;
+       long k;
 
        if (len < 1)
                return -EINVAL;
@@ -261,16 +261,16 @@ int __scf_unpack2(void* p, int shift, const uint8_t* buf, int len)
                        *(uint64_t*)p = u;
                        break;
                default:
-                       scf_loge("bits %d Not support!\n", bits);
+                       scf_loge("bits %ld Not support!\n", bits);
                        return -EINVAL;
                        break;
        };
 
-       scf_logd("u: %#lx, j: %d, bits: %d\n", u, j, bits);
+       scf_logd("u: %#lx, j: %d, bits: %ld\n", u, j, bits);
        return j;
 }
 
-int __scf_unpack(void* p, int size, const uint8_t* buf, int len)
+long __scf_unpack(void* p, long size, const uint8_t* buf, long len)
 {
        switch (size) {
                case 1:
@@ -288,25 +288,11 @@ int __scf_unpack(void* p, int size, const uint8_t* buf, int len)
                        break;
 
                case 4:
-#if 0
-                       if (4 <= len) {
-                               *(uint32_t*)p = *(uint32_t*)buf;
-                               return 4;
-                       }
-#else
                        return __scf_unpack2(p, 5, buf, len);
-#endif
                        break;
 
                case 8:
-#if 0
-                       if (8 <= len) {
-                               *(uint64_t*)p = *(uint64_t*)buf;
-                               return 8;
-                       }
-#else
                        return __scf_unpack2(p, 6, buf, len);
-#endif
                        break;
                default:
                        scf_loge("data type NOT support!\n");
@@ -316,10 +302,10 @@ int __scf_unpack(void* p, int size, const uint8_t* buf, int len)
        return -EINVAL;
 }
 
-int __scf_pack(void* p, int size, uint8_t** pbuf, int* plen)
+long __scf_pack(void* p, long size, uint8_t** pbuf, long* plen)
 {
        uint8_t pack[64];
-       int     len = 0;
+       long     len = 0;
 
        switch (size) {
                case 1:
@@ -331,29 +317,21 @@ int __scf_pack(void* p, int size, uint8_t** pbuf, int* plen)
                        len = 2;
                        break;
                case 4:
-#if 1
                        len = __scf_pack2(pack, *(uint32_t*)p, 5);
                        if (len < 0)
                                return len;
-#else
-                       *(uint32_t*)pack = *(uint32_t*)p;
-                       len = 4;
-#endif
-                       scf_logd("p: %p, %d, len: %d\n\n", p, *(uint32_t*)p, len);
+
+                       scf_logd("p: %p, %d, len: %ld\n\n", p, *(uint32_t*)p, len);
                        break;
                case 8:
-#if 1
                        len = __scf_pack2(pack, *(uint64_t*)p, 6);
                        if (len < 0)
                                return len;
-#else
-                       *(uint64_t*)pack = *(uint64_t*)p;
-                       len = 8;
-#endif
-                       scf_logd("p: %p, %ld, %#lx, %lg, len: %d\n\n", p, *(uint64_t*)p, *(uint64_t*)p, *(double*)p, len);
+
+                       scf_logd("p: %p, %ld, %#lx, %lg, len: %ld\n\n", p, *(uint64_t*)p, *(uint64_t*)p, *(double*)p, len);
                        break;
                default:
-                       scf_loge("data size '%d' NOT support!\n", size);
+                       scf_loge("data size '%ld' NOT support!\n", size);
                        return -EINVAL;
                        break;
        };
@@ -368,7 +346,7 @@ int __scf_pack(void* p, int size, uint8_t** pbuf, int* plen)
        return 0;
 }
 
-int scf_pack(void* p, scf_pack_info_t* infos, int n_infos, uint8_t** pbuf, int* plen)
+long scf_pack(void* p, scf_pack_info_t* infos, long n_infos, uint8_t** pbuf, long* plen)
 {
        if (!p || !infos || n_infos < 1 || !pbuf || !plen)
                return -EINVAL;
@@ -376,10 +354,10 @@ int scf_pack(void* p, scf_pack_info_t* infos, int n_infos, uint8_t** pbuf, int*
        if (!*pbuf)
                *plen = 0;
 
-//     printf("\n");
+//     prlongf("\n");
        scf_logd("p: %p\n", p);
 
-       int i;
+       long i;
        for (i = 0; i < n_infos; i++) {
                scf_logd("name: %s, size: %ld, offset: %ld, noffset: %ld, msize: %ld, members: %p, n_members: %ld\n",
                                infos[i].name, infos[i].size, infos[i].offset, infos[i].noffset, infos[i].msize, infos[i].members, infos[i].n_members);
@@ -388,22 +366,22 @@ int scf_pack(void* p, scf_pack_info_t* infos, int n_infos, uint8_t** pbuf, int*
 
                        void* a = *(void**)(p + infos[i].offset);
                        long  n = *(long* )(p + infos[i].noffset);
-                       int   j;
+                       long   j;
 
                        scf_logd("a: %p, n: %ld, infos[i].msize: %ld, infos[i].noffset: %ld\n", a, n, infos[i].msize, infos[i].noffset);
 
                        for (j = 0; j < n; j++) {
 
                                if (infos[i].members) {
-                                       int ret = scf_pack(*(void**)(a + j * infos[i].msize), infos[i].members, infos[i].n_members, pbuf, plen);
+                                       long ret = scf_pack(*(void**)(a + j * infos[i].msize), infos[i].members, infos[i].n_members, pbuf, plen);
                                        if (ret < 0) {
-                                               scf_loge("ret: %d\n", ret);
+                                               scf_loge("ret: %ld\n", ret);
                                                return ret;
                                        }
                                } else {
-                                       int ret = __scf_pack(a + j * infos[i].msize, infos[i].msize, pbuf, plen);
+                                       long ret = __scf_pack(a + j * infos[i].msize, infos[i].msize, pbuf, plen);
                                        if (ret < 0) {
-                                               scf_loge("ret: %d\n", ret);
+                                               scf_loge("ret: %ld\n", ret);
                                                return ret;
                                        }
                                }
@@ -414,17 +392,17 @@ int scf_pack(void* p, scf_pack_info_t* infos, int n_infos, uint8_t** pbuf, int*
 
                if (infos[i].members) {
 
-                       int ret = scf_pack(*(void**)(p + infos[i].offset), infos[i].members, infos[i].n_members, pbuf, plen);
+                       long ret = scf_pack(*(void**)(p + infos[i].offset), infos[i].members, infos[i].n_members, pbuf, plen);
                        if (ret < 0) {
-                               scf_loge("ret: %d\n", ret);
+                               scf_loge("ret: %ld\n", ret);
                                return ret;
                        }
                        continue;
                }
 
-               int ret = __scf_pack(p + infos[i].offset, infos[i].size, pbuf, plen);
+               long ret = __scf_pack(p + infos[i].offset, infos[i].size, pbuf, plen);
                if (ret < 0) {
-                       scf_loge("ret: %d\n", ret);
+                       scf_loge("ret: %ld\n", ret);
                        return ret;
                }
 
@@ -434,20 +412,20 @@ int scf_pack(void* p, scf_pack_info_t* infos, int n_infos, uint8_t** pbuf, int*
        return 0;
 }
 
-int scf_unpack(void** pp, scf_pack_info_t* infos, int n_infos, const uint8_t* buf, int len)
+long scf_unpack(void** pp, scf_pack_info_t* infos, long n_infos, const uint8_t* buf, long len)
 {
        if (!pp || !infos || n_infos < 1 || !buf || len < 1)
                return -EINVAL;
 
-       int size = infos[n_infos - 1].offset + infos[n_infos - 1].size;
+       long size = infos[n_infos - 1].offset + infos[n_infos - 1].size;
 
        void* p  = calloc(1, size);
        if (!p)
                return -ENOMEM;
 
-       int i;
-       int j;
-       int k = 0;
+       long i;
+       long j;
+       long k = 0;
 
        for (i = 0; i < n_infos; i++) {
 
@@ -464,18 +442,18 @@ int scf_unpack(void** pp, scf_pack_info_t* infos, int n_infos, const uint8_t* bu
                        for (j = 0; j < n; j++) {
 
                                if (infos[i].members) {
-                                       int ret = scf_unpack((void**)(a + j * infos[i].msize), infos[i].members, infos[i].n_members, buf + k, len - k);
+                                       long ret = scf_unpack((void**)(a + j * infos[i].msize), infos[i].members, infos[i].n_members, buf + k, len - k);
                                        if (ret < 0) {
-                                               scf_loge("ret: %d\n", ret);
+                                               scf_loge("ret: %ld\n", ret);
                                                return ret;
                                        }
 
                                        k += ret;
 
                                } else {
-                                       int ret = __scf_unpack(a + j * infos[i].msize, infos[i].msize, buf + k, len - k);
+                                       long ret = __scf_unpack(a + j * infos[i].msize, infos[i].msize, buf + k, len - k);
                                        if (ret < 0) {
-                                               scf_loge("ret: %d\n", ret);
+                                               scf_loge("ret: %ld\n", ret);
                                                return ret;
                                        }
 
@@ -488,9 +466,9 @@ int scf_unpack(void** pp, scf_pack_info_t* infos, int n_infos, const uint8_t* bu
 
                if (infos[i].members) {
 
-                       int ret = scf_unpack((void**)(p + infos[i].offset), infos[i].members, infos[i].n_members, buf + k, len - k);
+                       long ret = scf_unpack((void**)(p + infos[i].offset), infos[i].members, infos[i].n_members, buf + k, len - k);
                        if (ret < 0) {
-                               scf_loge("ret: %d\n", ret);
+                               scf_loge("ret: %ld\n", ret);
                                return ret;
                        }
 
@@ -498,9 +476,9 @@ int scf_unpack(void** pp, scf_pack_info_t* infos, int n_infos, const uint8_t* bu
                        continue;
                }
 
-               int ret = __scf_unpack(p + infos[i].offset, infos[i].size, buf + k, len - k);
+               long ret = __scf_unpack(p + infos[i].offset, infos[i].size, buf + k, len - k);
                if (ret < 0) {
-                       scf_loge("ret: %d\n", ret);
+                       scf_loge("ret: %ld\n", ret);
                        return ret;
                }
 
@@ -511,13 +489,13 @@ int scf_unpack(void** pp, scf_pack_info_t* infos, int n_infos, const uint8_t* bu
        return k;
 }
 
-int scf_unpack_free(void* p, scf_pack_info_t* infos, int n_infos)
+long scf_unpack_free(void* p, scf_pack_info_t* infos, long n_infos)
 {
        if (!p || !infos || n_infos < 1)
                return -EINVAL;
 
-       int i;
-       int j;
+       long i;
+       long j;
        for (i = 0; i < n_infos; i++) {
 
                if (infos[i].noffset >= 0) {
@@ -529,9 +507,9 @@ int scf_unpack_free(void* p, scf_pack_info_t* infos, int n_infos)
                        if (infos[i].members) {
 
                                for (j = 0; j < n; j++) {
-                                       int ret = scf_unpack_free(*(void**)(a + j * infos[i].msize), infos[i].members, infos[i].n_members);
+                                       long ret = scf_unpack_free(*(void**)(a + j * infos[i].msize), infos[i].members, infos[i].n_members);
                                        if (ret < 0) {
-                                               scf_loge("ret: %d\n", ret);
+                                               scf_loge("ret: %ld\n", ret);
                                                return ret;
                                        }
                                }
@@ -543,9 +521,9 @@ int scf_unpack_free(void* p, scf_pack_info_t* infos, int n_infos)
                }
 
                if (infos[i].members) {
-                       int ret = scf_unpack_free(*(void**)(p + infos[i].offset), infos[i].members, infos[i].n_members);
+                       long ret = scf_unpack_free(*(void**)(p + infos[i].offset), infos[i].members, infos[i].n_members);
                        if (ret < 0) {
-                               scf_loge("ret: %d\n", ret);
+                               scf_loge("ret: %ld\n", ret);
                                return ret;
                        }
                }
@@ -555,3 +533,40 @@ int scf_unpack_free(void* p, scf_pack_info_t* infos, int n_infos)
        free(p);
        return 0;
 }
+
+long scf_pack_read(uint8_t** pbuf, const char* cpk)
+{
+       if (!pbuf || !cpk)
+               return -EINVAL;
+
+       FILE* fp = fopen(cpk, "rb");
+       if (!fp)
+               return -EINVAL;
+
+       fseek(fp, 0, SEEK_END);
+
+       long len = ftell(fp);
+       if (len < 0) {
+               fclose(fp);
+               return -EINVAL;
+       }
+
+       uint8_t* buf = calloc(1, len);
+       if (!buf) {
+               fclose(fp);
+               return -ENOMEM;
+       }
+
+       fseek(fp, 0, SEEK_SET);
+
+       if (fread(buf, 1, len, fp) != len) {
+               free(buf);
+               fclose(fp);
+               return -EINVAL;
+       }
+
+       fclose(fp);
+
+       *pbuf = buf;
+       return len;
+}
index 133497b65f4e782e8bc5975b143099583c6e9578..97984d54a883cdab309454c8fb0d4564b47713fb 100644 (file)
@@ -16,9 +16,9 @@ struct scf_pack_info_s
        long             n_members;
 };
 
-int scf_pack       (void*  p,  scf_pack_info_t* infos, int n_infos,       uint8_t** pbuf, int* plen);
-int scf_unpack     (void** pp, scf_pack_info_t* infos, int n_infos, const uint8_t*  buf,  int  len);
-int scf_unpack_free(void*  p,  scf_pack_info_t* infos, int n_infos);
+long scf_pack       (void*  p,  scf_pack_info_t* infos, long n_infos,       uint8_t** pbuf, long* plen);
+long scf_unpack     (void** pp, scf_pack_info_t* infos, long n_infos, const uint8_t*  buf,  long  len);
+long scf_unpack_free(void*  p,  scf_pack_info_t* infos, long n_infos);
 
 #define SCF_PACK_DEF_VAR(type, var)    type  var
 #define SCF_PACK_DEF_VARS(type, vars)  long  n_##vars; type* vars
@@ -45,17 +45,19 @@ static scf_pack_info_t scf_pack_info_##type[] = {
 
 #define SCF_PACK_END(type) \
 }; \
-static int type##_pack(type* p, uint8_t** pbuf, int* plen) \
+static long type##_pack(type* p, uint8_t** pbuf, long* plen) \
 { \
        return scf_pack(p, scf_pack_info_##type, SCF_PACK_N_INFOS(type), pbuf, plen); \
 } \
-static int type##_unpack(type** pp, uint8_t* buf, int len) \
+static long type##_unpack(type** pp, uint8_t* buf, long len) \
 { \
        return scf_unpack((void**)pp, scf_pack_info_##type, SCF_PACK_N_INFOS(type), buf, len); \
 } \
-static int type##_free(type* p) \
+static long type##_free(type* p) \
 { \
        return scf_unpack_free(p, scf_pack_info_##type, SCF_PACK_N_INFOS(type)); \
 }
 
+long scf_pack_read(uint8_t** pbuf, const char* cpk);
+
 #endif
index cd251bf89978bb3e5331f6ba7e62167fd4846df4..c56a19f6fc82be9e7654ad8314c3288593569838 100644 (file)
@@ -12,34 +12,183 @@ static int component_pins[SCF_EDA_Components_NB] =
        SCF_EDA_Diode_NB,
        SCF_EDA_NPN_NB,
        SCF_EDA_PNP_NB,
+
+       SCF_EDA_NAND_NB,
+       SCF_EDA_NOR_NB,
+       SCF_EDA_NOT_NB,
 };
 
-static scf_edata_t  component_datas[] =
+static int __diode_path_off(ScfEpin* p0, ScfEpin* p1)
+{
+       if (SCF_EDA_Diode_NEG == p0->id)
+               return 1;
+       return 0;
+}
+
+static int __npn_path_off(ScfEpin* p0, ScfEpin* p1)
+{
+       if (SCF_EDA_NPN_E == p0->id)
+               return 1;
+
+       if (!p1 || SCF_EDA_NPN_E == p1->id)
+               return 0;
+       return 1;
+}
+
+static int __npn_shared(ScfEpin* p)
+{
+       if (SCF_EDA_NPN_E == p->id)
+               return 1;
+       return 0;
+}
+
+static int __pnp_path_off(ScfEpin* p0, ScfEpin* p1)
+{
+       if (SCF_EDA_PNP_E == p0->id)
+               return 0;
+       return 1;
+}
+
+static int __pnp_shared(ScfEpin* p)
+{
+       if (SCF_EDA_PNP_E == p->id)
+               return 1;
+       return 0;
+}
+
+static int __nand_path_off(ScfEpin* p0, ScfEpin* p1)
+{
+       if (SCF_EDA_NAND_NEG == p0->id)
+               return 1;
+
+       if (SCF_EDA_NAND_POS == p0->id) {
+               if (p1 && (SCF_EDA_NAND_IN0 == p1->id || SCF_EDA_NAND_IN1 == p1->id))
+                       return 1;
+
+       } else if (p1 && SCF_EDA_NAND_NEG != p1->id)
+               return 1;
+       return 0;
+}
+
+static int __nand_shared(ScfEpin* p)
+{
+       if (SCF_EDA_NAND_NEG == p->id || SCF_EDA_NAND_POS == p->id)
+               return 1;
+       return 0;
+}
+
+static int __nor_path_off(ScfEpin* p0, ScfEpin* p1)
 {
-       {SCF_EDA_None,       0,                   0, 0, 0,    0,   0,   0, 0},
-       {SCF_EDA_Battery,    0, SCF_EDA_Battery_POS, 0, 0, 1e-9, 1e9,   0, 0},
+       if (SCF_EDA_NOR_NEG == p0->id)
+               return 1;
 
-       {SCF_EDA_Resistor,   0,                   0, 0, 0,  1e4,   0,   0, 0},
-       {SCF_EDA_Capacitor,  0,                   0, 0, 0,   10, 0.1,   0, 0},
-       {SCF_EDA_Inductor,   0,                   0, 0, 0,   10,   0, 1e3, 0},
+       if (SCF_EDA_NOR_POS == p0->id) {
+               if (p1 && (SCF_EDA_NOR_IN0 == p1->id || SCF_EDA_NOR_IN1 == p1->id))
+                       return 1;
+
+       } else if (p1 && SCF_EDA_NOR_NEG != p1->id)
+               return 1;
+       return 0;
+}
+
+static int __nor_shared(ScfEpin* p)
+{
+       if (SCF_EDA_NOR_NEG == p->id || SCF_EDA_NOR_POS == p->id)
+               return 1;
+       return 0;
+}
+
+static int __not_path_off(ScfEpin* p0, ScfEpin* p1)
+{
+       if (SCF_EDA_NOT_NEG == p0->id)
+               return 1;
+
+       if (SCF_EDA_NOT_POS == p0->id) {
+               if (p1 && SCF_EDA_NOT_IN == p1->id)
+                       return 1;
+
+       } else if (p1 && SCF_EDA_NOT_NEG != p1->id)
+               return 1;
+       return 0;
+}
+
+static int __not_shared(ScfEpin* p)
+{
+       if (SCF_EDA_NOT_NEG == p->id || SCF_EDA_NOT_POS == p->id)
+               return 1;
+       return 0;
+}
+
+static ScfEops __diode_ops =
+{
+       __diode_path_off,
+       NULL,
 };
 
-static scf_edata_t  pin_datas[] =
+static ScfEops __npn_ops =
 {
-       {SCF_EDA_None,       0,                   0, 0, 0,    0,   0,   0, 0},
+       __npn_path_off,
+       __npn_shared,
+};
 
-       {SCF_EDA_Diode,      0,   SCF_EDA_Diode_NEG, 0, 0,  750,   0,   0, 0},
+static ScfEops __pnp_ops =
+{
+       __pnp_path_off,
+       __pnp_shared,
+};
 
-       {SCF_EDA_NPN,        0,       SCF_EDA_NPN_B, 0, 0,  750,   0,   0, 0},
-       {SCF_EDA_NPN,        0,       SCF_EDA_NPN_C, 0, 0,    3,   0,   0, 250},
+static ScfEops __nand_ops =
+{
+       __nand_path_off,
+       __nand_shared,
+};
 
-       {SCF_EDA_PNP,        0,       SCF_EDA_PNP_B, 0, 0,  750,   0,   0, 0},
-       {SCF_EDA_PNP,        0,       SCF_EDA_PNP_C, 0, 0,    3,   0,   0, 250},
+static ScfEops __nor_ops =
+{
+       __nor_path_off,
+       __nor_shared,
 };
 
-static scf_edata_t* _pin_find_data(const uint64_t type, const uint64_t model, const uint64_t pid)
+static ScfEops __not_ops =
 {
-       scf_edata_t* ed;
+       __not_path_off,
+       __not_shared,
+};
+
+static ScfEdata  component_datas[] =
+{
+       {SCF_EDA_None,       0,                   0, 0, 0,    0,   0,   0, 0, NULL, NULL},
+       {SCF_EDA_Battery,    0, SCF_EDA_Battery_POS, 0, 0, 1e-9, 1e9,   0, 0, NULL, NULL},
+
+       {SCF_EDA_Resistor,   0,                   0, 0, 0,  1e4,   0,   0, 0, NULL, NULL},
+       {SCF_EDA_Capacitor,  0,                   0, 0, 0,   10, 0.1,   0, 0, NULL, NULL},
+       {SCF_EDA_Inductor,   0,                   0, 0, 0,   10,   0, 1e3, 0, NULL, NULL},
+
+       {SCF_EDA_Diode,      0,                   0, 0, 0,    0,   0,   0, 0, &__diode_ops, NULL},
+       {SCF_EDA_NPN,        0,                   0, 0, 0,    0,   0,   0, 0, &__npn_ops,   NULL},
+       {SCF_EDA_PNP,        0,                   0, 0, 0,    0,   0,   0, 0, &__pnp_ops,   NULL},
+
+       {SCF_EDA_NAND,       0,                   0, 0, 0,    0,   0,   0, 0, &__nand_ops,  "./cpk/nand.cpk"},
+       {SCF_EDA_NOR,        0,                   0, 0, 0,    0,   0,   0, 0, &__nor_ops,   "./cpk/nor.cpk"},
+       {SCF_EDA_NOT,        0,                   0, 0, 0,    0,   0,   0, 0, &__not_ops,   "./cpk/not.cpk"},
+};
+
+static ScfEdata  pin_datas[] =
+{
+       {SCF_EDA_None,       0,                   0, 0, 0,    0,   0,   0,   0, NULL, NULL},
+
+       {SCF_EDA_Diode,      0,   SCF_EDA_Diode_NEG, 0, 0,  750,   0,   0,   0, NULL, NULL},
+
+       {SCF_EDA_NPN,        0,       SCF_EDA_NPN_B, 0, 0,  750,   0,   0,   0, NULL, NULL},
+       {SCF_EDA_NPN,        0,       SCF_EDA_NPN_C, 0, 0,    3,   0,   0, 250, NULL, NULL},
+
+       {SCF_EDA_PNP,        0,       SCF_EDA_PNP_B, 0, 0,  750,   0,   0,   0, NULL, NULL},
+       {SCF_EDA_PNP,        0,       SCF_EDA_PNP_C, 0, 0,    3,   0,   0, 250, NULL, NULL},
+};
+
+static ScfEdata* _pin_find_data(const uint64_t type, const uint64_t model, const uint64_t pid)
+{
+       ScfEdata* ed;
 
        int i;
        for (i = 0; i < sizeof(pin_datas) / sizeof(pin_datas[0]); i++) {
@@ -52,9 +201,9 @@ static scf_edata_t* _pin_find_data(const uint64_t type, const uint64_t model, co
        return NULL;
 }
 
-static scf_edata_t* _component_find_data(const uint64_t type, const uint64_t model)
+ScfEdata* scf_ecomponent__find_data(const uint64_t type, const uint64_t model)
 {
-       scf_edata_t* ed;
+       ScfEdata* ed;
 
        int i;
        for (i = 0; i < sizeof(component_datas) / sizeof(component_datas[0]); i++) {
@@ -342,7 +491,7 @@ int scf_epin__del_component(ScfEpin* pin, uint64_t cid, uint64_t pid)
 ScfEcomponent* scf_ecomponent__alloc(uint64_t type)
 {
        ScfEcomponent* c;
-       scf_edata_t*      ed;
+       ScfEdata*      ed;
 
        if (type >= SCF_EDA_Components_NB)
                return NULL;
@@ -353,13 +502,24 @@ ScfEcomponent* scf_ecomponent__alloc(uint64_t type)
 
        c->type = type;
 
-       ed = _component_find_data(c->type, c->model);
+       ed = scf_ecomponent__find_data(c->type, c->model);
        if (ed) {
-               c->v  = ed->v;
-               c->a  = ed->a;
-               c->r  = ed->r;
-               c->uf = ed->uf;
-               c->uh = ed->uh;
+               c->v   = ed->v;
+               c->a   = ed->a;
+               c->r   = ed->r;
+               c->uf  = ed->uf;
+               c->uh  = ed->uh;
+               c->ops = ed->ops;
+
+               if (ed->cpk) {
+                       c->n_cpk = strlen(ed->cpk) + 1;
+
+                       c->cpk = strdup(ed->cpk);
+                       if (!c->cpk) {
+                               ScfEcomponent_free(c);
+                               return NULL;
+                       }
+               }
        }
 
        int i;
index cf2a246d8e8efaa52cc58a3b22563fb163eee763..2f094ab32ecfe52242fe1dda23baec17f110b5dc 100644 (file)
@@ -15,6 +15,10 @@ enum {
        SCF_EDA_NPN,
        SCF_EDA_PNP,
 
+       SCF_EDA_NAND,
+       SCF_EDA_NOR,
+       SCF_EDA_NOT,
+
        SCF_EDA_Components_NB,
 };
 
@@ -74,6 +78,38 @@ enum {
        SCF_EDA_PNP_NB = SCF_EDA_NPN_NB,
 };
 
+enum {
+       SCF_EDA_NAND_NEG,
+       SCF_EDA_NAND_POS,
+
+       SCF_EDA_NAND_IN0,
+       SCF_EDA_NAND_IN1,
+       SCF_EDA_NAND_OUT,
+
+       SCF_EDA_NAND_NB,
+};
+
+enum {
+       SCF_EDA_NOR_NEG,
+       SCF_EDA_NOR_POS,
+
+       SCF_EDA_NOR_IN0,
+       SCF_EDA_NOR_IN1,
+       SCF_EDA_NOR_OUT,
+
+       SCF_EDA_NOR_NB,
+};
+
+enum {
+       SCF_EDA_NOT_NEG,
+       SCF_EDA_NOT_POS,
+
+       SCF_EDA_NOT_IN,
+       SCF_EDA_NOT_OUT,
+
+       SCF_EDA_NOT_NB,
+};
+
 typedef struct {
        uint64_t  type;
        uint64_t  model;
@@ -86,7 +122,10 @@ typedef struct {
        double    uf;
        double    uh;
        double    hfe;
-} scf_edata_t;
+
+       void*     ops;
+       char*     cpk;
+} ScfEdata;
 
 typedef struct {
        SCF_PACK_DEF_VAR(int, x0);
@@ -102,11 +141,18 @@ SCF_PACK_INFO_VAR(ScfLine, x1),
 SCF_PACK_INFO_VAR(ScfLine, y1),
 SCF_PACK_END(ScfLine)
 
+typedef struct scf_eops_s        ScfEops;
 typedef struct scf_epin_s        ScfEpin;
 typedef struct scf_ecomponent_s  ScfEcomponent;
 typedef struct scf_efunction_s   ScfEfunction;
 typedef struct scf_eboard_s      ScfEboard;
 
+struct scf_eops_s
+{
+       int (*off   )(ScfEpin* p0, ScfEpin* p1);
+       int (*shared)(ScfEpin* p);
+};
+
 struct scf_epin_s
 {
        SCF_PACK_DEF_VAR(uint64_t, id);
@@ -116,6 +162,8 @@ struct scf_epin_s
        SCF_PACK_DEF_VARS(uint64_t, tos);
        SCF_PACK_DEF_VAR(uint64_t, c_lid);
 
+       SCF_PACK_DEF_OBJ(ScfEcomponent, IC);
+
        SCF_PACK_DEF_VAR(double, v);
        SCF_PACK_DEF_VAR(double, a);
 
@@ -229,6 +277,10 @@ struct scf_ecomponent_s
        SCF_PACK_DEF_VAR(uint64_t, model);
        SCF_PACK_DEF_OBJS(ScfEpin, pins);
 
+       SCF_PACK_DEF_VARS(uint8_t, cpk);
+       SCF_PACK_DEF_OBJ(ScfEfunction, f);
+       SCF_PACK_DEF_OBJ(ScfEops,      ops);
+
        SCF_PACK_DEF_VAR(double, v);
        SCF_PACK_DEF_VAR(double, a);
 
@@ -238,6 +290,7 @@ struct scf_ecomponent_s
        SCF_PACK_DEF_VAR(double, uf);
        SCF_PACK_DEF_VAR(double, uh);
 
+
        SCF_PACK_DEF_VAR(int64_t, count);
        SCF_PACK_DEF_VAR(int64_t, color);
        SCF_PACK_DEF_VAR(int, status);
@@ -255,6 +308,8 @@ SCF_PACK_INFO_VAR(ScfEcomponent, type),
 SCF_PACK_INFO_VAR(ScfEcomponent, model),
 SCF_PACK_INFO_OBJS(ScfEcomponent, pins, ScfEpin),
 
+SCF_PACK_INFO_VARS(ScfEcomponent, cpk, uint8_t),
+
 SCF_PACK_INFO_VAR(ScfEcomponent, v),
 SCF_PACK_INFO_VAR(ScfEcomponent, a),
 
@@ -327,11 +382,11 @@ int            scf_epin__del_component(ScfEpin* pin, uint64_t cid, uint64_t pid)
 ScfEcomponent* scf_ecomponent__alloc  (uint64_t type);
 int            scf_ecomponent__add_pin(ScfEcomponent* c, ScfEpin* pin);
 int            scf_ecomponent__del_pin(ScfEcomponent* c, ScfEpin* pin);
+ScfEdata*      scf_ecomponent__find_data(const uint64_t type, const uint64_t model);
 
 ScfEfunction*  scf_efunction__alloc        (const   char* name);
 int            scf_efunction__add_component(ScfEfunction* f, ScfEcomponent* c);
 int            scf_efunction__del_component(ScfEfunction* f, ScfEcomponent* c);
-
 int            scf_efunction__add_eline    (ScfEfunction* f, ScfEline* el);
 int            scf_efunction__del_eline    (ScfEfunction* f, ScfEline* el);
 
index 94724c06e93ca8a1d0e9a650ee5bd128fedbc32c..0a3cd520702c2991eff08e48be2e68e3213c7f1e 100644 (file)
@@ -118,6 +118,8 @@ struct ses_edge_s
        int            index;
 
        uint8_t        bflag:1;
+
+       uint8_t        amplify_flag:1;
 };
 
 struct ses_node_s
index b9d3542f1e151599e87a23e226ef6c622c6570ef..d64d5bbe5d241ce393e5a50b57b525ae4db30221 100644 (file)
@@ -710,7 +710,7 @@ static int __ses_layout_lines(ScfEfunction* f, int d)
        ScfEline* el;
        ScfLine*  l;
 
-       size_t i;
+       long i;
 
        int ret = __ses_layout_lines2(f);
        if (ret < 0)
@@ -748,10 +748,10 @@ static void __ses_layout_components(ScfEfunction* f, int d)
        ScfEpin*       p0;
        ScfEpin*       p1;
 
-       size_t i;
-       size_t j;
-       size_t m;
-       size_t n;
+       long i;
+       long j;
+       long m;
+       long n;
 
        for (i = 0; i < f->n_elines - 1; i++) {
                el0       = f->elines[i];
@@ -829,12 +829,12 @@ static void __ses_xchg_components(ScfEfunction* f, int d)
        ScfEpin*       p2;
        ScfEpin*       p3;
 
-       size_t    i;
-       size_t    j;
-       size_t    k;
-       size_t    m;
-       size_t    n;
-       size_t    q;
+       long i;
+       long j;
+       long k;
+       long m;
+       long n;
+       long q;
 
        for (i = 0; i < f->n_elines; i++) {
                el        = f->elines[i];
@@ -906,32 +906,6 @@ static void __ses_xchg_components(ScfEfunction* f, int d)
        }
 }
 
-static inline void __ses_flip_neg(ScfEcomponent* c)
-{
-       ScfEpin* p;
-       size_t   i;
-
-       for (i = 0; i < c->n_pins; i++) {
-               p  =        c->pins[i];
-
-               if (p->x > 0)
-                       p->x = -p->x;
-       }
-}
-
-static inline void __ses_flip_pos(ScfEcomponent* c)
-{
-       ScfEpin* p;
-       size_t   i;
-
-       for (i = 0; i < c->n_pins; i++) {
-               p  =        c->pins[i];
-
-               if (p->x < 0)
-                       p->x = -p->x;
-       }
-}
-
 static int __ses_get_crosses(ScfEfunction* f, int d, scf_vector_t* crosses)
 {
        ses_vertex_t*  edge0;
@@ -944,12 +918,12 @@ static int __ses_get_crosses(ScfEfunction* f, int d, scf_vector_t* crosses)
        ScfEpin*       p2;
        ScfEpin*       p3;
 
-       size_t i;
-       size_t j;
-       size_t k;
-       size_t m;
-       size_t n;
-       size_t q;
+       long i;
+       long j;
+       long k;
+       long m;
+       long n;
+       long q;
 
        for (i = 0; i < f->n_components - 1; i++) {
                c0 =        f->components[i];
@@ -1216,9 +1190,10 @@ static void __ses_set_xy(ScfEfunction* f, int d)
        ScfEcomponent* c;
        ScfEpin*       p0;
        ScfEpin*       p1;
+       ScfEpin*       p2;
 
-       size_t i;
-       size_t j;
+       long i;
+       long j;
 
        for (i = 0; i < f->n_components; i++) {
                c  =        f->components[i];
@@ -1236,14 +1211,56 @@ static void __ses_set_xy(ScfEfunction* f, int d)
                        continue;
                }
 
-               for (j = 1; j < c->n_pins; j++) {
-                       p0 =        c->pins[j];
+               int n = 0;
+               if (c->color > 0)
+                       n = (c->color - 1) % 2;
+
+               switch (c->type) {
+                       case SCF_EDA_NPN:
+                       case SCF_EDA_PNP:
+                               p0    = c->pins[SCF_EDA_NPN_C];
+                               p1    = c->pins[SCF_EDA_NPN_E];
 
-                       if (j & 0x1)
-                               p0->x = c->x - d / 3;
-                       else
                                p0->x = c->x + d / 3;
-               }
+                               p1->x = c->x - d / 3;
+                               break;
+
+                       case SCF_EDA_NAND:
+                       case SCF_EDA_NOR:
+                               p1->x = c->x;
+
+                               p0 = c->pins[SCF_EDA_NAND_IN0];
+                               p1 = c->pins[SCF_EDA_NAND_IN1];
+                               p2 = c->pins[SCF_EDA_NAND_OUT];
+
+                               if (0 == n) {
+                                       p0->x = c->x + 36;
+                                       p1->x = c->x + 36;
+                                       p2->x = c->x - 36;
+                               } else {
+                                       p0->x = c->x - 36;
+                                       p1->x = c->x - 36;
+                                       p2->x = c->x + 36;
+                               }
+                               break;
+
+                       case SCF_EDA_NOT:
+                               p1->x = c->x;
+
+                               p0 = c->pins[SCF_EDA_NOT_IN];
+                               p1 = c->pins[SCF_EDA_NOT_OUT];
+
+                               if (c->x < p1->x) {
+                                       p0->x = c->x - 36;
+                                       p1->x = c->x + 36;
+                               } else {
+                                       p0->x = c->x + 36;
+                                       p1->x = c->x - 36;
+                               }
+                               break;
+                       default:
+                               break;
+               };
        }
 }
 
@@ -1436,6 +1453,19 @@ static void __ses_min_cx(ScfEfunction* f, int d)
                if (c->color > 0)
                        m0 = (c->color - 1) / 2;
 
+               int y0 = INT_MAX;
+               int y1 = 0;
+
+               for (k = 0; k < c->n_pins; k++) {
+                       p  =        c->pins[k];
+
+                       if (y0 > p->y)
+                               y0 = p->y;
+
+                       if (y1 < p->y)
+                               y1 = p->y;
+               }
+
                for (j = i - 1; j >= 0; j--) {
                        c2 = f->components[j];
 
@@ -1454,32 +1484,42 @@ static void __ses_min_cx(ScfEfunction* f, int d)
                                        p2 =        c2->pins[m];
 
                                        if (p->y == p2->y) {
-                                               if ((c->y >= p->y && c2->y >= p->y) || (c->y <= p->y && c2->y <= p->y)) {
+                                               if ((c->y >= p->y && c2->y >= p->y) || (c->y <= p->y && c2->y <= p->y))
+                                                       goto _max;
 
-                                                       if (max < c2->x) {
-                                                               max = c2->x;
-                                                               scf_logd("c%ld->x: %d, c%ld->x: %d\n", c->id, c->x, c2->id, c2->x);
-                                                       }
-                                               }
-                                       } else if (p->y > p2->y) {
-                                               if ((c->y < p->y && c2->y > c->y) || (c->y >= p->y && c2->y > p->y)) {
-                                                       if (max < c2->x)
-                                                               max = c2->x;
-                                               }
-                                       } else {
-                                               if ((c->y < p->y && c2->y < p->y) || (c->y >= p->y && c2->y < c->y)) {
-                                                       if (max < c2->x)
-                                                               max = c2->x;
-                                               }
+                                               scf_logd("c%ld->x: %d, c%ld->x: %d\n", c->id, c->x, c2->id, c2->x);
+                                               goto _next;
                                        }
                                }
                        }
+
+                       int y2 = INT_MAX;
+                       int y3 = 0;
+
+                       for (m = 0; m < c2->n_pins; m++) {
+                               p2 =        c2->pins[m];
+
+                               if (y2 > p2->y)
+                                       y2 = p2->y;
+
+                               if (y3 < p2->y)
+                                       y3 = p2->y;
+                       }
+
+                       if (!(y1 <= y2 || y0 >= y3))
+                               goto _max;
+_next:
+                       continue;
+_max:
+                       if (max < c2->x)
+                               max = c2->x;
                }
 
                if (0 == max)
                        continue;
+
                c->x = max + d;
-_set_px:
+
                for (k = 0; k < c->n_pins; k++) {
                        p         = c->pins[k];
                        p->x     += c->x - tmp;
@@ -1493,13 +1533,20 @@ _set_px:
                c2 =        f->components[i - 1];
 
                int tmp = c->x;
+               if (tmp - c2->x > d) {
 
-               if (c->x - c2->x > d) {
-                       c->x = c2->x + d;
+                       for (j = i; j < f->n_components; j++) {
+                               c  =        f->components[j];
 
-                       for (k = 0; k < c->n_pins; k++) {
-                               p         = c->pins[k];
-                               p->x     += c->x - tmp;
+                               if (c->x > tmp)
+                                       break;
+
+                               c->x = c2->x + d;
+
+                               for (k = 0; k < c->n_pins; k++) {
+                                       p         = c->pins[k];
+                                       p->x     += c->x - tmp;
+                               }
                        }
                }
        }
index 8516e65ecd98e70315536897370217ac344c8145..3893ccf04e287b945bd69310ff156a0c0d4cfe42 100644 (file)
@@ -332,7 +332,7 @@ static void ses_AbX_print(double* A, double* b, double* X, int N)
 {
        int i;
        int j;
-
+#if 0
        printf("A:\n");
        for (i = 0; i < N; i++) {
                for (j = 0; j < N; j++)
@@ -343,7 +343,7 @@ static void ses_AbX_print(double* A, double* b, double* X, int N)
        printf("\nb:\n");
        for (j = 0; j < N; j++)
                printf("%lg\n", b[j]);
-
+#endif
        printf("\nX:\n");
        for (j = 0; j < N; j++)
                printf("%lg\n", X[j]);
@@ -511,9 +511,9 @@ static int __ses_edges_update_Ab(ScfEfunction* f, scf_vector_t* edges, double* A
                        double Rb = SCF_EDA_V_NPN_ON / Ib;
 
                        if (-1e8 < Rb && Rb < 1e8) {
-                               if (dV < SCF_EDA_V_NPN_ON * 0.995 || dV > SCF_EDA_V_NPN_ON * 1.005) {
+                               if (dV < SCF_EDA_V_NPN_ON * 0.99 || dV > SCF_EDA_V_NPN_ON * 1.01) {
 
-                                       scf_logd("edge: [%d] c%ldp%ld-c%ldp%ld, Vb: %lg, Ve: %lg, dV: %lg, Ib: %lg, Rb: %lg\n",
+                                       scf_logi("edge: [%d] c%ldp%ld-c%ldp%ld, Vb: %lg, Ve: %lg, dV: %lg, Ib: %lg, Rb: %lg\n",
                                                        edge->index, p0->cid, p0->id, p1->cid, p1->id, Vb, Ve, dV, Ib, Rb);
 
                                        A[(n + edge->index) * N + n + edge->index] = -Rb;
@@ -524,7 +524,7 @@ static int __ses_edges_update_Ab(ScfEfunction* f, scf_vector_t* edges, double* A
                                c->lock   = 1;
                                (*n_offs)++;
 
-                               scf_logd("\033[34mc%ld, status: %d, dV: %lg, Ib: %lg, Rb: %lg, edge->index: %d\033[0m\n", c->id, c->status, dV, Ib, Rb, edge->index);
+                               scf_logi("\033[34mc%ld, status: %d, dV: %lg, Ib: %lg, Rb: %lg, edge->index: %d\033[0m\n", c->id, c->status, dV, Ib, Rb, edge->index);
                        }
 
                } else if (edge->edge_b) {
@@ -533,18 +533,40 @@ static int __ses_edges_update_Ab(ScfEfunction* f, scf_vector_t* edges, double* A
 
                        double dI = Ib * edge->hfe - Ic;
 
-                       if (dI < -1e-10) {
-                               scf_logd("edge: [%d] c%ldp%ld-c%ldp%ld [b%d], Ic: %lg, Ib: %lg, dI: %lg\n",
-                                               edge->index, p0->cid, p0->id, p1->cid, p1->id, edge->edge_b->index, Ic, Ib, dI);
+                       double Vb;
+                       double Ve;
 
-                               for (i = 0; i < N; i++)
-                                       A[(n + edge->index) * N + i] = 0;
+                       if (edge->edge_b->node1 && edge->edge_b->node1->lid != Bp->lid)
+                               Vb = X[edge->edge_b->node1->index];
+                       else
+                               Vb = Bp->v;
 
-                               A[(n + edge->index) * N + n + edge->index]         = -1;
-                               A[(n + edge->index) * N + n + edge->edge_b->index] = edge->hfe;
-                               b[ n + edge->index] = 0;
+                       if (edge->edge_b->node0 && edge->edge_b->node0->lid != Bn->lid)
+                               Ve = X[edge->edge_b->node0->index];
+                       else
+                               Ve = Bn->v;
 
-                               k++;
+                       double dV = Vb - Ve;
+                       double Rb = SCF_EDA_V_NPN_ON / Ib;
+
+                       if (dI < -1e-10
+                                       && -1e8 < Rb && Rb < 1e8) {
+
+                               if (!edge->amplify_flag) {
+                                       edge->amplify_flag = 1;
+
+                                       scf_logi("edge: [%d] c%ldp%ld-c%ldp%ld [b%d], Ic: %lg, Ib: %lg, dI: %lg, dVbe: %lg, Rb: %lg\n",
+                                                       edge->index, p0->cid, p0->id, p1->cid, p1->id, edge->edge_b->index, Ic, Ib, dI, dV, Rb);
+
+                                       for (i = 0; i < N; i++)
+                                               A[(n + edge->index) * N + i] = 0;
+
+                                       A[(n + edge->index) * N + n + edge->index]         = -1;
+                                       A[(n + edge->index) * N + n + edge->edge_b->index] = edge->hfe;
+                                       b[ n + edge->index] = 0;
+
+                                       k++;
+                               }
                        }
                }
        }
@@ -610,6 +632,7 @@ static int __ses_nodes_path_solve2(ScfEfunction* f, ses_path_t* path, int vip_m,
 
        int n_offs = 0;
 
+#define MAX_TRYS 100
        int try = 0;
        do {
                n_offs = 0;
@@ -624,9 +647,12 @@ static int __ses_nodes_path_solve2(ScfEfunction* f, ses_path_t* path, int vip_m,
                ret = __ses_edges_update_Ab(f, edges, A, b, X, N, &n_offs);
                try++;
 
-       } while (ret > 0 && try < 100);
+               scf_logi("ret: %d, try: %d\n\n", ret, try);
+
+       } while (ret > 0 && try < MAX_TRYS);
 
-       scf_logi("ret: %d, try: %d\n\n", ret, try);
+       if (try >= MAX_TRYS)
+               return -1;
 
        for (i = 0; i < n; i++) {
                node  = nodes->data[i];
similarity index 67%
rename from ses_step_simplify.c
rename to ses_step_draw.c
index e3a2ccea4e80bbea9b7a56c881a5ec75a24e92e3..b26587922752140b3390a91923cb3463730b8bc6 100644 (file)
@@ -65,6 +65,8 @@ void __ses_function_draw(ScfEfunction* f, cairo_t* cr)
 {
        ScfEcomponent*   c;
        ScfEpin*         p;
+       ScfEpin*         p0;
+       ScfEpin*         p1;
        ScfEpin*         pb;
        ScfEpin*         pc;
        ScfEpin*         pe;
@@ -83,7 +85,7 @@ void __ses_function_draw(ScfEfunction* f, cairo_t* cr)
                cairo_set_source_rgb  (cr, 0, 0, 0);
                cairo_select_font_face(cr, "Calibri", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
                cairo_set_font_size   (cr, 20);
-               cairo_move_to         (cr, c->x - 10 - n * 10, c->y - 5);
+               cairo_move_to         (cr, c->x - 10 - n * 10, c->y - 12);
                cairo_show_text       (cr, text);
                cairo_stroke(cr);
 
@@ -471,13 +473,291 @@ void __ses_function_draw(ScfEfunction* f, cairo_t* cr)
                                        ses_text_a(cr, c->x, c->y - 20, pe->a);
                                cairo_stroke(cr);
                                break;
+
+                       case SCF_EDA_NAND:
+                               p  = c->pins[SCF_EDA_NAND_OUT];
+                               p0 = c->pins[SCF_EDA_NAND_IN0];
+                               p1 = c->pins[SCF_EDA_NAND_IN1];
+
+                               if (c->x < p->x) {
+                                       cairo_move_to(cr, p->x, p->y);
+                                       cairo_line_to(cr, c->x + 32, c->y);
+                                       cairo_line_to(cr, c->x + 24, c->y);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x + 20, c->y, 4, 0, 2 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x + 6, c->y, 10, -0.5 * M_PI, 0.5 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_move_to(cr, c->x + 6, c->y + 10);
+                                       cairo_line_to(cr, c->x - 6, c->y + 10);
+                                       cairo_line_to(cr, c->x - 6, c->y - 10);
+                                       cairo_line_to(cr, c->x + 6, c->y - 10);
+
+                                       if (p0->y < p1->y) {
+                                               cairo_move_to(cr, c->x -  6, c->y - 5);
+                                               cairo_line_to(cr, c->x - 14, c->y - 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+
+                                               cairo_move_to(cr, c->x -  6, c->y + 5);
+                                               cairo_line_to(cr, c->x - 14, c->y + 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+                                       } else {
+                                               cairo_move_to(cr, c->x -  6, c->y - 5);
+                                               cairo_line_to(cr, c->x - 14, c->y - 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+
+                                               cairo_move_to(cr, c->x -  6, c->y + 5);
+                                               cairo_line_to(cr, c->x - 14, c->y + 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+                                       }
+
+                               } else {
+                                       cairo_move_to(cr, p->x, p->y);
+                                       cairo_line_to(cr, c->x - 32, c->y);
+                                       cairo_line_to(cr, c->x - 24, c->y);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x - 20, c->y, 4, 0, 2 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x - 6, c->y, 10, 0.5 * M_PI, 1.5 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_move_to(cr, c->x - 6, c->y + 10);
+                                       cairo_line_to(cr, c->x + 6, c->y + 10);
+                                       cairo_line_to(cr, c->x + 6, c->y - 10);
+                                       cairo_line_to(cr, c->x - 6, c->y - 10);
+
+                                       if (p0->y < p1->y) {
+                                               cairo_move_to(cr, c->x +  6, c->y - 5);
+                                               cairo_line_to(cr, c->x + 14, c->y - 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+
+                                               cairo_move_to(cr, c->x +  6, c->y + 5);
+                                               cairo_line_to(cr, c->x + 14, c->y + 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+                                       } else {
+                                               cairo_move_to(cr, c->x +  6, c->y - 5);
+                                               cairo_line_to(cr, c->x + 14, c->y - 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+
+                                               cairo_move_to(cr, c->x +  6, c->y + 5);
+                                               cairo_line_to(cr, c->x + 14, c->y + 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+                                       }
+                               }
+                               cairo_stroke(cr);
+
+                               p = c->pins[SCF_EDA_NAND_POS];
+                               if (p->y < c->y) {
+                                       cairo_move_to(cr, c->x, c->y - 10);
+                                       cairo_line_to(cr, p->x, p->y);
+
+                                       p = c->pins[SCF_EDA_NAND_NEG];
+                                       cairo_move_to(cr, c->x, c->y + 10);
+                                       cairo_line_to(cr, p->x, p->y);
+                               } else {
+                                       cairo_move_to(cr, c->x, c->y + 10);
+                                       cairo_line_to(cr, p->x, p->y);
+
+                                       p = c->pins[SCF_EDA_NAND_NEG];
+                                       cairo_move_to(cr, c->x, c->y - 10);
+                                       cairo_line_to(cr, p->x, p->y);
+                               }
+
+                               cairo_stroke(cr);
+                               break;
+
+                       case SCF_EDA_NOR:
+                               p  = c->pins[SCF_EDA_NOR_OUT];
+                               p0 = c->pins[SCF_EDA_NOR_IN0];
+                               p1 = c->pins[SCF_EDA_NOR_IN1];
+
+                               if (c->x < p->x) {
+                                       cairo_move_to(cr, p->x, p->y);
+                                       cairo_line_to(cr, c->x + 32, c->y);
+                                       cairo_line_to(cr, c->x + 24, c->y);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x + 20, c->y, 4, 0, 2 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_save(cr);
+                                       cairo_translate(cr, c->x, c->y);
+                                       cairo_scale(cr, 1.6, 1.0);
+                                       cairo_arc  (cr, 0, 0, 10, -0.5 * M_PI, 0.5 * M_PI);
+                                       cairo_restore(cr);
+                                       cairo_stroke(cr);
+
+                                       cairo_save(cr);
+                                       cairo_translate(cr, c->x - 6, c->y);
+                                       cairo_scale(cr, 0.6, 1.0);
+                                       cairo_arc  (cr, 0, 0, 10, -0.5 * M_PI, 0.5 * M_PI);
+                                       cairo_restore(cr);
+                                       cairo_stroke(cr);
+
+                                       cairo_move_to(cr, c->x,     c->y + 10);
+                                       cairo_line_to(cr, c->x - 6, c->y + 10);
+                                       cairo_move_to(cr, c->x - 6, c->y - 10);
+                                       cairo_line_to(cr, c->x,     c->y - 10);
+
+                                       if (p0->y < p1->y) {
+                                               cairo_move_to(cr, c->x -  2, c->y - 5);
+                                               cairo_line_to(cr, c->x - 10, c->y - 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+
+                                               cairo_move_to(cr, c->x -  2, c->y + 5);
+                                               cairo_line_to(cr, c->x - 10, c->y + 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+                                       } else {
+                                               cairo_move_to(cr, c->x -  2, c->y - 5);
+                                               cairo_line_to(cr, c->x - 10, c->y - 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+
+                                               cairo_move_to(cr, c->x -  2, c->y + 5);
+                                               cairo_line_to(cr, c->x - 10, c->y + 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+                                       }
+
+                               } else {
+                                       cairo_move_to(cr, p->x, p->y);
+                                       cairo_line_to(cr, c->x - 32, c->y);
+                                       cairo_line_to(cr, c->x - 24, c->y);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x - 20, c->y, 4, 0, 2 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_save(cr);
+                                       cairo_translate(cr, c->x, c->y);
+                                       cairo_scale(cr, 1.6, 1.0);
+                                       cairo_arc  (cr, 0, 0, 10, 0.5 * M_PI, 1.5 * M_PI);
+                                       cairo_restore(cr);
+                                       cairo_stroke(cr);
+
+                                       cairo_save(cr);
+                                       cairo_translate(cr, c->x + 6, c->y);
+                                       cairo_scale(cr, 0.6, 1.0);
+                                       cairo_arc  (cr, 0, 0, 10, 0.5 * M_PI, 1.5 * M_PI);
+                                       cairo_restore(cr);
+                                       cairo_stroke(cr);
+
+                                       cairo_move_to(cr, c->x,     c->y + 10);
+                                       cairo_line_to(cr, c->x + 6, c->y + 10);
+                                       cairo_move_to(cr, c->x + 6, c->y - 10);
+                                       cairo_line_to(cr, c->x,     c->y - 10);
+
+                                       if (p0->y < p1->y) {
+                                               cairo_move_to(cr, c->x +  2, c->y - 5);
+                                               cairo_line_to(cr, c->x + 10, c->y - 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+
+                                               cairo_move_to(cr, c->x +  2, c->y + 5);
+                                               cairo_line_to(cr, c->x + 10, c->y + 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+                                       } else {
+                                               cairo_move_to(cr, c->x +  2, c->y - 5);
+                                               cairo_line_to(cr, c->x + 10, c->y - 5);
+                                               cairo_line_to(cr, p1->x,     p1->y);
+
+                                               cairo_move_to(cr, c->x +  2, c->y + 5);
+                                               cairo_line_to(cr, c->x + 10, c->y + 5);
+                                               cairo_line_to(cr, p0->x,     p0->y);
+                                       }
+                               }
+                               cairo_stroke(cr);
+
+                               p = c->pins[SCF_EDA_NOR_POS];
+                               if (p->y < c->y) {
+                                       cairo_move_to(cr, c->x, c->y - 10);
+                                       cairo_line_to(cr, p->x, p->y);
+
+                                       p = c->pins[SCF_EDA_NOR_NEG];
+                                       cairo_move_to(cr, c->x, c->y + 10);
+                                       cairo_line_to(cr, p->x, p->y);
+                               } else {
+                                       cairo_move_to(cr, c->x, c->y + 10);
+                                       cairo_line_to(cr, p->x, p->y);
+
+                                       p = c->pins[SCF_EDA_NOR_NEG];
+                                       cairo_move_to(cr, c->x, c->y - 10);
+                                       cairo_line_to(cr, p->x, p->y);
+                               }
+
+                               cairo_stroke(cr);
+                               break;
+
+                       case SCF_EDA_NOT:
+                               p = c->pins[SCF_EDA_NOT_OUT];
+
+                               if (c->x < p->x) {
+                                       cairo_move_to(cr, p->x, p->y);
+                                       cairo_line_to(cr, c->x + 32, c->y);
+                                       cairo_line_to(cr, c->x + 24, c->y);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x + 20, c->y, 4, 0, 2 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_move_to(cr, c->x + 16, c->y);
+                                       cairo_line_to(cr, c->x - 16, c->y + 10);
+                                       cairo_line_to(cr, c->x - 16, c->y - 10);
+                                       cairo_line_to(cr, c->x + 16, c->y);
+
+                                       p = c->pins[SCF_EDA_NOT_IN];
+                                       cairo_move_to(cr, c->x - 16, c->y);
+                                       cairo_line_to(cr, c->x - 24, c->y);
+                                       cairo_line_to(cr, p->x,      p->y);
+                               } else {
+                                       cairo_move_to(cr, p->x, p->y);
+                                       cairo_line_to(cr, c->x - 32, c->y);
+                                       cairo_line_to(cr, c->x - 24, c->y);
+                                       cairo_stroke(cr);
+
+                                       cairo_arc(cr, c->x - 20, c->y, 4, 0, 2 * M_PI);
+                                       cairo_stroke(cr);
+
+                                       cairo_move_to(cr, c->x - 16, c->y);
+                                       cairo_line_to(cr, c->x + 16, c->y + 10);
+                                       cairo_line_to(cr, c->x + 16, c->y - 10);
+                                       cairo_line_to(cr, c->x - 16, c->y);
+
+                                       p = c->pins[SCF_EDA_NOT_IN];
+                                       cairo_move_to(cr, c->x + 16,  c->y);
+                                       cairo_line_to(cr, c->x + 24, c->y);
+                                       cairo_line_to(cr, p->x,      p->y);
+                               }
+                               cairo_stroke(cr);
+
+                               p = c->pins[SCF_EDA_NOT_POS];
+                               if (p->y < c->y) {
+                                       cairo_move_to(cr, c->x, c->y - 5);
+                                       cairo_line_to(cr, p->x, p->y);
+
+                                       p = c->pins[SCF_EDA_NOT_NEG];
+                                       cairo_move_to(cr, c->x, c->y + 5);
+                                       cairo_line_to(cr, p->x, p->y);
+                               } else {
+                                       cairo_move_to(cr, c->x, c->y + 5);
+                                       cairo_line_to(cr, p->x, p->y);
+
+                                       p = c->pins[SCF_EDA_NOT_NEG];
+                                       cairo_move_to(cr, c->x, c->y - 5);
+                                       cairo_line_to(cr, p->x, p->y);
+                               }
+
+                               cairo_stroke(cr);
+                               break;
                        default:
                                break;
                };
        }
 }
 
-int ses_simplify_draw(ScfEfunction* f, const char* file, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh, int64_t ns, int64_t count)
+int ses_draw(ScfEfunction* f, const char* file, uint32_t bx, uint32_t by, uint32_t bw, uint32_t bh, int64_t ns, int64_t count)
 {
        ScfEcomponent*   B;
        ScfEcomponent*   c;
@@ -622,12 +902,12 @@ int ses_simplify_draw(ScfEfunction* f, const char* file, uint32_t bx, uint32_t b
        return 0;
 }
 
-static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
+static int _draw_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t* ctx)
 {
        static int64_t i = 0;
 
        char file[128];
-       snprintf(file, sizeof(file) - 1, "./simplify_%ld.png", i);
+       snprintf(file, sizeof(file) - 1, "./draw_%ld.png", i);
 #if 0
        if (count < 64000)
                return 0;
@@ -642,16 +922,16 @@ static int _simplify_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx
                if (fp)
                        fprintf(fp, "%ld, %lg\n", i, f->elines[4]->v);
 #endif
-               ses_simplify_draw(f, file, f->x, f->y, f->w, f->h, ns, count);
+               ses_draw(f, file, f->x, f->y, f->w, f->h, ns, count);
                i++;
        }
 
        return 0;
 }
 
-ses_step_t   ses_step_simplify =
+ses_step_t   ses_step_draw =
 {
-       .name    = "simplify",
+       .name    = "draw",
 
-       .handler = _simplify_handler,
+       .handler = _draw_handler,
 };
index c27668a3d045dd442c0e3ca099670e7fd4a6f3ce..d2973569dec2ff3d6d03d198e8cd590194f0eb08 100644 (file)
@@ -120,7 +120,7 @@ int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
                        p->pr  = r;
                }
 
-               scf_loge("path: %d, i: %d, c%ldp%ld, sr: %lg\n", path->index, i, p->cid, p->id, p->sr);
+               scf_logd("path: %d, i: %d, c%ldp%ld, sr: %lg\n", path->index, i, p->cid, p->id, p->sr);
        }
 
        if (path->childs) {
@@ -172,7 +172,7 @@ int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
 
                        child->parent_pr = p1->pr;
 
-                       scf_logi("j: %d, c%ldp%ld, p->pr: %lg, p->sr: %lg, pr: %lg, dr: %lg\n", j, p1->cid, p1->id, p1->pr, p1->sr, pr, dr);
+                       scf_logd("j: %d, c%ldp%ld, p->pr: %lg, p->sr: %lg, pr: %lg, dr: %lg\n", j, p1->cid, p1->id, p1->pr, p1->sr, pr, dr);
 
                        for (++j; j < path->pins->size; j++) {
                                p       = path->pins->data[j];
@@ -180,10 +180,10 @@ int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
                                p->pr -= dr;
                                p->sr -= dr;
 
-                               scf_logi("j: %d, c%ldp%ld,  p->pr: %lg,  p->sr: %lg\n", j, p->cid, p->id, p->pr, p->sr);
+                               scf_logd("j: %d, c%ldp%ld,  p->pr: %lg,  p->sr: %lg\n", j, p->cid, p->id, p->pr, p->sr);
                        }
 
-                       scf_logw("child: %d, pr: %lg, dr: %lg\n", child->index, child->pr, dr);
+                       scf_logi("child: %d, pr: %lg, dr: %lg\n", child->index, child->pr, dr);
                }
        }
 
@@ -208,7 +208,7 @@ int __ses_path_jr(ScfEfunction* f, ses_path_t* path)
        path->pr = p->pr;
        path->sr = p->sr;
 
-       scf_loge("path: %d, pr: %lg, sr: %lg\n\n", path->index, path->pr, path->sr);
+       scf_logi("path: %d, pr: %lg, sr: %lg\n\n", path->index, path->pr, path->sr);
        return 0;
 }
 
index f5bb2479d2f0994921242717f8ff40a4fa4bdda2..a47b1fd93869135f1aa6074cc158aeec6ca8943c 100644 (file)
@@ -7,20 +7,24 @@ static int _output_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t
        ScfEpin*       Bn = B->pins[SCF_EDA_Battery_NEG];
        ScfEline*      el;
 
-       int i;
+       long i;
 
        printf("\n");
 
        for (i = 0; i < f->n_elines; i++) {
                el =        f->elines[i];
 
-               scf_logd("e%ld->vconst: %d\n", el->id, el->vconst);
-
                if (SCF_EDA_PIN_OUT & el->flags)
-                       scf_logw("out el: %ld, V: %lg\n", el->id, el->v);
+                       scf_logi("out el: %ld, V: %lg\n", el->id, el->v);
+       }
+
+       printf("\n");
+
+       for (i = 0; i < f->n_elines; i++) {
+               el =        f->elines[i];
 
-               else if (SCF_EDA_PIN_CF & el->flags)
-                       scf_logw("cf  el: %ld, V: %lg\n", el->id, el->v);
+               if (SCF_EDA_PIN_CF & el->flags)
+                       scf_logi("cf  el: %ld, V: %lg\n", el->id, el->v);
        }
 
        return 0;
index 23a638069174fef98b6b62f99bff5a30c2376be8..fbc0f7e9be3cffad7f4b1ff2361c366e7762e9b9 100644 (file)
@@ -24,7 +24,7 @@ static int __ses_dfs_add_ppath(scf_vector_t* paths, ses_path_t** ppath)
        return 0;
 }
 
-static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __paths, ses_path_t** ppath)
+static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_vector_t* __paths, ses_path_t** ppath, int flags)
 {
        ScfEcomponent*   c;
        ScfEline*        el;
@@ -34,13 +34,7 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
        int64_t i;
        int64_t j;
 
-       if (SCF_EDA_Diode == rc->type && SCF_EDA_Diode_NEG == rp->id)
-               return SCF_EDA_Path_OFF;
-
-       if (SCF_EDA_NPN == rc->type && SCF_EDA_NPN_E == rp->id)
-               return SCF_EDA_Path_OFF;
-
-       if (SCF_EDA_PNP == rc->type && SCF_EDA_PNP_E != rp->id)
+       if (rc->ops && rc->ops->off && rc->ops->off(rp, NULL))
                return SCF_EDA_Path_OFF;
 
        if (SCF_EDA_Status_OFF != rc->status) {
@@ -54,8 +48,7 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
                        return -ENOMEM;
        }
 
-       if (!((SCF_EDA_NPN == rc->type && SCF_EDA_NPN_E == rp->id)
-          || (SCF_EDA_PNP == rc->type && SCF_EDA_PNP_E == rp->id)))
+       if (!rc->ops || !rc->ops->shared || !rc->ops->shared(rp))
                rp->vflag = 1;
 
        scf_logd("c%ldp%ld, l%ld, vflag: %d, pflag: %d\n", rp->cid, rp->id, rp->lid, rp->vflag, rp->pflag);
@@ -68,9 +61,7 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
                if (np->vflag)
                        continue;
 
-               if (SCF_EDA_NPN == rc->type && SCF_EDA_NPN_E != np->id)
-                       continue;
-               if (SCF_EDA_PNP == rc->type && SCF_EDA_PNP_E == np->id)
+               if (rc->ops && rc->ops->off && rc->ops->off(rp, np))
                        continue;
 
                scf_logd("c%ldp%ld, l%ld, vflag: %d, pflag: %d\n", np->cid, np->id, np->lid, np->vflag, np->pflag);
@@ -91,7 +82,7 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
                                        return -ENOMEM;
                        }
 
-                       if (SCF_EDA_PNP == rc->type && 0 == (*ppath)->pins->size) {
+                       if (rc->ops && rc->ops->shared && rc->ops->shared(rp) && 0 == (*ppath)->pins->size) {
 
                                if (scf_vector_add((*ppath)->pins, rp) < 0)
                                        return -ENOMEM;
@@ -101,8 +92,7 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
                                return -ENOMEM;
                }
 
-               if (!((SCF_EDA_NPN == rc->type && SCF_EDA_NPN_E == np->id)
-                  || (SCF_EDA_PNP == rc->type && SCF_EDA_PNP_E == np->id)))
+               if (!rc->ops || !rc->ops->shared || !rc->ops->shared(np))
                        np->vflag = 1;
 
                if (SCF_EDA_PIN_NEG & el->flags) {
@@ -110,7 +100,12 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
 
                        if (SCF_EDA_Status_OFF == rc->status)
                                return 0;
-                       return __ses_dfs_add_ppath(__paths, ppath);
+
+                       ret = __ses_dfs_add_ppath(__paths, ppath);
+                       if (ret < 0)
+                               return ret;
+
+                       continue;
                }
 
                ses_path_t* off = NULL;
@@ -153,8 +148,7 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
                                *ppath = NULL;
                        }
 
-                       if (!((SCF_EDA_NPN == c->type && SCF_EDA_NPN_E == p->id)
-                          || (SCF_EDA_PNP == c->type && SCF_EDA_PNP_E == p->id)))
+                       if (!c->ops || !c->ops->shared || !c->ops->shared(p))
                                p->vflag = 1;
 
                        ses_path_t* tmp = NULL;
@@ -165,7 +159,7 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
                                *ppath = NULL;
                        }
 
-                       ret = __ses_dfs_path(f, c, p, __paths, ppath);
+                       ret = __ses_dfs_path(f, c, p, __paths, ppath, flags);
                        if (ret < 0)
                                return ret;
 
@@ -188,15 +182,13 @@ static int __ses_dfs_path(ScfEfunction* f, ScfEcomponent* rc, ScfEpin* rp, scf_v
                if (off)
                        *ppath = off;
 
-               if (*ppath) {
-                       scf_vector_del((*ppath)->pins, np);
+               if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) {
+                       if (*ppath)
+                               scf_vector_del((*ppath)->pins, np);
 
-                       if (SCF_EDA_Status_OFF != ret)
-                               ret = SCF_EDA_Path_OFF;
+                       if (SCF_EDA_Path_OFF == ret)
+                               np->vflag = 0;
                }
-
-               if (SCF_EDA_Path_OFF == ret)
-                       np->vflag = 0;
        }
 
        if (SCF_EDA_Status_OFF == ret || SCF_EDA_Path_OFF == ret) {
@@ -1194,7 +1186,7 @@ static void _topo_clear(ScfEfunction* f)
        }
 }
 
-static int _topo_paths(ScfEfunction* f, ScfEline* el, scf_vector_t* paths)
+static int _topo_paths(ScfEfunction* f, ScfEline* el, scf_vector_t* paths, int flags)
 {
        if (!f || !el || !paths)
                return -EINVAL;
@@ -1217,7 +1209,7 @@ static int _topo_paths(ScfEfunction* f, ScfEline* el, scf_vector_t* paths)
                if (c == B)
                        continue;
 
-               int ret = __ses_dfs_path(f, c, p, paths, &path);
+               int ret = __ses_dfs_path(f, c, p, paths, &path, flags);
                if (ret < 0)
                        return ret;
 
@@ -1560,7 +1552,7 @@ int ses_layout_paths(ScfEfunction* f, scf_vector_t*  paths)
        B  = f->components[0];
        el = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
 
-       int ret = _topo_paths(f, el, paths);
+       int ret = _topo_paths(f, el, paths, 0);
        if (ret < 0)
                return ret;
 
@@ -1570,13 +1562,13 @@ int ses_layout_paths(ScfEfunction* f, scf_vector_t*  paths)
 
                if (el->flags & SCF_EDA_PIN_IN) {
 
-                       ret = _topo_paths(f, el, paths);
+                       ret = _topo_paths(f, el, paths, 0);
                        if (ret < 0)
                                return ret;
                }
        }
 
-       ses_paths_print(paths);
+//     ses_paths_print(paths);
 
        return __ses_topo_layers(f, paths);
 }
@@ -1595,7 +1587,7 @@ static int _topo_handler(ScfEfunction* f, int64_t ns, int64_t count, ses_ctx_t*
        B  = f->components[0];
        el = f->elines[B->pins[SCF_EDA_Battery_POS]->lid];
 
-       int ret = _topo_paths(f, el, ctx->paths);
+       int ret = _topo_paths(f, el, ctx->paths, 1);
        if (ret < 0)
                return ret;
 
index 5b6f94c8c032a635bbe29875fab2405e771fc8ad..98014759af3d562c90b5ddd13d0f4bd60ff47fc6 100644 (file)
@@ -19,7 +19,7 @@ extern ses_step_t   ses_step_open;
 extern ses_step_t   ses_step_va_nodes;
 
 extern ses_step_t   ses_step_output;
-extern ses_step_t   ses_step_simplify;
+extern ses_step_t   ses_step_draw;
 
 
 static ses_step_t*  ses_steps_0[] =
@@ -49,7 +49,7 @@ static ses_step_t*  ses_steps_2[] =
        &ses_step_va_nodes,
 
        &ses_step_output,
-       &ses_step_simplify,
+       &ses_step_draw,
 };
 
 static int __ses_analyse_input(ScfEfunction* f, int64_t ns, int64_t i, ses_ctx_t* ctx)
index 5c5ce8c99ea8625cd2c785626d64e9024d6c2d0a..1ddd2a924b426aedea018867c5306bcc6e8d0321 100644 (file)
@@ -1,6 +1,6 @@
-#CFILES += main.c
+CFILES += main.c
 #CFILES += test.c
-CFILES += fft.c
+#CFILES += fft.c
 #CFILES += dct.c
 #CFILES += pnp.c
 #CFILES += colpitts.c