diff options
-rw-r--r-- | scripts/src/netlist.lua | 2 | ||||
-rw-r--r-- | src/lib/netlist/build/makefile | 3 | ||||
-rw-r--r-- | src/lib/netlist/core/state_var.h | 7 | ||||
-rw-r--r-- | src/lib/netlist/devices/nld_schmitt.cpp | 1 | ||||
-rw-r--r-- | src/lib/netlist/devices/nld_tms4800.cpp | 1 | ||||
-rw-r--r-- | src/lib/netlist/devices/nlid_system.h | 67 | ||||
-rw-r--r-- | src/lib/netlist/nl_base.cpp | 1 | ||||
-rw-r--r-- | src/lib/netlist/nl_base.h | 256 | ||||
-rw-r--r-- | src/lib/netlist/nl_setup.cpp | 3 |
9 files changed, 14 insertions, 327 deletions
diff --git a/scripts/src/netlist.lua b/scripts/src/netlist.lua index 20c83daf992..b19928aa464 100644 --- a/scripts/src/netlist.lua +++ b/scripts/src/netlist.lua @@ -54,6 +54,8 @@ project "netlist" MAME_DIR .. "src/lib/netlist/core/base_objects.h", MAME_DIR .. "src/lib/netlist/core/core_device.h", MAME_DIR .. "src/lib/netlist/core/device.h", + MAME_DIR .. "src/lib/netlist/core/device_macros.h", + MAME_DIR .. "src/lib/netlist/core/devices.h", MAME_DIR .. "src/lib/netlist/core/exec.h", MAME_DIR .. "src/lib/netlist/core/logic_family.h", MAME_DIR .. "src/lib/netlist/core/logic.h", diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 07c1e8d89f9..2c4dff9bae7 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -308,7 +308,8 @@ clang: -Wmissing-variable-declarations -Wno-float-equal -Wconversion \ -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wformat-nonliteral \ -Wno-exit-time-destructors -Winconsistent-missing-destructor-override \ - -Wno-return-std-move-in-c++11 -Wno-unreachable-code" + -Wno-return-std-move-in-c++11 -Wno-unreachable-code \ + -Wno-missing-prototypes" clang-libc: #clang-11 currently broken diff --git a/src/lib/netlist/core/state_var.h b/src/lib/netlist/core/state_var.h index 922789f584e..55db73c1ac2 100644 --- a/src/lib/netlist/core/state_var.h +++ b/src/lib/netlist/core/state_var.h @@ -169,5 +169,12 @@ namespace netlist } // namespace netlist +namespace plib +{ + template<typename X> + struct ptype_traits<netlist::state_var<X>> : ptype_traits<X> + { + }; +} // namespace plib #endif // NL_CORE_STATE_VAR_H_ diff --git a/src/lib/netlist/devices/nld_schmitt.cpp b/src/lib/netlist/devices/nld_schmitt.cpp index 5225bdcc139..f78b8f0cf65 100644 --- a/src/lib/netlist/devices/nld_schmitt.cpp +++ b/src/lib/netlist/devices/nld_schmitt.cpp @@ -8,7 +8,6 @@ #include "nld_schmitt.h" #include "netlist/analog/nlid_twoterm.h" -#include "netlist/devices/nlid_system.h" #include "netlist/nl_base.h" #include "netlist/nl_errstr.h" #include "netlist/solver/nld_solver.h" diff --git a/src/lib/netlist/devices/nld_tms4800.cpp b/src/lib/netlist/devices/nld_tms4800.cpp index d55827c2416..0c37821b37f 100644 --- a/src/lib/netlist/devices/nld_tms4800.cpp +++ b/src/lib/netlist/devices/nld_tms4800.cpp @@ -26,7 +26,6 @@ */ #include "nld_tms4800.h" -#include "netlist/devices/nlid_system.h" #include "netlist/nl_base.h" namespace netlist diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index a8ba6937164..26c58055b63 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -21,29 +21,6 @@ namespace netlist namespace devices { // ----------------------------------------------------------------------------- - // netlistparams - // ----------------------------------------------------------------------------- - - NETLIB_OBJECT(netlistparams) - { - NETLIB_CONSTRUCTOR(netlistparams) - , m_use_deactivate(*this, "USE_DEACTIVATE", false) - , m_startup_strategy(*this, "STARTUP_STRATEGY", 0) - , m_mos_capmodel(*this, "DEFAULT_MOS_CAPMODEL", 2) - , m_max_link_loops(*this, "MAX_LINK_RESOLVE_LOOPS", 100) - { - } - //NETLIB_RESETI() {} - //NETLIB_UPDATE_PARAMI() { } - public: - param_logic_t m_use_deactivate; - param_num_t<unsigned> m_startup_strategy; - param_num_t<unsigned> m_mos_capmodel; - //! How many times do we try to resolve links (connections) - param_num_t<unsigned> m_max_link_loops; - }; - - // ----------------------------------------------------------------------------- // clock // ----------------------------------------------------------------------------- @@ -300,50 +277,6 @@ namespace devices param_fp_t m_IN; }; - // ----------------------------------------------------------------------------- - // nld_gnd - // ----------------------------------------------------------------------------- - - NETLIB_OBJECT(gnd) - { - NETLIB_CONSTRUCTOR(gnd) - , m_Q(*this, "Q") - { - } - - NETLIB_UPDATE_PARAMI() - { - m_Q.push(nlconst::zero()); - } - - //NETLIB_RESETI() {} - protected: - analog_output_t m_Q; - }; - - // ----------------------------------------------------------------------------- - // nld_nc_pin - // ----------------------------------------------------------------------------- - - NETLIB_OBJECT(nc_pin) - { - public: - NETLIB_CONSTRUCTOR(nc_pin) - , m_I(*this, "I", NETLIB_DELEGATE(noop)) - { - } - - protected: - //NETLIB_RESETI() {} - - private: - NETLIB_HANDLERI(noop) - { - } - - analog_input_t m_I; - - }; // ----------------------------------------------------------------------------- // nld_frontier diff --git a/src/lib/netlist/nl_base.cpp b/src/lib/netlist/nl_base.cpp index c8684baccbf..ef98d4434de 100644 --- a/src/lib/netlist/nl_base.cpp +++ b/src/lib/netlist/nl_base.cpp @@ -13,7 +13,6 @@ #include "core/setup.h" #include "devices/nlid_proxy.h" -#include "devices/nlid_system.h" // netlist_params #include "nl_base.h" #include "nl_errstr.h" diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index 32cc1f0eacc..1eebae7b75a 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -23,167 +23,8 @@ #include "core/param.h" #include "core/state_var.h" #include "core/exec.h" - -//============================================================ -// MACROS / New Syntax -//============================================================ - -/// \brief Construct a netlist device name -/// -#define NETLIB_NAME(chip) nld_ ## chip - -/// \brief Start a netlist device class. -/// -/// Used to start defining a netlist device class. -/// The simplest device without inputs or outputs would look like this: -/// -/// NETLIB_OBJECT(some_object) -/// { -/// public: -/// NETLIB_CONSTRUCTOR(some_object) { } -/// }; -/// -/// Also refer to #NETLIB_CONSTRUCTOR. -#define NETLIB_OBJECT(name) \ -class NETLIB_NAME(name) : public delegator_t<device_t> - -/// \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<NETLIB_NAME(pclass)> - - - -// Only used for analog objects like diodes and resistors - -#define NETLIB_BASE_OBJECT(name) \ -class NETLIB_NAME(name) : public delegator_t<base_device_t> - -#define NETLIB_CONSTRUCTOR_PASS(cname, ...) \ - using this_type = NETLIB_NAME(cname); \ - public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name) \ - : 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) \ - using this_type = NETLIB_NAME(cname); \ - public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name)\ - : base_type(owner, name) - -/// \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) \ - using this_type = NETLIB_NAME(cname); \ - public: template <class CLASS> 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, ...) \ - using this_type = NETLIB_NAME(cname); \ - public: template <class CLASS> NETLIB_NAME(cname)(CLASS &owner, const pstring &name, __VA_ARGS__) \ - : 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. -/// -/// If NETLIB_IS_DYNAMIC(true) is added to the device definition the device -/// is treated as an analog dynamic device, i.e. \ref NETLIB_UPDATE_TERMINALSI -/// is called on a each step of the Newton-Raphson step -/// of solving the linear equations. -/// -/// You may also use e.g. NETLIB_IS_DYNAMIC(m_func() != "") to only make the -/// device a dynamic device if parameter m_func is set. -/// -/// \param expr boolean expression -/// -#define NETLIB_IS_DYNAMIC(expr) \ - public: virtual bool is_dynamic() const noexcept override { return expr; } - -/// \brief Add this to a device definition to mark the device as a time-stepping device. -/// -/// You have to implement NETLIB_TIMESTEP in this case as well. Currently, only -/// the capacitor and inductor devices uses this. -/// -/// You may also use e.g. NETLIB_IS_TIMESTEP(m_func() != "") to only make the -/// device a dynamic device if parameter m_func is set. This is used by the -/// Voltage Source element. -/// -/// Example: -/// -/// \code -/// NETLIB_TIMESTEP_IS_TIMESTEP() -/// NETLIB_TIMESTEPI() -/// { -/// // Gpar should support convergence -/// const nl_fptype G = m_C.Value() / step + m_GParallel; -/// const nl_fptype I = -G/// deltaV(); -/// set(G, 0.0, I); -/// } -/// \endcode - -#define NETLIB_IS_TIMESTEP(expr) \ - public: virtual bool is_timestep() const noexcept override { return expr; } - -/// \brief Used to implement the time stepping code. -/// -/// Please see \ref NETLIB_IS_TIMESTEP for an example. - -#define NETLIB_TIMESTEPI() \ - public: virtual void timestep(timestep_type ts_type, nl_fptype step) noexcept override - -/// \brief Used to implement the body of the time stepping code. -/// -/// Used when the implementation is outside the class definition -/// -/// Please see \ref NETLIB_IS_TIMESTEP for an example. -/// -/// \param cname Name of object as given to \ref NETLIB_OBJECT -/// -#define NETLIB_TIMESTEP(cname) \ - void NETLIB_NAME(cname) :: timestep(timestep_type ts_type, nl_fptype step) noexcept - -#define NETLIB_DELEGATE(name) nldelegate(&this_type :: name, this) - -#define NETLIB_UPDATE_TERMINALSI() virtual void update_terminals() noexcept override -#define NETLIB_HANDLERI(name) void name() noexcept -#define NETLIB_UPDATE_PARAMI() virtual void update_param() noexcept override -#define NETLIB_RESETI() virtual void reset() override - -#define NETLIB_SUB(chip) nld_ ## chip -#define NETLIB_SUB_UPTR(ns, chip) device_arena::unique_ptr< ns :: nld_ ## chip > - -#define NETLIB_HANDLER(chip, name) void NETLIB_NAME(chip) :: name() noexcept - -#define NETLIB_RESET(chip) void NETLIB_NAME(chip) :: reset(void) - -#define NETLIB_UPDATE_PARAM(chip) void NETLIB_NAME(chip) :: update_param() noexcept - -#define NETLIB_UPDATE_TERMINALS(chip) void NETLIB_NAME(chip) :: update_terminals() noexcept +#include "core/device_macros.h" +#include "core/devices.h" //============================================================ // Namespace starts @@ -192,89 +33,6 @@ class NETLIB_NAME(name) : public delegator_t<base_device_t> namespace netlist { - namespace devices - { - // ----------------------------------------------------------------------------- - // mainclock - // ----------------------------------------------------------------------------- - - NETLIB_OBJECT(mainclock) - { - NETLIB_CONSTRUCTOR(mainclock) - , m_Q(*this, "Q") - , m_freq(*this, "FREQ", nlconst::magic(7159000.0 * 5)) - { - m_inc = netlist_time::from_fp(plib::reciprocal(m_freq()*nlconst::two())); - } - - NETLIB_RESETI(); - - NETLIB_UPDATE_PARAMI() - { - m_inc = netlist_time::from_fp(plib::reciprocal(m_freq()*nlconst::two())); - } - - public: - logic_output_t m_Q; // NOLINT: needed in core - netlist_time m_inc; // NOLINT: needed in core - private: - param_fp_t m_freq; - }; - } // namespace devices - - - // ----------------------------------------------------------------------------- - // power pins - not a device, but a helper - // ----------------------------------------------------------------------------- - - /// \brief Power pins class. - /// - /// Power Pins are passive inputs. Delegate noop will silently ignore any - /// updates. - - class nld_power_pins - { - public: - using this_type = nld_power_pins; - - explicit nld_power_pins(device_t &owner) - : m_VCC(owner, owner.logic_family()->vcc_pin(), NETLIB_DELEGATE(noop)) - , m_GND(owner, owner.logic_family()->gnd_pin(), NETLIB_DELEGATE(noop)) - { - } - - // Some devices like the 74LS629 have two pairs of supply pins. - explicit nld_power_pins(device_t &owner, - const pstring &vcc, const pstring &gnd) - : m_VCC(owner, vcc, NETLIB_DELEGATE(noop)) - , m_GND(owner, gnd, NETLIB_DELEGATE(noop)) - { - } - - const analog_input_t &VCC() const noexcept - { - return m_VCC; - } - const analog_input_t &GND() const noexcept - { - return m_GND; - } - - private: - void noop() { } - analog_input_t m_VCC; - analog_input_t m_GND; - }; - - namespace devices - { - inline NETLIB_RESET(mainclock) - { - m_Q.net().set_next_scheduled_time(exec().time()); - } - } // namespace devices - - extern template struct state_var<std::uint8_t>; extern template struct state_var<std::uint16_t>; extern template struct state_var<std::uint32_t>; @@ -322,14 +80,4 @@ namespace netlist } // namespace netlist -namespace plib -{ - template<typename X> - struct ptype_traits<netlist::state_var<X>> : ptype_traits<X> - { - }; -} // namespace plib - - - #endif // NLBASE_H_ diff --git a/src/lib/netlist/nl_setup.cpp b/src/lib/netlist/nl_setup.cpp index 32ccfb5725f..3abc9b1bc75 100644 --- a/src/lib/netlist/nl_setup.cpp +++ b/src/lib/netlist/nl_setup.cpp @@ -5,7 +5,6 @@ #include "analog/nld_twoterm.h" #include "core/setup.h" #include "devices/nlid_proxy.h" -#include "devices/nlid_system.h" #include "devices/nlid_truthtable.h" #include "nl_base.h" #include "nl_factory.h" @@ -13,6 +12,7 @@ #include "nl_setup.h" #include "plib/penum.h" #include "plib/putil.h" +#include "plib/pstonum.h" #include "solver/nld_solver.h" @@ -1764,7 +1764,6 @@ bool source_token_t::parse(nlparse_t &setup, const pstring &name) if (name == m_name) { auto ret = setup.parse_tokens(m_store, name); - printf("parsed tokens: %s %d\n", name.c_str(), (int) ret); return ret; } |