diff options
author | 2020-11-18 00:58:30 +1100 | |
---|---|---|
committer | 2020-11-18 00:58:30 +1100 | |
commit | 612b6472e740560af41f603115a1163b481dd64c (patch) | |
tree | 0ba65831673b396522f65de5b4e2b8b8f024295e | |
parent | 95927464dd5edff2f790b60d85d35114fb2405d4 (diff) |
-unidasm: Allow input piped from stdin by specifying a bare hyphen as the filename. [AJR, Vas Crabb]
-netlist: Give devices the C++17 namespace treatment.
-Tidied up compiler warning options for 3rdparty.
-emu/render.cpp: Exposed a few information view item properties.
70 files changed, 702 insertions, 901 deletions
diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index 2e189f8a765..1830e14e66e 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -668,8 +668,8 @@ end configuration { "vsllvm" } buildoptions { - "-Wno-unused-function", "-Wno-enum-conversion", + "-Wno-unused-function", } configuration { } @@ -738,8 +738,8 @@ project "7z" configuration { "gmake or ninja" } buildoptions_c { - "-Wno-undef", "-Wno-strict-prototypes", + "-Wno-undef", } if _OPTIONS["gcc"]~=nil and string.find(_OPTIONS["gcc"], "clang") and str_to_version(_OPTIONS["gcc_version"]) >= 100000 then buildoptions_c { @@ -1009,10 +1009,10 @@ project "sqlite3" configuration { "gmake" } buildoptions_c { - "-Wno-discarded-qualifiers", - "-Wno-unused-but-set-variable", "-Wno-bad-function-cast", + "-Wno-discarded-qualifiers", "-Wno-undef", + "-Wno-unused-but-set-variable", } if _OPTIONS["gcc"]~=nil and ((string.find(_OPTIONS["gcc"], "clang") or string.find(_OPTIONS["gcc"], "asmjs") or string.find(_OPTIONS["gcc"], "android"))) then buildoptions_c { @@ -1359,10 +1359,9 @@ end configuration { "gmake or ninja" } buildoptions { "-Wno-uninitialized", + "-Wno-unused-but-set-variable", "-Wno-unused-function", "-Wno-unused-variable", - "-Wno-unused-but-set-variable", - "-Wno-format-extra-args", -- temp for mingw 6.1 till update bgfx code } configuration { "rpi" } buildoptions { @@ -1513,21 +1512,21 @@ project "portaudio" buildoptions { "-Wno-deprecated-declarations", "-Wno-missing-braces", - "-Wno-unused-variable", "-Wno-switch", "-Wno-unused-function", + "-Wno-unused-variable", } configuration { "gmake or ninja" } buildoptions_c { - "-Wno-strict-prototypes", "-Wno-bad-function-cast", - "-Wno-undef", "-Wno-missing-braces", - "-Wno-unused-variable", - "-Wno-unused-value", - "-Wno-unused-function", + "-Wno-strict-prototypes", + "-Wno-undef", "-Wno-unknown-pragmas", + "-Wno-unused-function", + "-Wno-unused-value", + "-Wno-unused-variable", } local version = str_to_version(_OPTIONS["gcc_version"]) @@ -1542,11 +1541,11 @@ project "portaudio" } else buildoptions_c { - "-Wno-unused-but-set-variable", "-Wno-maybe-uninitialized", "-Wno-sometimes-uninitialized", - "-w", + "-Wno-unused-but-set-variable", "-Wno-incompatible-pointer-types-discards-qualifiers", + "-w", } end if string.find(_OPTIONS["gcc"], "clang") and version >= 100000 then @@ -2119,13 +2118,13 @@ end MAME_DIR .. "3rdparty/bgfx/3rdparty/khronos", } buildoptions_c { - "-Wno-undef", + "-Wno-bad-function-cast", + "-Wno-discarded-qualifiers", "-Wno-format", "-Wno-format-security", - "-Wno-strict-prototypes", - "-Wno-bad-function-cast", "-Wno-pointer-to-int-cast", - "-Wno-discarded-qualifiers", + "-Wno-strict-prototypes", + "-Wno-undef", "-Wno-unused-but-set-variable", } diff --git a/src/emu/render.cpp b/src/emu/render.cpp index 178a56c5c78..41563bdb873 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -1364,7 +1364,7 @@ render_primitive_list &render_target::get_primitives() if (curitem.screen()) add_container_primitives(list, root_xform, item_xform, curitem.screen()->container(), curitem.blend_mode()); else - add_element_primitives(list, item_xform, *curitem.element(), curitem.state(), curitem.blend_mode()); + add_element_primitives(list, item_xform, *curitem.element(), curitem.element_state(), curitem.blend_mode()); } } else diff --git a/src/emu/render.h b/src/emu/render.h index f2e95164b63..3dc7376957c 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -748,6 +748,8 @@ public: // getters layout_element *element() const { return m_element; } screen_device *screen() { return m_screen; } + bool bounds_animated() const { return m_bounds.size() > 1U; } + bool color_animated() const { return m_color.size() > 1U; } render_bounds bounds() const { return m_get_bounds(); } render_color color() const { return m_get_color(); } int blend_mode() const { return m_blend_mode; } @@ -761,7 +763,8 @@ public: bool clickthrough() const { return m_clickthrough; } // fetch state based on configured source - int state() const { return m_get_elem_state(); } + int element_state() const { return m_get_elem_state(); } + int animation_state() const { return m_get_anim_state(); } // resolve tags, if any void resolve_tags(); diff --git a/src/lib/netlist/devices/net_lib.cpp b/src/lib/netlist/devices/net_lib.cpp index 3fc11f177cf..d458230232a 100644 --- a/src/lib/netlist/devices/net_lib.cpp +++ b/src/lib/netlist/devices/net_lib.cpp @@ -16,10 +16,7 @@ #define LIB_DECL(decl) factory.add( decl () ); #define LIB_ENTRY(nic) { NETLIB_DEVICE_DECL(nic); LIB_DECL(decl_ ## nic) } -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { void initialize_factory(factory::list_t &factory) { @@ -32,6 +29,5 @@ namespace devices } -} //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_2102a.cpp b/src/lib/netlist/devices/nld_2102a.cpp index 91c7c6b7ee0..dd03560a32d 100755 --- a/src/lib/netlist/devices/nld_2102a.cpp +++ b/src/lib/netlist/devices/nld_2102a.cpp @@ -26,10 +26,8 @@ #define ADDR2BYTE(a) ((a) >> 3) #define ADDR2BIT(a) ((a) & 0x7) -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(2102A) { NETLIB_CONSTRUCTOR(2102A) @@ -90,5 +88,4 @@ namespace netlist NETLIB_DEVICE_IMPL(2102A, "RAM_2102A", "+CEQ,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+A9,+RWQ,+DI,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4006.cpp b/src/lib/netlist/devices/nld_4006.cpp index cd0e441c6b5..1c1f09838aa 100644 --- a/src/lib/netlist/devices/nld_4006.cpp +++ b/src/lib/netlist/devices/nld_4006.cpp @@ -41,10 +41,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { // FIXME: optimize clock input @@ -114,5 +111,4 @@ namespace netlist NETLIB_DEVICE_IMPL(CD4006, "CD4006", "+CLOCK,+D1,+D2,+D3,+D4,+D1P4,+D1P4S,+D2P4,+D2P5,+D3P4,+D4P4,+D4P5,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4013.cpp b/src/lib/netlist/devices/nld_4013.cpp index eca94c328a5..e04e6cb8a57 100644 --- a/src/lib/netlist/devices/nld_4013.cpp +++ b/src/lib/netlist/devices/nld_4013.cpp @@ -42,10 +42,7 @@ #include "nl_base.h" #include "nl_factory.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { NETLIB_OBJECT(CD4013) { @@ -122,5 +119,4 @@ namespace netlist NETLIB_DEVICE_IMPL(CD4013, "CD4013", "+CLOCK,+DATA,+RESET,+SET,@VDD,@VSS") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4017.cpp b/src/lib/netlist/devices/nld_4017.cpp index 249fa8c3b59..7ac2952cfa1 100644 --- a/src/lib/netlist/devices/nld_4017.cpp +++ b/src/lib/netlist/devices/nld_4017.cpp @@ -40,10 +40,7 @@ #include "nl_base.h" #include "nl_factory.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { template <std::size_t MaxCount> NETLIB_OBJECT(CD4017_base) @@ -113,5 +110,4 @@ namespace netlist NETLIB_DEVICE_IMPL(CD4017, "CD4017", "") NETLIB_DEVICE_IMPL(CD4022, "CD4022", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4020.cpp b/src/lib/netlist/devices/nld_4020.cpp index 6ceecd6846e..709916582af 100644 --- a/src/lib/netlist/devices/nld_4020.cpp +++ b/src/lib/netlist/devices/nld_4020.cpp @@ -40,10 +40,7 @@ #include "nl_base.h" #include "nl_factory.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { template <unsigned TotalBits, unsigned LiveBitmask> NETLIB_OBJECT(CD4020_sub) @@ -170,5 +167,4 @@ namespace netlist NETLIB_DEVICE_IMPL(CD4024, "CD4024", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4029.cpp b/src/lib/netlist/devices/nld_4029.cpp index 4582746bf24..9c66ff6cdd6 100644 --- a/src/lib/netlist/devices/nld_4029.cpp +++ b/src/lib/netlist/devices/nld_4029.cpp @@ -130,10 +130,7 @@ #include "nl_base.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { NETLIB_OBJECT(CD4029) { @@ -268,5 +265,4 @@ namespace devices NETLIB_DEVICE_IMPL(CD4029, "CD4029", "+PE,+J1,+J2,+J3,+J4,+CI,+UD,+BD,+CLK,@VCC,@GND") -} // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4042.cpp b/src/lib/netlist/devices/nld_4042.cpp index a000d2e8af8..8fc942d5ea4 100644 --- a/src/lib/netlist/devices/nld_4042.cpp +++ b/src/lib/netlist/devices/nld_4042.cpp @@ -38,10 +38,7 @@ #include "nl_base.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { NETLIB_OBJECT(CD4042) @@ -116,5 +113,4 @@ namespace devices NETLIB_DEVICE_IMPL(CD4042, "CD4042", "+D1,+D2,+D3,+D4,+POL,+CLK,@VCC,@GND") -} // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4053.cpp b/src/lib/netlist/devices/nld_4053.cpp index 29634e9fdeb..cca49cd1339 100644 --- a/src/lib/netlist/devices/nld_4053.cpp +++ b/src/lib/netlist/devices/nld_4053.cpp @@ -26,10 +26,8 @@ #include "analog/nlid_twoterm.h" #include "solver/nld_solver.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(CD4053_GATE) { NETLIB_CONSTRUCTOR_MODEL(CD4053_GATE, "CD4XXX") @@ -140,5 +138,5 @@ namespace netlist }; NETLIB_DEVICE_IMPL(CD4053_GATE, "CD4053_GATE", "") - } //namespace devices -} // namespace netlist + +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4066.cpp b/src/lib/netlist/devices/nld_4066.cpp index 9e7d7e7c7fe..8de239472fe 100644 --- a/src/lib/netlist/devices/nld_4066.cpp +++ b/src/lib/netlist/devices/nld_4066.cpp @@ -25,10 +25,8 @@ #include "solver/nld_solver.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(CD4066_GATE) { NETLIB_CONSTRUCTOR_MODEL(CD4066_GATE, "CD4XXX") @@ -81,5 +79,5 @@ namespace netlist }; NETLIB_DEVICE_IMPL(CD4066_GATE, "CD4066_GATE", "") - } //namespace devices -} // namespace netlist + +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_4076.cpp b/src/lib/netlist/devices/nld_4076.cpp index a69d02e2d54..756c613ed5a 100644 --- a/src/lib/netlist/devices/nld_4076.cpp +++ b/src/lib/netlist/devices/nld_4076.cpp @@ -49,11 +49,7 @@ #include "nl_base.h" -namespace netlist -{ -namespace devices -{ - +namespace netlist::devices { NETLIB_OBJECT(CD4076) { @@ -128,5 +124,4 @@ namespace devices NETLIB_DEVICE_IMPL(CD4076, "CD4076", "+I1,+I2,+I3,+I4,+ID1,+ID2,+OD1,+OD2,@VCC,@GND") -} // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74107.cpp b/src/lib/netlist/devices/nld_74107.cpp index f49ed439d1e..4890bf38dbe 100644 --- a/src/lib/netlist/devices/nld_74107.cpp +++ b/src/lib/netlist/devices/nld_74107.cpp @@ -63,10 +63,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { template <typename D> NETLIB_OBJECT(74107_base) @@ -153,5 +150,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74107, "TTL_74107", "+CLK,+J,+K,+CLRQ,@VCC,@GND") NETLIB_DEVICE_IMPL(74107A, "TTL_74107A", "+CLK,+J,+K,+CLRQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74113.cpp b/src/lib/netlist/devices/nld_74113.cpp index d4fc729b2bc..b5e0e2ca3d6 100644 --- a/src/lib/netlist/devices/nld_74113.cpp +++ b/src/lib/netlist/devices/nld_74113.cpp @@ -62,10 +62,8 @@ // FIXME: this can probably be merged with nld_7473.cpp // FIXME: timing, see 74107 for example, use template -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(74113) { NETLIB_CONSTRUCTOR(74113) @@ -145,5 +143,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74113, "TTL_74113", "+CLK,+J,+K,+CLRQ,@VCC,@GND") NETLIB_DEVICE_IMPL(74113A, "TTL_74113A", "+CLK,+J,+K,+CLRQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74123.cpp b/src/lib/netlist/devices/nld_74123.cpp index 00a5047f764..3570536e60b 100644 --- a/src/lib/netlist/devices/nld_74123.cpp +++ b/src/lib/netlist/devices/nld_74123.cpp @@ -49,10 +49,7 @@ #include "analog/nlid_twoterm.h" #include "nlid_system.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { /// \brief Base monostable device /// @@ -290,5 +287,4 @@ namespace netlist NETLIB_DEVICE_IMPL(4538, "CD4538", "") NETLIB_DEVICE_IMPL(9602, "TTL_9602", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74125.cpp b/src/lib/netlist/devices/nld_74125.cpp index 1240619e1d6..91f9c11185f 100644 --- a/src/lib/netlist/devices/nld_74125.cpp +++ b/src/lib/netlist/devices/nld_74125.cpp @@ -9,10 +9,7 @@ #include <type_traits> -namespace netlist -{ - namespace devices - { +namespace netlist::devices { template <typename D> NETLIB_OBJECT(74125_base) @@ -77,5 +74,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74125, "TTL_74125_GATE", "") NETLIB_DEVICE_IMPL(74126, "TTL_74126_GATE", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74153.cpp b/src/lib/netlist/devices/nld_74153.cpp index bc2b54bcb98..edf15d7a541 100644 --- a/src/lib/netlist/devices/nld_74153.cpp +++ b/src/lib/netlist/devices/nld_74153.cpp @@ -44,10 +44,7 @@ #include "nl_base.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { // FIXME: timing is not 100% accurate, Strobe and Select inputs have a // slightly longer timing . @@ -107,5 +104,4 @@ namespace devices NETLIB_DEVICE_IMPL(74153, "TTL_74153", "+C0,+C1,+C2,+C3,+A,+B,+G,@VCC,@GND") -} //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74161.cpp b/src/lib/netlist/devices/nld_74161.cpp index e60c106f76a..e05f5429a96 100644 --- a/src/lib/netlist/devices/nld_74161.cpp +++ b/src/lib/netlist/devices/nld_74161.cpp @@ -17,14 +17,10 @@ // FIXME: this file could be created programmatically -namespace netlist -{ - namespace devices - { +namespace netlist::devices { - NETLIB_DEVICE_IMPL(74161, "TTL_74161", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") - // FIXME: This happens on copy/paste - NETLIB_DEVICE_IMPL(74161_fixme, "TTL_74161_FIXME", "+A,+B,+C,+D,+CLRQ,+LOADQ,+CLK,+ENP,+ENT,@VCC,@GND") + NETLIB_DEVICE_IMPL(74161, "TTL_74161", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") + // FIXME: This happens on copy/paste + NETLIB_DEVICE_IMPL(74161_fixme, "TTL_74161_FIXME", "+A,+B,+C,+D,+CLRQ,+LOADQ,+CLK,+ENP,+ENT,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74163.cpp b/src/lib/netlist/devices/nld_74163.cpp index ceb88c809cf..89ecfd80eb5 100644 --- a/src/lib/netlist/devices/nld_74163.cpp +++ b/src/lib/netlist/devices/nld_74163.cpp @@ -17,12 +17,8 @@ // FIXME: this file could be created programmatically -namespace netlist -{ - namespace devices - { +namespace netlist::devices { - NETLIB_DEVICE_IMPL(74163, "TTL_74163", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") + NETLIB_DEVICE_IMPL(74163, "TTL_74163", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74164.cpp b/src/lib/netlist/devices/nld_74164.cpp index 74096cf4147..c2df89bcd50 100644 --- a/src/lib/netlist/devices/nld_74164.cpp +++ b/src/lib/netlist/devices/nld_74164.cpp @@ -50,10 +50,8 @@ // FIXME: clk input to be separated - only falling edge relevant -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(74164) { NETLIB_CONSTRUCTOR(74164) @@ -115,5 +113,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74164, "TTL_74164", "+A,+B,+CLRQ,+CLK,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74165.cpp b/src/lib/netlist/devices/nld_74165.cpp index 19eb2267e02..63fee9fdb13 100644 --- a/src/lib/netlist/devices/nld_74165.cpp +++ b/src/lib/netlist/devices/nld_74165.cpp @@ -26,10 +26,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { NETLIB_OBJECT(74165) { @@ -97,5 +94,4 @@ namespace netlist // FIXME: Timing NETLIB_DEVICE_IMPL(74165, "TTL_74165", "+CLK,+CLKINH,+SH_LDQ,+SER,+A,+B,+C,+D,+E,+F,+G,+H,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74166.cpp b/src/lib/netlist/devices/nld_74166.cpp index 69082d89363..f12101a4737 100644 --- a/src/lib/netlist/devices/nld_74166.cpp +++ b/src/lib/netlist/devices/nld_74166.cpp @@ -28,10 +28,8 @@ // FIXME: separate handlers for inputs -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(74166) { NETLIB_CONSTRUCTOR(74166) @@ -119,5 +117,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74166, "TTL_74166", "+CLK,+CLKINH,+SH_LDQ,+SER,+A,+B,+C,+D,+E,+F,+G,+H,+CLRQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74174.cpp b/src/lib/netlist/devices/nld_74174.cpp index 32bc0f5d1a0..d9191ce5b48 100644 --- a/src/lib/netlist/devices/nld_74174.cpp +++ b/src/lib/netlist/devices/nld_74174.cpp @@ -35,10 +35,8 @@ #include "nl_base.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { + NETLIB_OBJECT(74174_GATE) { NETLIB_CONSTRUCTOR(74174_GATE) @@ -163,5 +161,4 @@ namespace devices NETLIB_DEVICE_IMPL(74174, "TTL_74174", "+CLK,+D1,+D2,+D3,+D4,+D5,+D6,+CLRQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74175.cpp b/src/lib/netlist/devices/nld_74175.cpp index 3329ff18893..07e5f7a29f6 100644 --- a/src/lib/netlist/devices/nld_74175.cpp +++ b/src/lib/netlist/devices/nld_74175.cpp @@ -37,10 +37,7 @@ // FIXME: optimize -namespace netlist -{ - namespace devices - { +namespace netlist::devices { static constexpr const std::array<netlist_time, 2> delay = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(25) }; static constexpr const std::array<netlist_time, 2> delay_clear = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) }; @@ -115,5 +112,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74175, "TTL_74175", "+CLK,+D1,+D2,+D3,+D4,+CLRQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74192.cpp b/src/lib/netlist/devices/nld_74192.cpp index 5f56f67dc93..a99b828afa2 100644 --- a/src/lib/netlist/devices/nld_74192.cpp +++ b/src/lib/netlist/devices/nld_74192.cpp @@ -29,10 +29,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { static constexpr const unsigned MAXCNT = 9; @@ -153,5 +150,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74192, "TTL_74192", "+A,+B,+C,+D,+CLEAR,+LOADQ,+CU,+CD,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74193.cpp b/src/lib/netlist/devices/nld_74193.cpp index e4dec831f68..c23119c2b66 100644 --- a/src/lib/netlist/devices/nld_74193.cpp +++ b/src/lib/netlist/devices/nld_74193.cpp @@ -25,10 +25,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { static constexpr const unsigned MAXCNT = 15; @@ -137,5 +134,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74193, "TTL_74193", "+A,+B,+C,+D,+CLEAR,+LOADQ,+CU,+CD,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74194.cpp b/src/lib/netlist/devices/nld_74194.cpp index c20f4b96021..4f9fbe69940 100644 --- a/src/lib/netlist/devices/nld_74194.cpp +++ b/src/lib/netlist/devices/nld_74194.cpp @@ -25,10 +25,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { // FIXME: Optimize NETLIB_OBJECT(74194) @@ -113,5 +110,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74194, "TTL_74194", "+CLK,+S0,+S1,+SRIN,+A,+B,+C,+D,+SLIN,+CLRQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74365.cpp b/src/lib/netlist/devices/nld_74365.cpp index 8f078743773..2cc582fbc8a 100644 --- a/src/lib/netlist/devices/nld_74365.cpp +++ b/src/lib/netlist/devices/nld_74365.cpp @@ -24,10 +24,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { /* FIXME: This should be a single device, i.e. one tristate buffer only. * @@ -71,5 +68,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74365, "TTL_74365", "+G1Q,+G2Q,+A1,+A2,+A3,+A4,+A5,+A6,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74377.cpp b/src/lib/netlist/devices/nld_74377.cpp index dc38dbc0d2d..aeb530e925a 100644 --- a/src/lib/netlist/devices/nld_74377.cpp +++ b/src/lib/netlist/devices/nld_74377.cpp @@ -50,10 +50,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { constexpr const std::array<netlist_time, 2> delay = { NLTIME_FROM_NS(25), NLTIME_FROM_NS(25) }; @@ -101,5 +98,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74377_GATE, "TTL_74377_GATE", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74393.cpp b/src/lib/netlist/devices/nld_74393.cpp index 5e9cef831d0..cf5adaf4e22 100644 --- a/src/lib/netlist/devices/nld_74393.cpp +++ b/src/lib/netlist/devices/nld_74393.cpp @@ -21,10 +21,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + static constexpr const unsigned MAXCNT = 15; NETLIB_OBJECT(74393) @@ -87,5 +85,4 @@ namespace netlist NETLIB_DEVICE_IMPL(74393, "TTL_74393", "+CP,+MR,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7448.cpp b/src/lib/netlist/devices/nld_7448.cpp index f4acbc432bd..09ed2e2a39f 100644 --- a/src/lib/netlist/devices/nld_7448.cpp +++ b/src/lib/netlist/devices/nld_7448.cpp @@ -26,10 +26,8 @@ #include <array> -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(7448) { NETLIB_CONSTRUCTOR(7448) @@ -136,5 +134,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7448, "TTL_7448", "+A,+B,+C,+D,+LTQ,+BIQ,+RBIQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7450.cpp b/src/lib/netlist/devices/nld_7450.cpp index d4fc9319b0f..19827c032f9 100644 --- a/src/lib/netlist/devices/nld_7450.cpp +++ b/src/lib/netlist/devices/nld_7450.cpp @@ -23,10 +23,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { static constexpr const std::array<netlist_time, 2> times = { NLTIME_FROM_NS(15), NLTIME_FROM_NS(22) }; @@ -90,5 +87,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7450, "TTL_7450_ANDORINVERT", "+A,+B,+C,+D,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7473.cpp b/src/lib/netlist/devices/nld_7473.cpp index dbfedecb72e..5314ad50968 100644 --- a/src/lib/netlist/devices/nld_7473.cpp +++ b/src/lib/netlist/devices/nld_7473.cpp @@ -59,10 +59,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(7473) { NETLIB_CONSTRUCTOR(7473) @@ -137,5 +135,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7473, "TTL_7473", "+CLK,+J,+K,+CLRQ,@VCC,@GND") NETLIB_DEVICE_IMPL(7473A, "TTL_7473A", "+CLK,+J,+K,+CLRQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7474.cpp b/src/lib/netlist/devices/nld_7474.cpp index 16a259312dd..da68a6b2ae5 100644 --- a/src/lib/netlist/devices/nld_7474.cpp +++ b/src/lib/netlist/devices/nld_7474.cpp @@ -44,10 +44,7 @@ #include <array> -namespace netlist -{ - namespace devices - { +namespace netlist::devices { NETLIB_OBJECT(7474) { @@ -117,5 +114,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7474, "TTL_7474", "+CLK,+D,+CLRQ,+PREQ,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7475.cpp b/src/lib/netlist/devices/nld_7475.cpp index 1e5e9c82b1c..73b32a34807 100644 --- a/src/lib/netlist/devices/nld_7475.cpp +++ b/src/lib/netlist/devices/nld_7475.cpp @@ -36,10 +36,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + template<bool HasQQ> NETLIB_OBJECT(7475_GATE_BASE) { @@ -97,5 +95,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7475_GATE, "TTL_7475_GATE", "") NETLIB_DEVICE_IMPL(7477_GATE, "TTL_7477_GATE", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7483.cpp b/src/lib/netlist/devices/nld_7483.cpp index d6708cbd3b6..5a311b5debd 100644 --- a/src/lib/netlist/devices/nld_7483.cpp +++ b/src/lib/netlist/devices/nld_7483.cpp @@ -26,10 +26,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(7483) { NETLIB_CONSTRUCTOR(7483) @@ -111,5 +109,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7483, "TTL_7483", "+A1,+A2,+A3,+A4,+B1,+B2,+B3,+B4,+C0,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7485.cpp b/src/lib/netlist/devices/nld_7485.cpp index 40a4831e1f7..5c15879c10b 100644 --- a/src/lib/netlist/devices/nld_7485.cpp +++ b/src/lib/netlist/devices/nld_7485.cpp @@ -24,10 +24,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(7485) { NETLIB_CONSTRUCTOR(7485) @@ -95,5 +93,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7485, "TTL_7485", "+A0,+A1,+A2,+A3,+B0,+B1,+B2,+B3,+LTIN,+EQIN,+GTIN,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7490.cpp b/src/lib/netlist/devices/nld_7490.cpp index abf93a4189b..ffd3870db60 100644 --- a/src/lib/netlist/devices/nld_7490.cpp +++ b/src/lib/netlist/devices/nld_7490.cpp @@ -54,10 +54,7 @@ #include "nl_base.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { static constexpr const std::array<netlist_time, 4> delay = { @@ -143,5 +140,4 @@ namespace devices NETLIB_DEVICE_IMPL(7490, "TTL_7490", "+A,+B,+R1,+R2,+R91,+R92,@VCC,@GND") -} // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7492.cpp b/src/lib/netlist/devices/nld_7492.cpp index 3bf120f3c68..15f5d0c6268 100644 --- a/src/lib/netlist/devices/nld_7492.cpp +++ b/src/lib/netlist/devices/nld_7492.cpp @@ -52,10 +52,7 @@ #include "nl_base.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { static constexpr const std::array<netlist_time, 4> delay = { @@ -135,5 +132,4 @@ namespace devices NETLIB_DEVICE_IMPL(7492, "TTL_7492", "+A,+B,+R1,+R2,@VCC,@GND") -} // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7493.cpp b/src/lib/netlist/devices/nld_7493.cpp index 54d44dc1fea..aca73ac3861 100644 --- a/src/lib/netlist/devices/nld_7493.cpp +++ b/src/lib/netlist/devices/nld_7493.cpp @@ -57,10 +57,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { static constexpr std::array<netlist_time, 3> out_delay { NLTIME_FROM_NS(18), NLTIME_FROM_NS(36), NLTIME_FROM_NS(54) }; @@ -133,5 +130,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7493, "TTL_7493", "+CLKA,+CLKB,+R1,+R2,@VCC,@GND") - } // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_7497.cpp b/src/lib/netlist/devices/nld_7497.cpp index 895f8b5a07f..33565397fc8 100644 --- a/src/lib/netlist/devices/nld_7497.cpp +++ b/src/lib/netlist/devices/nld_7497.cpp @@ -39,10 +39,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { static constexpr const std::array<netlist_time, 2> out_delay_CLK_Y = { NLTIME_FROM_NS(20), NLTIME_FROM_NS(26) }; // tPHL, tPLH static constexpr const std::array<netlist_time, 2> out_delay_CLK_Z = { NLTIME_FROM_NS(17), NLTIME_FROM_NS(12) }; @@ -168,5 +165,4 @@ namespace netlist NETLIB_DEVICE_IMPL(7497, "TTL_7497", "+CLK,+STRBQ,+ENQ,+UNITYQ,+CLR,+B0,+B1,+B2,+B3,+B4,+B5,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_74ls629.cpp b/src/lib/netlist/devices/nld_74ls629.cpp index 6e28feffdfc..398618e31dc 100644 --- a/src/lib/netlist/devices/nld_74ls629.cpp +++ b/src/lib/netlist/devices/nld_74ls629.cpp @@ -60,10 +60,7 @@ #include "analog/nlid_twoterm.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { struct SN74LS629clk { @@ -207,5 +204,4 @@ namespace netlist NETLIB_DEVICE_IMPL(SN74LS629, "SN74LS629", "CAP,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_8277.cpp b/src/lib/netlist/devices/nld_8277.cpp index 9832a2857cc..eaebff30eec 100644 --- a/src/lib/netlist/devices/nld_8277.cpp +++ b/src/lib/netlist/devices/nld_8277.cpp @@ -20,10 +20,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(8277_shifter) { NETLIB_CONSTRUCTOR(8277_shifter) @@ -165,5 +163,4 @@ namespace netlist NETLIB_DEVICE_IMPL(8277, "TTL_8277", "+RESET,+CLK,+CLKA,+D0A,+D1A,+DSA,+CLKB,+D0B,+D1B,+DSB,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_82s115.cpp b/src/lib/netlist/devices/nld_82s115.cpp index f1e49bd9f83..5c7db00f347 100755 --- a/src/lib/netlist/devices/nld_82s115.cpp +++ b/src/lib/netlist/devices/nld_82s115.cpp @@ -27,10 +27,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(82S115) { NETLIB_CONSTRUCTOR(82S115) @@ -93,5 +91,4 @@ namespace netlist NETLIB_DEVICE_IMPL(82S115, "PROM_82S115", "+CE1Q,+CE2,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+STROBE,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_82s16.cpp b/src/lib/netlist/devices/nld_82s16.cpp index 2fc92adfe30..44b2e5865ea 100755 --- a/src/lib/netlist/devices/nld_82s16.cpp +++ b/src/lib/netlist/devices/nld_82s16.cpp @@ -24,10 +24,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(82S16) { NETLIB_CONSTRUCTOR(82S16) @@ -123,5 +121,4 @@ namespace netlist NETLIB_DEVICE_IMPL(82S16, "TTL_82S16", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_9310.cpp b/src/lib/netlist/devices/nld_9310.cpp index f58f8cd59bf..b00fd764eec 100644 --- a/src/lib/netlist/devices/nld_9310.cpp +++ b/src/lib/netlist/devices/nld_9310.cpp @@ -17,12 +17,8 @@ // FIXME: this file could be created programmatically -namespace netlist -{ - namespace devices - { +namespace netlist::devices { - NETLIB_DEVICE_IMPL(9310, "TTL_9310", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") + NETLIB_DEVICE_IMPL(9310, "TTL_9310", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_9316.cpp b/src/lib/netlist/devices/nld_9316.cpp index 1444eab368e..39cddc41473 100644 --- a/src/lib/netlist/devices/nld_9316.cpp +++ b/src/lib/netlist/devices/nld_9316.cpp @@ -93,12 +93,8 @@ // FIXME: this file could be created programmatically -namespace netlist -{ - namespace devices - { +namespace netlist::devices { - NETLIB_DEVICE_IMPL(9316, "TTL_9316", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") + NETLIB_DEVICE_IMPL(9316, "TTL_9316", "+CLK,+ENP,+ENT,+CLRQ,+LOADQ,+A,+B,+C,+D,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_9321.cpp b/src/lib/netlist/devices/nld_9321.cpp index 29d63b2b3fc..8adaaad0f6b 100644 --- a/src/lib/netlist/devices/nld_9321.cpp +++ b/src/lib/netlist/devices/nld_9321.cpp @@ -20,10 +20,7 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { // FIXME: m_E should activate deactivate m_A @@ -66,5 +63,4 @@ namespace netlist NETLIB_DEVICE_IMPL(9321, "TTL_9321", "+E,+A0,+A1") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_9322.cpp b/src/lib/netlist/devices/nld_9322.cpp index 2d952487a02..8dee361c8bb 100644 --- a/src/lib/netlist/devices/nld_9322.cpp +++ b/src/lib/netlist/devices/nld_9322.cpp @@ -20,10 +20,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + class NETLIB_NAME(9322); NETLIB_OBJECT(9322_GATE) @@ -108,5 +106,4 @@ namespace netlist NETLIB_DEVICE_IMPL(9322, "TTL_9322", "+SELECT,+A1,+B1,+A2,+B2,+A3,+B3,+A4,+B4,+STROBE,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_am2847.cpp b/src/lib/netlist/devices/nld_am2847.cpp index fb4cc384aea..78627831bf6 100644 --- a/src/lib/netlist/devices/nld_am2847.cpp +++ b/src/lib/netlist/devices/nld_am2847.cpp @@ -20,10 +20,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(Am2847_shifter) { NETLIB_CONSTRUCTOR_MODEL(Am2847_shifter, "CD4XXX") @@ -128,5 +126,4 @@ namespace netlist NETLIB_DEVICE_IMPL(AM2847, "TTL_AM2847", "+CP,+INA,+INB,+INC,+IND,+RCA,+RCB,+RCC,+RCD,@VSS,@VDD") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_dm9314.cpp b/src/lib/netlist/devices/nld_dm9314.cpp index 0f3980df98b..edb789dda64 100644 --- a/src/lib/netlist/devices/nld_dm9314.cpp +++ b/src/lib/netlist/devices/nld_dm9314.cpp @@ -20,10 +20,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(9314) { NETLIB_CONSTRUCTOR(9314) @@ -98,5 +96,4 @@ namespace netlist NETLIB_DEVICE_IMPL(9314, "TTL_9314", "+EQ,+MRQ,+S0Q,+S1Q,+S2Q,+S3Q,+D0,+D1,+D2,+D3,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_dm9334.cpp b/src/lib/netlist/devices/nld_dm9334.cpp index d3989935f77..1631ed99264 100644 --- a/src/lib/netlist/devices/nld_dm9334.cpp +++ b/src/lib/netlist/devices/nld_dm9334.cpp @@ -64,10 +64,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(9334) { NETLIB_CONSTRUCTOR(9334) @@ -177,5 +175,4 @@ namespace netlist NETLIB_DEVICE_IMPL(9334, "TTL_9334", "+CQ,+EQ,+D,+A0,+A1,+A2,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_legacy.cpp b/src/lib/netlist/devices/nld_legacy.cpp index 338aeef73c9..31e2057d463 100644 --- a/src/lib/netlist/devices/nld_legacy.cpp +++ b/src/lib/netlist/devices/nld_legacy.cpp @@ -7,10 +7,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(nicRSFF) { NETLIB_CONSTRUCTOR(nicRSFF) @@ -96,5 +94,4 @@ namespace netlist NETLIB_DEVICE_IMPL(nicRSFF, "NETDEV_RSFF", "") NETLIB_DEVICE_IMPL(nicDelay, "NETDEV_DELAY", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_log.cpp b/src/lib/netlist/devices/nld_log.cpp index c2a6523f64a..d359e3c20d2 100644 --- a/src/lib/netlist/devices/nld_log.cpp +++ b/src/lib/netlist/devices/nld_log.cpp @@ -28,10 +28,8 @@ #include <thread> #include <vector> -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(log) { NETLIB_CONSTRUCTOR(log) @@ -187,5 +185,4 @@ namespace netlist NETLIB_DEVICE_IMPL(log, "LOG", "+I") NETLIB_DEVICE_IMPL(logD, "LOGD", "+I,+I2") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_mm5837.cpp b/src/lib/netlist/devices/nld_mm5837.cpp index 45b97ade9ef..3b18e07e5f6 100644 --- a/src/lib/netlist/devices/nld_mm5837.cpp +++ b/src/lib/netlist/devices/nld_mm5837.cpp @@ -19,10 +19,8 @@ #include "analog/nlid_twoterm.h" #include "solver/nld_matrix_solver.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(MM5837) { NETLIB_CONSTRUCTOR(MM5837) @@ -115,5 +113,4 @@ namespace netlist NETLIB_DEVICE_IMPL(MM5837, "MM5837", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_ne555.cpp b/src/lib/netlist/devices/nld_ne555.cpp index 3f1238681e2..7ba7c1e08a3 100644 --- a/src/lib/netlist/devices/nld_ne555.cpp +++ b/src/lib/netlist/devices/nld_ne555.cpp @@ -10,10 +10,8 @@ #define R_OFF (1E20) #define R_ON (1) -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(NE555) { NETLIB_CONSTRUCTOR(NE555) @@ -161,5 +159,5 @@ namespace netlist NETLIB_DEVICE_IMPL(NE555, "NE555", "") NETLIB_DEVICE_IMPL_ALIAS(MC1455P, NE555, "MC1455P", "") - } //namespace devices -} // namespace netlist + +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_r2r_dac.cpp b/src/lib/netlist/devices/nld_r2r_dac.cpp index da571930601..2b982674def 100644 --- a/src/lib/netlist/devices/nld_r2r_dac.cpp +++ b/src/lib/netlist/devices/nld_r2r_dac.cpp @@ -47,10 +47,8 @@ #include "analog/nlid_twoterm.h" #include "nl_factory.h" -namespace netlist -{ - namespace analog - { +namespace netlist::analog { + NETLIB_OBJECT_DERIVED(r2r_dac, twoterm) { NETLIB_CONSTRUCTOR(r2r_dac) @@ -85,10 +83,11 @@ namespace netlist } ); } - } //namespace analog - namespace devices { - NETLIB_DEVICE_IMPL_NS(analog, r2r_dac, "R2R_DAC", "VIN,R,N") - } // namespace devices +} // namespace netlist::analog + +namespace netlist::devices { + + NETLIB_DEVICE_IMPL_NS(analog, r2r_dac, "R2R_DAC", "VIN,R,N") -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_roms.cpp b/src/lib/netlist/devices/nld_roms.cpp index e2e4ba4eb77..ef4ccc71c8f 100644 --- a/src/lib/netlist/devices/nld_roms.cpp +++ b/src/lib/netlist/devices/nld_roms.cpp @@ -11,7 +11,7 @@ template <typename N, typename T> constexpr bool TOR(N n, T &a) { - return (n == 0 ? false : TOR(n-1, a) || a[n-1]()); + return (n == 0) ? false : (TOR(n - 1, a) || a[n - 1]()); } template <typename T> @@ -20,275 +20,273 @@ constexpr bool TOR(T &a) return TOR(a.size(), a); } -namespace netlist -{ - namespace devices +namespace netlist::devices { + + NETLIB_OBJECT(mk28000_prom) { - NETLIB_OBJECT(mk28000_prom) + NETLIB_CONSTRUCTOR(mk28000_prom) + , m_enable_lo(*this, "m_enable_lo", false) + , m_enable_hi(*this, "m_enable_hi", false) + , m_latched_rom(*this, "m_latched_rom", 0) + , m_A(*this, 1, "A{}", NETLIB_DELEGATE(addr)) + , m_ARQ(*this, "ARQ", NETLIB_DELEGATE(addr)) + , m_OE1(*this, "OE1", NETLIB_DELEGATE(oe1)) + , m_OE2(*this, "OE2", NETLIB_DELEGATE(oe2)) + , m_O(*this, 1, "O{}", 0) + , m_ROM(*this, "ROM") + , m_power_pins(*this) + { + } + + private: + NETLIB_HANDLERI(oe1) { - NETLIB_CONSTRUCTOR(mk28000_prom) - , m_enable_lo(*this, "m_enable_lo", false) - , m_enable_hi(*this, "m_enable_hi", false) - , m_latched_rom(*this, "m_latched_rom", 0) - , m_A(*this, 1, "A{}", NETLIB_DELEGATE(addr)) - , m_ARQ(*this, "ARQ", NETLIB_DELEGATE(addr)) - , m_OE1(*this, "OE1", NETLIB_DELEGATE(oe1)) - , m_OE2(*this, "OE2", NETLIB_DELEGATE(oe2)) - , m_O(*this, 1, "O{}", 0) - , m_ROM(*this, "ROM") - , m_power_pins(*this) + m_enable_lo = m_OE1(); + uint8_t o = m_enable_lo ? m_latched_rom : 0; + for (std::size_t i=0; i<4; i++) { + m_O.set_tristate(!m_enable_lo, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); + m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); } + } - private: - NETLIB_HANDLERI(oe1) + NETLIB_HANDLERI(oe2) + { + m_enable_hi = m_OE2(); + uint8_t o = m_enable_hi ? m_latched_rom : 0; + for (std::size_t i=4; i<8; i++) { - m_enable_lo = m_OE1(); - uint8_t o = m_enable_lo ? m_latched_rom : 0; - for (std::size_t i=0; i<4; i++) - { - m_O.set_tristate(!m_enable_lo, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); - m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); - } + m_O.set_tristate(!m_enable_hi, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); + m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); } + } - NETLIB_HANDLERI(oe2) + NETLIB_HANDLERI(addr) + { + if (!m_ARQ()) { - m_enable_hi = m_OE2(); - uint8_t o = m_enable_hi ? m_latched_rom : 0; - for (std::size_t i=4; i<8; i++) - { - m_O.set_tristate(!m_enable_hi, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); - m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); - } + const auto addr = m_A(); + m_latched_rom = m_ROM[addr]; } - - NETLIB_HANDLERI(addr) + uint8_t o = (m_enable_hi || m_enable_lo) ? m_latched_rom : 0; + for (std::size_t i=0; i<4; i++) { - if (!m_ARQ()) - { - const auto addr = m_A(); - m_latched_rom = m_ROM[addr]; - } - uint8_t o = (m_enable_hi || m_enable_lo) ? m_latched_rom : 0; - for (std::size_t i=0; i<4; i++) - { - m_O.set_tristate(!m_enable_lo, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); - m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); - } - for (std::size_t i=4; i<8; i++) - { - m_O.set_tristate(!m_enable_hi, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); - m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); - } + m_O.set_tristate(!m_enable_lo, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); + m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); } - - state_var<bool> m_enable_lo; - state_var<bool> m_enable_hi; - state_var<uint8_t> m_latched_rom; - object_array_t<logic_input_t, 11> m_A; - logic_input_t m_ARQ; - logic_input_t m_OE1; - logic_input_t m_OE2; - object_array_t<tristate_output_t, 8> m_O; - - param_rom_t<uint8_t, 11, 8> m_ROM; - nld_power_pins m_power_pins; - }; - - NETLIB_OBJECT(mcm14524_rom) - { - NETLIB_CONSTRUCTOR_MODEL(mcm14524_rom, "CD4XXX") - , m_enabled(*this, "m_enabled", true) - , m_latched_rom(*this, "m_latched_rom", 0) - , m_A(*this, 1, "A{}", NETLIB_DELEGATE(addr)) - , m_CLK(*this, "CLK", NETLIB_DELEGATE(addr)) - , m_clk_old(*this, "m_clk_old", true) - , m_EN(*this, "EN", NETLIB_DELEGATE(en)) - , m_B(*this, 1, "B{}", 0) - , m_ROM(*this, "ROM") - , m_taccc(*this, "m_taccc", netlist_time::from_nsec(1350)) - , m_taccen(*this, "m_taccen", netlist_time::from_nsec(245)) - , m_power_pins(*this, NETLIB_DELEGATE(vdd_vss)) + for (std::size_t i=4; i<8; i++) { + m_O.set_tristate(!m_enable_hi, NLTIME_FROM_NS(600), NLTIME_FROM_NS(600)); + m_O[i].push((o >> i) & 1, NLTIME_FROM_NS(600)); } + } + + state_var<bool> m_enable_lo; + state_var<bool> m_enable_hi; + state_var<uint8_t> m_latched_rom; + object_array_t<logic_input_t, 11> m_A; + logic_input_t m_ARQ; + logic_input_t m_OE1; + logic_input_t m_OE2; + object_array_t<tristate_output_t, 8> m_O; + + param_rom_t<uint8_t, 11, 8> m_ROM; + nld_power_pins m_power_pins; + }; + + NETLIB_OBJECT(mcm14524_rom) + { + NETLIB_CONSTRUCTOR_MODEL(mcm14524_rom, "CD4XXX") + , m_enabled(*this, "m_enabled", true) + , m_latched_rom(*this, "m_latched_rom", 0) + , m_A(*this, 1, "A{}", NETLIB_DELEGATE(addr)) + , m_CLK(*this, "CLK", NETLIB_DELEGATE(addr)) + , m_clk_old(*this, "m_clk_old", true) + , m_EN(*this, "EN", NETLIB_DELEGATE(en)) + , m_B(*this, 1, "B{}", 0) + , m_ROM(*this, "ROM") + , m_taccc(*this, "m_taccc", netlist_time::from_nsec(1350)) + , m_taccen(*this, "m_taccen", netlist_time::from_nsec(245)) + , m_power_pins(*this, NETLIB_DELEGATE(vdd_vss)) + { + } - private: - NETLIB_HANDLERI(en) + private: + NETLIB_HANDLERI(en) + { + m_enabled = m_EN(); + uint8_t o = m_enabled ? m_latched_rom : 0; // outputs are forced to 0 by enable going low; this chip does not have tri-state outputs! + for (std::size_t i=0; i<4; i++) { - m_enabled = m_EN(); - uint8_t o = m_enabled ? m_latched_rom : 0; // outputs are forced to 0 by enable going low; this chip does not have tri-state outputs! - for (std::size_t i=0; i<4; i++) - { - m_B[i].push((o >> i) & 1, m_taccen); - } + m_B[i].push((o >> i) & 1, m_taccen); } + } - NETLIB_HANDLERI(addr) + NETLIB_HANDLERI(addr) + { + if (!m_CLK() && m_clk_old) // latch on falling edge { - if (!m_CLK() && m_clk_old) // latch on falling edge - { - const auto addr = m_A(); - m_latched_rom = m_ROM[addr]; - } - m_clk_old = m_CLK(); - uint8_t o = m_enabled ? m_latched_rom : 0; // outputs are forced to 0 by enable going low; this chip does not have tri-state outputs! - for (std::size_t i=0; i<4; i++) - { - m_B[i].push((o >> i) & 1, m_taccc); - } + const auto addr = m_A(); + m_latched_rom = m_ROM[addr]; } - - NETLIB_HANDLERI(vdd_vss) + m_clk_old = m_CLK(); + uint8_t o = m_enabled ? m_latched_rom : 0; // outputs are forced to 0 by enable going low; this chip does not have tri-state outputs! + for (std::size_t i=0; i<4; i++) { - auto d = m_power_pins.VCC()() - m_power_pins.GND()(); - if (d > 0.1) // avoid unrealistic values - { - m_taccc = netlist_time::from_nsec(gsl::narrow_cast<unsigned>(7615.5 / d - 181)); - m_taccen = netlist_time::from_nsec(gsl::narrow_cast<unsigned>(1292.5 / d - 14.6)); - } + m_B[i].push((o >> i) & 1, m_taccc); } + } - state_var<bool> m_enabled; - state_var<uint8_t> m_latched_rom; - object_array_t<logic_input_t, 8> m_A; - logic_input_t m_CLK; - state_var<bool> m_clk_old; - logic_input_t m_EN; - object_array_t<tristate_output_t, 4> m_B; - param_rom_t<uint8_t, 8, 4> m_ROM; - state_var<netlist_time> m_taccc; // propagation time for data vs CLK - state_var<netlist_time> m_taccen; // propagation time for data vs /EN - nld_power_pins m_power_pins; - }; - - template <typename D> - NETLIB_OBJECT(generic_prom) + NETLIB_HANDLERI(vdd_vss) { - NETLIB_CONSTRUCTOR(generic_prom) - , m_enabled(*this, "m_enabled", true) - , m_TE(*this, "FORCE_TRISTATE_LOGIC", 0) - , m_A(*this, 0, "A{}", NETLIB_DELEGATE(addr)) - , m_CEQ(*this, 1, - D::chip_enable_mask::value ^ static_cast<size_t>(0xffff), pstring("CE{}"), - std::array<nldelegate, 3>{ NETLIB_DELEGATE(ce<0>), - NETLIB_DELEGATE(ce<1>), - NETLIB_DELEGATE(ce<2>)}) - , m_O(*this, D::data_name_offset::value, "O{}", m_TE()) - , m_ROM(*this, "ROM") - , m_power_pins(*this) + auto d = m_power_pins.VCC()() - m_power_pins.GND()(); + if (d > 0.1) // avoid unrealistic values { + m_taccc = netlist_time::from_nsec(gsl::narrow_cast<unsigned>(7615.5 / d - 181)); + m_taccen = netlist_time::from_nsec(gsl::narrow_cast<unsigned>(1292.5 / d - 14.6)); } + } + + state_var<bool> m_enabled; + state_var<uint8_t> m_latched_rom; + object_array_t<logic_input_t, 8> m_A; + logic_input_t m_CLK; + state_var<bool> m_clk_old; + logic_input_t m_EN; + object_array_t<tristate_output_t, 4> m_B; + param_rom_t<uint8_t, 8, 4> m_ROM; + state_var<netlist_time> m_taccc; // propagation time for data vs CLK + state_var<netlist_time> m_taccen; // propagation time for data vs /EN + nld_power_pins m_power_pins; + }; + + template <typename D> + NETLIB_OBJECT(generic_prom) + { + NETLIB_CONSTRUCTOR(generic_prom) + , m_enabled(*this, "m_enabled", true) + , m_TE(*this, "FORCE_TRISTATE_LOGIC", 0) + , m_A(*this, 0, "A{}", NETLIB_DELEGATE(addr)) + , m_CEQ(*this, 1, + D::chip_enable_mask::value ^ static_cast<size_t>(0xffff), pstring("CE{}"), + std::array<nldelegate, 3>{ NETLIB_DELEGATE(ce<0>), + NETLIB_DELEGATE(ce<1>), + NETLIB_DELEGATE(ce<2>)}) + , m_O(*this, D::data_name_offset::value, "O{}", m_TE()) + , m_ROM(*this, "ROM") + , m_power_pins(*this) + { + } - using data_type = typename plib::least_type_for_bits<D::data_width::value>::type; + using data_type = typename plib::least_type_for_bits<D::data_width::value>::type; - private: + private: - template <std::size_t N> - NETLIB_HANDLERI(ce) + template <std::size_t N> + NETLIB_HANDLERI(ce) + { + using cet = typename D::chip_enable_time; + m_enabled = (m_CEQ() == D::chip_enable_mask::value); + switch (D::output_id::value) { - using cet = typename D::chip_enable_time; - m_enabled = (m_CEQ() == D::chip_enable_mask::value); - switch (D::output_id::value) - { - case 0: // logic - { - m_O.push(m_ROM[m_A()], D::access_time::value()); - } - break; - case 1: // tristate - { - m_O.set_tristate(!m_enabled, cet::value(N), cet::value(N)); - m_O.push(m_ROM[m_A()], D::access_time::value()); - } - break; - default: // 2, open collector - { - const auto delay = m_enabled ? D::access_time::value() : cet::value(N); - const data_type o = m_enabled ? m_ROM[m_A()] : - (1 << D::data_width::value) - 1; - m_O.push(o, delay); - } - break; - } - + case 0: // logic + { + m_O.push(m_ROM[m_A()], D::access_time::value()); + } + break; + case 1: // tristate + { + m_O.set_tristate(!m_enabled, cet::value(N), cet::value(N)); + m_O.push(m_ROM[m_A()], D::access_time::value()); + } + break; + default: // 2, open collector + { + const auto delay = m_enabled ? D::access_time::value() : cet::value(N); + const data_type o = m_enabled ? m_ROM[m_A()] : + (1 << D::data_width::value) - 1; + m_O.push(o, delay); + } + break; } - NETLIB_HANDLERI(addr) + } + + NETLIB_HANDLERI(addr) + { + if (m_enabled) { - if (m_enabled) - { - m_O.push(m_ROM[m_A()], D::access_time::value()); - } + m_O.push(m_ROM[m_A()], D::access_time::value()); } + } - state_var<bool> m_enabled; - param_logic_t m_TE; - object_array_t<logic_input_t, D::address_width::value> m_A; - object_array_t<logic_input_t, D::chip_enable_inputs::value> m_CEQ; - object_array_t<typename D::output_type, D::data_width::value> m_O; + state_var<bool> m_enabled; + param_logic_t m_TE; + object_array_t<logic_input_t, D::address_width::value> m_A; + object_array_t<logic_input_t, D::chip_enable_inputs::value> m_CEQ; + object_array_t<typename D::output_type, D::data_width::value> m_O; - param_rom_t<uint8_t, D::address_width::value, D::data_width::value> m_ROM; - nld_power_pins m_power_pins; - }; + param_rom_t<uint8_t, D::address_width::value, D::data_width::value> m_ROM; + nld_power_pins m_power_pins; + }; - struct desc_82S126 : public desc_base - { - using address_width = desc_const<8>; - using data_width = desc_const<4>; - using data_name_offset = desc_const<1>; // O1, O2, .. - using chip_enable_inputs = desc_const<2>; - // MATCH_MASK : all 0 ==> all bits inverted - using chip_enable_mask = desc_const<0x00>; + struct desc_82S126 : public desc_base + { + using address_width = desc_const<8>; + using data_width = desc_const<4>; + using data_name_offset = desc_const<1>; // O1, O2, .. + using chip_enable_inputs = desc_const<2>; + // MATCH_MASK : all 0 ==> all bits inverted + using chip_enable_mask = desc_const<0x00>; - using chip_enable_time = times_ns2<25, 25>; - using access_time = time_ns<40>; + using chip_enable_time = times_ns2<25, 25>; + using access_time = time_ns<40>; - using output_type = tristate_output_t; - using output_id = desc_const<1>; // 0: logic, 1: tristate, 2: open collector - }; + using output_type = tristate_output_t; + using output_id = desc_const<1>; // 0: logic, 1: tristate, 2: open collector + }; - struct desc_74S287 : public desc_82S126 - { - using data_name_offset = desc_const<0>; // O0, O1, ... according to National Semiconductor datasheet - using chip_enable_time = times_ns2<15, 15>; - using access_time = time_ns<35>; - }; + struct desc_74S287 : public desc_82S126 + { + using data_name_offset = desc_const<0>; // O0, O1, ... according to National Semiconductor datasheet + using chip_enable_time = times_ns2<15, 15>; + using access_time = time_ns<35>; + }; - struct desc_82S123 : public desc_base - { - // FIXME: tristate outputs, add 82S23 (open collector) - using address_width = desc_const<5>; - using data_width = desc_const<8>; - using data_name_offset = desc_const<0>; // O0, O1, .. - using chip_enable_inputs = desc_const<1>; - // MATCH_MASK : all 0 ==> all bits inverted - using chip_enable_mask = desc_const<0x00>; - - using chip_enable_time = times_ns1<35>; - using access_time = time_ns<45>; - - using output_type = tristate_output_t; - using output_id = desc_const<1>; // 0: logic, 1: tristate, 2: open collector - }; - - struct desc_2716 : public desc_base - { - // FIXME: tristate outputs - using address_width = desc_const<11>; - using data_width = desc_const<8>; - using data_name_offset = desc_const<0>; // O0, O1, .. + struct desc_82S123 : public desc_base + { + // FIXME: tristate outputs, add 82S23 (open collector) + using address_width = desc_const<5>; + using data_width = desc_const<8>; + using data_name_offset = desc_const<0>; // O0, O1, .. + using chip_enable_inputs = desc_const<1>; + // MATCH_MASK : all 0 ==> all bits inverted + using chip_enable_mask = desc_const<0x00>; + + using chip_enable_time = times_ns1<35>; + using access_time = time_ns<45>; + + using output_type = tristate_output_t; + using output_id = desc_const<1>; // 0: logic, 1: tristate, 2: open collector + }; + + struct desc_2716 : public desc_base + { + // FIXME: tristate outputs + using address_width = desc_const<11>; + using data_width = desc_const<8>; + using data_name_offset = desc_const<0>; // O0, O1, .. - using chip_enable_inputs = desc_const<2>; - // MATCH_MASK : all 0 ==> all bits inverted - using chip_enable_mask = desc_const<0x00>; + using chip_enable_inputs = desc_const<2>; + // MATCH_MASK : all 0 ==> all bits inverted + using chip_enable_mask = desc_const<0x00>; - using chip_enable_time = times_ns2<450, 100>; //CE, OE - using access_time = time_ns<450>; + using chip_enable_time = times_ns2<450, 100>; //CE, OE + using access_time = time_ns<450>; - using output_type = tristate_output_t; - using output_id = desc_const<1>; // 0: logic, 1: tristate, 2: open collector - }; + using output_type = tristate_output_t; + using output_id = desc_const<1>; // 0: logic, 1: tristate, 2: open collector + }; using NETLIB_NAME(82S123) = NETLIB_NAME(generic_prom)<desc_82S123>; // 256 bits, 32x8, used as 256x4 using NETLIB_NAME(82S126) = NETLIB_NAME(generic_prom)<desc_82S126>; // 1024 bits, 32x32, used as 256x4 @@ -304,5 +302,4 @@ namespace netlist NETLIB_DEVICE_IMPL(MK28000, "PROM_MK28000", "+OE1,+OE2,+ARQ,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+A9,+A10,+A11,@VCC,@GND") NETLIB_DEVICE_IMPL(MCM14524, "ROM_MCM14524", "+EN,+CLK,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_schmitt.cpp b/src/lib/netlist/devices/nld_schmitt.cpp index 898e642ad53..8c9bf70d9d8 100644 --- a/src/lib/netlist/devices/nld_schmitt.cpp +++ b/src/lib/netlist/devices/nld_schmitt.cpp @@ -10,117 +10,113 @@ #include "nl_errstr.h" #include "solver/nld_solver.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { - /* - * Over-simplified TTL Schmitt trigger model - * It's good enough to work for 74xx/74LSxx if it isn't abused too badly - * It would need major changes to support 4000 or 74HCxx behaviour - * The input is over-simplified - it's actually more like a resistor in series with a diode, and can only source current - * Similarly, high output can only source current and low output can only sink current - * Propagation delays are ignored - * - */ + /* + * Over-simplified TTL Schmitt trigger model + * It's good enough to work for 74xx/74LSxx if it isn't abused too badly + * It would need major changes to support 4000 or 74HCxx behaviour + * The input is over-simplified - it's actually more like a resistor in series with a diode, and can only source current + * Similarly, high output can only source current and low output can only sink current + * Propagation delays are ignored + * + */ - class schmitt_trigger_model_t + class schmitt_trigger_model_t + { + public: + schmitt_trigger_model_t(param_model_t &model) + : m_VTP(model, "VTP") + , m_VTM(model, "VTM") + , m_VI(model, "VI") + , m_RI(model, "RI") + , m_VOH(model, "VOH") + , m_ROH(model, "ROH") + , m_VOL(model, "VOL") + , m_ROL(model, "ROL") + , m_TPLH(model, "TPLH") + , m_TPHL(model, "TPHL") { - public: - schmitt_trigger_model_t(param_model_t &model) - : m_VTP(model, "VTP") - , m_VTM(model, "VTM") - , m_VI(model, "VI") - , m_RI(model, "RI") - , m_VOH(model, "VOH") - , m_ROH(model, "ROH") - , m_VOL(model, "VOL") - , m_ROL(model, "ROL") - , m_TPLH(model, "TPLH") - , m_TPHL(model, "TPHL") - { - } + } - param_model_t::value_t m_VTP; - param_model_t::value_t m_VTM; - param_model_t::value_t m_VI; - param_model_t::value_t m_RI; - param_model_t::value_t m_VOH; - param_model_t::value_t m_ROH; - param_model_t::value_t m_VOL; - param_model_t::value_t m_ROL; - param_model_t::value_t m_TPLH; - param_model_t::value_t m_TPHL; - }; + param_model_t::value_t m_VTP; + param_model_t::value_t m_VTM; + param_model_t::value_t m_VI; + param_model_t::value_t m_RI; + param_model_t::value_t m_VOH; + param_model_t::value_t m_ROH; + param_model_t::value_t m_VOL; + param_model_t::value_t m_ROL; + param_model_t::value_t m_TPLH; + param_model_t::value_t m_TPHL; + }; - NETLIB_OBJECT(schmitt_trigger) + NETLIB_OBJECT(schmitt_trigger) + { + NETLIB_CONSTRUCTOR(schmitt_trigger) + , m_A(*this, "A", NETLIB_DELEGATE(input)) + , m_supply(*this) + , m_RVI(*this, "RVI") + , m_RVO(*this, "RVO") + , m_stmodel(*this, "STMODEL", "TTL_7414_GATE") + , m_modacc(m_stmodel) + , m_last_state(*this, "m_last_var", 1) { - NETLIB_CONSTRUCTOR(schmitt_trigger) - , m_A(*this, "A", NETLIB_DELEGATE(input)) - , m_supply(*this) - , m_RVI(*this, "RVI") - , m_RVO(*this, "RVO") - , m_stmodel(*this, "STMODEL", "TTL_7414_GATE") - , m_modacc(m_stmodel) - , m_last_state(*this, "m_last_var", 1) - { - register_subalias("Q", "RVO.1"); + register_subalias("Q", "RVO.1"); - connect("A", "RVI.1"); - // FIXME: need a symbolic reference from connect as well - connect(m_supply.GND(), m_RVI.N()); - connect(m_supply.GND(), m_RVO.N()); - } + connect("A", "RVI.1"); + // FIXME: need a symbolic reference from connect as well + connect(m_supply.GND(), m_RVI.N()); + connect(m_supply.GND(), m_RVO.N()); + } - protected: - NETLIB_RESETI() - { - m_last_state = 1; - m_RVI.reset(); - m_RVO.reset(); - m_RVI.set_G_V_I(plib::reciprocal(m_modacc.m_RI()), m_modacc.m_VI, nlconst::zero()); - m_RVO.set_G_V_I(plib::reciprocal(m_modacc.m_ROL()), m_modacc.m_VOL, nlconst::zero()); - } + protected: + NETLIB_RESETI() + { + m_last_state = 1; + m_RVI.reset(); + m_RVO.reset(); + m_RVI.set_G_V_I(plib::reciprocal(m_modacc.m_RI()), m_modacc.m_VI, nlconst::zero()); + m_RVO.set_G_V_I(plib::reciprocal(m_modacc.m_ROL()), m_modacc.m_VOL, nlconst::zero()); + } - private: - NETLIB_HANDLERI(input) + private: + NETLIB_HANDLERI(input) + { + const auto va(m_A.Q_Analog() - m_supply.GND().Q_Analog()); + if (m_last_state) { - const auto va(m_A.Q_Analog() - m_supply.GND().Q_Analog()); - if (m_last_state) + if (va < m_modacc.m_VTM) { - if (va < m_modacc.m_VTM) + m_last_state = 0; + m_RVO.change_state([this]() { - m_last_state = 0; - m_RVO.change_state([this]() - { - m_RVO.set_G_V_I(plib::reciprocal(m_modacc.m_ROH()), m_modacc.m_VOH, nlconst::zero()); - }); - } + m_RVO.set_G_V_I(plib::reciprocal(m_modacc.m_ROH()), m_modacc.m_VOH, nlconst::zero()); + }); } - else + } + else + { + if (va > m_modacc.m_VTP) { - if (va > m_modacc.m_VTP) + m_last_state = 1; + m_RVO.change_state([this]() { - m_last_state = 1; - m_RVO.change_state([this]() - { - m_RVO.set_G_V_I(plib::reciprocal(m_modacc.m_ROL()), m_modacc.m_VOL, nlconst::zero()); - }); - } + m_RVO.set_G_V_I(plib::reciprocal(m_modacc.m_ROL()), m_modacc.m_VOL, nlconst::zero()); + }); } } + } - analog_input_t m_A; - NETLIB_NAME(power_pins) m_supply; - analog::NETLIB_SUB(twoterm) m_RVI; - analog::NETLIB_SUB(twoterm) m_RVO; - param_model_t m_stmodel; - schmitt_trigger_model_t m_modacc; - state_var<int> m_last_state; - }; + analog_input_t m_A; + NETLIB_NAME(power_pins) m_supply; + analog::NETLIB_SUB(twoterm) m_RVI; + analog::NETLIB_SUB(twoterm) m_RVO; + param_model_t m_stmodel; + schmitt_trigger_model_t m_modacc; + state_var<int> m_last_state; + }; - NETLIB_DEVICE_IMPL(schmitt_trigger, "SCHMITT_TRIGGER", "STMODEL") + NETLIB_DEVICE_IMPL(schmitt_trigger, "SCHMITT_TRIGGER", "STMODEL") - } // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_system.cpp b/src/lib/netlist/devices/nld_system.cpp index 36ae9bc6e35..e622f8ce954 100644 --- a/src/lib/netlist/devices/nld_system.cpp +++ b/src/lib/netlist/devices/nld_system.cpp @@ -11,10 +11,7 @@ #include "plib/pstrutil.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { // ----------------------------------------------------------------------------- // extclock @@ -140,5 +137,4 @@ namespace devices NETLIB_DEVICE_IMPL(logic_input, "LOGIC_INPUT", "IN,MODEL") NETLIB_DEVICE_IMPL_ALIAS(logic_input_ttl, logic_input, "TTL_INPUT", "IN") -} // namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_tms4800.cpp b/src/lib/netlist/devices/nld_tms4800.cpp index f9ac6d00715..55b14921b2d 100644 --- a/src/lib/netlist/devices/nld_tms4800.cpp +++ b/src/lib/netlist/devices/nld_tms4800.cpp @@ -27,10 +27,8 @@ #include "nl_base.h" -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(TMS4800) { NETLIB_CONSTRUCTOR(TMS4800) @@ -88,5 +86,4 @@ namespace netlist NETLIB_DEVICE_IMPL(TMS4800, "ROM_TMS4800", "+AR,+OE1,+OE2,+A0,+A1,+A2,+A3,+A4,+A5,+A6,+A7,+A8,+A9,+A10,@VCC,@GND") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nld_tristate.cpp b/src/lib/netlist/devices/nld_tristate.cpp index cf4295bb39b..75576313af5 100644 --- a/src/lib/netlist/devices/nld_tristate.cpp +++ b/src/lib/netlist/devices/nld_tristate.cpp @@ -12,10 +12,8 @@ // FIXME: netlist now supports proper tristate outputs. All of this is legacy // now and needs to be removed at some time. -namespace netlist -{ - namespace devices - { +namespace netlist::devices { + NETLIB_OBJECT(tristate) { NETLIB_CONSTRUCTOR(tristate) @@ -73,5 +71,4 @@ namespace netlist NETLIB_DEVICE_IMPL(tristate, "TTL_TRISTATE", "+CEQ1,+D1,+CEQ2,+D2") NETLIB_DEVICE_IMPL(tristate3, "TTL_TRISTATE3", "") - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nlid_proxy.cpp b/src/lib/netlist/devices/nlid_proxy.cpp index e8cc27fc987..60aaef186c6 100644 --- a/src/lib/netlist/devices/nlid_proxy.cpp +++ b/src/lib/netlist/devices/nlid_proxy.cpp @@ -12,10 +12,7 @@ #include <array> -namespace netlist -{ - namespace devices - { +namespace netlist::devices { // ----------------------------------------------------------------------------- // nld_base_proxy @@ -184,6 +181,4 @@ namespace netlist } } - - } //namespace devices -} // namespace netlist +} // namespace netlist::devices diff --git a/src/lib/netlist/devices/nlid_proxy.h b/src/lib/netlist/devices/nlid_proxy.h index 74ad3469d63..8cacb245056 100644 --- a/src/lib/netlist/devices/nlid_proxy.h +++ b/src/lib/netlist/devices/nlid_proxy.h @@ -14,10 +14,7 @@ #include "analog/nlid_twoterm.h" #include "nl_base.h" -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { // ----------------------------------------------------------------------------- // nld_base_proxy @@ -121,7 +118,6 @@ namespace devices state_var<netlist_sig_t> m_last_state; }; -} // namespace devices -} // namespace netlist +} // namespace netlist::devices -#endif /* NLD_PROXY_H_ */ +#endif // NLD_PROXY_H_ diff --git a/src/lib/netlist/devices/nlid_system.h b/src/lib/netlist/devices/nlid_system.h index c1c44e764e1..475d16c46a9 100644 --- a/src/lib/netlist/devices/nlid_system.h +++ b/src/lib/netlist/devices/nlid_system.h @@ -16,10 +16,8 @@ #include <random> -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { + // ----------------------------------------------------------------------------- // clock // ----------------------------------------------------------------------------- @@ -579,7 +577,6 @@ namespace devices state_var<distribution> m_dis; }; -} // namespace devices -} // namespace netlist +} // namespace netlist::devices #endif // NLD_SYSTEM_H_ diff --git a/src/lib/netlist/devices/nlid_truthtable.cpp b/src/lib/netlist/devices/nlid_truthtable.cpp index db2471a704e..2bd1226d66a 100644 --- a/src/lib/netlist/devices/nlid_truthtable.cpp +++ b/src/lib/netlist/devices/nlid_truthtable.cpp @@ -12,10 +12,7 @@ #include <cstdint> #include <vector> -namespace netlist -{ -namespace devices -{ +namespace netlist::devices { template<std::size_t m_NI, std::size_t m_NO> class NETLIB_NAME(truthtable_t) : public device_t @@ -514,153 +511,152 @@ namespace devices return ignore.expand_and(jm); } -// ---------------------------------------------------------------------------------------- -// parseline -// ---------------------------------------------------------------------------------------- - -void truthtable_parser::parseline(unsigned cur, std::vector<pstring> list, - tt_bitset state, std::uint_least64_t val, std::vector<uint_least8_t> &timing_index) -{ - pstring elem = plib::trim(list[cur]); - std::uint_least64_t start = 0; - std::uint_least64_t end = 0; + // ---------------------------------------------------------------------------------------- + // parseline + // ---------------------------------------------------------------------------------------- - if (elem == "0") - { - start = 0; - end = 0; - } - else if (elem == "1") - { - start = 1; - end = 1; - } - else if (elem == "X") - { - start = 0; - end = 1; - } - else - nl_assert_always(false, "unknown input value (not 0, 1, or X)"); - for (std::uint_least64_t i = start; i <= end; i++) + void truthtable_parser::parseline(unsigned cur, std::vector<pstring> list, + tt_bitset state, std::uint_least64_t val, std::vector<uint_least8_t> &timing_index) { - tt_bitset nstate = state; - if (i==1) - nstate.set(cur); + pstring elem = plib::trim(list[cur]); + std::uint_least64_t start = 0; + std::uint_least64_t end = 0; - if (cur < m_num_bits - 1) + if (elem == "0") + { + start = 0; + end = 0; + } + else if (elem == "1") + { + start = 1; + end = 1; + } + else if (elem == "X") { - parseline(cur + 1, list, nstate, val, timing_index); + start = 0; + end = 1; } else + nl_assert_always(false, "unknown input value (not 0, 1, or X)"); + for (std::uint_least64_t i = start; i <= end; i++) { - // cutoff previous inputs and outputs for ignore - if (m_out_state[nstate] != m_out_state.mask() && m_out_state[nstate] != val) - throw nl_exception(plib::pfmt("Error in truthtable: State {1:04} already set, {2} != {3}\n") - .x(nstate.as_uint())(m_out_state[nstate])(val) ); - m_out_state.set(nstate, val); - for (std::size_t j=0; j<m_NO; j++) - m_timing[nstate * m_NO + j] = timing_index[j]; + tt_bitset nstate = state; + if (i==1) + nstate.set(cur); + + if (cur < m_num_bits - 1) + { + parseline(cur + 1, list, nstate, val, timing_index); + } + else + { + // cutoff previous inputs and outputs for ignore + if (m_out_state[nstate] != m_out_state.mask() && m_out_state[nstate] != val) + throw nl_exception(plib::pfmt("Error in truthtable: State {1:04} already set, {2} != {3}\n") + .x(nstate.as_uint())(m_out_state[nstate])(val) ); + m_out_state.set(nstate, val); + for (std::size_t j=0; j<m_NO; j++) + m_timing[nstate * m_NO + j] = timing_index[j]; + } } } -} - -void truthtable_parser::parse(const std::vector<pstring> &truthtable) -{ - unsigned line = 0; - - pstring ttline(truthtable[line]); - line++; - ttline = truthtable[line]; - line++; - for (unsigned j=0; j < m_size; j++) - m_out_state.set(j, tt_bitset::all_bits()); - - for (int j=0; j < 16; j++) - m_timing_nt[j] = netlist_time::zero(); - - while (!ttline.empty()) + void truthtable_parser::parse(const std::vector<pstring> &truthtable) { - std::vector<pstring> io(plib::psplit(ttline,'|')); - // checks - nl_assert_always(io.size() == 3, "io.count mismatch"); - std::vector<pstring> inout(plib::psplit(io[0], ',')); - nl_assert_always(inout.size() == m_num_bits, "number of bits not matching"); - std::vector<pstring> out(plib::psplit(io[1], ',')); - nl_assert_always(out.size() == m_NO, "output count not matching"); - std::vector<pstring> times(plib::psplit(io[2], ',')); - nl_assert_always(times.size() == m_NO, "timing count not matching"); + unsigned line = 0; + + pstring ttline(truthtable[line]); + line++; + ttline = truthtable[line]; + line++; - tt_bitset val = 0; - std::vector<uint_least8_t> tindex; + for (unsigned j=0; j < m_size; j++) + m_out_state.set(j, tt_bitset::all_bits()); - // - // FIXME: evaluation of outputs should be done in parseline to - // enable the use of inputs for output values, i.e. "I1" or "~I1" - // in addition to "0" and "1". + for (int j=0; j < 16; j++) + m_timing_nt[j] = netlist_time::zero(); - for (unsigned j=0; j<m_NO; j++) + while (!ttline.empty()) { - pstring outs = plib::trim(out[j]); - if (outs == "1") - val.set(j); + std::vector<pstring> io(plib::psplit(ttline,'|')); + // checks + nl_assert_always(io.size() == 3, "io.count mismatch"); + std::vector<pstring> inout(plib::psplit(io[0], ',')); + nl_assert_always(inout.size() == m_num_bits, "number of bits not matching"); + std::vector<pstring> out(plib::psplit(io[1], ',')); + nl_assert_always(out.size() == m_NO, "output count not matching"); + std::vector<pstring> times(plib::psplit(io[2], ',')); + nl_assert_always(times.size() == m_NO, "timing count not matching"); + + tt_bitset val = 0; + std::vector<uint_least8_t> tindex; + + // + // FIXME: evaluation of outputs should be done in parseline to + // enable the use of inputs for output values, i.e. "I1" or "~I1" + // in addition to "0" and "1". + + for (unsigned j=0; j<m_NO; j++) + { + pstring outs = plib::trim(out[j]); + if (outs == "1") + val.set(j); + else + nl_assert_always(outs == "0", "Unknown value (not 0 or 1"); + // FIXME: error handling + netlist_time t = netlist_time::from_nsec(plib::pstonum<std::int64_t>(plib::trim(times[j]))); + uint_least8_t k=0; + while (m_timing_nt[k] != netlist_time::zero() && m_timing_nt[k] != t) + k++; + m_timing_nt[k] = t; + tindex.push_back(k); //[j] = k; + } + + parseline(0, inout, 0 , val, tindex); + if (line < truthtable.size()) + ttline = truthtable[line]; else - nl_assert_always(outs == "0", "Unknown value (not 0 or 1"); - // FIXME: error handling - netlist_time t = netlist_time::from_nsec(plib::pstonum<std::int64_t>(plib::trim(times[j]))); - uint_least8_t k=0; - while (m_timing_nt[k] != netlist_time::zero() && m_timing_nt[k] != t) - k++; - m_timing_nt[k] = t; - tindex.push_back(k); //[j] = k; + ttline = ""; + line++; } - parseline(0, inout, 0 , val, tindex); - if (line < truthtable.size()) - ttline = truthtable[line]; - else - ttline = ""; - line++; - } - - // determine ignore mask by looping over all input combinations - std::vector<tt_bitset> ign(m_size); - for (tt_bitset &x : ign) - x.set(); + // determine ignore mask by looping over all input combinations + std::vector<tt_bitset> ign(m_size); + for (tt_bitset &x : ign) + x.set(); - for (std::uint_least64_t i=0; i < m_size; i++) - { - if (ign[i].all()) // not yet visited + for (std::uint_least64_t i=0; i < m_size; i++) { - tt_bitset tign = calculate_ignored_inputs(i); + if (ign[i].all()) // not yet visited + { + tt_bitset tign = calculate_ignored_inputs(i); - ign[i] = tign; + ign[i] = tign; - // don't need to recalculate similar ones - tt_bitset bitsk; - bitsk.set(tign.count()); + // don't need to recalculate similar ones + tt_bitset bitsk; + bitsk.set(tign.count()); - for (std::uint_least64_t k=0; k < bitsk; k++) - { - tt_bitset b = tign.expand_and(k); - ign[(i & tign.flip()) | b] = tign; + for (std::uint_least64_t k=0; k < bitsk; k++) + { + tt_bitset b = tign.expand_and(k); + ign[(i & tign.flip()) | b] = tign; + } } } - } - for (size_t i=0; i<m_size; i++) - { - if (m_out_state[i] == m_out_state.mask()) - throw nl_exception(plib::pfmt("truthtable: found element not set {1}\n").x(i) ); - m_out_state.set(i, m_out_state[i] | (ign[i] << m_NO)); + for (size_t i=0; i<m_size; i++) + { + if (m_out_state[i] == m_out_state.mask()) + throw nl_exception(plib::pfmt("truthtable: found element not set {1}\n").x(i) ); + m_out_state.set(i, m_out_state[i] | (ign[i] << m_NO)); + } } -} -} // namespace devices +} // namespace netlist::devices -namespace factory -{ +namespace netlist::factory { truthtable_base_element_t::truthtable_base_element_t(const pstring &name, properties &&props) @@ -708,5 +704,4 @@ namespace factory return ret; } -} // namespace factory -} // namespace netlist +} // namespace netlist::factory diff --git a/src/lib/netlist/devices/nlid_truthtable.h b/src/lib/netlist/devices/nlid_truthtable.h index 35f3786e71d..88833b7c688 100644 --- a/src/lib/netlist/devices/nlid_truthtable.h +++ b/src/lib/netlist/devices/nlid_truthtable.h @@ -13,23 +13,20 @@ #define USE_TT_ALTERNATIVE (0) -namespace netlist -{ - namespace factory +namespace netlist::factory { + + class truthtable_base_element_t : public factory::element_t { - class truthtable_base_element_t : public factory::element_t - { - public: - truthtable_base_element_t(const pstring &name,properties &&props); + public: + truthtable_base_element_t(const pstring &name,properties &&props); - std::vector<pstring> m_desc; - pstring m_family_name; - }; + std::vector<pstring> m_desc; + pstring m_family_name; + }; - host_arena::unique_ptr<truthtable_base_element_t> truthtable_create(tt_desc &desc, - properties &&props); + host_arena::unique_ptr<truthtable_base_element_t> truthtable_create(tt_desc &desc, + properties &&props); - } // namespace factory -} // namespace netlist +} // namespace netlist::factory #endif // NLID_TRUTHTABLE_H_ diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index 5572fc6e6d0..9200f206f56 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -191,11 +191,19 @@ using util::BIT; #include "eminline.h" #include <algorithm> +#include <cctype> +#include <cstdio> +#include <cstdlib> #include <cstring> #include <iostream> #include <stdexcept> -#include <cctype> +#ifdef _WIN32 +#include <fcntl.h> +#include <io.h> +#include <stdio.h> +#endif + using u8 = util::u8; using u16 = util::u16; @@ -1057,7 +1065,7 @@ static int parse_options(int argc, char *argv[], options *opts) char *curarg = argv[arg]; // is it a switch? - if(curarg[0] == '-') { + if(curarg[0] == '-' && curarg[1] != '\0') { if(pending_base || pending_arch || pending_mode || pending_skip || pending_count) goto usage; @@ -1083,11 +1091,9 @@ static int parse_options(int argc, char *argv[], options *opts) opts->xchbytes = true; else goto usage; - } + } else if(pending_base) { // base PC - else if(pending_base) - { int result; if(curarg[0] == '0' && curarg[1] == 'x') result = sscanf(&curarg[2], "%x", &opts->basepc); @@ -1098,30 +1104,26 @@ static int parse_options(int argc, char *argv[], options *opts) if(result != 1) goto usage; pending_base = false; - } - // mode - else if(pending_mode) - { + } else if(pending_mode) { + // mode if(sscanf(curarg, "%d", &opts->mode) != 1) goto usage; pending_mode = false; - } - // architecture - else if(pending_arch) { - int curarch; - for(curarch = 0; curarch < ARRAY_LENGTH(dasm_table); curarch++) - if(core_stricmp(curarg, dasm_table[curarch].name) == 0) - break; - if(curarch == ARRAY_LENGTH(dasm_table)) + } else if(pending_arch) { + // architecture + auto const arch = std::find_if( + std::begin(dasm_table), + std::end(dasm_table), + [&curarg] (dasm_table_entry const &e) { return !core_stricmp(curarg, e.name); }); + if (std::end(dasm_table) == arch) goto usage; - opts->dasm = &dasm_table[curarch]; + opts->dasm = &*arch; pending_arch = false; - } - // skip bytes - else if(pending_skip) { + } else if(pending_skip) { + // skip bytes int result; if(curarg[0] == '0' && curarg[1] == 'x') result = sscanf(&curarg[2], "%x", &opts->skip); @@ -1130,22 +1132,21 @@ static int parse_options(int argc, char *argv[], options *opts) if(result != 1) goto usage; pending_skip = false; - } - // size - else if(pending_count) { + } else if(pending_count) { + // size if(sscanf(curarg, "%d", &opts->count) != 1) goto usage; pending_count = false; - } - // filename - else if(opts->filename == nullptr) + } else if(opts->filename == nullptr) { + // filename opts->filename = curarg; - // fail - else + } else { + // fail goto usage; + } } // if we have a dangling option, error @@ -1155,6 +1156,7 @@ static int parse_options(int argc, char *argv[], options *opts) // if no file or no architecture, fail if(opts->filename == nullptr || opts->dasm == nullptr) goto usage; + return 0; usage: @@ -1166,8 +1168,7 @@ usage: const int colwidth = 1 + std::strlen(std::max_element(std::begin(dasm_table), std::end(dasm_table), [](const dasm_table_entry &a, const dasm_table_entry &b) { return std::strlen(a.name) < std::strlen(b.name); })->name); const int columns = std::max(1, 80 / colwidth); const int numrows = (ARRAY_LENGTH(dasm_table) + columns - 1) / columns; - for(unsigned curarch = 0; curarch < numrows * columns; curarch++) - { + for(unsigned curarch = 0; curarch < numrows * columns; curarch++) { const int row = curarch / columns; const int col = curarch % columns; const int index = col * numrows + row; @@ -1188,13 +1189,43 @@ int main(int argc, char *argv[]) return 1; // Load the file - void *data; - uint32_t length; - osd_file::error filerr = util::core_file::load(opts.filename, &data, length); - if(filerr != osd_file::error::NONE) + void *data = nullptr; + u32 length = 0; + if(std::strcmp(opts.filename, "-") != 0) { + osd_file::error filerr = util::core_file::load(opts.filename, &data, length); + if(filerr != osd_file::error::NONE) { + std::fprintf(stderr, "Error opening file '%s'\n", opts.filename); + return 1; + } + } + else { - fprintf(stderr, "Error opening file '%s'\n", opts.filename); - return 1; +#ifdef _WIN32 + if (_setmode(_fileno(stdin), _O_BINARY) == -1) { +#else + if (!std::freopen(nullptr, "rb", stdin)) { +#endif + std::fprintf(stderr, "Error reopening stin in binary mode\n"); + return 1; + } + std::size_t allocated = 0x1000; + data = std::malloc(allocated); + while(!std::ferror(stdin) && !std::feof(stdin)) { + if(length == allocated) { + allocated <<= 1; + data = std::realloc(data, allocated); + } + if(!data) { + std::fprintf(stderr, "Error allocating buffer\n"); + return 1; + } + + length += std::fread((u8 *)data + length, 1, allocated - length, stdin); + } + if(!length || (std::ferror(stdin) && !std::feof(stdin))) { + std::fprintf(stderr, "Error reading from stdin\n"); + return 1; + } } // Build the disasm object |