summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
authorGravatarGravatar MooglyGuy <therealmogminer@gmail.com>2019-11-23 13:52:24 +0100
committerGravatarGravatar MooglyGuy <therealmogminer@gmail.com>2019-11-23 13:52:24 +0100
commit6d9e19148841768bb9fef5057bbc2d223eec9ee0 (patch)
treec9f0d2c345effe287c404a17268483ac4009719f /src/lib
parent881040610ebdffd6c19793b722951270a046e0f3 (diff)
-netlist: Added 7442 4-Line BCD to 10-Line Decimal Decoder. [Ryan Holtz]
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/netlist/devices/nld_7442.cpp104
-rw-r--r--src/lib/netlist/devices/nld_7442.h63
2 files changed, 167 insertions, 0 deletions
diff --git a/src/lib/netlist/devices/nld_7442.cpp b/src/lib/netlist/devices/nld_7442.cpp
new file mode 100644
index 00000000000..7e952428b88
--- /dev/null
+++ b/src/lib/netlist/devices/nld_7442.cpp
@@ -0,0 +1,104 @@
+// license:GPL-2.0+
+// copyright-holders:Ryan Holtz
+/*
+ * nld_7442.cpp
+ *
+ */
+
+#include "nld_7442.h"
+#include "netlist/nl_base.h"
+#include "nlid_system.h"
+
+namespace netlist
+{
+namespace devices
+{
+ static C14CONSTEXPR const netlist_time delay = NLTIME_FROM_NS(30); // Worst-case through 3 levels of logic
+
+ NETLIB_OBJECT(7442)
+ {
+ NETLIB_CONSTRUCTOR(7442)
+ , m_A(*this, "A")
+ , m_B(*this, "B")
+ , m_C(*this, "C")
+ , m_D(*this, "D")
+ , m_val(*this, "m_val", 0)
+ , m_last_val(*this, "m_last_val", 0)
+ , m_Q(*this, {{"Q0", "Q1", "Q2", "Q3", "Q4", "Q5", "Q6", "Q7", "Q8", "Q9"}})
+ , m_power_pins(*this)
+ {
+ }
+
+ private:
+ NETLIB_UPDATEI();
+ NETLIB_RESETI();
+
+ void update_outputs() noexcept
+ {
+ for (std::size_t i=0; i<10; i++)
+ m_Q[i].push(i == m_val ? 0 : 1, delay);
+ }
+
+ logic_input_t m_A;
+ logic_input_t m_B;
+ logic_input_t m_C;
+ logic_input_t m_D;
+
+ state_var_u8 m_val;
+ state_var_u8 m_last_val;
+
+ object_array_t<logic_output_t, 10> m_Q;
+ nld_power_pins m_power_pins;
+ };
+
+ NETLIB_OBJECT_DERIVED(7442_dip, 7442)
+ {
+ NETLIB_CONSTRUCTOR_DERIVED(7442_dip, 7442)
+ {
+ register_subalias("1", "Q0");
+ register_subalias("2", "Q1");
+ register_subalias("3", "Q2");
+ register_subalias("4", "Q3");
+ register_subalias("5", "Q4");
+ register_subalias("6", "Q5");
+ register_subalias("7", "Q6");
+ register_subalias("8", "GND");
+
+ register_subalias("9", "Q7");
+ register_subalias("10", "Q8");
+ register_subalias("11", "Q9");
+ register_subalias("12", "D");
+ register_subalias("13", "C");
+ register_subalias("14", "B");
+ register_subalias("15", "A");
+ register_subalias("16", "VCC");
+ }
+ };
+
+ NETLIB_RESET(7442)
+ {
+ m_val = 0;
+ m_last_val = 0;
+ }
+
+ NETLIB_UPDATE(7442)
+ {
+ const netlist_sig_t new_A = m_A();
+ const netlist_sig_t new_B = m_B();
+ const netlist_sig_t new_C = m_C();
+ const netlist_sig_t new_D = m_D();
+
+ m_last_val = m_val;
+ m_val = (new_D << 3) | (new_C << 2) | (new_B << 1) | new_A;
+
+ if (m_last_val != m_val)
+ {
+ update_outputs();
+ }
+ }
+
+ NETLIB_DEVICE_IMPL(7442, "TTL_7442", "+A,+B,+C,+D,@VCC,@GND")
+ NETLIB_DEVICE_IMPL(7442_dip, "TTL_7442_DIP", "")
+
+} // namespace devices
+} // namespace netlist
diff --git a/src/lib/netlist/devices/nld_7442.h b/src/lib/netlist/devices/nld_7442.h
new file mode 100644
index 00000000000..b3d37ac0056
--- /dev/null
+++ b/src/lib/netlist/devices/nld_7442.h
@@ -0,0 +1,63 @@
+// license:GPL-2.0+
+// copyright-holders:Ryan Holtz
+/*
+ * nld_7442.h
+ *
+ * SN7442: 4-Line BCD to 10-Line Decimal Decoder
+ *
+ * +--------------+
+ * 0 |1 ++ 16| VCC
+ * 1 |2 15| A
+ * 2 |3 14| B
+ * 3 |4 13| C
+ * 4 |5 7492 12| D
+ * 5 |6 11| 9
+ * 6 |7 10| 8
+ * GND |8 9| 7
+ * +--------------+
+ *
+ * Truth Table
+ *
+ * +------++---+---+---+---++---+---+---+---+---+---+---+---+---+---+
+ * | Num. || D | C | B | A || 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
+ * +======++===+===+===+===++===+===+===+===+===+===+===+===+===+===+
+ * | 0 || 0 | 0 | 0 | 0 || 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | 1 || 0 | 0 | 0 | 1 || 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | 2 || 0 | 0 | 1 | 0 || 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | 3 || 0 | 0 | 1 | 1 || 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | 4 || 0 | 1 | 0 | 0 || 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
+ * | 5 || 0 | 1 | 0 | 1 || 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 |
+ * | 6 || 0 | 1 | 1 | 0 || 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 |
+ * | 7 || 0 | 1 | 1 | 1 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
+ * | 8 || 1 | 0 | 0 | 0 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
+ * | 9 || 1 | 0 | 0 | 1 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
+ * | - || 1 | 0 | 1 | 0 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | - || 1 | 0 | 1 | 1 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | - || 1 | 1 | 0 | 0 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | - || 1 | 1 | 0 | 1 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | - || 1 | 1 | 1 | 0 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * | - || 1 | 1 | 1 | 1 || 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
+ * +------++---+---+---+---++---+---+---+---+---+---+---+---+---+---+
+ *
+ * Naming conventions follow Texas Instruments datasheet
+ *
+ */
+
+#ifndef NLD_7442_H_
+#define NLD_7442_H_
+
+#include "netlist/nl_setup.h"
+
+#define TTL_7442(name, cA, cB, cC, cD) \
+ NET_REGISTER_DEV(TTL_7442, name) \
+ NET_CONNECT(name, GND, GND) \
+ NET_CONNECT(name, VCC, VCC) \
+ NET_CONNECT(name, A, cA) \
+ NET_CONNECT(name, B, cB) \
+ NET_CONNECT(name, C, cC) \
+ NET_CONNECT(name, D, cD)
+
+#define TTL_7442_DIP(name) \
+ NET_REGISTER_DEV(TTL_7442_DIP, name)
+
+#endif /* NLD_7442_H_ */