From 7adbe8da41ded4dcf798af2355ecf02eb5173831 Mon Sep 17 00:00:00 2001 From: "yu.dongliang" <18588496441@163.com> Date: Wed, 27 Sep 2023 17:43:52 +0800 Subject: [PATCH] scf_eda_pb.h --- scf_eda_pb.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/scf_eda_pb.h b/scf_eda_pb.h index a1586c4..059f2b6 100644 --- a/scf_eda_pb.h +++ b/scf_eda_pb.h @@ -110,4 +110,41 @@ int scf_eboard__add_function(ScfEboard* b, ScfEfunction* f); 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 -- 2.25.1