diff options
author | 2020-04-30 17:01:11 -0700 | |
---|---|---|
committer | 2020-05-01 10:08:40 +0200 | |
commit | 2b0aaee3ed4b85803e23d2f594728686107122bf (patch) | |
tree | 2e2c40342be7ad51adc3a4f36ba5c30bb7e5acce /src | |
parent | 13f6e92cec9bba6a96464e382f97d14e28628290 (diff) |
Add 74393 device and unit test.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/netlist/build/makefile | 1 | ||||
-rw-r--r-- | src/lib/netlist/devices/net_lib.cpp | 2 | ||||
-rw-r--r-- | src/lib/netlist/devices/net_lib.h | 1 | ||||
-rw-r--r-- | src/lib/netlist/devices/nld_74393.cpp | 115 | ||||
-rw-r--r-- | src/lib/netlist/devices/nld_74393.h | 37 | ||||
-rw-r--r-- | src/lib/netlist/examples/nld_74393_test.c | 32 |
6 files changed, 188 insertions, 0 deletions
diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile index 99000404552..1070b53bcc0 100644 --- a/src/lib/netlist/build/makefile +++ b/src/lib/netlist/build/makefile @@ -162,6 +162,7 @@ NLOBJS := \ $(NLOBJ)/devices/nld_74193.o \ $(NLOBJ)/devices/nld_74194.o \ $(NLOBJ)/devices/nld_74365.o \ + $(NLOBJ)/devices/nld_74393.o \ $(NLOBJ)/devices/nld_74ls629.o \ $(NLOBJ)/devices/nld_82S16.o \ $(NLOBJ)/devices/nld_82S115.o \ diff --git a/src/lib/netlist/devices/net_lib.cpp b/src/lib/netlist/devices/net_lib.cpp index d0d0077256b..1baf8bf33cb 100644 --- a/src/lib/netlist/devices/net_lib.cpp +++ b/src/lib/netlist/devices/net_lib.cpp @@ -126,6 +126,8 @@ namespace devices LIB_ENTRY(74193) LIB_ENTRY(74194) LIB_ENTRY(74365) + LIB_ENTRY(74393) + LIB_ENTRY(74393_dip) //ENTRY(74279, TTL_74279, "") // only dip available LIB_ENTRY(SN74LS629) LIB_ENTRY(82S16) diff --git a/src/lib/netlist/devices/net_lib.h b/src/lib/netlist/devices/net_lib.h index dbe1e8736fa..54e62c327e6 100644 --- a/src/lib/netlist/devices/net_lib.h +++ b/src/lib/netlist/devices/net_lib.h @@ -65,6 +65,7 @@ #include "nld_74193.h" #include "nld_74194.h" #include "nld_74365.h" +#include "nld_74393.h" #include "nld_7448.h" #include "nld_7450.h" #include "nld_7473.h" diff --git a/src/lib/netlist/devices/nld_74393.cpp b/src/lib/netlist/devices/nld_74393.cpp new file mode 100644 index 00000000000..56c554055a8 --- /dev/null +++ b/src/lib/netlist/devices/nld_74393.cpp @@ -0,0 +1,115 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * nld_74393.c + * + */ + +#include "nld_74393.h" +#include "netlist/nl_base.h" +#include "nlid_system.h" + +namespace netlist +{ + namespace devices + { + static constexpr const unsigned MAXCNT = 15; + + NETLIB_OBJECT(74393) + { + NETLIB_CONSTRUCTOR(74393) + , m_CP(*this, "CP") + , m_MR(*this, "MR") + , m_Q(*this, {"Q0", "Q1", "Q2", "Q3"}) + , m_cnt(*this, "m_cnt", 0) + , m_cp(*this, "m_cp", 0) + , m_mr(*this, "m_mr", 0) + , m_power_pins(*this) + { + } + + private: + NETLIB_RESETI() + { + m_cnt = 0; + } + + NETLIB_UPDATEI() + { + netlist_sig_t last_cp = m_cp; + netlist_sig_t last_mr = m_mr; + + m_cp = m_CP(); + m_mr = m_MR(); + + if (!last_mr && m_mr) + { + m_cnt = 0; + update_outputs_all(0, NLTIME_FROM_NS(24), NLTIME_FROM_NS(24), NLTIME_FROM_NS(24), NLTIME_FROM_NS(24)); + } + else if (!m_mr && last_cp && !m_cp) + { + auto cnt = (m_cnt + 1) & MAXCNT; + update_outputs_all(cnt, NLTIME_FROM_NS(13), NLTIME_FROM_NS(22), NLTIME_FROM_NS(31), NLTIME_FROM_NS(40)); + m_cnt = cnt; + } + } + + protected: + logic_input_t m_CP; + logic_input_t m_MR; + object_array_t<logic_output_t, 4> m_Q; + + state_var<unsigned> m_cnt; + state_var_sig m_cp; + state_var_sig m_mr; + + nld_power_pins m_power_pins; + + void update_outputs_all(unsigned cnt, netlist_time q0_delay, netlist_time q1_delay, netlist_time q2_delay, netlist_time q3_delay) noexcept + { + m_Q[0].push((cnt >> 0) & 1, q0_delay); + m_Q[1].push((cnt >> 1) & 1, q1_delay); + m_Q[2].push((cnt >> 2) & 1, q2_delay); + m_Q[3].push((cnt >> 3) & 1, q3_delay); + } + }; + + NETLIB_OBJECT(74393_dip) + { + NETLIB_CONSTRUCTOR(74393_dip) + , m_A(*this, "A") + , m_B(*this, "B") + { + register_subalias("1", "A.CP"); + register_subalias("2", "A.MR"); + register_subalias("3", "A.Q0"); + register_subalias("4", "A.Q1"); + register_subalias("5", "A.Q2"); + register_subalias("6", "A.Q3"); + register_subalias("7", "A.GND"); + + register_subalias("8", "B.Q3"); + register_subalias("9", "B.Q2"); + register_subalias("10", "B.Q1"); + register_subalias("11", "B.Q0"); + register_subalias("12", "B.MR"); + register_subalias("13", "B.CP"); + register_subalias("14", "A.VCC"); + + connect("A.GND", "B.GND"); + connect("A.VCC", "B.VCC"); + } + NETLIB_UPDATEI() { } + NETLIB_RESETI() { } + + private: + NETLIB_SUB(74393) m_A; + NETLIB_SUB(74393) m_B; + }; + + NETLIB_DEVICE_IMPL(74393, "TTL_74393", "+CP,+MR,@VCC,@GND") + NETLIB_DEVICE_IMPL(74393_dip, "TTL_74393_DIP", "") + + } //namespace devices +} // namespace netlist diff --git a/src/lib/netlist/devices/nld_74393.h b/src/lib/netlist/devices/nld_74393.h new file mode 100644 index 00000000000..b17f63b016a --- /dev/null +++ b/src/lib/netlist/devices/nld_74393.h @@ -0,0 +1,37 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * nld_74393.h + * + * DM74393: Dual 4-Stage Binary Counter + * + * +--------------+ + * /CP |1 ++ 14| VCC + * MR |2 13| /CP + * Q0 |3 12| MR + * Q1 |4 74393 11| Q0 + * Q2 |5 10| Q1 + * Q3 |6 9| Q2 + * GND |7 8| Q3 + * +--------------+ + * + * Naming conventions follow Motorola datasheet + * + */ + +#ifndef NLD_74393_H_ +#define NLD_74393_H_ + +#include "netlist/nl_setup.h" + +#define TTL_74393(name, cCP, cMR) \ + NET_REGISTER_DEV(TTL_74393, name) \ + NET_CONNECT(name, GND, GND) \ + NET_CONNECT(name, VCC, VCC) \ + NET_CONNECT(name, CP, cCP) \ + NET_CONNECT(name, MR, cMR) + +#define TTL_74393_DIP(name) \ + NET_REGISTER_DEV(TTL_74393_DIP, name) + +#endif /* NLD_74193_H_ */ diff --git a/src/lib/netlist/examples/nld_74393_test.c b/src/lib/netlist/examples/nld_74393_test.c new file mode 100644 index 00000000000..5dd33c6fce3 --- /dev/null +++ b/src/lib/netlist/examples/nld_74393_test.c @@ -0,0 +1,32 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * cdelay.c + * + */ + +#include "netlist/devices/net_lib.h" + +NETLIST_START(perf) + + SOLVER(Solver, 48000) + + ANALOG_INPUT(V5, 5) + + CLOCK(CLK, 100) // clock for driving the 74393 + CLOCK(CLK2, 3) // off-beat clock for master reset + TTL_74393_DIP(TESTCHIP) + + NET_C(V5, CLK.VCC, CLK2.VCC, TESTCHIP.14) + NET_C(GND, CLK.GND, CLK2.GND, TESTCHIP.7) + + NET_C(CLK, TESTCHIP.1, TESTCHIP.13) + NET_C(CLK2, TESTCHIP.2, TESTCHIP.12) + + LOG(logclk, CLK) + LOG(logQ0, TESTCHIP.3) + LOG(logQ1, TESTCHIP.4) + LOG(logQ2, TESTCHIP.5) + LOG(logQ3, TESTCHIP.6) + +NETLIST_END() |