summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/devices/nld_7490.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/devices/nld_7490.cpp')
-rw-r--r--src/lib/netlist/devices/nld_7490.cpp205
1 files changed, 106 insertions, 99 deletions
diff --git a/src/lib/netlist/devices/nld_7490.cpp b/src/lib/netlist/devices/nld_7490.cpp
index 3bd06a58a3a..7bcf1f7b214 100644
--- a/src/lib/netlist/devices/nld_7490.cpp
+++ b/src/lib/netlist/devices/nld_7490.cpp
@@ -1,40 +1,127 @@
-// license:GPL-2.0+
+// license:BSD-3-Clause
// copyright-holders:Couriersud
/*
- * nld_7490.c
+ * nld_7490.cpp
+ *
+ * DM7490: Decade Counters
+ *
+ * +--------------+
+ * B |1 ++ 14| A
+ * R01 |2 13| NC
+ * R02 |3 12| QA
+ * NC |4 7490 11| QD
+ * VCC |5 10| GND
+ * R91 |6 9| QB
+ * R92 |7 8| QC
+ * +--------------+
+ *
+ * Counter Sequence
+ *
+ * +-------++----+----+----+----+
+ * | COUNT || QD | QC | QB | QA |
+ * +=======++====+====+====+====+
+ * | 0 || 0 | 0 | 0 | 0 |
+ * | 1 || 0 | 0 | 0 | 1 |
+ * | 2 || 0 | 0 | 1 | 0 |
+ * | 3 || 0 | 0 | 1 | 1 |
+ * | 4 || 0 | 1 | 0 | 0 |
+ * | 5 || 0 | 1 | 0 | 1 |
+ * | 6 || 0 | 1 | 1 | 0 |
+ * | 7 || 0 | 1 | 1 | 1 |
+ * | 8 || 1 | 0 | 0 | 0 |
+ * | 9 || 1 | 0 | 0 | 1 |
+ * +-------++----+----+----+----+
+ *
+ * Note A Output QA is connected to input B for BCD count
+ *
+ * Reset Count Function table
+ *
+ * +-----+-----+-----+-----++----+----+----+----+
+ * | R01 | R02 | R91 | R92 || QD | QC | QB | QA |
+ * +=====+=====+=====+=====++====+====+====+====+
+ * | 1 | 1 | 0 | X || 0 | 0 | 0 | 0 |
+ * | 1 | 1 | X | 0 || 0 | 0 | 0 | 0 |
+ * | X | X | 1 | 1 || 1 | 0 | 0 | 1 |
+ * | X | 0 | X | 0 || COUNT |
+ * | 0 | X | 0 | X || COUNT |
+ * | 0 | X | X | 0 || COUNT |
+ * | X | 0 | 0 | X || COUNT |
+ * +-----+-----+-----+-----++----+----+----+----+
+ *
+ * Naming conventions follow National Semiconductor datasheet
*
*/
-#include "nld_7490.h"
-#include "netlist/nl_base.h"
-#include "nlid_system.h"
+#include "nl_base.h"
-namespace netlist
-{
- namespace devices
+namespace netlist::devices {
+
+ static constexpr const std::array<const netlist_time, 4> delay =
{
+ NLTIME_FROM_NS(18),
+ NLTIME_FROM_NS(36) - NLTIME_FROM_NS(18),
+ NLTIME_FROM_NS(54) - NLTIME_FROM_NS(18),
+ NLTIME_FROM_NS(72) - NLTIME_FROM_NS(18)
+ };
+
NETLIB_OBJECT(7490)
{
NETLIB_CONSTRUCTOR(7490)
- , m_A(*this, "A")
- , m_B(*this, "B")
- , m_R1(*this, "R1")
- , m_R2(*this, "R2")
- , m_R91(*this, "R91")
- , m_R92(*this, "R92")
+ , m_A(*this, "A", NETLIB_DELEGATE(inputs))
+ , m_B(*this, "B", NETLIB_DELEGATE(inputs))
+ , m_R1(*this, "R1", NETLIB_DELEGATE(inputs))
+ , m_R2(*this, "R2", NETLIB_DELEGATE(inputs))
+ , m_R91(*this, "R91", NETLIB_DELEGATE(inputs))
+ , m_R92(*this, "R92", NETLIB_DELEGATE(inputs))
, m_cnt(*this, "m_cnt", 0)
, m_last_A(*this, "m_last_A", 0)
, m_last_B(*this, "m_last_B", 0)
- , m_Q(*this, {{"QA", "QB", "QC", "QD"}})
+ , m_Q(*this, {"QA", "QB", "QC", "QD"})
, m_power_pins(*this)
{
}
private:
- NETLIB_UPDATEI();
- NETLIB_RESETI();
+ NETLIB_HANDLERI(inputs)
+ {
+ const netlist_sig_t new_A = m_A();
+ const netlist_sig_t new_B = m_B();
- void update_outputs();
+ if (m_R91() & m_R92())
+ {
+ m_cnt = 9;
+ m_Q.push(9, delay);
+ }
+ else if (m_R1() & m_R2())
+ {
+ m_cnt = 0;
+ m_Q.push(0, delay);
+ }
+ else
+ {
+ if (m_last_A && !new_A) // High - Low
+ {
+ m_cnt ^= 1;
+ m_Q[0].push(m_cnt & 1, delay[0]);
+ }
+ if (m_last_B && !new_B) // High - Low
+ {
+ m_cnt += 2;
+ if (m_cnt >= 10)
+ m_cnt &= 1; /* Output A is not reset! */
+ m_Q.push(m_cnt, delay);
+ }
+ }
+ m_last_A = new_A;
+ m_last_B = new_B;
+ }
+
+ NETLIB_RESETI()
+ {
+ m_cnt = 0;
+ m_last_A = 0;
+ m_last_B = 0;
+ }
logic_input_t m_A;
logic_input_t m_B;
@@ -51,86 +138,6 @@ namespace netlist
nld_power_pins m_power_pins;
};
- NETLIB_OBJECT_DERIVED(7490_dip, 7490)
- {
- NETLIB_CONSTRUCTOR_DERIVED(7490_dip, 7490)
- {
- register_subalias("1", "B");
- register_subalias("2", "R1");
- register_subalias("3", "R2");
-
- // register_subalias("4", ); --> NC
- register_subalias("5", "VCC");
- register_subalias("6", "R91");
- register_subalias("7", "R92");
-
- register_subalias("8", "QC");
- register_subalias("9", "QB");
- register_subalias("10", "GND");
- register_subalias("11", "QD");
- register_subalias("12", "QA");
- // register_subalias("13", ); --> NC
- register_subalias("14", "A");
- }
- };
-
- NETLIB_RESET(7490)
- {
- m_cnt = 0;
- m_last_A = 0;
- m_last_B = 0;
- }
-
- static constexpr const netlist_time delay[4] =
- {
- NLTIME_FROM_NS(18),
- NLTIME_FROM_NS(36) - NLTIME_FROM_NS(18),
- NLTIME_FROM_NS(54) - NLTIME_FROM_NS(18),
- NLTIME_FROM_NS(72) - NLTIME_FROM_NS(18)
- };
-
- NETLIB_UPDATE(7490)
- {
- const netlist_sig_t new_A = m_A();
- const netlist_sig_t new_B = m_B();
-
- if (m_R91() & m_R92())
- {
- m_cnt = 9;
- update_outputs();
- }
- else if (m_R1() & m_R2())
- {
- m_cnt = 0;
- update_outputs();
- }
- else
- {
- if (m_last_A && !new_A) // High - Low
- {
- m_cnt ^= 1;
- m_Q[0].push(m_cnt & 1, delay[0]);
- }
- if (m_last_B && !new_B) // High - Low
- {
- m_cnt += 2;
- if (m_cnt >= 10)
- m_cnt &= 1; /* Output A is not reset! */
- update_outputs();
- }
- }
- m_last_A = new_A;
- m_last_B = new_B;
- }
-
- NETLIB_FUNC_VOID(7490, update_outputs, ())
- {
- for (std::size_t i=0; i<4; i++)
- m_Q[i].push((m_cnt >> i) & 1, delay[i]);
- }
-
NETLIB_DEVICE_IMPL(7490, "TTL_7490", "+A,+B,+R1,+R2,+R91,+R92,@VCC,@GND")
- NETLIB_DEVICE_IMPL(7490_dip, "TTL_7490_DIP", "")
- } //namespace devices
-} // namespace netlist
+} // namespace netlist::devices