if (!f->ef)
return -ENOMEM;
- EDA_INST_ADD_COMPONENT(f, B, SCF_EDA_Battery);
+ EDA_INST_ADD_COMPONENT(f->ef, 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;
#include"scf_native.h"
#include"scf_eda_pb.h"
-#define EDA_INST_ADD_COMPONENT(_f, _c, _type) \
- do { \
- _c = scf_ecomponent__alloc(_type); \
- if (!_c) \
- return -ENOMEM; \
- \
- (_c)->id = (_f)->ef->n_components; \
- \
- int ret = scf_efunction__add_component((_f)->ef, _c); \
- if (ret < 0) { \
- scf_ecomponent__free(_c); \
- _c = NULL; \
- return ret; \
- } \
- \
- for (size_t i = 0; i < (_c)->n_pins; i++) \
- (_c)->pins[i]->cid = (_c)->id; \
- } while (0)
-
-#define EDA_PIN_ADD_COMPONENT(_pin, _cid, _pid) \
- do { \
- int ret = scf_epin__add_component((_pin), _cid, _pid); \
- if (ret < 0) \
- return ret; \
- } while (0)
-
-#define EDA_PIN_ADD_PIN(_c0, _pid0, _c1, _pid1) \
- do { \
- int ret = scf_epin__add_component((_c0)->pins[_pid0], (_c1)->id, (_pid1)); \
- if (ret < 0) \
- return ret; \
- \
- ret = scf_epin__add_component((_c1)->pins[_pid1], (_c0)->id, (_pid0)); \
- if (ret < 0) \
- return ret; \
- } while (0)
-
typedef struct {
scf_function_t* f;
(ProtobufCMessageInit) scf_line__init,
NULL,NULL,NULL /* reserved[123] */
};
-static const ProtobufCFieldDescriptor scf_epin__field_descriptors[27] =
+static const ProtobufCFieldDescriptor scf_epin__field_descriptors[28] =
{
{
"id",
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
- "vflag",
+ "n_diodes",
24,
PROTOBUF_C_LABEL_REQUIRED,
+ PROTOBUF_C_TYPE_INT32,
+ 0, /* quantifier_offset */
+ offsetof(ScfEpin, n_diodes),
+ NULL,
+ NULL,
+ 0, /* flags */
+ 0,NULL,NULL /* reserved1,reserved2, etc */
+ },
+ {
+ "vflag",
+ 25,
+ PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
offsetof(ScfEpin, vflag),
},
{
"pflag",
- 25,
+ 26,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
{
"vconst",
- 26,
+ 27,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
},
{
"aconst",
- 27,
+ 28,
PROTOBUF_C_LABEL_REQUIRED,
PROTOBUF_C_TYPE_BOOL,
0, /* quantifier_offset */
};
static const unsigned scf_epin__field_indices_by_name[] = {
8, /* field[8] = a */
- 26, /* field[26] = aconst */
+ 27, /* field[27] = aconst */
5, /* field[5] = c_lid */
1, /* field[1] = cid */
15, /* field[15] = dr */
18, /* field[18] = jsr */
7, /* field[7] = jv */
2, /* field[2] = lid */
- 24, /* field[24] = pflag */
+ 23, /* field[23] = n_diodes */
+ 25, /* field[25] = pflag */
19, /* field[19] = pr */
10, /* field[10] = r */
17, /* field[17] = sr */
12, /* field[12] = uF */
13, /* field[13] = uH */
6, /* field[6] = v */
- 25, /* field[25] = vconst */
- 23, /* field[23] = vflag */
+ 26, /* field[26] = vconst */
+ 24, /* field[24] = vflag */
21, /* field[21] = x */
22, /* field[22] = y */
};
static const ProtobufCIntRange scf_epin__number_ranges[1 + 1] =
{
{ 1, 0 },
- { 0, 27 }
+ { 0, 28 }
};
const ProtobufCMessageDescriptor scf_epin__descriptor =
{
"ScfEpin",
"",
sizeof(ScfEpin),
- 27,
+ 28,
scf_epin__field_descriptors,
scf_epin__field_indices_by_name,
1, scf_epin__number_ranges,
double jpr;
int32_t x;
int32_t y;
+ int32_t n_diodes;
protobuf_c_boolean vflag;
protobuf_c_boolean pflag;
protobuf_c_boolean vconst;
};
#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,NULL, 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
required int32 x = 22;
required int32 y = 23;
- required bool vflag = 24;
- required bool pflag = 25;
- required bool vconst = 26;
- required bool aconst = 27;
+ required int32 n_diodes = 24;
+
+ required bool vflag = 25;
+ required bool pflag = 26;
+
+ required bool vconst = 27;
+ required bool aconst = 28;
}
message scf_econn
for (i = 0; i < N; i++) {
- EDA_INST_ADD_COMPONENT(f, T, SCF_EDA_Transistor);
- EDA_INST_ADD_COMPONENT(f, R, SCF_EDA_Resistor);
+ 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);
for (i = 0; i < N; i++) {
- EDA_INST_ADD_COMPONENT(f, D0, SCF_EDA_Diode);
- EDA_INST_ADD_COMPONENT(f, D1, SCF_EDA_Diode);
- EDA_INST_ADD_COMPONENT(f, R, SCF_EDA_Resistor);
+ 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);
EDA_PIN_ADD_INPUT(in0, i, D0, SCF_EDA_Diode_NEG);
EDA_PIN_ADD_INPUT(in1, i, D1, SCF_EDA_Diode_NEG);
for (i = 0; i < N; i++) {
- EDA_INST_ADD_COMPONENT(f, D0, SCF_EDA_Diode);
- EDA_INST_ADD_COMPONENT(f, D1, SCF_EDA_Diode);
- EDA_INST_ADD_COMPONENT(f, R, SCF_EDA_Resistor);
+ 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);
EDA_PIN_ADD_INPUT(in0, i, D0, SCF_EDA_Diode_POS);
EDA_PIN_ADD_INPUT(in1, i, D1, SCF_EDA_Diode_POS);
#define SCF_EDA_V_MIN -10000000.0
#define SCF_EDA_V_MAX 10000000.0
+#define SCF_EDA_V_Diode_ON 0.69
+#define SCF_EDA_V_Diode_OFF 0.70
+
enum {
SCF_EDA_Battery_NEG,
SCF_EDA_Battery_POS,
int scf_eboard__del_function(ScfEboard* b, ScfEfunction* f);
void scf_eboard__free (ScfEboard* b);
+#define EDA_INST_ADD_COMPONENT(_ef, _c, _type) \
+ do { \
+ _c = scf_ecomponent__alloc(_type); \
+ if (!_c) \
+ return -ENOMEM; \
+ \
+ (_c)->id = (_ef)->n_components; \
+ \
+ int ret = scf_efunction__add_component(_ef, _c); \
+ if (ret < 0) { \
+ scf_ecomponent__free(_c); \
+ _c = NULL; \
+ return ret; \
+ } \
+ \
+ for (size_t i = 0; i < (_c)->n_pins; i++) \
+ (_c)->pins[i]->cid = (_c)->id; \
+ } while (0)
+
+#define EDA_PIN_ADD_COMPONENT(_pin, _cid, _pid) \
+ do { \
+ int ret = scf_epin__add_component((_pin), _cid, _pid); \
+ if (ret < 0) \
+ return ret; \
+ } while (0)
+
+#define EDA_PIN_ADD_PIN(_c0, _pid0, _c1, _pid1) \
+ do { \
+ int ret = scf_epin__add_component((_c0)->pins[_pid0], (_c1)->id, (_pid1)); \
+ if (ret < 0) \
+ return ret; \
+ \
+ ret = scf_epin__add_component((_c1)->pins[_pid1], (_c0)->id, (_pid0)); \
+ if (ret < 0) \
+ return ret; \
+ } while (0)
+
#endif