From: yu.dongliang <18588496441@163.com> Date: Thu, 19 Oct 2023 09:52:38 +0000 (+0800) Subject: use 'NOR, NAND' in EDA module when make electronic graph, don't use 'OR, AND' X-Git-Url: http://baseworks.info/?a=commitdiff_plain;h=9baddbf3589c12392a6126c6ebb8de48c9f8c576;p=scf.git use 'NOR, NAND' in EDA module when make electronic graph, don't use 'OR, AND' --- diff --git a/core/scf_core_types.h b/core/scf_core_types.h index 6bcc398..971f318 100644 --- a/core/scf_core_types.h +++ b/core/scf_core_types.h @@ -211,6 +211,8 @@ enum scf_core_types { SCF_VAR_U8, SCF_VAR_VOID, SCF_VAR_BIT, + SCF_VAR_BIT2, + SCF_VAR_BIT4, SCF_VAR_U16, SCF_VAR_U32, SCF_VAR_U64, diff --git a/native/eda/scf_eda.h b/native/eda/scf_eda.h index a48b68d..dabdca3 100644 --- a/native/eda/scf_eda.h +++ b/native/eda/scf_eda.h @@ -31,6 +31,10 @@ static inline int eda_variable_size(scf_variable_t* v) if (SCF_VAR_BIT == v->type) return 1; + if (SCF_VAR_BIT2 == v->type) + return 2; + if (SCF_VAR_BIT4 == v->type) + return 4; return v->size << 3; } diff --git a/native/eda/scf_eda.pb-c.c b/native/eda/scf_eda.pb-c.c index dc2927b..8689756 100644 --- a/native/eda/scf_eda.pb-c.c +++ b/native/eda/scf_eda.pb-c.c @@ -385,7 +385,7 @@ const ProtobufCMessageDescriptor scf_line__descriptor = (ProtobufCMessageInit) scf_line__init, NULL,NULL,NULL /* reserved[123] */ }; -static const ProtobufCFieldDescriptor scf_epin__field_descriptors[28] = +static const ProtobufCFieldDescriptor scf_epin__field_descriptors[29] = { { "id", @@ -676,9 +676,21 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[28] = 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "vflag", + "l_pos", 25, PROTOBUF_C_LABEL_REQUIRED, + PROTOBUF_C_TYPE_INT32, + 0, /* quantifier_offset */ + offsetof(ScfEpin, l_pos), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "vflag", + 26, + PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ offsetof(ScfEpin, vflag), @@ -689,7 +701,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[28] = }, { "pflag", - 26, + 27, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ @@ -701,7 +713,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[28] = }, { "vconst", - 27, + 28, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ @@ -713,7 +725,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[28] = }, { "aconst", - 28, + 29, PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_TYPE_BOOL, 0, /* quantifier_offset */ @@ -726,7 +738,7 @@ static const ProtobufCFieldDescriptor scf_epin__field_descriptors[28] = }; static const unsigned scf_epin__field_indices_by_name[] = { 8, /* field[8] = a */ - 27, /* field[27] = aconst */ + 28, /* field[28] = aconst */ 5, /* field[5] = c_lid */ 1, /* field[1] = cid */ 15, /* field[15] = dr */ @@ -739,9 +751,10 @@ static const unsigned scf_epin__field_indices_by_name[] = { 11, /* field[11] = jr */ 18, /* field[18] = jsr */ 7, /* field[7] = jv */ + 24, /* field[24] = l_pos */ 2, /* field[2] = lid */ 23, /* field[23] = n_diodes */ - 25, /* field[25] = pflag */ + 26, /* field[26] = pflag */ 19, /* field[19] = pr */ 10, /* field[10] = r */ 17, /* field[17] = sr */ @@ -749,15 +762,15 @@ static const unsigned scf_epin__field_indices_by_name[] = { 12, /* field[12] = uF */ 13, /* field[13] = uH */ 6, /* field[6] = v */ - 26, /* field[26] = vconst */ - 24, /* field[24] = vflag */ + 27, /* field[27] = vconst */ + 25, /* field[25] = vflag */ 21, /* field[21] = x */ 22, /* field[22] = y */ }; static const ProtobufCIntRange scf_epin__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 28 } + { 0, 29 } }; const ProtobufCMessageDescriptor scf_epin__descriptor = { @@ -767,7 +780,7 @@ const ProtobufCMessageDescriptor scf_epin__descriptor = "ScfEpin", "", sizeof(ScfEpin), - 28, + 29, scf_epin__field_descriptors, scf_epin__field_indices_by_name, 1, scf_epin__number_ranges, diff --git a/native/eda/scf_eda.pb-c.h b/native/eda/scf_eda.pb-c.h index 24e3c9d..c8234f3 100644 --- a/native/eda/scf_eda.pb-c.h +++ b/native/eda/scf_eda.pb-c.h @@ -70,6 +70,7 @@ struct _ScfEpin int32_t x; int32_t y; int32_t n_diodes; + int32_t l_pos; protobuf_c_boolean vflag; protobuf_c_boolean pflag; protobuf_c_boolean vconst; @@ -77,7 +78,7 @@ struct _ScfEpin }; #define SCF_EPIN__INIT \ { PROTOBUF_C_MESSAGE_INIT (&scf_epin__descriptor) \ - , 0, 0, 0, 0, 0,NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + , 0, 0, 0, 0, 0,NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } struct _ScfEconn diff --git a/native/eda/scf_eda.proto b/native/eda/scf_eda.proto index 9338efe..f793189 100644 --- a/native/eda/scf_eda.proto +++ b/native/eda/scf_eda.proto @@ -41,12 +41,13 @@ message scf_epin required int32 y = 23; required int32 n_diodes = 24; + required int32 l_pos = 25; - required bool vflag = 25; - required bool pflag = 26; + required bool vflag = 26; + required bool pflag = 27; - required bool vconst = 27; - required bool aconst = 28; + required bool vconst = 28; + required bool aconst = 29; } message scf_econn diff --git a/native/eda/scf_eda_inst.c b/native/eda/scf_eda_inst.c index 2179c08..10dc574 100644 --- a/native/eda/scf_eda_inst.c +++ b/native/eda/scf_eda_inst.c @@ -76,6 +76,189 @@ } \ } while (0) +#define EDA_PIN_ADD_INPUT_EF(_in, _i, _ef, _p) \ + EDA_PIN_ADD_INPUT(_in, _i, (_ef)->components[(_p)->cid], (_p)->id) + + +static int __eda_bit_nand(scf_function_t* f, ScfEpin** in0, ScfEpin** in1, ScfEpin** out) +{ + ScfEcomponent* B = f->ef->components[0]; + ScfEcomponent* T0 = NULL; + ScfEcomponent* T1 = NULL; + ScfEcomponent* R0 = NULL; + ScfEcomponent* R1 = NULL; + ScfEcomponent* R = NULL; + + EDA_INST_ADD_COMPONENT(f->ef, T0, SCF_EDA_NPN); + EDA_INST_ADD_COMPONENT(f->ef, T1, SCF_EDA_NPN); + EDA_INST_ADD_COMPONENT(f->ef, R0, SCF_EDA_Resistor); + EDA_INST_ADD_COMPONENT(f->ef, R1, SCF_EDA_Resistor); + EDA_INST_ADD_COMPONENT(f->ef, R, SCF_EDA_Resistor); + + EDA_PIN_ADD_PIN(R, 1, B, SCF_EDA_Battery_POS); + EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_C, R, 0); + EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_E, T1, SCF_EDA_NPN_C); + EDA_PIN_ADD_PIN(T1, SCF_EDA_NPN_E, B, SCF_EDA_Battery_NEG); + + EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_B, R0, 0); + EDA_PIN_ADD_PIN(T1, SCF_EDA_NPN_B, R1, 0); + + *in0 = R0->pins[1]; + *in1 = R1->pins[1]; + *out = R ->pins[0]; + return 0; +} + +static int __eda_bit_nor(scf_function_t* f, ScfEpin** in0, ScfEpin** in1, ScfEpin** out) +{ + ScfEcomponent* B = f->ef->components[0]; + ScfEcomponent* T0 = NULL; + ScfEcomponent* T1 = NULL; + ScfEcomponent* R0 = NULL; + ScfEcomponent* R1 = NULL; + ScfEcomponent* R = NULL; + + EDA_INST_ADD_COMPONENT(f->ef, T0, SCF_EDA_NPN); + EDA_INST_ADD_COMPONENT(f->ef, T1, SCF_EDA_NPN); + EDA_INST_ADD_COMPONENT(f->ef, R0, SCF_EDA_Resistor); + EDA_INST_ADD_COMPONENT(f->ef, R1, SCF_EDA_Resistor); + EDA_INST_ADD_COMPONENT(f->ef, R, SCF_EDA_Resistor); + + EDA_PIN_ADD_PIN(R, 1, B, SCF_EDA_Battery_POS); + EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_C, R, 0); + EDA_PIN_ADD_PIN(T1, SCF_EDA_NPN_C, R, 0); + EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_C, T1, SCF_EDA_NPN_C); + EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_E, T1, SCF_EDA_NPN_E); + EDA_PIN_ADD_PIN(T1, SCF_EDA_NPN_E, B, SCF_EDA_Battery_NEG); + + EDA_PIN_ADD_PIN(T0, SCF_EDA_NPN_B, R0, 0); + EDA_PIN_ADD_PIN(T1, SCF_EDA_NPN_B, R1, 0); + + *in0 = R0->pins[1]; + *in1 = R1->pins[1]; + *out = R ->pins[0]; + return 0; +} + +static int __eda_bit_not(scf_function_t* f, ScfEpin** in, ScfEpin** out) +{ + ScfEcomponent* B = f->ef->components[0]; + ScfEcomponent* T = NULL; + ScfEcomponent* R = NULL; + + EDA_INST_ADD_COMPONENT(f->ef, R, SCF_EDA_Resistor); + EDA_INST_ADD_COMPONENT(f->ef, T, SCF_EDA_NPN); + + EDA_PIN_ADD_PIN(R, 1, B, SCF_EDA_Battery_POS); + EDA_PIN_ADD_PIN(T, SCF_EDA_NPN_C, R, 0); + EDA_PIN_ADD_PIN(T, SCF_EDA_NPN_E, B, SCF_EDA_Battery_NEG); + + *in = T->pins[SCF_EDA_NPN_B]; + *out = R->pins[0]; + return 0; +} + +static int __eda_bit_and(scf_function_t* f, ScfEpin** in0, ScfEpin** in1, ScfEpin** out) +{ + ScfEpin* nad0 = NULL; + ScfEpin* nad1 = NULL; + ScfEpin* nad_ = NULL; + + ScfEpin* not0 = NULL; + ScfEpin* not_ = NULL; + + int ret = __eda_bit_nand(f, &nad0, &nad1, &nad_); + if (ret < 0) + return ret; + + ret = __eda_bit_not(f, ¬0, ¬_); + if (ret < 0) + return ret; + + EDA_PIN_ADD_PIN_EF(f->ef, not0, nad_); + + *in0 = nad0; + *in1 = nad1; + *out = not_; + return 0; +} + +static int __eda_bit_or(scf_function_t* f, ScfEpin** in0, ScfEpin** in1, ScfEpin** out) +{ + ScfEpin* nor0 = NULL; + ScfEpin* nor1 = NULL; + ScfEpin* nor_ = NULL; + + ScfEpin* not0 = NULL; + ScfEpin* not_ = NULL; + + int ret = __eda_bit_nor(f, &nor0, &nor1, &nor_); + if (ret < 0) + return ret; + + ret = __eda_bit_not(f, ¬0, ¬_); + if (ret < 0) + return ret; + + EDA_PIN_ADD_PIN_EF(f->ef, not0, nor_); + + *in0 = nor0; + *in1 = nor1; + *out = not_; + return 0; +} + +/* + x + y = ~(x & y) & (x | y) + x + y = (x NAND y) & (x | y) + x + y = ~(~(x NAND y) | ~(x | y)) + x + y = ~(x NAND y) NOR (x NOR y)) + cf = ~(x NAND y) + */ +static int __eda_bit_add(scf_function_t* f, ScfEpin** in0, ScfEpin** in1, ScfEpin** out, ScfEpin** cf) +{ + ScfEpin* nad0 = NULL; + ScfEpin* nad1 = NULL; + ScfEpin* nad_ = NULL; + + ScfEpin* not = NULL; + ScfEpin* cf_ = NULL; + + ScfEpin* nor0 = NULL; + ScfEpin* nor1 = NULL; + ScfEpin* nor_ = NULL; + + ScfEpin* nor2 = NULL; + ScfEpin* nor3 = NULL; + ScfEpin* out_ = NULL; + + int ret = __eda_bit_nand(f, &nad0, &nad1, &nad_); + if (ret < 0) + return ret; + + ret = __eda_bit_not(f, ¬, &cf_); + if (ret < 0) + return ret; + EDA_PIN_ADD_PIN_EF(f->ef, not, nad_); + + ret = __eda_bit_nor(f, &nor0, &nor1, &nor_); + if (ret < 0) + return ret; + EDA_PIN_ADD_PIN_EF(f->ef, nor0, nad0); + EDA_PIN_ADD_PIN_EF(f->ef, nor1, nad1); + + ret = __eda_bit_nor(f, &nor2, &nor3, &out_); + if (ret < 0) + return ret; + EDA_PIN_ADD_PIN_EF(f->ef, nor2, cf_); + EDA_PIN_ADD_PIN_EF(f->ef, nor3, nor_); + + *in0 = nad0; + *in1 = nad1; + *out = out_; + *cf = cf_; + return 0; +} static int _eda_inst_bit_not_handler(scf_native_t* ctx, scf_3ac_code_t* c) { @@ -84,10 +267,6 @@ static int _eda_inst_bit_not_handler(scf_native_t* ctx, scf_3ac_code_t* c) scf_dag_node_t* in = src->dag_node; scf_dag_node_t* out = dst->dag_node; - ScfEcomponent* T = NULL; - ScfEcomponent* R = NULL; - ScfEcomponent* B = f->ef->components[0]; - int i; int N = eda_variable_size(in->var); @@ -98,17 +277,16 @@ static int _eda_inst_bit_not_handler(scf_native_t* ctx, scf_3ac_code_t* c) for (i = 0; i < N; i++) { - EDA_INST_ADD_COMPONENT(f->ef, T, SCF_EDA_Transistor); - EDA_INST_ADD_COMPONENT(f->ef, R, SCF_EDA_Resistor); - - EDA_PIN_ADD_INPUT(in, i, T, SCF_EDA_Transistor_B); + ScfEpin* pi = NULL; + ScfEpin* po = NULL; - EDA_PIN_ADD_PIN(T, SCF_EDA_Transistor_C, R, 1); - EDA_PIN_ADD_PIN(T, SCF_EDA_Transistor_E, B, SCF_EDA_Battery_NEG); + int ret = __eda_bit_not(f, &pi, &po); + if (ret < 0) + return ret; - EDA_PIN_ADD_PIN(R, 0, B, SCF_EDA_Battery_POS); + EDA_PIN_ADD_INPUT(in, i, f->ef->components[pi->cid], pi->id); - out->pins[i] = T->pins[SCF_EDA_Transistor_C]; + out->pins[i] = po; } return 0; @@ -122,11 +300,6 @@ static int _eda_inst_bit_and_handler(scf_native_t* ctx, scf_3ac_code_t* c) scf_dag_node_t* in1 = src1->dag_node; scf_dag_node_t* out = dst ->dag_node; - ScfEcomponent* D0 = NULL; - ScfEcomponent* D1 = NULL; - ScfEcomponent* R = NULL; - ScfEcomponent* B = f->ef->components[0]; - int i; int N = eda_variable_size(in0->var); @@ -139,20 +312,18 @@ static int _eda_inst_bit_and_handler(scf_native_t* ctx, scf_3ac_code_t* c) for (i = 0; i < N; i++) { - EDA_INST_ADD_COMPONENT(f->ef, D0, SCF_EDA_Diode); - EDA_INST_ADD_COMPONENT(f->ef, D1, SCF_EDA_Diode); - EDA_INST_ADD_COMPONENT(f->ef, R, SCF_EDA_Resistor); + ScfEpin* p0 = NULL; + ScfEpin* p1 = NULL; + ScfEpin* po = NULL; - EDA_PIN_ADD_INPUT(in0, i, D0, SCF_EDA_Diode_NEG); - EDA_PIN_ADD_INPUT(in1, i, D1, SCF_EDA_Diode_NEG); + int ret = __eda_bit_and(f, &p0, &p1, &po); + if (ret < 0) + return ret; - EDA_PIN_ADD_PIN(D0, SCF_EDA_Diode_POS, D1, SCF_EDA_Diode_POS); - EDA_PIN_ADD_PIN(D0, SCF_EDA_Diode_POS, R, 1); - EDA_PIN_ADD_PIN(D1, SCF_EDA_Diode_POS, R, 1); + EDA_PIN_ADD_INPUT(in0, i, f->ef->components[p0->cid], p0->id); + EDA_PIN_ADD_INPUT(in1, i, f->ef->components[p1->cid], p1->id); - EDA_PIN_ADD_PIN(R, 0, B, SCF_EDA_Battery_POS); - - out->pins[i] = R ->pins[1]; + out->pins[i] = po; } return 0; @@ -166,9 +337,44 @@ static int _eda_inst_bit_or_handler(scf_native_t* ctx, scf_3ac_code_t* c) scf_dag_node_t* in1 = src1->dag_node; scf_dag_node_t* out = dst ->dag_node; - ScfEcomponent* D0 = NULL; - ScfEcomponent* D1 = NULL; - ScfEcomponent* R = NULL; + int i; + int N = eda_variable_size(in0->var); + + EDA_INST_IN_CHECK(in0, N); + EDA_INST_IN_CHECK(in1, N); + + in0->n_pins = N; + in1->n_pins = N; + out->n_pins = N; + + for (i = 0; i < N; i++) { + + ScfEpin* p0 = NULL; + ScfEpin* p1 = NULL; + ScfEpin* po = NULL; + + int ret = __eda_bit_or(f, &p0, &p1, &po); + if (ret < 0) + return ret; + + EDA_PIN_ADD_INPUT(in0, i, f->ef->components[p0->cid], p0->id); + EDA_PIN_ADD_INPUT(in1, i, f->ef->components[p1->cid], p1->id); + + out->pins[i] = po; + } + + return 0; +} + +static int _eda_inst_add_handler(scf_native_t* ctx, scf_3ac_code_t* c) +{ + EDA_INST_OP3_CHECK() + + scf_dag_node_t* in0 = src0->dag_node; + scf_dag_node_t* in1 = src1->dag_node; + scf_dag_node_t* out = dst ->dag_node; + + ScfEpin* Pc = NULL; ScfEcomponent* B = f->ef->components[0]; int i; @@ -183,20 +389,21 @@ static int _eda_inst_bit_or_handler(scf_native_t* ctx, scf_3ac_code_t* c) for (i = 0; i < N; i++) { - EDA_INST_ADD_COMPONENT(f->ef, D0, SCF_EDA_Diode); - EDA_INST_ADD_COMPONENT(f->ef, D1, SCF_EDA_Diode); - EDA_INST_ADD_COMPONENT(f->ef, R, SCF_EDA_Resistor); + ScfEpin* p0 = NULL; + ScfEpin* p1 = NULL; + ScfEpin* cf = NULL; + ScfEpin* res = NULL; - EDA_PIN_ADD_INPUT(in0, i, D0, SCF_EDA_Diode_POS); - EDA_PIN_ADD_INPUT(in1, i, D1, SCF_EDA_Diode_POS); + int ret = __eda_bit_add(f, &p0, &p1, &res, &cf); + if (ret < 0) + return ret; - EDA_PIN_ADD_PIN(D0, SCF_EDA_Diode_NEG, D1, SCF_EDA_Diode_NEG); - EDA_PIN_ADD_PIN(D0, SCF_EDA_Diode_NEG, R, 0); - EDA_PIN_ADD_PIN(D1, SCF_EDA_Diode_NEG, R, 0); + EDA_PIN_ADD_INPUT_EF(in0, i, f->ef, p0); + EDA_PIN_ADD_INPUT_EF(in1, i, f->ef, p1); - EDA_PIN_ADD_PIN(R, 1, B, SCF_EDA_Battery_NEG); - - out->pins[i] = R ->pins[0]; + Pc = cf; // carry flag + out->pins[i] = res; // result + cf->flags |= SCF_EDA_PIN_CF; } return 0; @@ -567,6 +774,8 @@ static eda_inst_handler_t eda_inst_handlers[] = {SCF_OP_BIT_AND, _eda_inst_bit_and_handler}, {SCF_OP_BIT_OR, _eda_inst_bit_or_handler}, + {SCF_OP_ADD, _eda_inst_add_handler}, + {SCF_OP_3AC_TEQ, _eda_inst_teq_handler}, {SCF_OP_3AC_CMP, _eda_inst_cmp_handler}, diff --git a/native/eda/scf_eda_pb.c b/native/eda/scf_eda_pb.c index c5ec14c..62edc7d 100644 --- a/native/eda/scf_eda_pb.c +++ b/native/eda/scf_eda_pb.c @@ -11,7 +11,8 @@ static int component_pins[SCF_EDA_Components_NB] = 2, // SCF_EDA_Inductor SCF_EDA_Diode_NB, - SCF_EDA_Transistor_NB, + SCF_EDA_NPN_NB, + SCF_EDA_PNP_NB, }; static scf_edata_t component_datas[] = @@ -26,11 +27,15 @@ static scf_edata_t component_datas[] = static scf_edata_t pin_datas[] = { - {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {SCF_EDA_None, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + + {SCF_EDA_Diode, 0, SCF_EDA_Diode_NEG, 0, 0, 750, 0, 0, 0, 0}, + + {SCF_EDA_NPN, 0, SCF_EDA_NPN_B, 0, 0, 750, 0, 0, 0, 0}, + {SCF_EDA_NPN, 0, SCF_EDA_NPN_C, 0, 0, 50, 0, 0, 0, 150}, - {SCF_EDA_Diode, 0, SCF_EDA_Diode_NEG, 0, 0, 750, 0, 0, 0, 0}, - {SCF_EDA_Transistor, 0, SCF_EDA_Transistor_B, 0, 0, 750, 0, 0, 0, 0}, - {SCF_EDA_Transistor, 0, SCF_EDA_Transistor_C, 0, 0, 750, 0, 0, 0, 100}, + {SCF_EDA_PNP, 0, SCF_EDA_PNP_B, 0, 0, 750, 0, 0, 0, 0}, + {SCF_EDA_PNP, 0, SCF_EDA_PNP_C, 0, 0, 50, 0, 0, 0, 150}, }; static scf_edata_t* _pin_find_data(const uint64_t type, const uint64_t model, const uint64_t pid) diff --git a/native/eda/scf_eda_pb.h b/native/eda/scf_eda_pb.h index 059f2b6..5fdb4ba 100644 --- a/native/eda/scf_eda_pb.h +++ b/native/eda/scf_eda_pb.h @@ -12,7 +12,8 @@ enum { SCF_EDA_Inductor, SCF_EDA_Diode, - SCF_EDA_Transistor, + SCF_EDA_NPN, + SCF_EDA_PNP, SCF_EDA_Components_NB, }; @@ -22,6 +23,7 @@ enum { #define SCF_EDA_PIN_OUT 2 #define SCF_EDA_PIN_POS 4 #define SCF_EDA_PIN_NEG 8 +#define SCF_EDA_PIN_CF 16 #define SCF_EDA_V_INIT -10001001.0 #define SCF_EDA_V_MIN -10000000.0 @@ -50,10 +52,17 @@ enum { }; enum { - SCF_EDA_Transistor_B, - SCF_EDA_Transistor_E, - SCF_EDA_Transistor_C, - SCF_EDA_Transistor_NB, + SCF_EDA_NPN_B, + SCF_EDA_NPN_E, + SCF_EDA_NPN_C, + SCF_EDA_NPN_NB, +}; + +enum { + SCF_EDA_PNP_B, + SCF_EDA_PNP_E, + SCF_EDA_PNP_C, + SCF_EDA_PNP_NB, }; typedef struct { @@ -147,4 +156,7 @@ void scf_eboard__free (ScfEboard* b); return ret; \ } while (0) +#define EDA_PIN_ADD_PIN_EF(_ef, _p0, _p1) \ + EDA_PIN_ADD_PIN((_ef)->components[(_p0)->cid], (_p0)->id, (_ef)->components[(_p1)->cid], (_p1)->id) + #endif diff --git a/parse/scf_parse.c b/parse/scf_parse.c index eb07ab9..bfdc50d 100644 --- a/parse/scf_parse.c +++ b/parse/scf_parse.c @@ -24,6 +24,8 @@ scf_base_type_t base_types[] = {SCF_VAR_VOID, "void", 1}, {SCF_VAR_BIT, "bit", 1}, + {SCF_VAR_BIT2, "bit2_t", 1}, + {SCF_VAR_BIT4, "bit4_t", 1}, {SCF_VAR_INT, "int", 4}, {SCF_VAR_FLOAT, "float", 4},