summaryrefslogtreecommitdiffstats
path: root/src/lib/netlist/devices/nld_7474.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/devices/nld_7474.cpp')
-rw-r--r--src/lib/netlist/devices/nld_7474.cpp132
1 files changed, 45 insertions, 87 deletions
diff --git a/src/lib/netlist/devices/nld_7474.cpp b/src/lib/netlist/devices/nld_7474.cpp
index 9d020663f46..740af6ad3c1 100644
--- a/src/lib/netlist/devices/nld_7474.cpp
+++ b/src/lib/netlist/devices/nld_7474.cpp
@@ -1,3 +1,4 @@
+
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
@@ -6,60 +7,47 @@
*/
#include "nld_7474.h"
-#include "../nl_base.h"
+#include "netlist/nl_base.h"
namespace netlist
{
namespace devices
{
- NETLIB_OBJECT(7474sub)
+
+ NETLIB_OBJECT(7474)
{
- NETLIB_CONSTRUCTOR(7474sub)
- , m_CLK(*this, "CLK")
+ NETLIB_CONSTRUCTOR(7474)
+ , m_D(*this, "D")
+ , m_CLRQ(*this, "CLRQ")
+ , m_PREQ(*this, "PREQ")
+ , m_CLK(*this, "CLK", NETLIB_DELEGATE(7474, clk))
, m_Q(*this, "Q")
, m_QQ(*this, "QQ")
, m_nextD(*this, "m_nextD", 0)
{
}
+ private:
NETLIB_RESETI();
NETLIB_UPDATEI();
+ NETLIB_HANDLERI(clk);
- public:
+ logic_input_t m_D;
+ logic_input_t m_CLRQ;
+ logic_input_t m_PREQ;
logic_input_t m_CLK;
logic_output_t m_Q;
logic_output_t m_QQ;
- state_var<unsigned> m_nextD;
-
- inline void newstate(const netlist_sig_t stateQ, const netlist_sig_t stateQQ);
- private:
-
- };
+ state_var<netlist_sig_t> m_nextD;
- NETLIB_OBJECT(7474)
- {
- NETLIB_CONSTRUCTOR(7474)
- , sub(*this, "sub")
- , m_D(*this, "D")
- , m_CLRQ(*this, "CLRQ")
- , m_PREQ(*this, "PREQ")
+ void newstate(const netlist_sig_t stateQ, const netlist_sig_t stateQQ)
{
- register_subalias("CLK", sub.m_CLK);
-
- register_subalias("Q", sub.m_Q);
- register_subalias("QQ", sub.m_QQ);
+ // 0: High-to-low 40 ns, 1: Low-to-high 25 ns
+ static constexpr const netlist_time delay[2] = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) };
+ m_Q.push(stateQ, delay[stateQ]);
+ m_QQ.push(stateQQ, delay[stateQQ]);
}
-
- NETLIB_RESETI();
- NETLIB_UPDATEI();
-
- public:
- NETLIB_SUB(7474sub) sub;
-
- logic_input_t m_D;
- logic_input_t m_CLRQ;
- logic_input_t m_PREQ;
};
NETLIB_OBJECT(7474_dip)
@@ -68,20 +56,20 @@ namespace netlist
, m_1(*this, "1")
, m_2(*this, "2")
{
- register_subalias("1", m_1.m_CLRQ);
- register_subalias("2", m_1.m_D);
- register_subalias("3", m_1.sub.m_CLK);
- register_subalias("4", m_1.m_PREQ);
- register_subalias("5", m_1.sub.m_Q);
- register_subalias("6", m_1.sub.m_QQ);
+ register_subalias("1", "1.CLRQ");
+ register_subalias("2", "1.D");
+ register_subalias("3", "1.CLK");
+ register_subalias("4", "1.PREQ");
+ register_subalias("5", "1.Q");
+ register_subalias("6", "1.QQ");
// register_subalias("7", ); ==> GND
- register_subalias("8", m_2.sub.m_QQ);
- register_subalias("9", m_2.sub.m_Q);
- register_subalias("10", m_2.m_PREQ);
- register_subalias("11", m_2.sub.m_CLK);
- register_subalias("12", m_2.m_D);
- register_subalias("13", m_2.m_CLRQ);
+ register_subalias("8", "2.QQ");
+ register_subalias("9", "2.Q");
+ register_subalias("10", "2.PREQ");
+ register_subalias("11", "2.CLK");
+ register_subalias("12", "2.D");
+ register_subalias("13", "2.CLRQ");
// register_subalias("14", ); ==> VCC
}
NETLIB_UPDATEI();
@@ -92,77 +80,47 @@ namespace netlist
NETLIB_SUB(7474) m_2;
};
- inline void NETLIB_NAME(7474sub)::newstate(const netlist_sig_t stateQ, const netlist_sig_t stateQQ)
+ NETLIB_HANDLER(7474, clk)
{
- // 0: High-to-low 40 ns, 1: Low-to-high 25 ns
- const netlist_time delay[2] = { NLTIME_FROM_NS(40), NLTIME_FROM_NS(25) };
- m_Q.push(stateQ, delay[stateQ]);
- m_QQ.push(stateQQ, delay[stateQQ]);
- }
-
- NETLIB_UPDATE(7474sub)
- {
- //if (INP_LH(m_CLK))
- {
- newstate(m_nextD, !m_nextD);
- m_CLK.inactivate();
- }
+ newstate(m_nextD, !m_nextD);
+ m_CLK.inactivate();
}
NETLIB_UPDATE(7474)
{
- if (m_PREQ() && m_CLRQ())
+ const auto preq(m_PREQ());
+ const auto clrq(m_CLRQ());
+ if (preq & clrq)
{
m_D.activate();
- sub.m_nextD = m_D();
- sub.m_CLK.activate_lh();
- }
- else if (!m_PREQ())
- {
- sub.newstate(1, 0);
- sub.m_CLK.inactivate();
- m_D.inactivate();
- }
- else if (!m_CLRQ())
- {
- sub.newstate(0, 1);
- sub.m_CLK.inactivate();
- m_D.inactivate();
+ m_nextD = m_D();
+ m_CLK.activate_lh();
}
else
{
- sub.newstate(1, 1);
- sub.m_CLK.inactivate();
+ newstate(preq ^ 1, clrq ^ 1);
+ m_CLK.inactivate();
m_D.inactivate();
}
}
NETLIB_RESET(7474)
{
- sub.do_reset();
- }
-
- NETLIB_RESET(7474sub)
- {
m_CLK.set_state(logic_t::STATE_INP_LH);
-
+ m_D.set_state(logic_t::STATE_INP_ACTIVE);
m_nextD = 0;
}
NETLIB_RESET(7474_dip)
{
- // m_1.do_reset();
- //m_2.do_reset();
}
NETLIB_UPDATE(7474_dip)
{
- //m_1.update_dev();
- //m_2.update_dev();
}
- NETLIB_DEVICE_IMPL(7474)
- NETLIB_DEVICE_IMPL(7474_dip)
+ NETLIB_DEVICE_IMPL(7474, "TTL_7474", "+CLK,+D,+CLRQ,+PREQ")
+ NETLIB_DEVICE_IMPL(7474_dip, "TTL_7474_DIP", "")
} //namespace devices
} // namespace netlist