From 82a2535d38c6954649dba3da1bc7992555b292d1 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 8 May 2020 14:13:31 +0200 Subject: [PATCH] netlist: remove family_setter and other maintenance. (nw) - removed family_setter - naming alignment, family becomes model. - architecture cleanups.) - reviewed reset logic. - pass truthtable family as string to factory. This is another set of changes on the path to align logic families and models. As a side effect, the object model now makes a clear distinction between analog models and logic models. The number of macros in nl_base.h has decreased significantly due to these changes. --- src/lib/netlist/analog/nld_bjt.cpp | 10 +- src/lib/netlist/analog/nld_generic_models.h | 6 +- src/lib/netlist/analog/nld_mosfet.cpp | 4 +- src/lib/netlist/analog/nld_opamps.cpp | 10 +- src/lib/netlist/analog/nld_switches.cpp | 4 +- src/lib/netlist/analog/nlid_fourterm.h | 10 +- src/lib/netlist/analog/nlid_twoterm.h | 22 +- src/lib/netlist/devices/nld_4006.cpp | 9 +- src/lib/netlist/devices/nld_4020.cpp | 8 +- src/lib/netlist/devices/nld_4066.cpp | 8 +- src/lib/netlist/devices/nld_4316.cpp | 4 +- src/lib/netlist/devices/nld_74107.cpp | 2 +- src/lib/netlist/devices/nld_74123.cpp | 4 +- src/lib/netlist/devices/nld_74161.cpp | 12 +- src/lib/netlist/devices/nld_74164.cpp | 12 +- src/lib/netlist/devices/nld_74165.cpp | 14 +- src/lib/netlist/devices/nld_74166.cpp | 14 +- src/lib/netlist/devices/nld_74174.cpp | 15 +- src/lib/netlist/devices/nld_74175.cpp | 12 +- src/lib/netlist/devices/nld_74192.cpp | 15 +- src/lib/netlist/devices/nld_74193.cpp | 13 +- src/lib/netlist/devices/nld_74194.cpp | 11 +- src/lib/netlist/devices/nld_7442.cpp | 12 +- src/lib/netlist/devices/nld_7448.cpp | 10 +- src/lib/netlist/devices/nld_7473.cpp | 2 +- src/lib/netlist/devices/nld_7475.cpp | 12 +- src/lib/netlist/devices/nld_7483.cpp | 10 +- src/lib/netlist/devices/nld_7490.cpp | 14 +- src/lib/netlist/devices/nld_7492.cpp | 14 +- src/lib/netlist/devices/nld_7497.cpp | 15 +- src/lib/netlist/devices/nld_82S115.cpp | 10 +- src/lib/netlist/devices/nld_82S16.cpp | 20 +- src/lib/netlist/devices/nld_9310.cpp | 16 +- src/lib/netlist/devices/nld_am2847.cpp | 11 +- src/lib/netlist/devices/nld_dm9314.cpp | 19 +- src/lib/netlist/devices/nld_dm9334.cpp | 19 +- src/lib/netlist/devices/nld_log.cpp | 2 +- src/lib/netlist/devices/nld_ne555.cpp | 28 +- src/lib/netlist/devices/nld_r2r_dac.cpp | 2 +- src/lib/netlist/devices/nld_system.cpp | 4 +- src/lib/netlist/devices/nld_system.h | 4 +- src/lib/netlist/devices/nlid_proxy.cpp | 10 +- src/lib/netlist/devices/nlid_proxy.h | 10 +- src/lib/netlist/devices/nlid_system.h | 28 +- src/lib/netlist/devices/nlid_truthtable.cpp | 18 +- src/lib/netlist/devices/nlid_truthtable.h | 10 +- src/lib/netlist/examples/vs.c | 32 -- src/lib/netlist/macro/nlm_other.cpp | 4 +- src/lib/netlist/nl_base.cpp | 113 ++-- src/lib/netlist/nl_base.h | 560 +++++++++++--------- src/lib/netlist/nl_config.h | 4 + src/lib/netlist/nl_factory.cpp | 2 +- src/lib/netlist/nl_factory.h | 8 +- src/lib/netlist/plib/prandom.h | 2 +- 54 files changed, 644 insertions(+), 600 deletions(-) delete mode 100644 src/lib/netlist/examples/vs.c diff --git a/src/lib/netlist/analog/nld_bjt.cpp b/src/lib/netlist/analog/nld_bjt.cpp index a4ae9a38c9f..59f6860ce10 100644 --- a/src/lib/netlist/analog/nld_bjt.cpp +++ b/src/lib/netlist/analog/nld_bjt.cpp @@ -122,7 +122,7 @@ namespace analog // Have a common start for transistors - NETLIB_OBJECT(QBJT) + NETLIB_BASE_OBJECT(QBJT) { public: enum q_type { @@ -171,7 +171,7 @@ namespace analog NETLIB_OBJECT_DERIVED(QBJT_switch, QBJT) { - NETLIB_CONSTRUCTOR_DERIVED(QBJT_switch, QBJT) + NETLIB_CONSTRUCTOR(QBJT_switch) , m_RB(*this, "m_RB", true) , m_RC(*this, "m_RC", true) , m_BC(*this, "m_BC", true) @@ -214,7 +214,7 @@ namespace analog NETLIB_OBJECT_DERIVED(QBJT_EB, QBJT) { public: - NETLIB_CONSTRUCTOR_DERIVED(QBJT_EB, QBJT) + NETLIB_CONSTRUCTOR(QBJT_EB) , m_modacc(m_model) , m_gD_BC(*this, "m_D_BC") , m_gD_BE(*this, "m_D_BE") @@ -235,13 +235,13 @@ namespace analog if (m_modacc.m_CJE > nlconst::zero()) { - create_and_register_subdevice("m_CJE", m_CJE); + create_and_register_subdevice(*this, "m_CJE", m_CJE); connect("B", "m_CJE.1"); connect("E", "m_CJE.2"); } if (m_modacc.m_CJC > nlconst::zero()) { - create_and_register_subdevice("m_CJC", m_CJC); + create_and_register_subdevice(*this, "m_CJC", m_CJC); connect("B", "m_CJC.1"); connect("C", "m_CJC.2"); } diff --git a/src/lib/netlist/analog/nld_generic_models.h b/src/lib/netlist/analog/nld_generic_models.h index 04ab9231791..26e483cbfc5 100644 --- a/src/lib/netlist/analog/nld_generic_models.h +++ b/src/lib/netlist/analog/nld_generic_models.h @@ -45,7 +45,7 @@ namespace analog class generic_capacitor { public: - generic_capacitor(device_t &dev, const pstring &name) + generic_capacitor(core_device_t &dev, const pstring &name) : m_h(dev, name + ".m_h", nlconst::zero()) , m_c(dev, name + ".m_c", nlconst::zero()) , m_v(dev, name + ".m_v", nlconst::zero()) @@ -133,7 +133,7 @@ namespace analog struct generic_capacitor_const { public: - generic_capacitor_const(device_t &dev, const pstring &name) + generic_capacitor_const(core_device_t &dev, const pstring &name) : m_gmin(nlconst::zero()) { plib::unused_var(dev, name); @@ -210,7 +210,7 @@ namespace analog class generic_diode { public: - generic_diode(device_t &dev, const pstring &name) + generic_diode(core_device_t &dev, const pstring &name) : m_Vd(dev, name + ".m_Vd", nlconst::diode_start_voltage()) , m_Id(dev, name + ".m_Id", nlconst::zero()) , m_G(dev, name + ".m_G", nlconst::cgminalt()) diff --git a/src/lib/netlist/analog/nld_mosfet.cpp b/src/lib/netlist/analog/nld_mosfet.cpp index e7dce0db3bc..3e21a8d028c 100644 --- a/src/lib/netlist/analog/nld_mosfet.cpp +++ b/src/lib/netlist/analog/nld_mosfet.cpp @@ -145,7 +145,7 @@ namespace analog // Have a common start for mosfets - NETLIB_OBJECT(FET) + NETLIB_BASE_OBJECT(FET) { public: enum q_type { @@ -181,7 +181,7 @@ namespace analog NETLIB_OBJECT_DERIVED(MOSFET, FET) { public: - NETLIB_CONSTRUCTOR_DERIVED(MOSFET, FET) + NETLIB_CONSTRUCTOR(MOSFET) , m_DG(*this, "m_DG", true) , m_SG(*this, "m_SG", true) , m_SD(*this, "m_SD", true) diff --git a/src/lib/netlist/analog/nld_opamps.cpp b/src/lib/netlist/analog/nld_opamps.cpp index 26a69b52b59..1890ba85826 100644 --- a/src/lib/netlist/analog/nld_opamps.cpp +++ b/src/lib/netlist/analog/nld_opamps.cpp @@ -102,7 +102,7 @@ namespace netlist }; - NETLIB_OBJECT(opamp) + NETLIB_BASE_OBJECT(opamp) { NETLIB_CONSTRUCTOR(opamp) , m_RP(*this, "RP1") @@ -135,8 +135,8 @@ namespace netlist } if (m_type == 2 || m_type == 3) { - create_and_register_subdevice("CP1", m_CP); - create_and_register_subdevice("EBUF", m_EBUF); + create_and_register_subdevice(*this, "CP1", m_CP); + create_and_register_subdevice(*this, "EBUF", m_EBUF); #if TEST_ALT_OUTPUT create_and_register_subdevice("RO", m_RO); #endif @@ -166,8 +166,8 @@ namespace netlist if (m_type == 3) { - create_and_register_subdevice("DN", m_DN, "D(IS=1e-15 N=1)"); - create_and_register_subdevice("DP", m_DP, "D(IS=1e-15 N=1)"); + create_and_register_subdevice(*this, "DN", m_DN, "D(IS=1e-15 N=1)"); + create_and_register_subdevice(*this, "DP", m_DP, "D(IS=1e-15 N=1)"); connect("DP.K", "VH"); connect("VL", "DN.A"); diff --git a/src/lib/netlist/analog/nld_switches.cpp b/src/lib/netlist/analog/nld_switches.cpp index 84f864641ce..45515a8c416 100644 --- a/src/lib/netlist/analog/nld_switches.cpp +++ b/src/lib/netlist/analog/nld_switches.cpp @@ -19,7 +19,7 @@ namespace netlist // SWITCH // ---------------------------------------------------------------------------------------- - NETLIB_OBJECT(switch1) + NETLIB_BASE_OBJECT(switch1) { NETLIB_CONSTRUCTOR(switch1) , m_R(*this, "R") @@ -60,7 +60,7 @@ namespace netlist // SWITCH2 // ---------------------------------------------------------------------------------------- - NETLIB_OBJECT(switch2) + NETLIB_BASE_OBJECT(switch2) { NETLIB_CONSTRUCTOR(switch2) , m_R1(*this, "R1") diff --git a/src/lib/netlist/analog/nlid_fourterm.h b/src/lib/netlist/analog/nlid_fourterm.h index 34c6b4f9a8b..d3bfad330b6 100644 --- a/src/lib/netlist/analog/nlid_fourterm.h +++ b/src/lib/netlist/analog/nlid_fourterm.h @@ -33,7 +33,7 @@ namespace analog { // // RI = 1 / NETLIST_GMIN // - NETLIB_OBJECT(VCCS) + NETLIB_BASE_OBJECT(VCCS) { public: NETLIB_CONSTRUCTOR_EX(VCCS, nl_fptype ri = nlconst::magic(1e9)) @@ -91,7 +91,7 @@ namespace analog { NETLIB_OBJECT_DERIVED(LVCCS, VCCS) { public: - NETLIB_CONSTRUCTOR_DERIVED(LVCCS, VCCS) + NETLIB_CONSTRUCTOR(LVCCS) , m_cur_limit(*this, "CURLIM", nlconst::magic(1000.0)) , m_vi(nlconst::zero()) { @@ -137,7 +137,7 @@ namespace analog { NETLIB_OBJECT_DERIVED(CCCS, VCCS) { public: - NETLIB_CONSTRUCTOR_DERIVED_PASS(CCCS, VCCS, nlconst::one()) + NETLIB_CONSTRUCTOR_PASS(CCCS, nlconst::one()) { set_gfac(-plib::reciprocal(m_RI())); } @@ -179,7 +179,7 @@ namespace analog { NETLIB_OBJECT_DERIVED(VCVS, VCCS) { public: - NETLIB_CONSTRUCTOR_DERIVED(VCVS, VCCS) + NETLIB_CONSTRUCTOR(VCVS) , m_RO(*this, "RO", nlconst::one()) , m_OP2(*this, "_OP2", &m_ON2) , m_ON2(*this, "_ON2", &m_OP2) @@ -231,7 +231,7 @@ namespace analog { NETLIB_OBJECT_DERIVED(CCVS, VCCS) { public: - NETLIB_CONSTRUCTOR_DERIVED_PASS(CCVS, VCCS, nlconst::one()) + NETLIB_CONSTRUCTOR_PASS(CCVS, nlconst::one()) , m_RO(*this, "RO", nlconst::one()) , m_OP2(*this, "_OP2", &m_ON2) , m_ON2(*this, "_ON2", &m_OP2) diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h index f7226ee57db..14fad2cf051 100644 --- a/src/lib/netlist/analog/nlid_twoterm.h +++ b/src/lib/netlist/analog/nlid_twoterm.h @@ -68,7 +68,7 @@ namespace analog return d2; } - NETLIB_OBJECT(twoterm) + NETLIB_BASE_OBJECT(twoterm) { // FIXME locate use case of owned = true and eliminate them if possible NETLIB_CONSTRUCTOR_EX(twoterm, bool terminals_owned = false) @@ -171,7 +171,7 @@ namespace analog NETLIB_OBJECT_DERIVED(R_base, twoterm) { - NETLIB_CONSTRUCTOR_DERIVED(R_base, twoterm) + NETLIB_CONSTRUCTOR(R_base) { } @@ -197,7 +197,7 @@ namespace analog NETLIB_OBJECT_DERIVED(R, R_base) { - NETLIB_CONSTRUCTOR_DERIVED(R, R_base) + NETLIB_CONSTRUCTOR(R) , m_R(*this, "R", nlconst::magic(1e9)) { } @@ -231,7 +231,7 @@ namespace analog // nld_POT // ----------------------------------------------------------------------------- - NETLIB_OBJECT(POT) + NETLIB_BASE_OBJECT(POT) { NETLIB_CONSTRUCTOR(POT) , m_R1(*this, "_R1") @@ -263,7 +263,7 @@ namespace analog param_logic_t m_Reverse; }; - NETLIB_OBJECT(POT2) + NETLIB_BASE_OBJECT(POT2) { NETLIB_CONSTRUCTOR(POT2) , m_R1(*this, "_R1") @@ -297,7 +297,7 @@ namespace analog NETLIB_OBJECT_DERIVED(C, twoterm) { public: - NETLIB_CONSTRUCTOR_DERIVED(C, twoterm) + NETLIB_CONSTRUCTOR(C) , m_C(*this, "C", nlconst::magic(1e-6)) , m_cap(*this, "m_cap") { @@ -398,7 +398,7 @@ namespace analog NETLIB_OBJECT_DERIVED(L, twoterm) { public: - NETLIB_CONSTRUCTOR_DERIVED(L, twoterm) + NETLIB_CONSTRUCTOR(L) , m_L(*this, "L", nlconst::magic(1e-6)) , m_gmin(nlconst::zero()) , m_G(nlconst::zero()) @@ -486,7 +486,7 @@ namespace analog NETLIB_OBJECT_DERIVED(D, twoterm) { public: - NETLIB_CONSTRUCTOR_DERIVED_EX(D, twoterm, const pstring &model = "D") + NETLIB_CONSTRUCTOR_EX(D, const pstring &model = "D") , m_model(*this, "MODEL", model) , m_D(*this, "m_D") { @@ -514,7 +514,7 @@ namespace analog NETLIB_OBJECT_DERIVED(Z, twoterm) { public: - NETLIB_CONSTRUCTOR_DERIVED_EX(Z, twoterm, const pstring &model = "D") + NETLIB_CONSTRUCTOR_EX(Z, const pstring &model = "D") , m_model(*this, "MODEL", model) , m_D(*this, "m_D") , m_R(*this, "m_R") @@ -547,7 +547,7 @@ namespace analog NETLIB_OBJECT_DERIVED(VS, twoterm) { public: - NETLIB_CONSTRUCTOR_DERIVED(VS, twoterm) + NETLIB_CONSTRUCTOR(VS) , m_t(*this, "m_t", nlconst::zero()) , m_R(*this, "RI", nlconst::magic(0.1)) , m_V(*this, "V", nlconst::zero()) @@ -596,7 +596,7 @@ namespace analog NETLIB_OBJECT_DERIVED(CS, twoterm) { public: - NETLIB_CONSTRUCTOR_DERIVED(CS, twoterm) + NETLIB_CONSTRUCTOR(CS) , m_t(*this, "m_t", nlconst::zero()) , m_I(*this, "I", nlconst::one()) , m_func(*this,"FUNC", "") diff --git a/src/lib/netlist/devices/nld_4006.cpp b/src/lib/netlist/devices/nld_4006.cpp index 96e38813402..24d7f4bb9a9 100644 --- a/src/lib/netlist/devices/nld_4006.cpp +++ b/src/lib/netlist/devices/nld_4006.cpp @@ -14,8 +14,8 @@ namespace netlist { NETLIB_OBJECT(CD4006) { - NETLIB_CONSTRUCTOR(CD4006) - NETLIB_FAMILY("CD4XXX") + NETLIB_CONSTRUCTOR_MODEL(CD4006, "CD4XXX") + //NETLIB_FAMILY("CD4XXX") , m_CLOCK(*this, "CLOCK") , m_I(*this, {"D1", "D2", "D3", "D4"}) , m_Q(*this, {"D1P4", "D1P4S", "D2P4", "D2P5", "D3P4", "D4P4", "D3P5"}) @@ -25,10 +25,6 @@ namespace netlist { } - NETLIB_RESETI() - { - } - NETLIB_UPDATEI() { if (m_last_clock && !m_CLOCK()) @@ -93,7 +89,6 @@ namespace netlist register_subalias("14", "A.VDD"); } - NETLIB_RESETI() {} NETLIB_UPDATEI() {} private: NETLIB_SUB(CD4006) A; diff --git a/src/lib/netlist/devices/nld_4020.cpp b/src/lib/netlist/devices/nld_4020.cpp index 4fbe3486b4f..0a5d72aae56 100644 --- a/src/lib/netlist/devices/nld_4020.cpp +++ b/src/lib/netlist/devices/nld_4020.cpp @@ -15,8 +15,8 @@ namespace netlist { NETLIB_OBJECT(CD4020_sub) { - NETLIB_CONSTRUCTOR(CD4020_sub) - NETLIB_FAMILY("CD4XXX") + NETLIB_CONSTRUCTOR_MODEL(CD4020_sub, "CD4XXX") + //NETLIB_FAMILY() , m_IP(*this, "IP") , m_Q(*this, {"Q1", "_Q2", "_Q3", "Q4", "Q5", "Q6", "Q7", "Q8", "Q9", "Q10", "Q11", "Q12", "Q13", "Q14"}) @@ -59,8 +59,8 @@ namespace netlist NETLIB_OBJECT(CD4020) { - NETLIB_CONSTRUCTOR(CD4020) - NETLIB_FAMILY("CD4XXX") + NETLIB_CONSTRUCTOR_MODEL(CD4020, "CD4XXX") + //NETLIB_FAMILY() , m_sub(*this, "sub") , m_RESET(*this, "RESET") { diff --git a/src/lib/netlist/devices/nld_4066.cpp b/src/lib/netlist/devices/nld_4066.cpp index 30536b2009d..254a1a93de3 100644 --- a/src/lib/netlist/devices/nld_4066.cpp +++ b/src/lib/netlist/devices/nld_4066.cpp @@ -30,8 +30,8 @@ namespace netlist { NETLIB_OBJECT(CD4066_GATE) { - NETLIB_CONSTRUCTOR(CD4066_GATE) - NETLIB_FAMILY("CD4XXX") + NETLIB_CONSTRUCTOR_MODEL(CD4066_GATE, "CD4XXX") + //NETLIB_FAMILY("CD4XXX") , m_supply(*this, "VDD", "VSS") , m_R(*this, "R") , m_control(*this, "CTL") @@ -83,8 +83,8 @@ namespace netlist NETLIB_OBJECT(CD4066_GATE_DYNAMIC) { - NETLIB_CONSTRUCTOR(CD4066_GATE_DYNAMIC) - NETLIB_FAMILY("CD4XXX") + NETLIB_CONSTRUCTOR_MODEL(CD4066_GATE_DYNAMIC, "CD4XXX") + //NETLIB_FAMILY("CD4XXX") , m_supply(*this, "VDD", "VSS") , m_R(*this, "R", true) , m_DUM1(*this, "_DUM1", true) diff --git a/src/lib/netlist/devices/nld_4316.cpp b/src/lib/netlist/devices/nld_4316.cpp index 8d807b79bbd..81d7c981295 100644 --- a/src/lib/netlist/devices/nld_4316.cpp +++ b/src/lib/netlist/devices/nld_4316.cpp @@ -13,8 +13,8 @@ namespace netlist { namespace devices { NETLIB_OBJECT(CD4316_GATE) { - NETLIB_CONSTRUCTOR(CD4316_GATE) - NETLIB_FAMILY("CD4XXX") + NETLIB_CONSTRUCTOR_MODEL(CD4316_GATE, "CD4XXX") + //NETLIB_FAMILY("CD4XXX") , m_supply(*this, "VDD", "VSS") , m_R(*this, "_R") , m_S(*this, "S") diff --git a/src/lib/netlist/devices/nld_74107.cpp b/src/lib/netlist/devices/nld_74107.cpp index 38da321d75e..6494079c7ec 100644 --- a/src/lib/netlist/devices/nld_74107.cpp +++ b/src/lib/netlist/devices/nld_74107.cpp @@ -62,7 +62,7 @@ namespace netlist NETLIB_OBJECT_DERIVED(74107, 74107A) { public: - NETLIB_CONSTRUCTOR_DERIVED(74107, 74107A) + NETLIB_CONSTRUCTOR(74107) { m_delay[0] = delay_107[0]; m_delay[1] = delay_107[1]; diff --git a/src/lib/netlist/devices/nld_74123.cpp b/src/lib/netlist/devices/nld_74123.cpp index e4cdd8b5312..7477d3bd40c 100644 --- a/src/lib/netlist/devices/nld_74123.cpp +++ b/src/lib/netlist/devices/nld_74123.cpp @@ -229,8 +229,8 @@ namespace netlist NETLIB_OBJECT(4538_dip) { - NETLIB_CONSTRUCTOR(4538_dip) - NETLIB_FAMILY("CD4XXX") + NETLIB_CONSTRUCTOR_MODEL(4538_dip, "CD4XXX") + //NETLIB_FAMILY() , m_A(*this, "A") , m_B(*this, "B") { diff --git a/src/lib/netlist/devices/nld_74161.cpp b/src/lib/netlist/devices/nld_74161.cpp index 7c116948be3..4eb102aa05e 100644 --- a/src/lib/netlist/devices/nld_74161.cpp +++ b/src/lib/netlist/devices/nld_74161.cpp @@ -37,7 +37,11 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_cnt = 0; + m_last_CLK = 0; + } NETLIB_UPDATEI(); friend class NETLIB_NAME(74161_dip); @@ -92,12 +96,6 @@ namespace netlist NETLIB_SUB(74161) A; }; - NETLIB_RESET(74161) - { - m_cnt = 0; - m_last_CLK = 0; - } - // FIXME: Timing static constexpr const std::array delay = { diff --git a/src/lib/netlist/devices/nld_74164.cpp b/src/lib/netlist/devices/nld_74164.cpp index d42e49640a6..39b60ae20dc 100644 --- a/src/lib/netlist/devices/nld_74164.cpp +++ b/src/lib/netlist/devices/nld_74164.cpp @@ -29,7 +29,12 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_cnt = 0; + m_last_CLK = 0; + } + NETLIB_UPDATEI(); friend class NETLIB_NAME(74164_dip); @@ -71,11 +76,6 @@ namespace netlist NETLIB_SUB(74164) A; }; - NETLIB_RESET(74164) - { - m_cnt = 0; - m_last_CLK = 0; - } NETLIB_UPDATE(74164) { diff --git a/src/lib/netlist/devices/nld_74165.cpp b/src/lib/netlist/devices/nld_74165.cpp index 41ad825af9a..36f5e59b7f5 100644 --- a/src/lib/netlist/devices/nld_74165.cpp +++ b/src/lib/netlist/devices/nld_74165.cpp @@ -28,7 +28,11 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_shifter = 0; + m_last_CLK = 0; + } NETLIB_UPDATEI(); friend class NETLIB_NAME(74165_dip); @@ -70,17 +74,11 @@ namespace netlist register_subalias("16", "A.VCC"); } NETLIB_RESETI() {} - NETLIB_UPDATEI() {}; + NETLIB_UPDATEI() {} private: NETLIB_SUB(74165) A; }; - NETLIB_RESET(74165) - { - m_shifter = 0; - m_last_CLK = 0; - } - // FIXME: Timing NETLIB_UPDATE(74165) { diff --git a/src/lib/netlist/devices/nld_74166.cpp b/src/lib/netlist/devices/nld_74166.cpp index 75595342d15..7011ef013df 100644 --- a/src/lib/netlist/devices/nld_74166.cpp +++ b/src/lib/netlist/devices/nld_74166.cpp @@ -29,7 +29,12 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_shifter = 0; + m_last_CLRQ = 0; + m_last_CLK = 0; + } NETLIB_UPDATEI(); friend class NETLIB_NAME(74166_dip); @@ -77,13 +82,6 @@ namespace netlist NETLIB_SUB(74166) A; }; - NETLIB_RESET(74166) - { - m_shifter = 0; - m_last_CLRQ = 0; - m_last_CLK = 0; - } - NETLIB_UPDATE(74166) { netlist_sig_t old_qh = m_QH.net().Q(); diff --git a/src/lib/netlist/devices/nld_74174.cpp b/src/lib/netlist/devices/nld_74174.cpp index c6073322082..a95b5ca967c 100644 --- a/src/lib/netlist/devices/nld_74174.cpp +++ b/src/lib/netlist/devices/nld_74174.cpp @@ -25,7 +25,12 @@ namespace devices { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_CLK.set_state(logic_t::STATE_INP_LH); + m_clrq = 0; + m_data = 0xFF; + } NETLIB_UPDATEI(); NETLIB_HANDLERI(sub) @@ -111,14 +116,6 @@ namespace devices } } - - NETLIB_RESET(74174) - { - m_CLK.set_state(logic_t::STATE_INP_LH); - m_clrq = 0; - m_data = 0xFF; - } - NETLIB_DEVICE_IMPL(74174, "TTL_74174", "+CLK,+D1,+D2,+D3,+D4,+D5,+D6,+CLRQ,@VCC,@GND") NETLIB_DEVICE_IMPL(74174_dip,"TTL_74174_DIP", "") diff --git a/src/lib/netlist/devices/nld_74175.cpp b/src/lib/netlist/devices/nld_74175.cpp index 0a1ea12d7aa..9d84128fc31 100644 --- a/src/lib/netlist/devices/nld_74175.cpp +++ b/src/lib/netlist/devices/nld_74175.cpp @@ -26,7 +26,11 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_CLK.set_state(logic_t::STATE_INP_LH); + m_data = 0xFF; + } NETLIB_UPDATEI(); NETLIB_HANDLERI(clk); @@ -116,12 +120,6 @@ namespace netlist } - NETLIB_RESET(74175) - { - m_CLK.set_state(logic_t::STATE_INP_LH); - m_data = 0xFF; - } - NETLIB_DEVICE_IMPL(74175, "TTL_74175", "+CLK,+D1,+D2,+D3,+D4,+CLRQ,@VCC,@GND") NETLIB_DEVICE_IMPL(74175_dip,"TTL_74175_DIP", "") diff --git a/src/lib/netlist/devices/nld_74192.cpp b/src/lib/netlist/devices/nld_74192.cpp index c201efe1feb..36c1426ee37 100644 --- a/src/lib/netlist/devices/nld_74192.cpp +++ b/src/lib/netlist/devices/nld_74192.cpp @@ -36,7 +36,13 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_cnt = 0; + m_last_CU = 0; + m_last_CD = 0; + } + NETLIB_UPDATEI(); friend class NETLIB_NAME(74192_dip); @@ -101,13 +107,6 @@ namespace netlist NETLIB_SUB(74192) A; }; - NETLIB_RESET(74192) - { - m_cnt = 0; - m_last_CU = 0; - m_last_CD = 0; - } - // FIXME: Timing static constexpr const std::array delay = { diff --git a/src/lib/netlist/devices/nld_74193.cpp b/src/lib/netlist/devices/nld_74193.cpp index 80866ecc1ee..fab3b172f5c 100644 --- a/src/lib/netlist/devices/nld_74193.cpp +++ b/src/lib/netlist/devices/nld_74193.cpp @@ -35,7 +35,12 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_cnt = 0; + m_last_CU = 0; + m_last_CD = 0; + } NETLIB_UPDATEI(); friend class NETLIB_NAME(74193_dip); @@ -88,12 +93,6 @@ namespace netlist NETLIB_SUB(74193) A; }; - NETLIB_RESET(74193) - { - m_cnt = 0; - m_last_CU = 0; - m_last_CD = 0; - } // FIXME: Timing static constexpr const std::array delay = diff --git a/src/lib/netlist/devices/nld_74194.cpp b/src/lib/netlist/devices/nld_74194.cpp index a5cce89feee..8b56692e546 100644 --- a/src/lib/netlist/devices/nld_74194.cpp +++ b/src/lib/netlist/devices/nld_74194.cpp @@ -29,7 +29,11 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_last_CLK = 0; + m_last_Q = 0; + } NETLIB_UPDATEI(); friend class NETLIB_NAME(74194_dip); @@ -78,11 +82,6 @@ namespace netlist NETLIB_SUB(74194) A; }; - NETLIB_RESET(74194) - { - m_last_CLK = 0; - m_last_Q = 0; - } // FIXME: Timing NETLIB_UPDATE(74194) diff --git a/src/lib/netlist/devices/nld_7442.cpp b/src/lib/netlist/devices/nld_7442.cpp index e745b1785ba..54bcb0feed4 100644 --- a/src/lib/netlist/devices/nld_7442.cpp +++ b/src/lib/netlist/devices/nld_7442.cpp @@ -30,7 +30,11 @@ namespace devices private: NETLIB_UPDATEI(); - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_val = 0; + m_last_val = 0; + } void update_outputs() noexcept { @@ -79,12 +83,6 @@ namespace devices NETLIB_SUB(7442) A; }; - NETLIB_RESET(7442) - { - m_val = 0; - m_last_val = 0; - } - NETLIB_UPDATE(7442) { const netlist_sig_t new_A = m_A(); diff --git a/src/lib/netlist/devices/nld_7448.cpp b/src/lib/netlist/devices/nld_7448.cpp index e0943ac3a2c..80314db4ee1 100644 --- a/src/lib/netlist/devices/nld_7448.cpp +++ b/src/lib/netlist/devices/nld_7448.cpp @@ -31,7 +31,10 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_state = 0; + } NETLIB_UPDATEI(); friend class NETLIB_NAME(7448_dip); @@ -149,11 +152,6 @@ namespace netlist } } - NETLIB_RESET(7448) - { - m_state = 0; - } - NETLIB_DEVICE_IMPL(7448, "TTL_7448", "+A,+B,+C,+D,+LTQ,+BIQ,+RBIQ,@VCC,@GND") NETLIB_DEVICE_IMPL(7448_dip, "TTL_7448_DIP", "") diff --git a/src/lib/netlist/devices/nld_7473.cpp b/src/lib/netlist/devices/nld_7473.cpp index 199fbb931f1..e73163edd27 100644 --- a/src/lib/netlist/devices/nld_7473.cpp +++ b/src/lib/netlist/devices/nld_7473.cpp @@ -47,7 +47,7 @@ namespace netlist NETLIB_OBJECT_DERIVED(7473A, 7473) { public: - NETLIB_CONSTRUCTOR_DERIVED(7473A, 7473) { } + NETLIB_CONSTRUCTOR(7473A) { } }; diff --git a/src/lib/netlist/devices/nld_7475.cpp b/src/lib/netlist/devices/nld_7475.cpp index e15c1718256..81ea424321a 100644 --- a/src/lib/netlist/devices/nld_7475.cpp +++ b/src/lib/netlist/devices/nld_7475.cpp @@ -26,7 +26,10 @@ namespace netlist register_subalias("Q1", m_Q[0]); } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_last_Q = 0; + } NETLIB_UPDATEI(); void update_outputs(std::size_t start, std::size_t end); @@ -46,7 +49,7 @@ namespace netlist NETLIB_OBJECT_DERIVED(7475, 7477) { - NETLIB_CONSTRUCTOR_DERIVED(7475, 7477) + NETLIB_CONSTRUCTOR(7475) , m_QQ(*this, {"QQ1", "QQ2", "QQ3", "QQ4"}) { } @@ -142,11 +145,6 @@ namespace netlist } } - NETLIB_RESET(7477) - { - m_last_Q = 0; - } - NETLIB_UPDATE(7477) { netlist_sig_t c1c2 = m_C1C2(); diff --git a/src/lib/netlist/devices/nld_7483.cpp b/src/lib/netlist/devices/nld_7483.cpp index b9d45d4d54d..265b9a9cc16 100644 --- a/src/lib/netlist/devices/nld_7483.cpp +++ b/src/lib/netlist/devices/nld_7483.cpp @@ -35,7 +35,10 @@ namespace netlist , m_power_pins(*this) { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_lastr = 0; + } NETLIB_UPDATEI(); NETLIB_HANDLERI(upd_a); NETLIB_HANDLERI(upd_b); @@ -93,11 +96,6 @@ namespace netlist NETLIB_SUB(7483) A; }; - NETLIB_RESET(7483) - { - m_lastr = 0; - } - NETLIB_HANDLER(7483, upd_a) { m_a = static_cast((m_A1() << 0) | (m_A2() << 1) | (m_A3() << 2) | (m_A4() << 3)); diff --git a/src/lib/netlist/devices/nld_7490.cpp b/src/lib/netlist/devices/nld_7490.cpp index d8680e2a1d9..f38650daeb2 100644 --- a/src/lib/netlist/devices/nld_7490.cpp +++ b/src/lib/netlist/devices/nld_7490.cpp @@ -40,7 +40,12 @@ namespace devices private: NETLIB_UPDATEI(); - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_cnt = 0; + m_last_A = 0; + m_last_B = 0; + } void update_outputs() noexcept { @@ -91,13 +96,6 @@ namespace devices NETLIB_SUB(7490) A; }; - NETLIB_RESET(7490) - { - m_cnt = 0; - m_last_A = 0; - m_last_B = 0; - } - NETLIB_UPDATE(7490) { const netlist_sig_t new_A = m_A(); diff --git a/src/lib/netlist/devices/nld_7492.cpp b/src/lib/netlist/devices/nld_7492.cpp index 4bf6d316729..603daf21588 100644 --- a/src/lib/netlist/devices/nld_7492.cpp +++ b/src/lib/netlist/devices/nld_7492.cpp @@ -38,7 +38,12 @@ namespace devices private: NETLIB_UPDATEI(); - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_cnt = 0; + m_last_A = 0; + m_last_B = 0; + } void update_outputs() noexcept { @@ -87,13 +92,6 @@ namespace devices NETLIB_SUB(7492) A; }; - NETLIB_RESET(7492) - { - m_cnt = 0; - m_last_A = 0; - m_last_B = 0; - } - NETLIB_UPDATE(7492) { const netlist_sig_t new_A = m_A(); diff --git a/src/lib/netlist/devices/nld_7497.cpp b/src/lib/netlist/devices/nld_7497.cpp index a9aab390f27..06ac9996b45 100644 --- a/src/lib/netlist/devices/nld_7497.cpp +++ b/src/lib/netlist/devices/nld_7497.cpp @@ -41,7 +41,13 @@ namespace netlist } private: - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_cnt = 0; + m_rate = 0; + m_lastclock = 0; + } + NETLIB_UPDATEI(); NETLIB_HANDLERI(noop) { } @@ -88,13 +94,6 @@ namespace netlist } }; - NETLIB_RESET(7497) - { - m_cnt = 0; - m_rate = 0; - m_lastclock = 0; - } - NETLIB_UPDATE(7497) { m_rate = rate(); diff --git a/src/lib/netlist/devices/nld_82S115.cpp b/src/lib/netlist/devices/nld_82S115.cpp index 2c0a0ef16e6..0c14a4a80c6 100644 --- a/src/lib/netlist/devices/nld_82S115.cpp +++ b/src/lib/netlist/devices/nld_82S115.cpp @@ -26,7 +26,10 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_last_O = 0; + } NETLIB_UPDATEI(); friend class NETLIB_NAME(82S115_dip); @@ -85,11 +88,6 @@ namespace netlist NETLIB_SUB(82S115) A; }; - NETLIB_RESET(82S115) - { - m_last_O = 0; - } - // FIXME: timing! NETLIB_UPDATE(82S115) { diff --git a/src/lib/netlist/devices/nld_82S16.cpp b/src/lib/netlist/devices/nld_82S16.cpp index 0a3dbf8fd61..6d7312765e1 100644 --- a/src/lib/netlist/devices/nld_82S16.cpp +++ b/src/lib/netlist/devices/nld_82S16.cpp @@ -29,7 +29,15 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + for (std::size_t i=0; i<4; i++) + { + m_ram[i] = 0; + } + m_addr = 0; + m_enq = 0; + } NETLIB_UPDATEI(); NETLIB_HANDLERI(addr) { @@ -130,16 +138,6 @@ namespace netlist } } - NETLIB_RESET(82S16) - { - for (std::size_t i=0; i<4; i++) - { - m_ram[i] = 0; - } - m_addr = 0; - m_enq = 0; - } - NETLIB_DEVICE_IMPL(82S16, "TTL_82S16", "") NETLIB_DEVICE_IMPL(82S16_dip, "TTL_82S16_DIP", "") diff --git a/src/lib/netlist/devices/nld_9310.cpp b/src/lib/netlist/devices/nld_9310.cpp index 2658026ea9e..9dd1f67332e 100644 --- a/src/lib/netlist/devices/nld_9310.cpp +++ b/src/lib/netlist/devices/nld_9310.cpp @@ -39,7 +39,13 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_CLK.set_state(logic_t::STATE_INP_LH); + m_cnt = 0; + m_loadq = 1; + m_ent = 1; + } NETLIB_UPDATEI(); NETLIB_HANDLERI(abcd) { } // do nothing @@ -190,14 +196,6 @@ namespace netlist NETLIB_SUB(9310) A; }; - NETLIB_RESET(9310) - { - m_CLK.set_state(logic_t::STATE_INP_LH); - m_cnt = 0; - m_loadq = 1; - m_ent = 1; - } - NETLIB_UPDATE(9310) { m_loadq = m_LOADQ(); diff --git a/src/lib/netlist/devices/nld_am2847.cpp b/src/lib/netlist/devices/nld_am2847.cpp index f0dc228c7b9..b86e0d6828b 100644 --- a/src/lib/netlist/devices/nld_am2847.cpp +++ b/src/lib/netlist/devices/nld_am2847.cpp @@ -84,7 +84,11 @@ namespace netlist register_subalias("VDD", "A.VDD"); } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_last_CP = 0; + } + NETLIB_UPDATEI(); friend class NETLIB_NAME(AM2847_dip); @@ -126,11 +130,6 @@ namespace netlist NETLIB_SUB(AM2847) A; }; - NETLIB_RESET(AM2847) - { - m_last_CP = 0; - } - NETLIB_UPDATE(AM2847) { if (m_last_CP && !m_CP()) diff --git a/src/lib/netlist/devices/nld_dm9314.cpp b/src/lib/netlist/devices/nld_dm9314.cpp index 6cb65a9ea90..a67b7079419 100644 --- a/src/lib/netlist/devices/nld_dm9314.cpp +++ b/src/lib/netlist/devices/nld_dm9314.cpp @@ -29,7 +29,15 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_last_MRQ = 0; + m_last_EQ = 0; + m_last_SQ = 0; + m_last_D = 0; + m_last_Q = 0; + } + NETLIB_UPDATEI(); friend class NETLIB_NAME(9314_dip); @@ -75,15 +83,6 @@ namespace netlist NETLIB_SUB(9314) A; }; - NETLIB_RESET(9314) - { - m_last_MRQ = 0; - m_last_EQ = 0; - m_last_SQ = 0; - m_last_D = 0; - m_last_Q = 0; - } - NETLIB_UPDATE(9314) { netlist_time delay = NLTIME_FROM_NS(24); //FIXME! diff --git a/src/lib/netlist/devices/nld_dm9334.cpp b/src/lib/netlist/devices/nld_dm9334.cpp index 50878de8e0b..15031f3c5fc 100644 --- a/src/lib/netlist/devices/nld_dm9334.cpp +++ b/src/lib/netlist/devices/nld_dm9334.cpp @@ -29,7 +29,15 @@ namespace netlist { } - NETLIB_RESETI(); + NETLIB_RESETI() + { + m_last_CQ = 0; + m_last_EQ = 0; + m_last_D = 0; + m_last_A = 0; + m_last_Q = 0; + } + NETLIB_UPDATEI(); friend class NETLIB_NAME(9334_dip); @@ -78,15 +86,6 @@ namespace netlist NETLIB_SUB(9334) A; }; - NETLIB_RESET(9334) - { - m_last_CQ = 0; - m_last_EQ = 0; - m_last_D = 0; - m_last_A = 0; - m_last_Q = 0; - } - NETLIB_UPDATE(9334) { uint_fast8_t a = 0; diff --git a/src/lib/netlist/devices/nld_log.cpp b/src/lib/netlist/devices/nld_log.cpp index 0662f3fc5f3..cf9ed418fe7 100644 --- a/src/lib/netlist/devices/nld_log.cpp +++ b/src/lib/netlist/devices/nld_log.cpp @@ -51,7 +51,7 @@ namespace netlist NETLIB_OBJECT_DERIVED(logD, log) { - NETLIB_CONSTRUCTOR_DERIVED(logD, log) + NETLIB_CONSTRUCTOR(logD) , m_I2(*this, "I2") { } diff --git a/src/lib/netlist/devices/nld_ne555.cpp b/src/lib/netlist/devices/nld_ne555.cpp index 793e8be842a..ae8cb1b0d52 100644 --- a/src/lib/netlist/devices/nld_ne555.cpp +++ b/src/lib/netlist/devices/nld_ne555.cpp @@ -115,7 +115,7 @@ namespace netlist return ret; } }; - +#if 1 NETLIB_OBJECT(NE555_dip) { NETLIB_CONSTRUCTOR(NE555_dip) @@ -130,20 +130,40 @@ namespace netlist register_subalias("7", "A.DISCH"); // Pin 7 register_subalias("8", "A.VCC"); // Pin 8 } - NETLIB_RESETI() {} - NETLIB_UPDATEI() {} + // FIXME: R_base needs to be removed from the code base + // The reset on R_Base executed after NE555 reset will + // overwrite values. + NETLIB_RESETI() { A.reset(); } + NETLIB_UPDATEI() { } private: NETLIB_SUB(NE555) A; }; +#else + NETLIB_OBJECT_DERIVED(NE555_dip, NE555) + { + NETLIB_CONSTRUCTOR_DERIVED(NE555_dip) + { + register_subalias("1", "GND"); // Pin 1 + register_subalias("2", "TRIG"); // Pin 2 + register_subalias("3", "OUT"); // Pin 3 + register_subalias("4", "RESET"); // Pin 4 + register_subalias("5", "CONT"); // Pin 5 + register_subalias("6", "THRESH"); // Pin 6 + register_subalias("7", "DISCH"); // Pin 7 + register_subalias("8", "VCC"); // Pin 8 + } + }; +#endif NETLIB_RESET(NE555) { +#if 0 m_R1.reset(); m_R2.reset(); m_R3.reset(); m_ROUT.reset(); m_RDIS.reset(); - +#endif /* FIXME make resistances a parameter, properly model other variants */ m_R1.set_R(nlconst::magic(5000)); m_R2.set_R(nlconst::magic(5000)); diff --git a/src/lib/netlist/devices/nld_r2r_dac.cpp b/src/lib/netlist/devices/nld_r2r_dac.cpp index 4a9524e07e0..2ea95ca4996 100644 --- a/src/lib/netlist/devices/nld_r2r_dac.cpp +++ b/src/lib/netlist/devices/nld_r2r_dac.cpp @@ -15,7 +15,7 @@ namespace netlist { NETLIB_OBJECT_DERIVED(r2r_dac, twoterm) { - NETLIB_CONSTRUCTOR_DERIVED(r2r_dac, twoterm) + NETLIB_CONSTRUCTOR(r2r_dac) , m_VIN(*this, "VIN", nlconst::one()) , m_R(*this, "R", nlconst::one()) , m_num(*this, "N", 1) diff --git a/src/lib/netlist/devices/nld_system.cpp b/src/lib/netlist/devices/nld_system.cpp index b5689d637f5..20592f9f46d 100644 --- a/src/lib/netlist/devices/nld_system.cpp +++ b/src/lib/netlist/devices/nld_system.cpp @@ -85,9 +85,9 @@ namespace devices NETLIB_DEVICE_IMPL(netlistparams, "PARAMETER", "") using NETLIB_NAME(logic_input8) = NETLIB_NAME(logic_inputN)<8>; - NETLIB_DEVICE_IMPL(logic_input8, "LOGIC_INPUT8", "IN,FAMILY") + NETLIB_DEVICE_IMPL(logic_input8, "LOGIC_INPUT8", "IN,MODEL") - NETLIB_DEVICE_IMPL(logic_input, "LOGIC_INPUT", "IN,FAMILY") + NETLIB_DEVICE_IMPL(logic_input, "LOGIC_INPUT", "IN,MODEL") NETLIB_DEVICE_IMPL_ALIAS(logic_input_ttl, logic_input, "TTL_INPUT", "IN") } // namespace devices diff --git a/src/lib/netlist/devices/nld_system.h b/src/lib/netlist/devices/nld_system.h index 70d54016fa8..b3812e8d305 100644 --- a/src/lib/netlist/devices/nld_system.h +++ b/src/lib/netlist/devices/nld_system.h @@ -22,12 +22,12 @@ #define LOGIC_INPUT(name, v, family) \ NET_REGISTER_DEV(LOGIC_INPUT, name) \ PARAM(name.IN, v) \ - PARAM(name.FAMILY, family) + PARAM(name.MODEL, family) #define LOGIC_INPUT8(name, v, family) \ NET_REGISTER_DEV(LOGIC_INPUT8, name) \ PARAM(name.IN, v) \ - PARAM(name.FAMILY, family) + PARAM(name.MODEL, family) #define ANALOG_INPUT(name, v) \ NET_REGISTER_DEV(ANALOG_INPUT, name) \ diff --git a/src/lib/netlist/devices/nlid_proxy.cpp b/src/lib/netlist/devices/nlid_proxy.cpp index 159b36407ac..65e2f5f9a74 100644 --- a/src/lib/netlist/devices/nlid_proxy.cpp +++ b/src/lib/netlist/devices/nlid_proxy.cpp @@ -19,11 +19,17 @@ namespace netlist nld_base_proxy::nld_base_proxy(netlist_state_t &anetlist, const pstring &name, const logic_t *inout_proxied) - : device_t(anetlist, name) + : device_t(anetlist, name, inout_proxied->logic_family()) , m_tp(nullptr) , m_tn(nullptr) { - set_logic_family(inout_proxied->logic_family()); + //set_logic_family(inout_proxied->logic_family()); + + if (logic_family() == nullptr) + { + // FIXME convert to error + printf("nullptr family in proxy\n"); + } const std::vector> power_syms = { {"VCC", "VEE"}, {"VCC", "GND"}, {"VDD", "VSS"}}; diff --git a/src/lib/netlist/devices/nlid_proxy.h b/src/lib/netlist/devices/nlid_proxy.h index 61b11cddff9..1425e61bfdf 100644 --- a/src/lib/netlist/devices/nlid_proxy.h +++ b/src/lib/netlist/devices/nlid_proxy.h @@ -23,7 +23,7 @@ namespace devices // nld_base_proxy // ----------------------------------------------------------------------------- - NETLIB_OBJECT(base_proxy) + class nld_base_proxy : public device_t { public: nld_base_proxy(netlist_state_t &anetlist, const pstring &name, @@ -44,7 +44,7 @@ namespace devices // nld_a_to_d_proxy // ----------------------------------------------------------------------------- - NETLIB_OBJECT_DERIVED(base_a_to_d_proxy, base_proxy) + class nld_base_a_to_d_proxy : public nld_base_proxy { public: virtual logic_output_t &out() noexcept = 0; @@ -55,7 +55,7 @@ namespace devices }; - NETLIB_OBJECT_DERIVED(a_to_d_proxy, base_a_to_d_proxy) + class nld_a_to_d_proxy : public nld_base_a_to_d_proxy { public: nld_a_to_d_proxy(netlist_state_t &anetlist, const pstring &name, @@ -81,7 +81,7 @@ namespace devices // nld_base_d_to_a_proxy // ----------------------------------------------------------------------------- - NETLIB_OBJECT_DERIVED(base_d_to_a_proxy, base_proxy) + class nld_base_d_to_a_proxy : public nld_base_proxy { public: // only used in setup @@ -93,7 +93,7 @@ namespace devices }; - NETLIB_OBJECT_DERIVED(d_to_a_proxy, base_d_to_a_proxy) + class nld_d_to_a_proxy : public nld_base_d_to_a_proxy { public: nld_d_to_a_proxy(netlist_state_t &anetlist, const pstring &name, diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index b2c2b078083..3dd9c34a137 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -53,7 +53,7 @@ namespace devices , m_feedback(*this, "FB") , m_Q(*this, "Q") , m_freq(*this, "FREQ", nlconst::magic(7159000.0 * 5.0)) - , m_FAMILY(*this, "FAMILY", "FAMILY(TYPE=TTL)") + , m_model(*this, "MODEL", "FAMILY(TYPE=TTL)") , m_supply(*this) { m_inc = netlist_time::from_fp(plib::reciprocal(m_freq()*nlconst::two())); @@ -79,7 +79,7 @@ namespace devices param_fp_t m_freq; netlist_time m_inc; - param_model_t m_FAMILY; + param_model_t m_model; NETLIB_NAME(power_pins) m_supply; }; @@ -193,10 +193,10 @@ namespace devices , m_Q(*this, "Q") , m_IN(*this, "IN", false) // make sure we get the family first - , m_FAMILY(*this, "FAMILY", "FAMILY(TYPE=TTL)") + , m_model(*this, "MODEL", "FAMILY(TYPE=TTL)") , m_supply(*this) { - set_logic_family(state().setup().family_from_model(m_FAMILY())); + set_logic_family(state().setup().family_from_model(m_model())); m_Q.set_logic_family(this->logic_family()); } @@ -212,7 +212,7 @@ namespace devices logic_output_t m_Q; param_logic_t m_IN; - param_model_t m_FAMILY; + param_model_t m_model; NETLIB_NAME(power_pins) m_supply; }; @@ -223,10 +223,10 @@ namespace devices , m_Q(*this, "Q{}") , m_IN(*this, "IN", 0) // make sure we get the family first - , m_FAMILY(*this, "FAMILY", "FAMILY(TYPE=TTL)") + , m_model(*this, "model", "MODEL(TYPE=TTL)") , m_supply(*this) { - set_logic_family(state().setup().family_from_model(m_FAMILY())); + set_logic_family(state().setup().family_from_model(m_model())); for (auto &q : m_Q) q.set_logic_family(this->logic_family()); } @@ -244,7 +244,7 @@ namespace devices object_array_t m_Q; param_int_t m_IN; - param_model_t m_FAMILY; + param_model_t m_model; NETLIB_NAME(power_pins) m_supply; }; @@ -465,11 +465,11 @@ namespace devices , m_GON(*this, "GON", nlconst::magic(1e9)) // FIXME: all switches should have some on value , m_GOFF(*this, "GOFF", nlconst::cgmin()) , m_last_state(*this, "m_last_state", 0) - , m_FAMILY(*this, "FAMILY", "FAMILY(TYPE=TTL)") + , m_model(*this, "MODEL", "FAMILY(TYPE=TTL)") , m_power_pins(*this) { // Pass on logic family - set_logic_family(state().setup().family_from_model(m_FAMILY())); + set_logic_family(state().setup().family_from_model(m_model())); m_I.set_logic_family(this->logic_family()); // connect and register pins @@ -528,7 +528,7 @@ namespace devices private: state_var m_last_state; - param_model_t m_FAMILY; + param_model_t m_model; nld_power_pins m_power_pins; }; @@ -545,12 +545,12 @@ namespace devices , m_IN(*this, "IN") , m_Q(*this, "Q") , m_QQ(*this, "QQ") - , m_FAMILY(*this, "FAMILY", "FAMILY(TYPE=TTL)") + , m_model(*this, "MODEL", "FAMILY(TYPE=TTL)") , m_power_pins(*this) , m_last_state(*this, "m_last_state", 2) // ensure first execution { // Pass on logic family - set_logic_family(state().setup().family_from_model(m_FAMILY())); + set_logic_family(state().setup().family_from_model(m_model())); m_Q.set_logic_family(this->logic_family()); m_QQ.set_logic_family(this->logic_family()); } @@ -579,7 +579,7 @@ namespace devices analog_input_t m_IN; logic_output_t m_Q; logic_output_t m_QQ; - param_model_t m_FAMILY; + param_model_t m_model; nld_power_pins m_power_pins; private: diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index f58a6853c09..5de1bd7e039 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -245,7 +245,7 @@ namespace devices : truthtable_base_element_t(name, classname, def_param, sourcefile) { } - unique_pool_ptr make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) override + unique_pool_ptr make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) override { using tt_type = nld_truthtable_t; @@ -259,14 +259,7 @@ namespace devices desc_s.parse(m_desc); } - // update truthtable family definitions - if (m_family_name != "") - m_family_desc = anetlist.setup().family_from_model(m_family_name); - - if (m_family_desc == nullptr) - throw nl_exception("family description not found for {1}", m_family_name); - - return pool.make_unique(anetlist, name, *m_family_desc, *m_ttbl, m_desc); + return pool.make_unique(anetlist, name, m_family_name, *m_ttbl, m_desc); } private: unique_pool_ptr::truthtable_t> m_ttbl; @@ -481,13 +474,14 @@ namespace factory truthtable_base_element_t::truthtable_base_element_t(const pstring &name, const pstring &classname, const pstring &def_param, const pstring &sourcefile) : factory::element_t(name, classname, def_param, sourcefile) - , m_family_desc(family_TTL()) + , m_family_name(NETLIST_DEFAULT_TRUTHTABLE_FAMILY) { } #define ENTRYY(n, m, s) case (n * 100 + m): \ { using xtype = devices::netlist_factory_truthtable_t; \ - ret = plib::make_unique(desc.name, desc.classname, desc.def_param, s); } break + ret = plib::make_unique(desc.name, desc.classname, desc.def_param, s); } \ + break #define ENTRY(n, s) ENTRYY(n, 1, s); ENTRYY(n, 2, s); ENTRYY(n, 3, s); \ ENTRYY(n, 4, s); ENTRYY(n, 5, s); ENTRYY(n, 6, s); \ @@ -516,7 +510,7 @@ namespace factory nl_assert_always(false, msg.c_str()); } ret->m_desc = desc.desc; - ret->m_family_name = desc.family; + ret->m_family_name = (desc.family != "" ? desc.family : pstring(NETLIST_DEFAULT_TRUTHTABLE_FAMILY)); return ret; } diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h index eda377f3c0a..7f2b5f1768e 100644 --- a/src/lib/netlist/devices/nlid_truthtable.h +++ b/src/lib/netlist/devices/nlid_truthtable.h @@ -38,10 +38,8 @@ namespace devices template<> struct uint_for_size<8> { using type = uint_least64_t; }; template - NETLIB_OBJECT(truthtable_t) + class NETLIB_NAME(truthtable_t) : public device_t { - private: - detail::family_setter_t m_fam; public: using type_t = typename uint_for_size::value>::type; @@ -63,10 +61,9 @@ namespace devices template nld_truthtable_t(C &owner, const pstring &name, - const logic_family_desc_t &fam, + const pstring &model, truthtable_t &ttp, const std::vector &desc) - : device_t(owner, name) - , m_fam(*this, fam) + : device_t(owner, name, model) #if USE_TT_ALTERNATIVE , m_state(*this, "m_state", 0) #endif @@ -225,7 +222,6 @@ namespace factory std::vector m_desc; pstring m_family_name; - const logic_family_desc_t *m_family_desc; }; // FIXME: the returned element is missing a pointer to the family ... diff --git a/src/lib/netlist/examples/vs.c b/src/lib/netlist/examples/vs.c deleted file mode 100644 index 6dc3543df96..00000000000 --- a/src/lib/netlist/examples/vs.c +++ /dev/null @@ -1,32 +0,0 @@ -// license:CC0 -// copyright-holders:Couriersud -/* - * vs_cs.c - * - * Voltage and current source test - * - */ - -#include "netlist/devices/net_lib.h" - -NETLIST_START(vs) - - /* Standard stuff */ - - SOLVER(Solver, 480) - PARAM(Solver.ACCURACY, 1e-6) - PARAM(Solver.METHOD, "MAT_CR") - PARAM(Solver.DYNAMIC_TS, 1) - - RES(R1, 1000) - VS(VS1, 1) - PARAM(VS1.R, 1) - PARAM(VS1.FUNC, "T 10000.0 * sin 1.0 +") - NET_C(R1.1, VS1.P) - NET_C(R1.2, VS1.N) - NET_C(GND, VS1.N) - - //LOG(tt, VS1.P) - //LOG(tt1, R1.1) - -NETLIST_END() diff --git a/src/lib/netlist/macro/nlm_other.cpp b/src/lib/netlist/macro/nlm_other.cpp index 401fe7fc172..a5d665aa17b 100644 --- a/src/lib/netlist/macro/nlm_other.cpp +++ b/src/lib/netlist/macro/nlm_other.cpp @@ -45,7 +45,7 @@ NETLIST_END() //- Identifier: NE566_DIP //- Title: NE566 Voltage Controlled Oscillator -//-Description: The LM566CN is a general purpose voltage controlled oscillator +//- Description: The LM566CN is a general purpose voltage controlled oscillator //- which may be used to generate square and triangula waves, the frequency //- of which is a very linear function of a control voltage. The frequency //- is also a function of an external resistor and capacitor. @@ -96,7 +96,7 @@ static NETLIST_START(NE566_DIP) RES(ROSQ, 5200) PARAM(VO.RO, 50) - PARAM(COMP.FAMILY, "FAMILY(IVL=0.16 IVH=0.4 OVL=0.1 OVH=0.1 ORL=50 ORH=50)") + PARAM(COMP.MODEL, "FAMILY(IVL=0.16 IVH=0.4 OVL=0.1 OVH=0.1 ORL=50 ORH=50)") PARAM(SW.GOFF, 0) // This has to be zero to block current sources NET_C(CI2.IN, VI.OP) diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index 8f84e8812d3..527257a570f 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -557,9 +557,6 @@ namespace netlist , m_hint_deactivate(false) , m_active_outputs(*this, "m_active_outputs", 1) { - // FIXME: logic_family should always be nullptr here - if (logic_family() == nullptr) - set_logic_family(family_TTL()); if (exec().stats_enabled()) m_stats = owner.make_object(); } @@ -569,10 +566,6 @@ namespace netlist , m_hint_deactivate(false) , m_active_outputs(*this, "m_active_outputs", 1) { - set_logic_family(owner.logic_family()); - //printf("%s %f %f\n", this->name().c_str(), logic_family()->R_low(), logic_family()->R_high()); - if (logic_family() == nullptr) - set_logic_family(family_TTL()); owner.state().register_device(this->name(), owned_pool_ptr(this, false)); if (exec().stats_enabled()) m_stats = owner.state().make_object(); @@ -590,20 +583,20 @@ namespace netlist } // ---------------------------------------------------------------------------------------- - // device_t + // base_device_t // ---------------------------------------------------------------------------------------- - device_t::device_t(netlist_state_t &owner, const pstring &name) + base_device_t::base_device_t(netlist_state_t &owner, const pstring &name) : core_device_t(owner, name) { } - device_t::device_t(core_device_t &owner, const pstring &name) + base_device_t::base_device_t(base_device_t &owner, const pstring &name) : core_device_t(owner, name) { } - void device_t::register_subalias(const pstring &name, const detail::core_terminal_t &term) + void base_device_t::register_subalias(const pstring &name, const detail::core_terminal_t &term) { pstring alias = this->name() + "." + name; @@ -611,7 +604,7 @@ namespace netlist state().setup().register_alias_nofqn(alias, term.name()); } - void device_t::register_subalias(const pstring &name, const pstring &aliased) + void base_device_t::register_subalias(const pstring &name, const pstring &aliased) { pstring alias = this->name() + "." + name; pstring aliased_fqn = this->name() + "." + aliased; @@ -620,33 +613,93 @@ namespace netlist state().setup().register_alias_nofqn(alias, aliased_fqn); } - void device_t::connect(const detail::core_terminal_t &t1, const detail::core_terminal_t &t2) + void base_device_t::connect(const detail::core_terminal_t &t1, const detail::core_terminal_t &t2) { state().setup().register_link_fqn(t1.name(), t2.name()); } - void device_t::connect(const pstring &t1, const pstring &t2) + void base_device_t::connect(const pstring &t1, const pstring &t2) { state().setup().register_link_fqn(name() + "." + t1, name() + "." + t2); } - // ----------------------------------------------------------------------------- - // family_setter_t - // ----------------------------------------------------------------------------- - // NOLINTNEXTLINE(modernize-use-equals-default) - detail::family_setter_t::family_setter_t() + // ---------------------------------------------------------------------------------------- + // device_t + // ---------------------------------------------------------------------------------------- + + device_t::device_t(netlist_state_t &owner, const pstring &name) + : base_device_t(owner, name) { + // FIXME: this needs debugging! + if (logic_family() == nullptr) + { + //printf("Issue with 1 %s\n", this->name().c_str()); + set_logic_family(family_TTL()); + } } - detail::family_setter_t::family_setter_t(core_device_t &dev, const pstring &desc) + device_t::device_t(netlist_state_t &owner, const pstring &name, + const pstring &model) + : base_device_t(owner, name) { - dev.set_logic_family(dev.state().setup().family_from_model(desc)); + //printf("In 1a %s: %s\n", this->name().c_str(), model.c_str()); + set_logic_family(state().setup().family_from_model(model)); //printf("%s %f %f\n", this->name().c_str(), logic_family()->R_low(), logic_family()->R_high()); + // FIXME: this needs debugging! + if (logic_family() == nullptr) + { + printf("Issue with 1a %s\n", this->name().c_str()); + set_logic_family(family_TTL()); + } } - detail::family_setter_t::family_setter_t(core_device_t &dev, const logic_family_desc_t &desc) + device_t::device_t(netlist_state_t &owner, const pstring &name, + const logic_family_desc_t *desc) + : base_device_t(owner, name) { - dev.set_logic_family(&desc); + set_logic_family(desc); + // FIXME: this needs debugging! + if (logic_family() == nullptr) + { + printf("Issue with 1b %s\n", this->name().c_str()); + set_logic_family(family_TTL()); + } + } + + device_t::device_t(device_t &owner, const pstring &name) + : base_device_t(owner, name) + { + set_logic_family(owner.logic_family()); + //printf("%s %f %f\n", this->name().c_str(), logic_family()->R_low(), logic_family()->R_high()); + if (logic_family() == nullptr) + { + printf("Issue with 2 %s\n", this->name().c_str()); + set_logic_family(family_TTL()); + } + } + + device_t::device_t(device_t &owner, const pstring &name, const pstring &model) + : base_device_t(owner, name) + { + set_logic_family(state().setup().family_from_model(model)); + //printf("%s %f %f\n", this->name().c_str(), logic_family()->R_low(), logic_family()->R_high()); + if (logic_family() == nullptr) + { + printf("Issue with 3 %s\n", this->name().c_str()); + set_logic_family(family_TTL()); + } + } + + device_t::device_t(device_t &owner, const pstring &name, const logic_family_desc_t *desc) + : base_device_t(owner, name) + { + set_logic_family(desc); + //printf("%s %f %f\n", this->name().c_str(), logic_family()->R_low(), logic_family()->R_high()); + if (logic_family() == nullptr) + { + printf("Issue with 3 %s\n", this->name().c_str()); + set_logic_family(family_TTL()); + } } // ---------------------------------------------------------------------------------------- @@ -780,7 +833,7 @@ namespace netlist { } - logic_t::logic_t(core_device_t &dev, const pstring &aname, const state_e state, + logic_t::logic_t(device_t &dev, const pstring &aname, const state_e state, nldelegate delegate) : core_terminal_t(dev, aname, state, delegate) { @@ -819,7 +872,7 @@ namespace netlist // logic_output_t // ---------------------------------------------------------------------------------------- - logic_output_t::logic_output_t(core_device_t &dev, const pstring &aname) + logic_output_t::logic_output_t(device_t &dev, const pstring &aname) : logic_t(dev, aname, STATE_OUT) , m_my_net(dev.state(), name() + ".net", this) { @@ -870,7 +923,7 @@ namespace netlist // logic_input_t // ----------------------------------------------------------------------------- - logic_input_t::logic_input_t(core_device_t &dev, const pstring &aname, + logic_input_t::logic_input_t(device_t &dev, const pstring &aname, nldelegate delegate) : logic_t(dev, aname, STATE_INP_ACTIVE, delegate) { @@ -882,7 +935,7 @@ namespace netlist // Parameters ... // ---------------------------------------------------------------------------------------- - param_t::param_t(device_t &device, const pstring &name) + param_t::param_t(core_device_t &device, const pstring &name) : device_object_t(device, device.name() + "." + name) { device.state().setup().register_param_t(this->name(), *this); @@ -906,7 +959,7 @@ namespace netlist } - pstring param_t::get_initial(const device_t &dev, bool *found) const + pstring param_t::get_initial(const core_device_t &dev, bool *found) const { pstring res = dev.state().setup().get_initial_param_val(this->name(), ""); *found = (res != ""); @@ -918,7 +971,7 @@ namespace netlist return state().setup().models().type(str()); } - param_str_t::param_str_t(device_t &device, const pstring &name, const pstring &val) + param_str_t::param_str_t(core_device_t &device, const pstring &name, const pstring &val) : param_t(device, name) { m_param = device.state().setup().get_initial_param_val(this->name(),val); @@ -928,7 +981,7 @@ namespace netlist { } - param_ptr_t::param_ptr_t(device_t &device, const pstring &name, uint8_t * val) + param_ptr_t::param_ptr_t(core_device_t &device, const pstring &name, uint8_t * val) : param_t(device, name) { m_param = val; //device.setup().get_initial_param_val(this->name(),val); diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 8b0b5ecd5ee..169def605b3 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -36,12 +36,10 @@ // MACROS / New Syntax //============================================================ -/// Construct a netlist device name +/// \brief Construct a netlist device name +/// #define NETLIB_NAME(chip) nld_ ## chip -#define NETLIB_OBJECT_DERIVED(name, pclass) \ -class NETLIB_NAME(name) : public NETLIB_NAME(pclass) - /// \brief Start a netlist device class. /// /// Used to start defining a netlist device class. @@ -54,49 +52,66 @@ class NETLIB_NAME(name) : public NETLIB_NAME(pclass) /// }; /// /// Also refer to #NETLIB_CONSTRUCTOR. - #define NETLIB_OBJECT(name) \ -class NETLIB_NAME(name) : public device_t +class NETLIB_NAME(name) : public delegator_t -#define NETLIB_CONSTRUCTOR_DERIVED(cname, pclass) \ - private: detail::family_setter_t m_famsetter; \ +/// \brief Start a derived netlist device class. +/// +/// Used to define a derived device class based on plcass. +/// The simplest device without inputs or outputs would look like this: +/// +/// NETLIB_OBJECT_DERIVED(some_object, parent_object) +/// { +/// public: +/// NETLIB_CONSTRUCTOR(some_object) { } +/// }; +/// +/// Also refer to #NETLIB_CONSTRUCTOR. +#define NETLIB_OBJECT_DERIVED(name, pclass) \ +class NETLIB_NAME(name) : public delegator_t + + + +// Only used for analog objects like diodes and resistors + +#define NETLIB_BASE_OBJECT(name) \ +class NETLIB_NAME(name) : public delegator_t + +#define NETLIB_CONSTRUCTOR_PASS(cname, ...) \ public: template NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \ - : NETLIB_NAME(pclass)(owner, name) - -// FIXME: Only used by diode -#define NETLIB_CONSTRUCTOR_DERIVED_EX(cname, pclass, ...) \ - private: detail::family_setter_t m_famsetter; \ - public: template NETLIB_NAME(cname)(CLASS &owner, const pstring &name, __VA_ARGS__) \ - : NETLIB_NAME(pclass)(owner, name) - -#define NETLIB_CONSTRUCTOR_DERIVED_PASS(cname, pclass, ...) \ - private: detail::family_setter_t m_famsetter; \ - public: template NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \ - : NETLIB_NAME(pclass)(owner, name, __VA_ARGS__) - + : base_type(owner, name, __VA_ARGS__) /// \brief Used to define the constructor of a netlist device. +/// /// Use this to define the constructor of a netlist device. Please refer to /// #NETLIB_OBJECT for an example. - #define NETLIB_CONSTRUCTOR(cname) \ - private: detail::family_setter_t m_famsetter; \ public: template NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \ - : device_t(owner, name) + : base_type(owner, name) -/// \brief Used to define the destructor of a netlist device. -/// The use of a destructor for netlist device should normally not be necessary. - -#define NETLIB_DESTRUCTOR(name) public: virtual ~NETLIB_NAME(name)() noexcept override +/// \brief Used to define the constructor of a netlist device and define a default model. +/// +/// +/// NETLIB_CONSTRUCTOR_MODEL(some_object, "TTL") +/// { +/// public: +/// NETLIB_CONSTRUCTOR(some_object) { } +/// }; +/// +#define NETLIB_CONSTRUCTOR_MODEL(cname, cmodel) \ + public: template NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \ + : base_type(owner, name, cmodel) /// \brief Define an extended constructor and add further parameters to it. /// The macro allows to add further parameters to a device constructor. This is /// normally used for sub-devices and system devices only. - #define NETLIB_CONSTRUCTOR_EX(cname, ...) \ - private: detail::family_setter_t m_famsetter; \ public: template NETLIB_NAME(cname)(CLASS &owner, const pstring &name, __VA_ARGS__) \ - : device_t(owner, name) + : base_type(owner, name) + +/// \brief Used to define the destructor of a netlist device. +/// The use of a destructor for netlist device should normally not be necessary. +#define NETLIB_DESTRUCTOR(name) public: virtual ~NETLIB_NAME(name)() noexcept override /// \brief Add this to a device definition to mark the device as dynamic. /// @@ -156,8 +171,6 @@ class NETLIB_NAME(name) : public device_t #define NETLIB_TIMESTEP(cname) \ void NETLIB_NAME(cname) :: timestep(nl_fptype step) noexcept -#define NETLIB_FAMILY(family) , m_famsetter(*this, family) - #define NETLIB_DELEGATE(chip, name) nldelegate(&NETLIB_NAME(chip) :: name, this) #define NETLIB_UPDATE_TERMINALSI() virtual void update_terminals() noexcept override @@ -218,6 +231,15 @@ namespace netlist class core_device_t; class device_t; + template + class delegator_t : public CX + { + protected: + using base_type = delegator_t; + using delegated_type = CX; + using delegated_type::delegated_type; + }; + namespace detail { class net_t; @@ -868,7 +890,7 @@ namespace netlist class logic_t : public detail::core_terminal_t, public logic_family_t { public: - logic_t(core_device_t &dev, const pstring &aname, + logic_t(device_t &dev, const pstring &aname, state_e state, nldelegate delegate = nldelegate()); logic_net_t & net() noexcept; @@ -886,7 +908,7 @@ namespace netlist class logic_input_t : public logic_t { public: - logic_input_t(core_device_t &dev, const pstring &aname, + logic_input_t(device_t &dev, const pstring &aname, nldelegate delegate = nldelegate()); netlist_sig_t operator()() const noexcept @@ -978,7 +1000,7 @@ namespace netlist { public: - logic_output_t(core_device_t &dev, const pstring &aname); + logic_output_t(device_t &dev, const pstring &aname); void initial(netlist_sig_t val) noexcept; @@ -996,6 +1018,10 @@ namespace netlist logic_net_t m_my_net; }; + // ----------------------------------------------------------------------------- + // analog_output_t + // ----------------------------------------------------------------------------- + class analog_output_t : public analog_t { public: @@ -1009,13 +1035,205 @@ namespace netlist analog_net_t m_my_net; }; + // ----------------------------------------------------------------------------- + // param_t + // ----------------------------------------------------------------------------- + + class param_t : public detail::device_object_t + { + public: + + enum param_type_t { + STRING, + DOUBLE, + INTEGER, + LOGIC, + POINTER // Special-case which is always initialized at MAME startup time + }; + + param_t(core_device_t &device, const pstring &name); + + PCOPYASSIGNMOVE(param_t, delete) + + param_type_t param_type() const noexcept(false); + + protected: + virtual ~param_t() noexcept = default; // not intended to be destroyed + + void update_param() noexcept; + + pstring get_initial(const core_device_t &dev, bool *found) const; + + template + void set_and_update_param(C &p, const C v) noexcept + { + if (p != v) + { + p = v; + update_param(); + } + } + + }; + + // ----------------------------------------------------------------------------- + // numeric parameter template + // ----------------------------------------------------------------------------- + + template + class param_num_t final: public param_t + { + public: + param_num_t(core_device_t &device, const pstring &name, T val) noexcept(false); + + T operator()() const noexcept { return m_param; } + operator T() const noexcept { return m_param; } + + void set(const T ¶m) noexcept { set_and_update_param(m_param, param); } + private: + T m_param; + }; + + template + class param_enum_t final: public param_t + { + public: + param_enum_t(core_device_t &device, const pstring &name, T val) noexcept(false); + + T operator()() const noexcept { return T(m_param); } + operator T() const noexcept { return T(m_param); } + void set(const T ¶m) noexcept { set_and_update_param(m_param, static_cast(param)); } + private: + int m_param; + }; + + // FIXME: these should go as well + using param_logic_t = param_num_t; + using param_int_t = param_num_t; + using param_fp_t = param_num_t; + + // ----------------------------------------------------------------------------- + // pointer parameter + // ----------------------------------------------------------------------------- + + class param_ptr_t final: public param_t + { + public: + param_ptr_t(core_device_t &device, const pstring &name, std::uint8_t* val); + std::uint8_t * operator()() const noexcept { return m_param; } + void set(std::uint8_t *param) noexcept { set_and_update_param(m_param, param); } + private: + std::uint8_t* m_param; + }; + + // ----------------------------------------------------------------------------- + // string parameter + // ----------------------------------------------------------------------------- + + class param_str_t : public param_t + { + public: + param_str_t(core_device_t &device, const pstring &name, const pstring &val); + + const pstring &operator()() const noexcept { return str(); } + void set(const pstring ¶m) + { + if (m_param != param) + { + m_param = param; + changed(); + update_param(); + } + } + protected: + virtual void changed() noexcept; + const pstring &str() const noexcept { return m_param; } + private: + pstring m_param; + }; + + // ----------------------------------------------------------------------------- + // model parameter + // ----------------------------------------------------------------------------- + + class param_model_t : public param_str_t + { + public: + + template + class value_base_t + { + public: + value_base_t(param_model_t ¶m, const pstring &name) + : m_value(static_cast(param.value(name))) + { + } + T operator()() const noexcept { return m_value; } + operator T() const noexcept { return m_value; } + private: + const T m_value; + }; + + using value_t = value_base_t; + + param_model_t(core_device_t &device, const pstring &name, const pstring &val) + : param_str_t(device, name, val) { } + + pstring value_str(const pstring &entity); + nl_fptype value(const pstring &entity); + pstring type(); + // hide this + void set(const pstring ¶m) = delete; + protected: + void changed() noexcept override; + private: + }; + + // ----------------------------------------------------------------------------- + // data parameter + // ----------------------------------------------------------------------------- + + class param_data_t : public param_str_t + { + public: + param_data_t(core_device_t &device, const pstring &name) + : param_str_t(device, name, "") + { + } + + plib::unique_ptr stream(); + protected: + void changed() noexcept override { } + }; + + // ----------------------------------------------------------------------------- + // rom parameter + // ----------------------------------------------------------------------------- + + template + class param_rom_t final: public param_data_t + { + public: + + param_rom_t(core_device_t &device, const pstring &name); + + ST operator[] (std::size_t n) const noexcept { return m_data[n]; } + protected: + void changed() noexcept override + { + stream()->read(reinterpret_cast(&m_data[0]),1< m_data; + }; + + // ----------------------------------------------------------------------------- // core_device_t // ----------------------------------------------------------------------------- - class core_device_t : - public detail::netlist_object_t, - public logic_family_t + class core_device_t : public detail::netlist_object_t { public: core_device_t(netlist_state_t &owner, const pstring &name); @@ -1090,22 +1308,21 @@ namespace netlist }; // ----------------------------------------------------------------------------- - // device_t + // base_device_t // ----------------------------------------------------------------------------- - class device_t : public core_device_t + class base_device_t : public core_device_t { public: + base_device_t(netlist_state_t &owner, const pstring &name); + base_device_t(base_device_t &owner, const pstring &name); - device_t(netlist_state_t &owner, const pstring &name); - device_t(core_device_t &owner, const pstring &name); + PCOPYASSIGNMOVE(base_device_t, delete) - PCOPYASSIGNMOVE(device_t, delete) + ~base_device_t() noexcept override = default; - ~device_t() noexcept override = default; - - template - void create_and_register_subdevice(const pstring &name, unique_pool_ptr &dev, Args&&... args); + template + void create_and_register_subdevice(O& owner, const pstring &name, unique_pool_ptr &dev, Args&&... args); void register_subalias(const pstring &name, const detail::core_terminal_t &term); void register_subalias(const pstring &name, const pstring &aliased); @@ -1121,223 +1338,45 @@ namespace netlist }; // ----------------------------------------------------------------------------- - // param_t + // device_t // ----------------------------------------------------------------------------- - class param_t : public detail::device_object_t + class device_t : public base_device_t, + public logic_family_t { public: + device_t(netlist_state_t &owner, const pstring &name); + device_t(netlist_state_t &owner, const pstring &name, + const pstring &model); + device_t(netlist_state_t &owner, const pstring &name, + const logic_family_desc_t *desc); - enum param_type_t { - STRING, - DOUBLE, - INTEGER, - LOGIC, - POINTER // Special-case which is always initialized at MAME startup time - }; + device_t(device_t &owner, const pstring &name); + device_t(device_t &owner, const pstring &name, + const pstring &model); + device_t(device_t &owner, const pstring &name, + const logic_family_desc_t *desc); - param_t(device_t &device, const pstring &name); + PCOPYASSIGNMOVE(device_t, delete) - PCOPYASSIGNMOVE(param_t, delete) - - param_type_t param_type() const noexcept(false); + ~device_t() noexcept override = default; protected: - virtual ~param_t() noexcept = default; // not intended to be destroyed - void update_param() noexcept - { - device().update_param(); - } + NETLIB_UPDATEI() { } + NETLIB_UPDATE_TERMINALSI() { } - pstring get_initial(const device_t &dev, bool *found) const; - - template - void set_and_update_param(C &p, const C v) noexcept - { - if (p != v) - { - p = v; - update_param(); - } - } - - }; - - // ----------------------------------------------------------------------------- - // numeric parameter template - // ----------------------------------------------------------------------------- - - template - class param_num_t final: public param_t - { - public: - param_num_t(device_t &device, const pstring &name, T val) noexcept(false); - - T operator()() const noexcept { return m_param; } - operator T() const noexcept { return m_param; } - - void set(const T ¶m) noexcept { set_and_update_param(m_param, param); } - private: - T m_param; - }; - - template - class param_enum_t final: public param_t - { - public: - param_enum_t(device_t &device, const pstring &name, T val) noexcept(false); - - T operator()() const noexcept { return T(m_param); } - operator T() const noexcept { return T(m_param); } - void set(const T ¶m) noexcept { set_and_update_param(m_param, static_cast(param)); } - private: - int m_param; - }; - - // FIXME: these should go as well - using param_logic_t = param_num_t; - using param_int_t = param_num_t; - using param_fp_t = param_num_t; - - // ----------------------------------------------------------------------------- - // pointer parameter - // ----------------------------------------------------------------------------- - - class param_ptr_t final: public param_t - { - public: - param_ptr_t(device_t &device, const pstring &name, std::uint8_t* val); - std::uint8_t * operator()() const noexcept { return m_param; } - void set(std::uint8_t *param) noexcept { set_and_update_param(m_param, param); } - private: - std::uint8_t* m_param; - }; - - // ----------------------------------------------------------------------------- - // string parameter - // ----------------------------------------------------------------------------- - - class param_str_t : public param_t - { - public: - param_str_t(device_t &device, const pstring &name, const pstring &val); - - const pstring &operator()() const noexcept { return str(); } - void set(const pstring ¶m) - { - if (m_param != param) - { - m_param = param; - changed(); - update_param(); - } - } - protected: - virtual void changed() noexcept; - const pstring &str() const noexcept { return m_param; } - private: - pstring m_param; - }; - - // ----------------------------------------------------------------------------- - // model parameter - // ----------------------------------------------------------------------------- - - class param_model_t : public param_str_t - { - public: - - template - class value_base_t - { - public: - value_base_t(param_model_t ¶m, const pstring &name) - : m_value(static_cast(param.value(name))) - { - } - T operator()() const noexcept { return m_value; } - operator T() const noexcept { return m_value; } - private: - const T m_value; - }; - - using value_t = value_base_t; - - param_model_t(device_t &device, const pstring &name, const pstring &val) - : param_str_t(device, name, val) { } - - pstring value_str(const pstring &entity); - nl_fptype value(const pstring &entity); - pstring type(); - // hide this - void set(const pstring ¶m) = delete; - protected: - void changed() noexcept override; - private: - }; - - // ----------------------------------------------------------------------------- - // data parameter - // ----------------------------------------------------------------------------- - - class param_data_t : public param_str_t - { - public: - param_data_t(device_t &device, const pstring &name) - : param_str_t(device, name, "") - { - } - - plib::unique_ptr stream(); - protected: - void changed() noexcept override { } - }; - - // ----------------------------------------------------------------------------- - // rom parameter - // ----------------------------------------------------------------------------- - - template - class param_rom_t final: public param_data_t - { - public: - - param_rom_t(device_t &device, const pstring &name); - - ST operator[] (std::size_t n) const noexcept { return m_data[n]; } - protected: - void changed() noexcept override - { - stream()->read(reinterpret_cast(&m_data[0]),1< m_data; }; namespace detail { - - // ----------------------------------------------------------------------------- - // family_setter_t - // ----------------------------------------------------------------------------- - - struct family_setter_t - { - // NOLINTNEXTLINE(modernize-use-equals-default) - family_setter_t(); - family_setter_t(core_device_t &dev, const pstring &desc); - family_setter_t(core_device_t &dev, const logic_family_desc_t &desc); - }; - - template - using timed_queue = plib::timed_queue_linear; - // Use timed_queue_heap to use stdc++ heap functions instead of linear processing. // This slows down processing by about 25% on a Kaby Lake. // template // using timed_queue = plib::timed_queue_heap; + template + using timed_queue = plib::timed_queue_linear; + // ----------------------------------------------------------------------------- // queue_t // ----------------------------------------------------------------------------- @@ -1757,8 +1796,8 @@ namespace netlist class object_array_t : public plib::uninitialised_array_t { public: - template - object_array_t(core_device_t &dev, const std::initializer_list &names, Args&&... args) + template + object_array_t(D &dev, const std::initializer_list &names, Args&&... args) { passert_always_msg(names.size() == N, "initializer_list size mismatch"); std::size_t i = 0; @@ -1766,15 +1805,15 @@ namespace netlist this->emplace(i++, dev, pstring(n), std::forward(args)...); } - template - object_array_t(core_device_t &dev, const pstring &fmt, Args&&... args) + template + object_array_t(D &dev, const pstring &fmt, Args&&... args) { for (std::size_t i = 0; iemplace(i, dev, plib::pfmt(fmt)(i), std::forward(args)...); } - template - object_array_t(core_device_t &dev, std::size_t offset, const pstring &fmt, Args&&... args) + template + object_array_t(D &dev, std::size_t offset, const pstring &fmt, Args&&... args) { for (std::size_t i = 0; iemplace(i, dev, plib::pfmt(fmt)(i+offset), std::forward(args)...); @@ -1830,14 +1869,13 @@ namespace netlist return m_netlist.nlstate(); } - template - void device_t::create_and_register_subdevice(const pstring &name, unique_pool_ptr &dev, Args&&... args) + inline void param_t::update_param() noexcept { - dev = state().make_object(*this, name, std::forward(args)...); + device().update_param(); } template - param_num_t::param_num_t(device_t &device, const pstring &name, const T val) + param_num_t::param_num_t(core_device_t &device, const pstring &name, const T val) : param_t(device, name) { //m_param = device.setup().get_initial_param_val(this->name(),val); @@ -1860,7 +1898,7 @@ namespace netlist } template - param_enum_t::param_enum_t(device_t &device, const pstring &name, const T val) + param_enum_t::param_enum_t(core_device_t &device, const pstring &name, const T val) : param_t(device, name), m_param(val) { bool found = false; @@ -1881,7 +1919,7 @@ namespace netlist } template - param_rom_t::param_rom_t(device_t &device, const pstring &name) + param_rom_t::param_rom_t(core_device_t &device, const pstring &name) : param_data_t(device, name) { auto f = stream(); @@ -1894,6 +1932,12 @@ namespace netlist device.state().log().warning(MW_ROM_NOT_FOUND(str())); } + template + void base_device_t::create_and_register_subdevice(O &owner, const pstring &name, unique_pool_ptr &dev, Args&&... args) + { + dev = state().make_object(owner, name, std::forward(args)...); + } + inline void logic_input_t::inactivate() noexcept { if (!is_state(STATE_INP_PASSIVE)) diff --git a/src/lib/netlist/nl_config.h b/src/lib/netlist/nl_config.h index 68d9224135c..71217627aeb 100644 --- a/src/lib/netlist/nl_config.h +++ b/src/lib/netlist/nl_config.h @@ -178,6 +178,10 @@ static constexpr const auto NETLIST_INTERNAL_RES = 10'000'000'000LL; static constexpr const int NETLIST_CLOCK = 1'000'000'000; +// FIXME: need a better solution for global constants. + +static constexpr const char *NETLIST_DEFAULT_TRUTHTABLE_FAMILY = "74XX"; + /// \brief Floating point types used /// /// nl_fptype is the floating point type used throughout the diff --git a/src/lib/netlist/nl_factory.cpp b/src/lib/netlist/nl_factory.cpp index 90659d45e32..0260dfa364f 100644 --- a/src/lib/netlist/nl_factory.cpp +++ b/src/lib/netlist/nl_factory.cpp @@ -76,7 +76,7 @@ namespace factory { // factory_lib_entry_t: factory class to wrap macro based chips/elements // ----------------------------------------------------------------------------- - unique_pool_ptr library_element_t::make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) + unique_pool_ptr library_element_t::make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) { return pool.make_unique(anetlist, name); } diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index 151c21cf349..cbeb6b03a55 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -34,7 +34,7 @@ factory::constructor_ptr_t decl_ ## p_alias = NETLIB_NAME(p_alias ## _c); namespace netlist { - class device_t; + class core_device_t; class nlparse_t; class setup_t; class netlist_state_t; @@ -55,7 +55,7 @@ namespace factory { PCOPYASSIGNMOVE(element_t, default) - virtual unique_pool_ptr make_device(nlmempool &pool, + virtual unique_pool_ptr make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) = 0; @@ -88,7 +88,7 @@ namespace factory { const pstring &def_param, const pstring &sourcefile) : element_t(name, classname, def_param, sourcefile) { } - unique_pool_ptr make_device(nlmempool &pool, + unique_pool_ptr make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) override { @@ -159,7 +159,7 @@ namespace factory { { } - unique_pool_ptr make_device(nlmempool &pool, + unique_pool_ptr make_device(nlmempool &pool, netlist_state_t &anetlist, const pstring &name) override; diff --git a/src/lib/netlist/plib/prandom.h b/src/lib/netlist/plib/prandom.h index c5d363b2f5c..df93c697493 100644 --- a/src/lib/netlist/plib/prandom.h +++ b/src/lib/netlist/plib/prandom.h @@ -124,7 +124,7 @@ namespace plib const auto mmin(static_cast(p.min())); const auto mmax(static_cast(p.max())); // -> 0 to a - return (p() - mmin) / (mmax - mmin) * m - b; + return (static_cast(p())- mmin) / (mmax - mmin) * m - b; } template