CFILES += ses_steps.c
CFILES += ses_step_battery.c
+CFILES += ses_step_crystal.c
+
CFILES += ses_step_dc_input.c
CFILES += ses_step_ac_input.c
#CFILES += ttl_if.c
#CFILES += ttl_d_flip_flop.c
#CFILES += ttl_mla.c
+#CFILES += op_amp_f007.c
+CFILES += crystal.c
+
#CFILES += ttl_mla_test.c
#CFILES += ttl_if_test.c
#CFILES += ttl_nand_test.c
#CFILES += ttl_add_test.c
#CFILES += ttl_adc_test.c
#CFILES += ttl_ck_test.c
-#CFILES += add.c
-#CFILES += jk_gate.c
-#CFILES += jk_gate2.c
-#CFILES += rs_gate.c
#CFILES += ttl_dff_test.c
#CFILES += for_test.c
-#CFILES += add_gate.c
-#CFILES += adc_gate.c
-#CFILES += op_amp_741.c
-CFILES += op_amp_f007.c
#CFILES += op_amp_test.c
CFILES += ../scf_eda_pack.c
CFILES += ../pack/scf_pack.c
--- /dev/null
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+ ScfEcomponent* Rs;
+ ScfEcomponent* Ls;
+ ScfEcomponent* Cs;
+
+ ScfEfunction* f = scf_efunction__alloc("crystal.cpk");
+
+ EDA_INST_ADD_COMPONENT(f, Ls, SCF_EDA_Inductor);
+ EDA_INST_ADD_COMPONENT(f, Cs, SCF_EDA_Capacitor);
+
+ EDA_PIN_ADD_PIN(Ls, 0, Cs, 1);
+
+ Ls->r = 5;
+ Ls->uh = 2546;
+ Cs->r = 1;
+ Cs->uf = 0.09972e-6;
+
+ Ls->pins[1]->ic_lid = 1;
+ Cs->pins[0]->ic_lid = 0;
+
+ int ret = ses_layout_function(f, 100);
+ if (ret < 0)
+ return ret;
+
+ ses_draw(f, "crystal.png", f->x, f->y, f->w, f->h, 0, -1);
+
+ long len = 0;
+ uint8_t* buf = NULL;
+
+ ScfEfunction_pack(f, &buf, &len);
+ ScfEfunction_free(f);
+ f = NULL;
+
+ FILE* fp = fopen("./crystal.cpk", "wb");
+ if (!fp)
+ return -EINVAL;
+
+ fwrite(buf, len, 1, fp);
+ fclose(fp);
+ return 0;
+}
R0->r = 4000;
R1->r = 1600;
R2->r = 130;
- R3->r = 10 * 1000;
+ R3->r = 1000;
R0->pins[1]->flags = SCF_EDA_PIN_POS;
R3->pins[0]->flags = SCF_EDA_PIN_NEG;
R0->r = 4000;
R1->r = 1600;
R2->r = 130;
- R3->r = 10 * 1000;
+ R3->r = 1000;
R0->pins[1]->flags = SCF_EDA_PIN_POS;
R3->pins[0]->flags = SCF_EDA_PIN_NEG;
static void usage()
{
- printf("usage: ./ses [-l 0] [-f fname] [-t timeslice] [-c count] [-d 0] [-s Nth] [-n N] [-I IC] [-V \"v0, v1 - v2,...\"] [-A \"i1,i2c,...\"] src.cpk\n\n");
- printf("-l: if need layout: 0 not, 1 layout, default is 1.\n");
- printf("-f: function name in board\n");
- printf("-t: time slice, such as 100ps, 100ns, 100us, 100ms.\n");
- printf("-c: count of running times\n");
- printf("-d: if draw graphs of circuit status: 0 not, 1 draw, default is 1.\n");
- printf("-s: show from the Nth sample\n");
- printf("-n: show when every N samples\n");
- printf("-I: show the internal circuit graph of IC number\n");
- printf("-V: save the voltage of lines in 'v.txt', v1 - v2 means the diff voltage between line 1 and line 2.\n");
- printf("-A: save the current of components in 'a.txt', i1 means the component with ID 1, i2c means the C pin of NPN or PNP with ID 2.\n");
- printf("src.cpk: electronic model file to simulate\n\n");
+ fprintf(stderr, "usage: ./ses [-l 0] [-f fname] [-t timeslice] [-c count] [-d 0] [-s Nth] [-n N] [-I IC] [-V \"v0, v1 - v2,...\"] [-A \"i1,i2c,...\"] [-dc] src.cpk\n\n");
+ fprintf(stderr, "-l: if need layout: 0 not, 1 layout, default is 1.\n");
+ fprintf(stderr, "-f: function name in board\n");
+ fprintf(stderr, "-t: time slice, such as 100ps, 100ns, 100us, 100ms.\n");
+ fprintf(stderr, "-c: count of running times\n");
+ fprintf(stderr, "-d: if draw graphs of circuit status: 0 not, 1 draw, default is 1.\n");
+ fprintf(stderr, "-s: show from the Nth sample\n");
+ fprintf(stderr, "-n: show when every N samples\n");
+ fprintf(stderr, "-I: show the internal circuit graph of IC number\n");
+ fprintf(stderr, "-V: save the voltage of lines in 'v.txt', v1 - v2 means the diff voltage between line 1 and line 2.\n");
+ fprintf(stderr, "-A: save the current of components in 'a.txt', i1 means the component with ID 1, i2c means the C pin of NPN or PNP with ID 2.\n");
+
+ fprintf(stderr, "-dc: run in DC mode, default is AC mode.\n");
+ fprintf(stderr, "src.cpk: electronic model file to simulate\n\n");
}
-int main(int argc, char* argv[])
+int run(int argc, char* argv[])
{
if (argc < 2) {
usage();
int draw = 1;
int start = 0;
int every = 1;
+ int dc = 0;
long i;
long j;
break;
case 'd':
+ if (3 == len && 'c' == argv[i][2]) {
+ dc = 1;
+ break;
+ }
+
if (++i >= argc) {
usage();
return -EINVAL;
return -EINVAL;
}
- ps = atol(argv[i]);
+ double __ps = atof(argv[i]);
len = strlen(argv[i]);
if (len > 2) {
if (!strcmp(argv[i] + len - 2, "ns"))
- ps *= 1000LL;
+ __ps *= 1e3;
else if (!strcmp(argv[i] + len - 2, "us"))
- ps *= 1000LL * 1000LL;
+ __ps *= 1e6;
else if (!strcmp(argv[i] + len - 2, "ms"))
- ps *= 1000LL * 1000LL * 1000LL;
+ __ps *= 1e9;
}
+
+ ps = __ps;
break;
default:
break;
long len = scf_pack_read(&buf, cpk);
if (len < 0) {
- scf_loge("scf_pack_read error: %ld\n", len);
+ scf_loge("scf_pack_read '%s' error: %ld\n", cpk, len);
return len;
}
return ret;
}
- scf_logi("c%ld, c->x: %d, c->y: %d, c->color: %ld\n", c->id, c->x, c->y, c->color);
+ scf_logd("c%ld, c->x: %d, c->y: %d, c->color: %ld\n", c->id, c->x, c->y, c->color);
c->pf = f;
ctx->N = every;
ctx->i = 0;
ctx->draw_flag = draw;
+ ctx->dc_flag = dc;
ret = 0;
if (fname) {
if (!strcmp(f->name, fname)) {
- printf("f: %s\n", f->name);
+ fprintf(stderr, "f: %s\n", f->name);
ret = ses_steps_analyse(b, f, ps, count, ctx);
}
} else {
- printf("f: %s\n", f->name);
+ fprintf(stderr, "f: %s\n", f->name);
ret = ses_steps_analyse(b, f, ps, count, ctx);
}
ScfEboard_free(b);
return ret;
}
+
+int main(int argc, char* argv[])
+{
+ if (argc >= 2)
+ return run(argc, argv);
+
+ long ret = 0;
+ long len = 0;
+ char* buf = NULL;
+ char* args[256];
+
+ usage();
+ printf("# ");
+
+ while ((ret = getline(&buf, &len, stdin)) != -1) {
+ char* p0 = buf;
+ char* p1 = p0;
+ int i = 0;
+
+ while (*p1) {
+ if (' ' == *p1 || '\n' == *p1 || '\r' == *p1 || '\t' == *p1) {
+ *p1 = '\0';
+
+ if ('\0' == *p0) {
+ p0 = ++p1;
+ continue;
+ }
+
+ if (i >= sizeof(args) / sizeof(args[0])) {
+ scf_loge("args should not be more than 256.\n");
+ free(buf);
+ return -1;
+ }
+
+ args[i++] = p0;
+ p0 = ++p1;
+ } else
+ ++p1;
+ }
+
+ ret = run(i, args);
+
+ free(buf);
+ buf = NULL;
+ len = 0;
+
+ if (ret < 0)
+ return ret;
+
+ printf("# ");
+ }
+
+ free(buf);
+ return ret;
+}
} while (0)
#ifdef SCF_DEBUG
-#define scf_logd(fmt, ...) printf("%s(), %d, "fmt, __func__, __LINE__, ##__VA_ARGS__)
+#define scf_logd(fmt, ...) fprintf(stderr, "%s(), %d, "fmt, __func__, __LINE__, ##__VA_ARGS__)
#else
#define scf_logd(fmt, ...)
#endif
-#define scf_logi(fmt, ...) printf("%s(), %d, info: "fmt, __func__, __LINE__, ##__VA_ARGS__)
+#define scf_logi(fmt, ...) fprintf(stderr, "%s(), %d, info: "fmt, __func__, __LINE__, ##__VA_ARGS__)
-#define scf_loge(fmt, ...) printf("%s(), %d, \033[31m error:\033[0m "fmt, __func__, __LINE__, ##__VA_ARGS__)
-#define scf_logw(fmt, ...) printf("%s(), %d, \033[33m warning:\033[0m "fmt, __func__, __LINE__, ##__VA_ARGS__)
-
-#define SCF_CHECK_ERROR(cond, ret, fmt, ...) \
- do { \
- if (cond) { \
- printf("%s(), %d, \033[31m error:\033[0m "fmt, __func__, __LINE__, ##__VA_ARGS__); \
- return ret; \
- } \
- } while (0)
+#define scf_loge(fmt, ...) fprintf(stderr, "%s(), %d, \033[31m error:\033[0m "fmt, __func__, __LINE__, ##__VA_ARGS__)
+#define scf_logw(fmt, ...) fprintf(stderr, "%s(), %d, \033[33m warning:\033[0m "fmt, __func__, __LINE__, ##__VA_ARGS__)
#endif
-
SCF_EDA_Signal_NB,
SCF_EDA_OP_AMP_NB,
+ 2, // crystal oscillator
};
static int __diode_path_off(ScfEpin* p0, ScfEpin* p1, int flags)
static ScfEdata component_datas[] =
{
- {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_Battery, 0, 0, 0, 0, 1e-9, 1e9, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_Signal, 0, 0, 0, 0, 1e-9, 1e9, 0, 0, NULL, NULL, NULL},
-
- {SCF_EDA_Resistor, 0, 0, 0, 0, 1e4, 0, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_Capacitor, 0, 0, 0, 0, 10, 0.1, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_Inductor, 0, 0, 0, 0, 10, 0, 1e3, 0, NULL, NULL, NULL},
-
- {SCF_EDA_Diode, 0, 0, 0, 0, 0, 0, 0, 0, &__diode_ops, NULL, "./cpk/9013.txt"},
- {SCF_EDA_NPN, 0, 0, 0, 0, 0, 0, 0, 0, &__npn_ops, NULL, "./cpk/9013.txt"},
- {SCF_EDA_PNP, 0, 0, 0, 0, 0, 0, 0, 0, &__pnp_ops, NULL, "./cpk/9012.txt"},
-
- {SCF_EDA_NAND, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_nand_ops, "./cpk/ttl_nand.cpk", NULL},
- {SCF_EDA_NOT, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_not_ops, "./cpk/ttl_not.cpk", NULL},
- {SCF_EDA_AND, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_and.cpk", NULL},
- {SCF_EDA_OR, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_or.cpk", NULL},
- {SCF_EDA_NOR, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_nor.cpk", NULL},
- {SCF_EDA_XOR, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_xor.cpk", NULL},
- {SCF_EDA_DFF, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_dff.cpk", NULL},
-
- {SCF_EDA_ADD, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_add_ops, "./cpk/ttl_add.cpk", NULL},
- {SCF_EDA_ADC, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_adc_ops, "./cpk/ttl_adc.cpk", NULL},
-
- {SCF_EDA_NAND4, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_nand4_ops, "./cpk/ttl_nand4.cpk", NULL},
- {SCF_EDA_AND2_OR, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_and2_or_ops, "./cpk/ttl_and2_or.cpk", NULL},
- {SCF_EDA_IF, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_if_ops, "./cpk/ttl_if.cpk", NULL},
- {SCF_EDA_MLA, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_mla_ops, "./cpk/ttl_mla.cpk", NULL},
-
- {SCF_EDA_NOT, SCF_EDA_TTL_DELAY, 0, 0, 0, 0, 0, 0, 0, &__ttl_not_ops, "./cpk/ttl_not_delay.cpk", NULL},
-
- {SCF_EDA_OP_AMP, 0, 0, 0, 0, 0, 0, 0, 0, &__741_op_amp_ops, "./cpk/op_amp_f007.cpk", NULL},
+ {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_Battery, 0, 0, 0, 0, 1e-9, 1e9, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_Signal, 0, 0, 0, 0, 1e-9, 1e9, 0, 0, 0, NULL, NULL, NULL},
+
+ {SCF_EDA_Resistor, 0, 0, 0, 0, 1e4, 0, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_Capacitor, 0, 0, 0, 0, 10, 0.1, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_Inductor, 0, 0, 0, 0, 10, 0, 1e3, 0, 0, NULL, NULL, NULL},
+
+ {SCF_EDA_Diode, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__diode_ops, NULL, "./cpk/9013.txt"},
+ {SCF_EDA_NPN, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__npn_ops, NULL, "./cpk/9013.txt"},
+ {SCF_EDA_PNP, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__pnp_ops, NULL, "./cpk/9012.txt"},
+
+ {SCF_EDA_NAND, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_nand_ops, "./cpk/ttl_nand.cpk", NULL},
+ {SCF_EDA_NOT, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_not_ops, "./cpk/ttl_not.cpk", NULL},
+ {SCF_EDA_AND, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_and.cpk", NULL},
+ {SCF_EDA_OR, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_or.cpk", NULL},
+ {SCF_EDA_NOR, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_nor.cpk", NULL},
+ {SCF_EDA_XOR, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_xor.cpk", NULL},
+ {SCF_EDA_DFF, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_gate_ops, "./cpk/ttl_dff.cpk", NULL},
+
+ {SCF_EDA_ADD, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_add_ops, "./cpk/ttl_add.cpk", NULL},
+ {SCF_EDA_ADC, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_adc_ops, "./cpk/ttl_adc.cpk", NULL},
+
+ {SCF_EDA_NAND4, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_nand4_ops, "./cpk/ttl_nand4.cpk", NULL},
+ {SCF_EDA_AND2_OR, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_and2_or_ops, "./cpk/ttl_and2_or.cpk", NULL},
+ {SCF_EDA_IF, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_if_ops, "./cpk/ttl_if.cpk", NULL},
+ {SCF_EDA_MLA, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_mla_ops, "./cpk/ttl_mla.cpk", NULL},
+
+ {SCF_EDA_NOT, SCF_EDA_TTL_DELAY, 0, 0, 0, 0, 0, 0, 0, 0, &__ttl_not_ops, "./cpk/ttl_not_delay.cpk", NULL},
+
+ {SCF_EDA_OP_AMP, 0, 0, 0, 0, 0, 0, 0, 0, 0, &__741_op_amp_ops, "./cpk/op_amp_f007.cpk", NULL},
+
+ {SCF_EDA_Crystal, 0, 0, 0, 0, 0, 0, 0, 0, 1e7, NULL, "./cpk/crystal.cpk", NULL},
};
static ScfEdata pin_datas[] =
{
- {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_Diode, 0, SCF_EDA_Diode_NEG, 0, 0, 750, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_Diode, 0, SCF_EDA_Diode_NEG, 0, 0, 750, 0, 0, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_NPN, 0, SCF_EDA_NPN_B, 0, 0, 750, 0, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_NPN, 0, SCF_EDA_NPN_C, 0, 0, 3, 0, 0, 200, NULL, NULL, NULL},
+ {SCF_EDA_NPN, 0, SCF_EDA_NPN_B, 0, 0, 750, 0, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_NPN, 0, SCF_EDA_NPN_C, 0, 0, 3, 0, 0, 200, 0, NULL, NULL, NULL},
- {SCF_EDA_PNP, 0, SCF_EDA_PNP_B, 0, 0, 750, 0, 0, 0, NULL, NULL, NULL},
- {SCF_EDA_PNP, 0, SCF_EDA_PNP_C, 0, 0, 3, 0, 0, 200, NULL, NULL, NULL},
+ {SCF_EDA_PNP, 0, SCF_EDA_PNP_B, 0, 0, 750, 0, 0, 0, 0, NULL, NULL, NULL},
+ {SCF_EDA_PNP, 0, SCF_EDA_PNP_C, 0, 0, 3, 0, 0, 200, 0, NULL, NULL, NULL},
};
static ScfEdata* _pin_find_data(const uint64_t type, const uint64_t model, const uint64_t pid)
c->r = ed->r;
c->uf = ed->uf;
c->uh = ed->uh;
+ c->Hz = ed->Hz;
c->ops = ed->ops;
}
SCF_EDA_OP_AMP,
+ SCF_EDA_Crystal,
+
SCF_EDA_Components_NB,
};
double uf;
double uh;
double hfe;
+ double Hz;
void* ops;
char* cpk;
SCF_PACK_DEF_VAR(double, uf);
SCF_PACK_DEF_VAR(double, uh);
+ SCF_PACK_DEF_VAR(double, Hz);
+
SCF_PACK_DEF_VAR(int64_t, mirror_id);
SCF_PACK_DEF_VAR(int64_t, count);
SCF_PACK_INFO_VAR(ScfEcomponent, r),
SCF_PACK_INFO_VAR(ScfEcomponent, uf),
SCF_PACK_INFO_VAR(ScfEcomponent, uh),
+SCF_PACK_INFO_VAR(ScfEcomponent, Hz),
SCF_PACK_INFO_VAR(ScfEcomponent, mirror_id),
char* Vshow;
char* Ashow;
- FILE* Vfp;
- FILE* Afp;
-
int changed;
int start;
int N;
int i;
+
uint8_t draw_flag:1;
+ uint8_t dc_flag:1;
};
struct ses_step_s
for (i = 0; i < b->n_functions; i++) {
f = b->functions[i];
- printf("f: %s\n", f->name);
+ fprintf(stderr, "f: %s\n", f->name);
int ret = ses_layout_function(f, d);
if (ret < 0) {
int i;
int j;
- printf("A:\n");
+ fprintf(stderr, "A:\n");
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++)
- printf("%3lg ", A[i * N + j]);
- printf("\n");
+ fprintf(stderr, "%3lg ", A[i * N + j]);
+ fprintf(stderr, "\n");
}
- printf("\nb:\n");
+ fprintf(stderr, "\nb:\n");
for (j = 0; j < N; j++)
- printf("%lg\n", b[j]);
+ fprintf(stderr, "%lg\n", b[j]);
- printf("\nX:\n");
+ fprintf(stderr, "\nX:\n");
for (j = 0; j < N; j++)
- printf("%lg\n", X[j]);
+ fprintf(stderr, "%lg\n", X[j]);
}
/*
edge->r = r;
scf_logd("c%ldp%ld-c%ldp%ld, r: %lg, cv: %lg, uh: %lg, la: %lg, edge->index: %d\n", p0->cid, p0->id, p1->cid, p1->id, r, cv, uh, la, edge->index);
+
+ if (edge->edge_b) {
+ edge->amplify_flag = 1;
+
+ 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;
+ continue;
+ }
/* dv = idt / C
v = Ldi/dt
v0 - v1 - ir = cv + idt/C + Ldi/dt
#if 1
scf_logi("\033[31medge: [%d], ", edge->index);
ses_pin_print(p0);
- printf("status: %d, dV: %lg, Vb: %lg, Ve: %lg, Ib: %lg\033[0m\n", c->status, dV, Vb, Ve, Ib);
+ fprintf(stderr, "status: %d, dV: %lg, Vb: %lg, Ve: %lg, Ib: %lg\033[0m\n", c->status, dV, Vb, Ve, Ib);
#endif
}
} else if (dV > SCF_EDA_V_Diode_OFF) {
#if 1
scf_logi("\033[32medge: [%d], ", edge->index);
ses_pin_print(p0);
- printf("status: %d, dV: %lg, Vb: %lg, Ve: %lg, Ib: %lg\033[0m\n", c->status, dV, Vb, Ve, Ib);
+ fprintf(stderr, "status: %d, dV: %lg, Vb: %lg, Ve: %lg, Ib: %lg\033[0m\n", c->status, dV, Vb, Ve, Ib);
#endif
k++;
}
#if 1
scf_logi("edge: [%d], ", edge->index);
ses_pin_print(p0);
- printf("status: %d, dV: %lg, Vb: %lg, Ve: %lg, V: %lg, Ib: %lg, Rb: %lg\n", c->status, dV, Vb, Ve, V, Ib, Rb);
+ fprintf(stderr, "status: %d, dV: %lg, Vb: %lg, Ve: %lg, V: %lg, Ib: %lg, Rb: %lg\n", c->status, dV, Vb, Ve, V, Ib, Rb);
#endif
A[(n + edge->index) * N + n + edge->index] = -Rb;
b[ n + edge->index] += 0;
#if 0
scf_logi("edge: [%d], ", edge->index);
ses_pin_print(p0);
- printf("status: %d, dV: %lg, Vb: %lg, Ve: %lg, V: %lg, Ib: %lg, Rb: %lg\n", c->status, dV, Vb, Ve, V, Ib, Rb);
+ fprintf(stderr, "status: %d, dV: %lg, Vb: %lg, Ve: %lg, V: %lg, Ib: %lg, Rb: %lg\n", c->status, dV, Vb, Ve, V, Ib, Rb);
#endif
}
} else {
#if 0
scf_logi("\033[34medge: [%d], ", edge->index);
ses_pin_print(p0);
- printf("status: %d, dV: %lg, Vb: %lg, Ve: %lg, V: %lg, Ib: %lg, Rb: %lg\033[0m\n", c->status, dV, Vb, Ve, V, Ib, Rb);
-#endif
- }
-
- } else if (edge->edge_b) {
- double Ic = X[n + edge->index];
- double Ib = X[n + edge->edge_b->index];
- double Vc = Vb;
-
- if (edge->edge_b->node1 && !edge->edge_b->node1->el->vconst)
- Vb = X[edge->edge_b->node1->index];
- else {
- p = edge->edge_b->path->pins->data[edge->edge_b->vip_m];
- Vb = ses_top_pline(p)->v;
- }
-
- double dI = Ib * edge->hfe - Ic;
- double V = SCF_EDA_V_NPN_ON;
- double Rb = V / Ib;
-#if 1
- if (c->curves && c->n_curves > 0) {
- __ses_Vb_by_curve(c, Ib, &V);
- __ses_Vb_by_curve(c, V, &V);
- Rb = V / Ib;
- }
+ fprintf(stderr, "status: %d, dV: %lg, Vb: %lg, Ve: %lg, V: %lg, Ib: %lg, Rb: %lg\033[0m\n", c->status, dV, Vb, Ve, V, Ib, Rb);
#endif
- if (dI < -1e-10 && -1e8 < Rb && Rb < 1e8) {
- if (!edge->amplify_flag) {
- edge->amplify_flag = 1;
-
- 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++;
- }
}
}
}
scf_logi("\033[33medge: [%d], ", edge->index);
ses_pin_print(p0);
ses_pin_print(p1);
- printf("Vc: %lg, Ve: %lg, Vce: %lg, Ic: %lg, hfe: %lg, alpha: %lg\033[0m\n", Vc, Ve, Vc - Ve, Ic, hfe, alpha);
+ fprintf(stderr, "Vc: %lg, Ve: %lg, Vce: %lg, Ic: %lg, hfe: %lg, alpha: %lg\033[0m\n", Vc, Ve, Vc - Ve, Ic, hfe, alpha);
}
static int __edge_update_hfe(ses_edge_t* edge, double* A, double* X, int N, int n, double alpha)
}
if (k > 0)
- printf("\n");
+ fprintf(stderr, "\n");
}
return k;
}
scf_logi("\033[31medge: [%d], ", edge->index);
ses_pin_print(p0);
ses_pin_print(p1);
- printf("Vmax: %lg\033[0m\n", Vmax);
+ fprintf(stderr, "Vmax: %lg\033[0m\n", Vmax);
}
__ses_gsl_solve(A, N);
try++;
} while (ret > 0 && try < MAX_TRYS);
- __ses_nodes_update_vmax(f, nodes, A, b, X, N, n);
+// __ses_nodes_update_vmax(f, nodes, A, b, X, N, n);
if (try >= MAX_TRYS)
scf_loge("try: %d\n\n", try);
edge->a = X[n + edge->index];
#if 1
if (edge->a < -1e-4)
- printf("\033[36m");
+ fprintf(stderr, "\033[36m");
ses_pin_print(p0);
ses_pin_print(p1);
if (edge->a < -1e-4)
- printf(", v: %lg, %lg, a: %lg, edge->index: %d\033[0m\n", p0->v, p1->v, edge->a, edge->index);
+ fprintf(stderr, ", v: %lg, %lg, a: %lg, edge->index: %d\033[0m\n", p0->v, p1->v, edge->a, edge->index);
else
- printf(", v: %lg, %lg, a: %lg, edge->index: %d\n", p0->v, p1->v, edge->a, edge->index);
+ fprintf(stderr, ", v: %lg, %lg, a: %lg, edge->index: %d\n", p0->v, p1->v, edge->a, edge->index);
#endif
if (SCF_EDA_NPN == c->type) {
if (SCF_EDA_NPN_B == p0->id
c->v = (edge->a * sign - c->a) * c->uh * 1000000.0 / ps;
+ if (c->pf->IC && SCF_EDA_Crystal == c->pf->IC->type)
+ c->pf->IC->v += c->v;
+
} else if (SCF_EDA_Capacitor == c->type) {
-// if (!c->pf->IC || SCF_EDA_OP_AMP != c->pf->IC->type)
- c->v += edge->a * sign * ps / 1000000.0 / c->uf;
+ c->v += edge->a * sign * ps / 1000000.0 / c->uf;
+
+ if (c->pf->IC && SCF_EDA_Crystal == c->pf->IC->type) {
+ c->pf->IC->a = edge->a * sign;
+ c->pf->IC->v += c->v;
+ }
}
c->a = edge->a * sign;
switch (IC->type) {
case SCF_EDA_NAND:
- printf("Nand%ld_", IC->id);
+ fprintf(stderr, "Nand%ld_", IC->id);
break;
case SCF_EDA_NOR:
- printf("Nor%ld_", IC->id);
+ fprintf(stderr, "Nor%ld_", IC->id);
break;
case SCF_EDA_NOT:
- printf("Not%ld_", IC->id);
+ fprintf(stderr, "Not%ld_", IC->id);
break;
case SCF_EDA_AND:
- printf("And%ld_", IC->id);
+ fprintf(stderr, "And%ld_", IC->id);
break;
case SCF_EDA_OR:
- printf("Or%ld_", IC->id);
+ fprintf(stderr, "Or%ld_", IC->id);
break;
case SCF_EDA_XOR:
- printf("Xor%ld_", IC->id);
+ fprintf(stderr, "Xor%ld_", IC->id);
break;
case SCF_EDA_ADD:
- printf("Add%ld_", IC->id);
+ fprintf(stderr, "Add%ld_", IC->id);
break;
default:
- printf("IC%ld_", IC->id);
+ fprintf(stderr, "IC%ld_", IC->id);
break;
};
}
switch (p->c->type) {
case SCF_EDA_Resistor:
- printf("R%ldp%ld ", p->cid, p->id);
+ fprintf(stderr, "R%ldp%ld ", p->cid, p->id);
break;
case SCF_EDA_Capacitor:
- printf("C%ldp%ld ", p->cid, p->id);
+ fprintf(stderr, "C%ldp%ld ", p->cid, p->id);
break;
case SCF_EDA_Inductor:
- printf("L%ldp%ld ", p->cid, p->id);
+ fprintf(stderr, "L%ldp%ld ", p->cid, p->id);
break;
case SCF_EDA_Diode:
- printf("D%ldp%ld ", p->cid, p->id);
+ fprintf(stderr, "D%ldp%ld ", p->cid, p->id);
break;
case SCF_EDA_NPN:
case SCF_EDA_PNP:
if (SCF_EDA_NPN_B == p->id)
- printf("T%ldb ", p->cid);
+ fprintf(stderr, "T%ldb ", p->cid);
else if (SCF_EDA_NPN_C == p->id)
- printf("T%ldc ", p->cid);
+ fprintf(stderr, "T%ldc ", p->cid);
else
- printf("T%lde ", p->cid);
+ fprintf(stderr, "T%lde ", p->cid);
break;
default:
- printf("c%ldp%ld ", p->cid, p->id);
+ fprintf(stderr, "c%ldp%ld ", p->cid, p->id);
break;
};
}
int i;
if (!path->parent)
- printf("\033[31mpath : %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, \033[0m\n",
+ fprintf(stderr, "\033[31mpath : %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, \033[0m\n",
path->index, path->n_diodes, path->n_NPNs, path->n_PNPs, path->n_capacitors, path->n_transistors);
for (i = 0; i < path->pins->size; i++) {
ses_pin_print(p);
}
- printf("\n");
+ fprintf(stderr, "\n");
if (path->connections) {
for (i = 0; i < path->connections->size; i++) {
child = path->connections->data[i];
if (child->parent == path) {
- printf("\n");
- printf("\033[34mconnection: %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, parent: %d, \033[0m\n",
+ fprintf(stderr, "\n");
+ fprintf(stderr, "\033[34mconnection: %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, parent: %d, \033[0m\n",
child->index, child->n_diodes, child->n_NPNs, child->n_PNPs, child->n_capacitors, child->n_transistors, path->index);
ses_path_print(child);
} else
- printf("\033[34mconnection: %d\033[0m\n", child->index);
+ fprintf(stderr, "\033[34mconnection: %d\033[0m\n", child->index);
}
}
for (i = 0; i < path->childs->size; i++) {
child = path->childs->data[i];
- printf("\n");
- printf("\033[32mchild : %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, parent: %d, \033[0m\n",
+ fprintf(stderr, "\n");
+ fprintf(stderr, "\033[32mchild : %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, parent: %d, \033[0m\n",
child->index, child->n_diodes, child->n_NPNs, child->n_PNPs, child->n_capacitors, child->n_transistors, path->index);
ses_path_print(child);
for (i = 0; i < path->bridges->size; i++) {
child = path->bridges->data[i];
- printf("\n");
- printf("\033[33mbridge: %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, parent: %d, \033[0m\n",
+ fprintf(stderr, "\n");
+ fprintf(stderr, "\033[33mbridge: %d, n_diodes: %d, n_NPNs: %d, n_PNPs: %d, n_capacitors: %d, n_transistors: %d, parent: %d, \033[0m\n",
child->index, child->n_diodes, child->n_NPNs, child->n_PNPs, child->n_capacitors, child->n_transistors, path->index);
ses_path_print(child);
path = paths->data[i];
ses_path_print(path);
- printf("------------------------\n");
+ fprintf(stderr, "------------------------\n");
}
}
--- /dev/null
+#include"ses_core.h"
+
+static int __crystal_Hz(ScfEfunction* f)
+{
+ ScfEcomponent* c;
+
+ long i;
+ long j;
+ for (i = 0; i < f->n_components; i++) {
+ c = f->components[i];
+
+ if (SCF_EDA_Crystal == c->type) {
+ assert(c->f);
+
+ ScfEcomponent* Ls = NULL;
+ ScfEcomponent* Cs = NULL;
+ ScfEcomponent* c2;
+
+ for (j = 0; j < c->f->n_components; j++) {
+ c2 = c->f->components[j];
+
+ if (SCF_EDA_Capacitor == c2->type)
+ Cs = c2;
+ else if (SCF_EDA_Inductor == c2->type)
+ Ls = c2;
+ }
+
+ double T = 1.0 / (2.0 * 3.1415926 * c->Hz);
+
+ Ls->uh = T * T / Cs->uf * 1e12;
+ scf_logi("Ls->uh: %lg, Cs->uf: %lg, c->Hz: %lg\n", Ls->uh, Cs->uf, c->Hz);
+ continue;
+ }
+
+ if (c->f) {
+ int ret = __crystal_Hz(c->f);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int _crystal_handler(ScfEfunction* f, int64_t ps, int64_t count, ses_ctx_t* ctx)
+{
+ return __crystal_Hz(f);
+}
+
+ses_step_t ses_step_crystal =
+{
+ .name = "crystal",
+
+ .handler = _crystal_handler,
+};
#include"ses_core.h"
-static int __dc_diode_status(ScfEfunction* root, ScfEfunction* f, ScfEline* LP, ScfEline* LN)
+static int __dc_diode_status(ScfEfunction* root, ScfEfunction* f, ScfEline* LP, ScfEline* LN, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEpin* pb;
c = f->components[i];
if (c->f) {
- int ret = __dc_diode_status(root, c->f, LP, LN);
+ int ret = __dc_diode_status(root, c->f, LP, LN, ctx);
if (ret < 0)
return ret;
if (lb == LP && le == LN) {
scf_loge("short connected, ");
ses_pin_print(pb);
- printf("\n");
+ fprintf(stderr, "\n");
return -EINVAL;
}
}
check:
- if ((c->pf->IC && SCF_EDA_OP_AMP == c->pf->IC->type)
+ if (!ctx->dc_flag
+ || (c->pf->IC && SCF_EDA_OP_AMP == c->pf->IC->type)
|| pe->v >= LP->v - SCF_EDA_V_NPN_OFF
|| pb->v <= LN->v + SCF_EDA_V_NPN_OFF) {
c->lock = 0;
scf_logi("\033[34m status: %d, lock: %d, ", c->status, c->lock);
ses_pin_print(pb);
- printf("pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\033[0m\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_Diode_OFF);
+ fprintf(stderr, "pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\033[0m\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_Diode_OFF);
}
return 0;
ScfEline* LP = ses_find_line_by_flag(f, SCF_EDA_PIN_POS);
ScfEline* LN = ses_find_line_by_flag(f, SCF_EDA_PIN_NEG);
- return __dc_diode_status(f, f, LP, LN);
+ return __dc_diode_status(f, f, LP, LN, ctx);
}
ses_step_t ses_step_dc_diode =
el2 = f->elines[B->pins[k]->lid];
- el->v = el2->v;
+ ses_line_set_v(el, el2->v);
el->vconst = 1;
scf_logi("el->io_lid: %ld, k: %d, v: %lg\n", el->io_lid, k, el->v);
#include"ses_core.h"
-static int __dc_npn_status(ScfEfunction* root, ScfEfunction* f, ScfEline* LP, ScfEline* LN)
+static int __dc_npn_status(ScfEfunction* root, ScfEfunction* f, ScfEline* LP, ScfEline* LN, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEpin* pb;
c = f->components[i];
if (c->f) {
- int ret = __dc_npn_status(root, c->f, LP, LN);
+ int ret = __dc_npn_status(root, c->f, LP, LN, ctx);
if (ret < 0)
return ret;
if (lb == LP && le == LN) {
scf_loge("short connected, ");
ses_pin_print(pb);
- printf("\n");
+ fprintf(stderr, "\n");
return -EINVAL;
}
scf_logi("\033[34m status: %d, lock: %d, \033[0m", c->status, c->lock);
ses_pin_print(pb);
- printf("pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_NPN_OFF);
+ fprintf(stderr, "pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_NPN_OFF);
continue;
}
scf_logi("\033[34m status: %d, lock: %d, \033[0m", c->status, c->lock);
ses_pin_print(pb);
- printf("pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_NPN_OFF);
+ fprintf(stderr, "pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_NPN_OFF);
continue;
}
#endif
}
check:
- if ((c->pf->IC && SCF_EDA_OP_AMP == c->pf->IC->type)
+ if (!ctx->dc_flag
+ || (c->pf->IC && SCF_EDA_OP_AMP == c->pf->IC->type)
|| pe->v >= LP->v - SCF_EDA_V_NPN_OFF
|| pb->v <= LN->v + SCF_EDA_V_NPN_OFF) {
c->lock = 0;
scf_logi("\033[34m status: %d, lock: %d, ", c->status, c->lock);
ses_pin_print(pb);
- printf("pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\033[0m\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_NPN_OFF);
+ fprintf(stderr, "pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\033[0m\n", pb->v, pe->v, pb->v - pe->v, SCF_EDA_V_NPN_OFF);
}
return 0;
ScfEline* LP = ses_find_line_by_flag(f, SCF_EDA_PIN_POS);
ScfEline* LN = ses_find_line_by_flag(f, SCF_EDA_PIN_NEG);
- return __dc_npn_status(f, f, LP, LN);
+ return __dc_npn_status(f, f, LP, LN, ctx);
}
ses_step_t ses_step_dc_npn =
#include"ses_core.h"
-static int __dc_pnp_status(ScfEfunction* root, ScfEfunction* f, ScfEline* LP, ScfEline* LN)
+static int __dc_pnp_status(ScfEfunction* root, ScfEfunction* f, ScfEline* LP, ScfEline* LN, ses_ctx_t* ctx)
{
ScfEcomponent* c;
ScfEpin* pb;
c = f->components[i];
if (c->f) {
- int ret = __dc_pnp_status(root, c->f, LP, LN);
+ int ret = __dc_pnp_status(root, c->f, LP, LN, ctx);
if (ret < 0)
return ret;
if (le == LP && lb == LN) {
scf_loge("short connected, ");
ses_pin_print(pb);
- printf("\n");
+ fprintf(stderr, "\n");
return -EINVAL;
}
}
check:
- if ((c->pf->IC && SCF_EDA_OP_AMP == c->pf->IC->type)
+ if (!ctx->dc_flag
+ || (c->pf->IC && SCF_EDA_OP_AMP == c->pf->IC->type)
|| pb->v >= LP->v - SCF_EDA_V_NPN_OFF
|| pe->v <= LN->v + SCF_EDA_V_NPN_OFF) {
c->lock = 0;
scf_logi("\033[34m status: %d, lock: %d, ", c->status, c->lock);
ses_pin_print(pb);
- printf("pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\033[0m\n", pb->v, pe->v, pe->v - pb->v, SCF_EDA_V_PNP_OFF);
+ fprintf(stderr, "pb->v: %lg, pe->v: %lg, diff: %lg, off: %lg\033[0m\n", pb->v, pe->v, pe->v - pb->v, SCF_EDA_V_PNP_OFF);
}
return 0;
ScfEline* LP = ses_find_line_by_flag(f, SCF_EDA_PIN_POS);
ScfEline* LN = ses_find_line_by_flag(f, SCF_EDA_PIN_NEG);
- return __dc_pnp_status(f, f, LP, LN);
+ return __dc_pnp_status(f, f, LP, LN, ctx);
}
ses_step_t ses_step_dc_pnp =
#include<cairo/cairo.h>
#include"ses_core.h"
-#define SHOW_BITS 1000.0
+#define SHOW_BITS 1000.0
+#define SHOW_DATA(d) ((int64_t)((d) * SHOW_BITS) / SHOW_BITS)
static void ses_text_a(cairo_t* cr, int x, int y, double a)
{
SHOW_COLOR(cr, 0.0, 0.0, 0.7);
if (a > 1e-1 || a < -1e-1) {
- snprintf(text, sizeof(text) - 1, "%lgA", (int64_t)(a * SHOW_BITS) / SHOW_BITS);
+ snprintf(text, sizeof(text) - 1, "%lgA", SHOW_DATA(a));
cairo_move_to (cr, x, y);
cairo_show_text(cr, text);
} else if (a > 1e-5 || a < -1e-5) {
- snprintf(text, sizeof(text) - 1, "%lgmA", (int64_t)(a * 1000.0 * SHOW_BITS) / SHOW_BITS);
+ snprintf(text, sizeof(text) - 1, "%lgmA", SHOW_DATA(a * 1000.0));
cairo_move_to (cr, x, y);
cairo_show_text(cr, text);
} else if (a > 1e-9 || a < -1e-9) {
- snprintf(text, sizeof(text) - 1, "%lguA", (int64_t)(a * 1000000.0 * SHOW_BITS) / SHOW_BITS);
+ snprintf(text, sizeof(text) - 1, "%lguA", SHOW_DATA(a * 1000000.0));
cairo_move_to (cr, x, y);
cairo_show_text(cr, text);
} else if (a > 1e-13 || a < -1e-13) {
- snprintf(text, sizeof(text) - 1, "%lgnA", (int64_t)(a * 1e9 * SHOW_BITS) / SHOW_BITS);
+ snprintf(text, sizeof(text) - 1, "%lgnA", SHOW_DATA(a * 1e9));
cairo_move_to (cr, x, y);
cairo_show_text(cr, text);
SHOW_COLOR(cr, 0.0, 0.0, 0.7);
if (v > 1e-1 || v < -1e-1) {
- snprintf(text, sizeof(text) - 1, "%lgV", (int64_t)(v * SHOW_BITS) / SHOW_BITS);
+ snprintf(text, sizeof(text) - 1, "%lgV", SHOW_DATA(v));
cairo_move_to (cr, x, y);
cairo_show_text(cr, text);
} else if (v > 1e-5 || v < -1e-5) {
- snprintf(text, sizeof(text) - 1, "%lgmV", (int64_t)(v * 1000.0 * SHOW_BITS) / SHOW_BITS);
+ snprintf(text, sizeof(text) - 1, "%lgmV", SHOW_DATA(v * 1000.0));
cairo_move_to (cr, x, y);
cairo_show_text(cr, text);
} else if (v > 1e-9 || v < -1e-9) {
- snprintf(text, sizeof(text) - 1, "%lguV", (int64_t)(v * 1000000.0 * SHOW_BITS) / SHOW_BITS);
+ snprintf(text, sizeof(text) - 1, "%lguV", SHOW_DATA(v * 1000000.0));
cairo_move_to (cr, x, y);
cairo_show_text(cr, text);
cairo_move_to(cr, c->x + 10, c->y + 8);
break;
+ case SCF_EDA_Crystal:
+ n = snprintf(text, sizeof(text) - 1, "X%ld", c->id);
+
+ cairo_move_to(cr, c->x - 8 - n * 10, c->y - 12);
+ break;
+
case SCF_EDA_Capacitor:
n = snprintf(text, sizeof(text) - 1, "C%ld", c->id);
case SCF_EDA_Inductor:
n = snprintf(text, sizeof(text) - 1, "L%ld", c->id);
- cairo_move_to(cr, c->x - 12 - n * 10, c->y - 12);
+ cairo_move_to(cr, c->x - 8 - n * 10, c->y - 12);
break;
case SCF_EDA_Diode:
cairo_show_text(cr, text);
cairo_stroke(cr);
- cairo_set_font_size(cr, 16);
+ cairo_set_font_size(cr, 15);
#if 0
snprintf(text, sizeof(text) - 1, "c%ld", c->color);
cairo_move_to(cr, c->x - 10, c->y - 24);
cairo_stroke(cr);
break;
+ case SCF_EDA_Crystal:
+ cairo_rectangle(cr, c->x - 8, c->y - 3, 16, 6);
+ cairo_fill(cr);
+ cairo_stroke(cr);
+
+ p0 = c->pins[0];
+ p1 = c->pins[1];
+
+ if (p0->y < c->y) {
+ cairo_move_to(cr, p0->x, p0->y);
+ cairo_line_to(cr, c->x, c->y - 6);
+
+ cairo_move_to(cr, p1->x, p1->y);
+ cairo_line_to(cr, c->x, c->y + 6);
+
+ cairo_move_to(cr, c->x - 6, c->y + 6);
+ cairo_line_to(cr, c->x + 6, c->y + 6);
+ cairo_stroke(cr);
+
+ SHOW_COLOR(cr, 0.0, 0.0, 0.8);
+ cairo_move_to(cr, c->x - 6, c->y - 6);
+ cairo_line_to(cr, c->x + 6, c->y - 6);
+ cairo_stroke(cr);
+ } else {
+ cairo_move_to(cr, p0->x, p0->y);
+ cairo_line_to(cr, c->x, c->y + 6);
+
+ cairo_move_to(cr, p1->x, p1->y);
+ cairo_line_to(cr, c->x, c->y - 6);
+
+ cairo_move_to(cr, c->x - 6, c->y - 6);
+ cairo_line_to(cr, c->x + 6, c->y - 6);
+ cairo_stroke(cr);
+
+ SHOW_COLOR(cr, 0.0, 0.0, 0.8);
+ cairo_move_to(cr, c->x - 6, c->y + 6);
+ cairo_line_to(cr, c->x + 6, c->y + 6);
+ cairo_stroke(cr);
+ }
+
+ cairo_select_font_face(cr, "Georgia", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+
+ ses_text_v(cr, c->x + 10, c->y + 8, c->v);
+ ses_text_a(cr, c->x + 10, c->y + 23, c->a);
+
+ SHOW_COLOR(cr, 0.0, 0.0, 0.0);
+ if (c->Hz > 999999)
+ snprintf(text, sizeof(text) - 1, "%lgMHz", SHOW_DATA(c->Hz / 1e6));
+ else if (c->Hz > 999)
+ snprintf(text, sizeof(text) - 1, "%lgkHz", SHOW_DATA(c->Hz / 1000.0));
+ else
+ snprintf(text, sizeof(text) - 1, "%lgHz", SHOW_DATA(c->Hz));
+
+ cairo_move_to (cr, c->x + 8, c->y - 9);
+ cairo_show_text(cr, text);
+ cairo_stroke(cr);
+ break;
+
case SCF_EDA_Capacitor:
SHOW_COLOR(cr, 0.8, 0.0, 0.0);
SHOW_COLOR(cr, 0.0, 0.0, 0.0);
- if (c->uf < 1e-5)
- snprintf(text, sizeof(text) - 1, "%lgpF", c->uf * 1e6);
+ if (c->uf < 1e-4)
+ snprintf(text, sizeof(text) - 1, "%lgpF", SHOW_DATA(c->uf * 1e6));
else if (c->uf < 1e-2)
- snprintf(text, sizeof(text) - 1, "%lgnF", c->uf * 1000.0);
+ snprintf(text, sizeof(text) - 1, "%lgnF", SHOW_DATA(c->uf * 1000.0));
else
- snprintf(text, sizeof(text) - 1, "%lguF", c->uf);
+ snprintf(text, sizeof(text) - 1, "%lguF", SHOW_DATA(c->uf));
cairo_move_to (cr, c->x + 2, c->y - 8);
cairo_show_text(cr, text);
SHOW_COLOR(cr, 0.0, 0.0, 0.0);
if (c->uh > 100000.0)
- snprintf(text, sizeof(text) - 1, "%lgH", c->uh / 1000000.0);
+ snprintf(text, sizeof(text) - 1, "%lgH", SHOW_DATA(c->uh / 1000000.0));
else if (c->uh > 100.0)
- snprintf(text, sizeof(text) - 1, "%lgmH", c->uh / 1000.0);
- else if (c->uh < 1e-3)
- snprintf(text, sizeof(text) - 1, "%lgnH", c->uh * 1000.0);
+ snprintf(text, sizeof(text) - 1, "%lgmH", SHOW_DATA(c->uh / 1000.0));
+ else if (c->uh < 1e-2)
+ snprintf(text, sizeof(text) - 1, "%lgnH", SHOW_DATA(c->uh * 1000.0));
else
- snprintf(text, sizeof(text) - 1, "%lguH", c->uh);
+ snprintf(text, sizeof(text) - 1, "%lguH", SHOW_DATA(c->uh));
cairo_move_to (cr, c->x + 4, c->y - 5);
cairo_show_text(cr, text);
ses_text_a(cr, c->x + 8, c->y + 27, c->a);
SHOW_COLOR(cr, 0.0, 0.0, 0.0);
- if (c->r + c->dr > 1e6)
- snprintf(text, sizeof(text) - 1, "%lgMΩ", (int64_t)(c->r + c->dr) / 1000000.0);
- else if (c->r + c->dr > 999)
- snprintf(text, sizeof(text) - 1, "%lgkΩ", (int64_t)((c->r + c->dr) * 1000.0) / 1000000.0);
+ if (c->r > 999999)
+ snprintf(text, sizeof(text) - 1, "%lgMΩ", SHOW_DATA(c->r / 1e6));
+ else if (c->r > 999)
+ snprintf(text, sizeof(text) - 1, "%lgkΩ", SHOW_DATA(c->r / 1000.0));
else
- snprintf(text, sizeof(text) - 1, "%lgΩ", (int64_t)((c->r + c->dr) * 1000.0) / 1000.0);
+ snprintf(text, sizeof(text) - 1, "%lgΩ", SHOW_DATA(c->r));
cairo_move_to (cr, c->x + 8, c->y - 9);
cairo_show_text(cr, text);
n = snprintf(text, sizeof(text) - 1, "%lgV", B->pins[SCF_EDA_Battery_POS]->v);
else if (el->v > 1e-2 || el->v < -1e-2)
- n = snprintf(text, sizeof(text) - 1, "%lgV", (int64_t)(el->v * SHOW_BITS) / SHOW_BITS);
+ n = snprintf(text, sizeof(text) - 1, "%lgV", SHOW_DATA(el->v));
else if (el->v > 1e-5 || el->v < -1e-5)
- n = snprintf(text, sizeof(text) - 1, "%lgmV", (int64_t)(el->v * 1000.0 * SHOW_BITS) / SHOW_BITS);
+ n = snprintf(text, sizeof(text) - 1, "%lgmV", SHOW_DATA(el->v * 1000.0));
else
- n = snprintf(text, sizeof(text) - 1, "%lguV", (int64_t)(el->v * 1000000.0 * SHOW_BITS) / SHOW_BITS);
+ n = snprintf(text, sizeof(text) - 1, "%lguV", SHOW_DATA(el->v * 1e6));
if (el->v == B->pins[SCF_EDA_Battery_POS]->v)
SHOW_COLOR(cr, 1, 0, 0);
if (!ctx->Ashow)
return 0;
- if (!ctx->Afp) {
- ctx->Afp = fopen("a.txt", "w");
- if (!ctx->Afp)
- return -1;
- }
-
char* p;
int j = -1;
int k = SCF_EDA_NPN_E;
- fprintf(ctx->Afp, "%d", ctx->i);
+ printf("A, %d", ctx->i);
for (p = ctx->Ashow; *p; p++) {
if (SCF_EDA_NPN == c->type || SCF_EDA_PNP == c->type)
a = c->pins[k]->a;
- fprintf(ctx->Afp, ", %lg", a);
+ printf(", %lg", a);
}
j = -1;
if (SCF_EDA_NPN == c->type || SCF_EDA_PNP == c->type)
a = c->pins[k]->a;
- fprintf(ctx->Afp, ", %lg", a);
+ printf(", %lg", a);
}
- fprintf(ctx->Afp, "\n");
- fflush(ctx->Afp);
+ printf("\n");
return 0;
}
if (!ctx->Vshow)
return 0;
- if (!ctx->Vfp) {
- ctx->Vfp = fopen("v.txt", "w");
- if (!ctx->Vfp)
- return -1;
- }
-
char* p;
int op = 0;
int j = -1;
int k = -1;
- fprintf(ctx->Vfp, "%d", ctx->i);
+ printf("V, %d", ctx->i);
for (p = ctx->Vshow; *p; p++) {
&& j < f->n_elines
&& k < f->n_elines
&& k >= 0)
- fprintf(ctx->Vfp, ", %lg", f->elines[j]->v - f->elines[k]->v);
+ printf(", %lg", f->elines[j]->v - f->elines[k]->v);
} else {
if (j >= 0 && j < f->n_elines)
- fprintf(ctx->Vfp, ", %lg", f->elines[j]->v);
+ printf(", %lg", f->elines[j]->v);
}
j = -1;
&& j < f->n_elines
&& k < f->n_elines
&& k >= 0)
- fprintf(ctx->Vfp, ", %lg", f->elines[j]->v - f->elines[k]->v);
+ printf(", %lg", f->elines[j]->v - f->elines[k]->v);
} else {
if (j >= 0 && j < f->n_elines)
- fprintf(ctx->Vfp, ", %lg", f->elines[j]->v);
+ printf(", %lg", f->elines[j]->v);
}
- fprintf(ctx->Vfp, "\n");
- fflush(ctx->Vfp);
+ printf("\n");
return 0;
}
// scf_logw("");
// ses_eline_print(el);
-// printf("->v: %lg\n", el->v);
+// fprintf(stderr, "->v: %lg\n", el->v);
}
static void __open_status_IC(ScfEfunction* f, ScfEcomponent* IC, ScfEline* LP, ScfEline* LN)
__open_status_IC(f, c, LP, LN);
}
- printf("\n");
+ fprintf(stderr, "\n");
return 0;
}
ScfEline* el;
long i;
- printf("\n");
+ fprintf(stderr, "\n");
for (i = 0; i < f->n_elines; i++) {
el = f->elines[i];
scf_logi("out el: %ld, V: %lg\n", el->id, el->v);
}
- printf("\n");
+ fprintf(stderr, "\n");
for (i = 0; i < f->n_elines; i++) {
el = f->elines[i];
#if 0
scf_logw("branch l%ld, ", el->id);
ses_pin_print(p);
- printf("\n");
+ fprintf(stderr, "\n");
#endif
ret = __ses_dfs_add_ppath(__paths, ppath);
if (ret < 0)
#if 0
scf_logi("");
ses_pin_print(np);
- printf("l%ld, vflag: %d, pflag: %d\n", np->lid, np->vflag, np->pflag);
+ fprintf(stderr, "l%ld, vflag: %d, pflag: %d\n", np->lid, np->vflag, np->pflag);
#endif
return ret;
}
#if 0
scf_logi("*** rc->f->n_elines: %ld, ", rc->f->n_elines);
ses_pin_print(rp);
- printf("l%ld, vflag: %d, pflag: %d\n", rp->lid, rp->vflag, rp->pflag);
+ fprintf(stderr, "l%ld, vflag: %d, pflag: %d\n", rp->lid, rp->vflag, rp->pflag);
#endif
int size = __paths->size;
#if 0
scf_logi("\033[34m--- j:%ld, rc->f: %p, \033[0m", j, rc->f);
ses_pin_print(rp);
- printf(", l%ld, vflag: %d, pflag: %d, p: ", p->lid, p->vflag, p->pflag);
+ fprintf(stderr, ", l%ld, vflag: %d, pflag: %d, p: ", p->lid, p->vflag, p->pflag);
ses_pin_print(p);
- printf("\n");
+ fprintf(stderr, "\n");
#endif
if (p->pflag) {
assert(p != rp);
#if 0
scf_logi("");
ses_pin_print(rp);
- printf("l%ld, vflag: %d, pflag: %d\n", rp->lid, rp->vflag, rp->pflag);
+ fprintf(stderr, "l%ld, vflag: %d, pflag: %d\n", rp->lid, rp->vflag, rp->pflag);
#endif
int ret = 0;
long i;
#if 0
scf_logi("");
ses_pin_print(np);
- printf("l%ld, vflag: %d, pflag: %d\n", np->lid, np->vflag, np->pflag);
+ fprintf(stderr, "l%ld, vflag: %d, pflag: %d\n", np->lid, np->vflag, np->pflag);
#endif
el = rc->pf->elines[np->lid];
#if 0
scf_loge("off: ");
ses_pin_print(rp);
- printf("l%ld, vflag: %d, pflag: %d\n\n", rp->lid, rp->vflag, rp->pflag);
+ fprintf(stderr, "l%ld, vflag: %d, pflag: %d\n\n", rp->lid, rp->vflag, rp->pflag);
#endif
}
}
scf_logi("\033[36mconnect path: \033[0m");
ses_pin_print(p2);
ses_pin_print(__p3);
- printf("(%d)--", path1->pins->size);
+ fprintf(stderr, "(%d)--", path1->pins->size);
ses_pin_print(__p0);
ses_pin_print(p1);
- printf("(%d)\n", path0->pins->size);
+ fprintf(stderr, "(%d)\n", path0->pins->size);
#endif
int ret = __topo_path_xchg(f, paths, path0, m, path1, k + 1);
if (ret < 0)
scf_logi("\033[36mconnect path: \033[0m");
ses_pin_print(p2);
ses_pin_print(p);
- printf("(%d)--", path1->pins->size);
+ fprintf(stderr, "(%d)--", path1->pins->size);
ses_pin_print(p0);
ses_pin_print(p1);
- printf("\n");
+ fprintf(stderr, "\n");
#endif
int ret = __topo_path_xchg(f, paths, path0, 0, path1, k + 1);
if (ret < 0)
scf_logi("\033[36mconnect path: \033[0m");
ses_pin_print(p2);
ses_pin_print(__p3);
- printf("(%d)--", path1->pins->size);
+ fprintf(stderr, "(%d)--", path1->pins->size);
ses_pin_print(__p0);
ses_pin_print(p1);
- printf("(%d)\n", path0->pins->size);
+ fprintf(stderr, "(%d)\n", path0->pins->size);
#endif
int ret = __topo_path_xchg(f, paths, path0, m, path1, k + 1);
if (ret < 0)
if (SCF_EDA_Inductor != c->type)
c->a = 0;
+ if (SCF_EDA_Crystal == c->type)
+ c->v = 0;
+
for (j = 0; j < c->n_pins; j++) {
p = c->pins[j];
p->vflag = 0;
return 0;
}
-static int _topo_path_leaf(ScfEfunction* f, scf_vector_t* paths)
-{
- ses_path_t* leaf;
- ses_path_t* path;
- ScfEpin* p0;
- ScfEpin* p1;
-
- int i;
- int k;
-
- for (i = paths->size - 1; i >= 0; i--) {
- leaf = paths->data[i];
-
- p0 = leaf->pins->data[0];
- p1 = leaf->pins->data[leaf->pins->size - 1];
-
- if (SES_LINE_POS(p0) && SES_LINE_NEG(p1))
- continue;
-
- if (leaf->childs || leaf->bridges || leaf->connections)
- continue;
-
- path = NULL;
-
- k = __topo_connect(f, paths, leaf, p1, &path);
- if (k < 0) {
- k = __topo_connect(f, paths, leaf, p0, &path);
- if (k < 0)
- continue;
-
- leaf->parent_p0 = (k + 1) & ~0x1;
- leaf->parent_p1 = -2;
- } else {
- leaf->parent_p0 = -2;
- leaf->parent_p1 = k;
- }
-
- if (!path->bridges) {
- path->bridges = scf_vector_alloc();
- if (!path->bridges)
- return -ENOMEM;
- }
-
- int ret = scf_vector_add(path->bridges, leaf);
- if (ret < 0)
- return ret;
-
- assert(0 == scf_vector_del(paths, leaf));
-
- leaf->parent = path;
- }
-
- return 0;
-}
-
static int _topo_add_connection(ses_path_t* path, ses_path_t* conn)
{
if (!conn->connections) {
return 0;
}
-static int _topo_path_parallel(ScfEfunction* f, scf_vector_t* paths)
-{
- ses_path_t* parent;
- ses_path_t* child;
- ScfEpin* p0;
- ScfEpin* p1;
- ScfEpin* p2;
- ScfEpin* p3;
-
- int i;
- int j;
-
- for (i = 0; i < paths->size - 1; i++) {
- parent = paths->data[i];
-
- p0 = parent->pins->data[0];
- p1 = parent->pins->data[parent->pins->size - 1];
-
- for (j = paths->size - 1; j > i; j--) {
- child = paths->data[j];
-
- p2 = child->pins->data[0];
- p3 = child->pins->data[child->pins->size - 1];
-
- if (ses_same_line(p0, p2) && ses_same_line(p1, p3)) {
-
- int ret = ses_path_add(f, parent, child);
- if (ret < 0)
- return ret;
-
- assert(0 == scf_vector_del(paths, child));
-
- if (child->childs) {
- ret = _topo_paths_mov_top(f, child->childs, parent, child);
- if (ret < 0)
- return ret;
- }
-
- if (child->bridges) {
- ret = _topo_paths_mov_top(f, child->bridges, parent, child);
- if (ret < 0)
- return ret;
- }
- }
- }
- }
-
- return 0;
-}
-
int __ses_topo_layers(ScfEfunction* f, scf_vector_t* paths, int layout_flag)
{
ses_path_t* path;
int ret = _topo_paths_lc(f, f, ctx->paths);
if (ret < 0)
return ret;
-#if 0
- ret = __ses_topo_layers(f, ctx->paths, 0);
- if (ret < 0)
- return ret;
-
- ret = __topo_bridge_connections(f, ctx->paths, 0);
- if (ret < 0)
- return ret;
-
- ret = _topo_path_parallel(f, ctx->paths);
- if (ret < 0)
- return ret;
- ret = _topo_path_leaf(f, ctx->paths);
- if (ret < 0)
- return ret;
-#endif
ses_paths_print(ctx->paths);
return 0;
}
#include"ses_core.h"
extern ses_step_t ses_step_battery;
+extern ses_step_t ses_step_crystal;
extern ses_step_t ses_step_dc_input;
extern ses_step_t ses_step_ac_input;
static ses_step_t* ses_steps_0[] =
{
&ses_step_battery,
+ &ses_step_crystal,
&ses_step_dc_input,
// &ses_step_ac_input,
__ses_init_v(f);
for (i = 0; i < count; i++) {
- printf("\n\033[36m%s(), %d(), count: %ld\033[0m\n", __func__, __LINE__, i);
+ fprintf(stderr, "\n\033[36m%s(), %d(), count: %ld\033[0m\n", __func__, __LINE__, i);
int ret = __ses_analyse_input(f, ps, i, ctx);
if (ret < 0)
int j;
for (j = 0; j < 1; j++) {
- printf("\n\033[33m%s(), %d(), j: %d\033[0m\n", __func__, __LINE__, j);
+ fprintf(stderr, "\n\033[33m%s(), %d(), j: %d\033[0m\n", __func__, __LINE__, j);
ret = __ses_analyse_current(f, ps, i, ctx);
scf_vector_free (ctx->paths);
}
- if (ctx->Vfp)
- fclose(ctx->Vfp);
-
- if (ctx->Afp)
- fclose(ctx->Afp);
-
free(ctx);
}
}
ScfEpin* p;
int j;
- printf("[%d] ", edge->index);
+ fprintf(stderr, "[%d] ", edge->index);
if (edge->vip_m < edge->vip_n) {
}
}
- printf("(");
+ fprintf(stderr, "(");
if (edge->node1)
- printf("%d", edge->node1->index);
+ fprintf(stderr, "%d", edge->node1->index);
else
- printf(" ");
- printf("-->");
+ fprintf(stderr, " ");
+ fprintf(stderr, "-->");
if (edge->node0)
- printf("%d", edge->node0->index);
+ fprintf(stderr, "%d", edge->node0->index);
else
- printf(" ");
- printf(")");
+ fprintf(stderr, " ");
+ fprintf(stderr, ")");
if (edge->edge_b)
- printf(" b[%d]", edge->edge_b->index);
+ fprintf(stderr, " b[%d]", edge->edge_b->index);
if (edge->mirror)
- printf(" m[%d]", edge->mirror->index);
- printf("; ");
+ fprintf(stderr, " m[%d]", edge->mirror->index);
+ fprintf(stderr, "; ");
}
ses_node_t* ses_node_alloc()
ses_edge_t* edge;
int i;
- printf("node %d: \n", node->index);
+ fprintf(stderr, "node %d: \n", node->index);
for (i = 0; i < node->edges->size; i++) {
edge = node->edges->data[i];
ses_edge_print(edge);
- printf("\n");
+ fprintf(stderr, "\n");
}
- printf("\n");
+ fprintf(stderr, "\n");
}
void ses_nodes_print(scf_vector_t* nodes)
if (el->pf->IC)
ses_IC_print(el->pf->IC);
- printf("el%ld", el->id);
+ fprintf(stderr, "el%ld", el->id);
}
void ses_elines_print(ScfEfunction* f)
el = f->elines[i];
ses_eline_print(el);
- printf("->v: %lg\n", el->v);
+ fprintf(stderr, "->v: %lg\n", el->v);
}
}
for (j = 0; j < c->n_pins; j++) {
p = c->pins[j];
- printf("c%ldp%ld->v: %lg\n", p->cid, p->id, p->v);
+ fprintf(stderr, "c%ldp%ld->v: %lg\n", p->cid, p->id, p->v);
}
}
}
--- /dev/null
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+ ScfEcomponent* B;
+
+ ScfEcomponent* NAND;
+ ScfEcomponent* R1;
+ ScfEcomponent* R2;
+
+ ScfEcomponent* L;
+ ScfEcomponent* C1;
+ ScfEcomponent* C2;
+
+ ScfEfunction* f;
+ ScfEboard* b;
+
+ b = scf_eboard__alloc();
+ f = scf_efunction__alloc("LC_NAND");
+
+ 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, NAND, SCF_EDA_NAND);
+ EDA_INST_ADD_COMPONENT(f, R1, SCF_EDA_Resistor);
+ EDA_INST_ADD_COMPONENT(f, R2, SCF_EDA_Resistor);
+
+ EDA_INST_ADD_COMPONENT(f, L, SCF_EDA_Inductor);
+ EDA_INST_ADD_COMPONENT(f, C1, SCF_EDA_Capacitor);
+ EDA_INST_ADD_COMPONENT(f, C2, SCF_EDA_Capacitor);
+
+ EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_POS, NAND, SCF_EDA_NAND_POS);
+ EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_NEG, NAND, SCF_EDA_NAND_NEG);
+
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_IN0, NAND, SCF_EDA_NAND_IN1);
+
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_OUT, R1, 1);
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_IN0, R1, 0);
+
+ EDA_PIN_ADD_PIN(L, 1, C2, 1);
+ EDA_PIN_ADD_PIN(L, 0, C1, 1);
+ EDA_PIN_ADD_PIN(C1, 0, C2, 0);
+ EDA_PIN_ADD_PIN(C1, 0, B, SCF_EDA_Battery_NEG);
+
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_OUT, R2, 1);
+ EDA_PIN_ADD_PIN(R2, 0, L, 1);
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_IN0, L, 0);
+
+ NAND->pins[SCF_EDA_NAND_OUT]->flags |= SCF_EDA_PIN_OUT;
+
+ B->v = 5;
+
+ R1->r = 1000 * 1000;
+ R2->r = 1000;
+ L->uh = 1000;
+ C1->uf = 0.001;
+ C2->uf = 0.001;
+
+ scf_eboard__add_function(b, f);
+
+ long len = 0;
+ uint8_t* buf = NULL;
+
+ ScfEboard_pack(b, &buf, &len);
+ ScfEboard_free(b);
+ b = NULL;
+
+ FILE* fp = fopen("./LC_NAND_oscillator.cpk", "wb");
+ if (!fp)
+ return -EINVAL;
+
+ fwrite(buf, len, 1, fp);
+ fclose(fp);
+ return 0;
+}
#CFILES += main.c
-#CFILES += test.c
-#CFILES += fft.c
-#CFILES += dct.c
#CFILES += pnp.c
#CFILES += colpitts.c
#CFILES += astable_multivibrator.c
#CFILES += two_battery.c
-CFILES += opa_rc.c
+#CFILES += opa_rc.c
+#CFILES += crystal.c
+#CFILES += crystal_NAND.c
+#CFILES += LC_NAND.c
+
+#CFILES += test.c
+CFILES += fft.c
+#CFILES += dct.c
#CFILES += draw_timing.c
CFILES += ../scf_eda_pack.c
--- /dev/null
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+ ScfEcomponent* B;
+
+ ScfEcomponent* T;
+ ScfEcomponent* R1;
+ ScfEcomponent* R2;
+ ScfEcomponent* R3;
+
+ ScfEcomponent* X;
+ ScfEcomponent* C1;
+ ScfEcomponent* C2;
+ ScfEcomponent* C3;
+
+ ScfEfunction* f;
+ ScfEboard* b;
+
+ b = scf_eboard__alloc();
+ f = scf_efunction__alloc("crystal_oscillator");
+
+ 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, T, SCF_EDA_NPN);
+ EDA_INST_ADD_COMPONENT(f, R1, SCF_EDA_Resistor);
+ EDA_INST_ADD_COMPONENT(f, R2, SCF_EDA_Resistor);
+ EDA_INST_ADD_COMPONENT(f, R3, SCF_EDA_Resistor);
+
+ EDA_INST_ADD_COMPONENT(f, X, SCF_EDA_Crystal);
+ EDA_INST_ADD_COMPONENT(f, C1, SCF_EDA_Capacitor);
+ EDA_INST_ADD_COMPONENT(f, C2, SCF_EDA_Capacitor);
+ EDA_INST_ADD_COMPONENT(f, C3, SCF_EDA_Capacitor);
+
+ EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_POS, R1, 1);
+ EDA_PIN_ADD_PIN(R1, 0, T, SCF_EDA_NPN_C);
+ EDA_PIN_ADD_PIN(T, SCF_EDA_NPN_E, R2, 1);
+ EDA_PIN_ADD_PIN(R2, 0, B, SCF_EDA_Battery_NEG);
+
+ EDA_PIN_ADD_PIN(T, SCF_EDA_NPN_C, R3, 1);
+ EDA_PIN_ADD_PIN(T, SCF_EDA_NPN_B, R3, 0);
+
+ EDA_PIN_ADD_PIN(X, 1, C2, 1);
+ EDA_PIN_ADD_PIN(X, 0, C1, 1);
+ EDA_PIN_ADD_PIN(C1, 0, C2, 0);
+ EDA_PIN_ADD_PIN(C1, 0, B, SCF_EDA_Battery_NEG);
+
+ EDA_PIN_ADD_PIN(X, 1, T, SCF_EDA_NPN_C);
+ EDA_PIN_ADD_PIN(X, 0, C3, 1);
+ EDA_PIN_ADD_PIN(C3, 0, T, SCF_EDA_NPN_B);
+
+ T->pins[SCF_EDA_NPN_C]->flags |= SCF_EDA_PIN_OUT;
+ T->pins[SCF_EDA_NPN_C]->hfe = 220;
+
+ B->v = 5;
+
+ R1->r = 2000;
+ R2->r = 200;
+ R3->r = 1000 * 200;
+
+ X ->Hz = 3.5e6;
+ C1->uf = 22e-6;
+ C2->uf = 22e-6;
+ C3->uf = 10;
+
+ scf_eboard__add_function(b, f);
+
+ long len = 0;
+ uint8_t* buf = NULL;
+
+ ScfEboard_pack(b, &buf, &len);
+ ScfEboard_free(b);
+ b = NULL;
+
+ FILE* fp = fopen("./crystal_oscillator.cpk", "wb");
+ if (!fp)
+ return -EINVAL;
+
+ fwrite(buf, len, 1, fp);
+ fclose(fp);
+ return 0;
+}
--- /dev/null
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"ses_core.h"
+
+int main(int argc, char* argv[])
+{
+ ScfEcomponent* B;
+
+ ScfEcomponent* NAND;
+ ScfEcomponent* R1;
+ ScfEcomponent* R2;
+
+ ScfEcomponent* Rs;
+ ScfEcomponent* Ls;
+ ScfEcomponent* Cs;
+
+ ScfEcomponent* C1;
+ ScfEcomponent* C2;
+
+ ScfEfunction* f;
+ ScfEboard* b;
+
+ b = scf_eboard__alloc();
+ f = scf_efunction__alloc("crystal_NAND");
+
+ 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, NAND, SCF_EDA_NAND);
+ EDA_INST_ADD_COMPONENT(f, R1, SCF_EDA_Resistor);
+ EDA_INST_ADD_COMPONENT(f, R2, SCF_EDA_Resistor);
+
+ EDA_INST_ADD_COMPONENT(f, Rs, SCF_EDA_Resistor);
+ EDA_INST_ADD_COMPONENT(f, Ls, SCF_EDA_Inductor);
+ EDA_INST_ADD_COMPONENT(f, Cs, SCF_EDA_Capacitor);
+
+ EDA_INST_ADD_COMPONENT(f, C1, SCF_EDA_Capacitor);
+ EDA_INST_ADD_COMPONENT(f, C2, SCF_EDA_Capacitor);
+
+ EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_POS, NAND, SCF_EDA_NAND_POS);
+ EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_NEG, NAND, SCF_EDA_NAND_NEG);
+
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_IN0, NAND, SCF_EDA_NAND_IN1);
+
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_OUT, R1, 1);
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_IN0, R1, 0);
+
+ EDA_PIN_ADD_PIN(Rs, 0, Ls, 1);
+ EDA_PIN_ADD_PIN(Ls, 0, Cs, 1);
+
+ EDA_PIN_ADD_PIN(Rs, 1, C2, 1);
+ EDA_PIN_ADD_PIN(Cs, 0, C1, 1);
+ EDA_PIN_ADD_PIN(C1, 0, C2, 0);
+ EDA_PIN_ADD_PIN(C1, 0, B, SCF_EDA_Battery_NEG);
+
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_OUT, R2, 1);
+ EDA_PIN_ADD_PIN(R2, 0, Rs, 1);
+ EDA_PIN_ADD_PIN(NAND, SCF_EDA_NAND_IN0, Cs, 0);
+
+ NAND->pins[SCF_EDA_NAND_OUT]->flags |= SCF_EDA_PIN_OUT;
+
+ B->v = 5;
+
+ R1->r = 1000 * 1000;
+ R2->r = 1000;
+
+ Rs->r = 5;
+ Ls->r = 1;
+ Cs->r = 1;
+ Ls->uh = 1000;
+ Cs->uf = 22e-6;
+
+ C1->uf = 0.001;
+ C2->uf = 0.001;
+
+ scf_eboard__add_function(b, f);
+
+ long len = 0;
+ uint8_t* buf = NULL;
+
+ ScfEboard_pack(b, &buf, &len);
+ ScfEboard_free(b);
+ b = NULL;
+
+ FILE* fp = fopen("./crystal_NAND.cpk", "wb");
+ if (!fp)
+ return -EINVAL;
+
+ fwrite(buf, len, 1, fp);
+ fclose(fp);
+ return 0;
+}
#define REAL(z,i) ((z)[2*(i)])
#define IMAG(z,i) ((z)[2*(i)+1])
-#define N 512
+#define N 1024
int main()
{
cairo_surface_t* surface;
cairo_t* cr;
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1200, 720);
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, N + 100, 720);
cr = cairo_create (surface);
cairo_set_line_width(cr, 2);
cairo_set_source_rgb(cr, 1, 1, 1);
- cairo_rectangle (cr, 0, 0, 1280, 720);
+ cairo_rectangle (cr, 0, 0, N + 100, 720);
cairo_fill(cr);
cairo_stroke(cr);
double s = 0.0;
double min = 10.0;
double max = 0.0;
+ char c = 0;
for (i = 0; i < N; i++) {
- fscanf(fp, "%d, %lg", &j, &v);
+ fscanf(fp, "%c, %d, %lg", &c, &j, &v);
REAL(data, i) = v;
IMAG(data, i) = 0.0;
if (min > v)
min = v;
- cairo_move_to(cr, 40 + 1 * (i - 1), 300 - 20 * v0);
- cairo_line_to(cr, 40 + 1 * i, 300 - 20 * v);
- cairo_stroke(cr);
-
s += v;
}
v0 = v;
#endif
}
- cairo_move_to(cr, 20, 300 - 10 * (max + min));
- cairo_line_to(cr, 1200, 300 - 10 * (max + min));
+ double avg = (max + min) / 2;
+ double pix = 100.0 / (max - min);
+
+ fseek(fp, 0, SEEK_SET);
+ for (i = 0; i < N; i++) {
+ fscanf(fp, "%c, %d, %lg", &c, &j, &v);
+
+ if (i > 1 && i < N) {
+ cairo_move_to(cr, 40 + 1 * (i - 1), 300 - pix * (v0 - avg));
+ cairo_line_to(cr, 40 + 1 * i, 300 - pix * (v - avg));
+ cairo_stroke(cr);
+ }
+
+ v0 = v;
+ }
+
+ cairo_move_to(cr, 20, 300);
+ cairo_line_to(cr, N + 80, 300);
cairo_stroke(cr);
- printf("avg: %lg, max: %lg, min: %lg, 300 - 10 * (max + min): %lg\n", (max + min) / 2, max, min, 300 - 10 * (max + min));
+ printf("avg: %lg, max: %lg, min: %lg, pix: %lg/%lg\n", avg, max, min, pix, max - min);
cairo_surface_write_to_png(surface, "sin.png");
printf("%d, %lg %lg\n", i, REAL(data, i) / sqrt(N), IMAG(data, i) / sqrt(N));
}
- double f = 1000 * 1000 * imax / N;
+ double f = 2000.0 * 1e6 * imax / N;
printf("avg: %lg, Zmax: %lg, imax: %d, f: %lg\n", sum / (N - 1), Zmax, imax, f);
+++ /dev/null
-#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* R1;
- ScfEcomponent* R2;
-
- ScfEfunction* f;
- ScfEboard* b;
-
- b = scf_eboard__alloc();
- f = scf_efunction__alloc("sin_oscillator");
-
- 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, R0, SCF_EDA_Resistor);
- EDA_INST_ADD_COMPONENT(f, T0, SCF_EDA_NPN);
- EDA_INST_ADD_COMPONENT(f, R1, SCF_EDA_Resistor);
- EDA_INST_ADD_COMPONENT(f, R2, SCF_EDA_Resistor);
-
- EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_POS, R0, 1);
- EDA_PIN_ADD_PIN(B, SCF_EDA_Battery_POS, R1, 1);
-
- EDA_PIN_ADD_PIN(R0, 0, T0, SCF_EDA_NPN_B);
- EDA_PIN_ADD_PIN(R1, 0, T0, SCF_EDA_NPN_C);
- EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_E, R2, 1);
- EDA_PIN_ADD_PIN(R2, 0, B, SCF_EDA_Battery_NEG);
-
- T0->pins[SCF_EDA_NPN_C]->flags |= SCF_EDA_PIN_OUT;
- T0->pins[SCF_EDA_NPN_C]->hfe = 80;
-
- R0->r = 1000 * 10;
- R1->r = 1000;
- R2->r = 100;
-
- 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("./test.cpk", "wb");
- if (!fp)
- return -EINVAL;
-
- fwrite(buf, len, 1, fp);
- fclose(fp);
-
- return 0;
-}
+++ /dev/null
-0, 2.13208
-1, 2.38949
-2, 2.23283
-3, 2.48285
-4, 2.45575
-5, 2.56437
-6, 2.68932
-7, 2.5387
-8, 2.54218
-9, 2.53663
-10, 2.64899
-11, 2.68221
-12, 2.62339
-13, 2.80192
-14, 2.75316
-15, 2.74723
-16, 2.67439
-17, 2.95593
-18, 2.64538
-19, 2.9787
-20, 2.73434
-21, 2.93464
-22, 2.86214
-23, 2.75561
-24, 2.76333
-25, 2.94852
-26, 2.89052
-27, 3.00143
-28, 3.04008
-29, 2.95826
-30, 2.95658
-31, 2.88063
-32, 3.0633
-33, 3.10414
-34, 3.12577
-35, 3.03991
-36, 3.22946
-37, 3.30166
-38, 3.28851
-39, 3.11064
-40, 3.28833
-41, 3.30982
-42, 3.14457
-43, 3.20641
-44, 3.12846
-45, 3.31886
-46, 3.36288
-47, 3.28914
-48, 3.19167
-49, 3.36793
-50, 3.30324
-51, 3.40888
-52, 3.33287
-53, 3.24033
-54, 3.31515
-55, 3.34863
-56, 3.26273
-57, 3.16493
-58, 3.34007
-59, 3.36206
-60, 3.45495
-61, 3.50641
-62, 3.4254
-63, 3.60361
-64, 3.4665
-65, 3.63286
-66, 3.46455
-67, 3.4569
-68, 3.64808
-69, 3.57349
-70, 3.68024
-71, 3.60285
-72, 3.50104
-73, 3.68119
-74, 3.61525
-75, 3.62188
-76, 3.72188
-77, 3.75517
-78, 3.85025
-79, 3.6848
-80, 3.75468
-81, 3.76599
-82, 3.87205
-83, 3.70659
-84, 3.7928
-85, 3.80258
-86, 3.78763
-87, 3.90154
-88, 3.92385
-89, 3.94793
-90, 3.86628
-91, 4.04405
-92, 3.97506
-93, 3.80208
-94, 3.92942
-95, 3.63662
-96, 3.75362
-97, 3.93322
-98, 3.98091
-99, 4.08843
-100, 4.09603
-101, 4.01992
-102, 4.02927
-103, 4.10356
-104, 4.04043
-105, 4.01904
-106, 4.11779
-107, 3.98382
-108, 4.12752
-109, 4.13555
-110, 3.98075
-111, 4.06033
-112, 4.23588
-113, 4.0027
-114, 4.14337
-115, 3.90923
-116, 4.03169
-117, 3.96853
-118, 4.15831
-119, 4.16498
-120, 4.09948
-121, 4.08805
-122, 3.99892
-123, 4.00233
-124, 4.16627
-125, 4.30389
-126, 4.30386
-127, 4.24722
-128, 4.21934
-129, 4.11948
-130, 4.19074
-131, 4.37842
-132, 4.43089
-133, 4.36509
-134, 4.26449
-135, 4.33731
-136, 4.34222
-137, 4.3638
-138, 4.43991
-139, 4.37073
-140, 4.37363
-141, 4.3743
-142, 4.54416
-143, 4.4651
-144, 4.37942
-145, 4.37692
-146, 3.8804
-147, 4.58595
-148, 4.44275
-149, 4.48275
-150, 4.31009
-151, 4.38659
-152, 4.51879
-153, 4.4928
-154, 4.49271
-155, 4.33285
-156, 4.54341
-157, 4.49648
-158, 4.49245
-159, 4.57774
-160, 4.51809
-161, 4.59196
-162, 4.59082
-163, 4.51811
-164, 4.56934
-165, 4.44416
-166, 4.57492
-167, 4.52176
-168, 4.69915
-169, 4.61404
-170, 4.61289
-171, 4.66836
-172, 4.69716
-173, 4.54284
-174, 4.67514
-175, 4.68925
-176, 4.50114
-177, 4.51755
-178, 4.56938
-179, 4.75097
-180, 4.70176
-181, 4.49848
-182, 4.57626
-183, 4.67455
-184, 4.77866
-185, 4.70609
-186, 4.56724
-187, 4.75278
-188, 4.85325
-189, 4.63563
-190, 4.77179
-191, 4.78467
-192, 4.94007
-193, 4.96517
-194, 4.90686
-195, 4.35706
-196, 4.97794
-197, 4.96305
-198, 4.90907
-199, 4.98106
-200, 4.88974
-201, 4.98652
-202, 4.82007
-203, 4.93275
-204, 4.80944
-205, 4.24273
-206, 4.55276
-207, 4.71837
-208, 4.94968
-209, 4.94702
-210, 4.98662
-211, 4.97586
-212, 4.9887
-213, 4.9838
-214, 4.98066
-215, 4.98867
-216, 5.0318
-217, 4.98604
-218, 4.96149
-219, 4.9851
-220, 5.02289
-221, 4.9239
-222, 4.97783
-223, 4.98925
-224, 4.98781
-225, 5.08306
-226, 5.01137
-227, 4.98713
-228, 5.07848
-229, 5.00943
-230, 5.07552
-231, 5.00222
-232, 4.99044
-233, 4.98971
-234, 4.92488
-235, 4.93332
-236, 4.98987
-237, 4.81875
-238, 4.58579
-239, 4.5947
-240, 4.36254
-241, 4.29727
-242, 4.38218
-243, 4.28025
-244, 4.21077
-245, 4.18975
-246, 4.20901
-247, 4.21188
-248, 4.0726
-249, 3.9696
-250, 3.61913
-251, 3.5383
-252, 3.5628
-253, 3.43792
-254, 3.44152
-255, 3.49177
-256, 3.43107
-257, 3.38868
-258, 3.39343
-259, 3.35427
-260, 3.35321
-261, 3.36823
-262, 3.34709
-263, 3.3686
-264, 3.36832
-265, 3.32954
-266, 3.31812
-267, 3.31688
-268, 3.33872
-269, 3.28546
-270, 3.26747
-271, 3.25683
-272, 3.23746
-273, 2.8825
-274, 3.35591
-275, 3.28977
-276, 3.22464
-277, 3.21837
-278, 3.21489
-279, 3.20853
-280, 3.22325
-281, 3.21249
-282, 3.18781
-283, 3.16809
-284, 3.11347
-285, 3.15598
-286, 3.14428
-287, 3.18223
-288, 2.81148
-289, 3.37431
-290, 3.26587
-291, 3.2213
-292, 3.2213
-293, 3.20903
-294, 3.21861
-295, 3.21398
-296, 3.22911
-297, 3.22585
-298, 3.26204
-299, 3.22098
-300, 3.19378
-301, 3.20361
-302, 3.19584
-303, 3.21097
-304, 3.2821
-305, 3.21143
-306, 3.22281
-307, 3.21044
-308, 3.25118
-309, 3.17331
-310, 3.19443
-311, 3.21125
-312, 3.20545
-313, 3.26406
-314, 3.28707
-315, 3.28584
-316, 3.28617
-317, 3.22017
-318, 3.19896
-319, 3.19874
-320, 2.50462
-321, 3.39303
-322, 3.3438
-323, 3.36115
-324, 3.30999
-325, 3.31346
-326, 3.28987
-327, 3.27508
-328, 3.27076
-329, 3.26712
-330, 3.34476
-331, 3.35874
-332, 3.36514
-333, 3.24859
-334, 3.27504
-335, 3.3592
-336, 3.36832
-337, 3.30345
-338, 3.33376
-339, 3.33151
-340, 3.34543
-341, 3.38261
-342, 3.34998
-343, 3.36194
-344, 3.3355
-345, 3.38855
-346, 3.3875
-347, 3.41735
-348, 3.39603
-349, 3.40963
-350, 3.38779
-351, 3.39266
-352, 3.42148
-353, 3.41006
-354, 3.43749
-355, 3.39357
-356, 3.41801
-357, 3.44995
-358, 3.45555
-359, 3.42421
-360, 3.4234
-361, 3.42321
-362, 3.42555
-363, 3.33314
-364, 3.41304
-365, 3.43145
-366, 3.43935
-367, 3.41391
-368, 3.44901
-369, 3.3337
-370, 3.39442
-371, 3.3528
-372, 3.35754
-373, 3.37209
-374, 3.38392
-375, 3.38039
-376, 3.40601
-377, 3.41786
-378, 3.41785
-379, 3.46041
-380, 3.54033
-381, 3.52695
-382, 3.52783
-383, 3.57498
-384, 1.32579
-385, 3.6227
-386, 3.63638
-387, 3.64581
-388, 3.60546
-389, 3.59556
-390, 3.62466
-391, 3.62134
-392, 3.67367
-393, 3.68761
-394, 3.67741
-395, 3.66349
-396, 3.65938
-397, 3.61752
-398, 3.61494
-399, 3.61835
-400, 3.63379
-401, 3.63969
-402, 3.64895
-403, 3.67198
-404, 2.68957
-405, 4.03279
-406, 4.02441
-407, 2.79805
-408, 4.11949
-409, 4.04118
-410, 4.08086
-411, 3.9476
-412, 1.78051
-413, 1.68485
-414, 3.96256
-415, 3.98327
-416, 3.99431
-417, 4.00565
-418, 3.98249
-419, 4.04517
-420, 3.99148
-421, 4.0322
-422, 4.03997
-423, 4.06094
-424, 2.89884
-425, 4.22268
-426, 4.04922
-427, 2.95748
-428, 3.96907
-429, 4.09722
-430, 4.06566
-431, 2.86896
-432, 3.94281
-433, 4.0211
-434, 4.03518
-435, 3.97858
-436, 3.9948
-437, 3.98346
-438, 4.00065
-439, 4.02364
-440, 4.03978
-441, 4.07175
-442, 4.09056
-443, 2.0118
-444, 2.16126
-445, 2.03352
-446, 2.50013
-447, 3.1259
-448, 2.74588
-449, 3.29986
-450, 2.77648
-451, 2.94137
-452, 2.91157
-453, 3.00271
-454, 2.81717
-455, 3.5262
-456, 3.6481
-457, 2.95621
-458, 3.0557
-459, 2.94417
-460, 3.07852
-461, 3.44557
-462, 3.24696
-463, 3.2518
-464, 3.41009
-465, 3.61717
-466, 4.28662
-467, 5.6578
-468, 4.6118
-469, 4.67737
-470, 4.25566
-471, 3.98123
-472, 3.7769
-473, 5.18243
-474, 5.45351
-475, 4.88072
-476, 4.59733
-477, 4.88371
-478, 4.89936
-479, 4.90935
-480, 4.64011
-481, 4.96066
-482, 4.97311
-483, 4.36167
-484, 5.41538
-485, 3.43685
-486, 5.42988
-487, 3.16915
-488, 3.79269
-489, 4.99028
-490, 4.89835
-491, 3.96859
-492, 4.42669
-493, 4.20309
-494, 4.90677
-495, 4.32589
-496, 3.34028
-497, 4.92968
-498, 4.94964
-499, 3.18155
-500, 4.27806
-501, 4.9805
-502, 4.98025
-503, 4.9881
-504, 3.214
-505, 4.06582
-506, 3.25406
-507, 3.23653
-508, 4.97834
-509, 4.42907
-510, 4.95403
-511, 4.23166
-512, 4.93361
-513, 4.60094
-514, 4.40375
-515, 4.65495
-516, 4.57164
-517, 4.85458
-518, 5.00691
-519, 4.92807
-520, 4.85648
-521, 4.90386