summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-05-27 18:44:23 +1000
committer Vas Crabb <vas@vastheman.com>2017-05-27 18:44:23 +1000
commit2d4ba2471d86555562870973bd456c8dc2581d33 (patch)
tree1e9ba23de32b657e045e3f116fea17fba96d54c4 /src
parent95b2aa3dc30776e08c77f1707d5ce8d5af90c1b7 (diff)
netlist: add a crude TTL schmitt trigger model and hook up in 1B11142
sound board, completing the tromba circuit (nw) I'm not sure whether the model works properly or not, but in the circuit where it's used, I don't think it can work properly with the current TTL output model. A capacitor is charged by the Q output of a 74LS74 flipflop (U3A) until the voltage passes the Schmitt trigger's threshold, causing it to reset the flipflop. However, the positive trigger voltage of the Schmitt trigger is 1.6V, but our TTL output model has a high output voltage of 1.0V (see nl_base.cpp:89). I realise the simplified model of TTL logic with high impedance inputs and outputs behaving as though thery're loaded is convenient and fast to simulate, but it's not detailed enough for applications like this where 7400-series chips are used in analog circuitry. This is what held me up last time I tried adding a netlist for this sound board.
Diffstat (limited to 'src')
-rw-r--r--src/lib/netlist/devices/net_lib.cpp1
-rw-r--r--src/lib/netlist/devices/net_lib.h2
-rw-r--r--src/lib/netlist/devices/nld_schmitt.cpp131
-rw-r--r--src/lib/netlist/devices/nld_schmitt.h25
-rw-r--r--src/lib/netlist/macro/nlm_base.cpp1
-rw-r--r--src/lib/netlist/macro/nlm_ttl74xx.cpp73
-rw-r--r--src/lib/netlist/macro/nlm_ttl74xx.h16
-rw-r--r--src/mame/audio/nl_zac1b11142.cpp8
8 files changed, 253 insertions, 4 deletions
diff --git a/src/lib/netlist/devices/net_lib.cpp b/src/lib/netlist/devices/net_lib.cpp
index 661df946512..d0875338eab 100644
--- a/src/lib/netlist/devices/net_lib.cpp
+++ b/src/lib/netlist/devices/net_lib.cpp
@@ -101,6 +101,7 @@ namespace netlist
ENTRYX(CD4020, CD4020, "")
ENTRYX(CD4066_GATE, CD4066_GATE, "")
ENTRYX(CD4316_GATE, CD4316_GATE, "")
+ ENTRYX(schmitt_trigger, SCHMITT_TRIGGER, "MODEL")
/* entries with suffix WI are legacy only */
ENTRYX(CD4020, CD4020_WI, "+IP,+RESET,+VDD,+VSS")
//ENTRY(4066, CD_4066, "+A,B")
diff --git a/src/lib/netlist/devices/net_lib.h b/src/lib/netlist/devices/net_lib.h
index 4c32235f6fc..49002594138 100644
--- a/src/lib/netlist/devices/net_lib.h
+++ b/src/lib/netlist/devices/net_lib.h
@@ -76,6 +76,8 @@
#include "nld_r2r_dac.h"
+#include "nld_schmitt.h"
+
#include "nld_tristate.h"
#include "nld_log.h"
diff --git a/src/lib/netlist/devices/nld_schmitt.cpp b/src/lib/netlist/devices/nld_schmitt.cpp
new file mode 100644
index 00000000000..4bc41075f89
--- /dev/null
+++ b/src/lib/netlist/devices/nld_schmitt.cpp
@@ -0,0 +1,131 @@
+// license:BSD-3-Clause
+// copyright-holders:Vas Crabb
+/*
+ * nld_schmitt.cpp
+ *
+ */
+
+#include "nld_schmitt.h"
+
+#include "../nl_base.h"
+#include "../nl_errstr.h"
+#include "../analog/nlid_twoterm.h"
+#include "../solver/nld_solver.h"
+
+#include <cmath>
+
+
+namespace netlist
+{
+ namespace 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
+ *
+ */
+
+ class schmitt_trigger_model_t : public param_model_t
+ {
+ public:
+ schmitt_trigger_model_t(device_t &device, const pstring &name, const pstring &val)
+ : param_model_t(device, name, val)
+ , m_VTP(*this, "VTP")
+ , m_VTM(*this, "VTM")
+ , m_VI(*this, "VI")
+ , m_RI(*this, "RI")
+ , m_VOH(*this, "VOH")
+ , m_ROH(*this, "ROH")
+ , m_VOL(*this, "VOL")
+ , m_ROL(*this, "ROL")
+ , m_TPLH(*this, "TPLH")
+ , m_TPHL(*this, "TPHL")
+ {
+ }
+
+ value_t m_VTP;
+ value_t m_VTM;
+ value_t m_VI;
+ value_t m_RI;
+ value_t m_VOH;
+ value_t m_ROH;
+ value_t m_VOL;
+ value_t m_ROL;
+ value_t m_TPLH;
+ value_t m_TPHL;
+ };
+
+ NETLIB_OBJECT(schmitt_trigger)
+ {
+ NETLIB_CONSTRUCTOR(schmitt_trigger)
+ , m_A(*this, "A")
+ , m_GND(*this, "GND")
+ , m_RVI(*this, "RVI")
+ , m_RVO(*this, "RVO")
+ , m_model(*this, "MODEL", "TTL_7414_GATE")
+ , m_last_state(*this, "m_last_var", 1)
+ , m_is_timestep(false)
+ {
+ register_subalias("Q", m_RVO.m_P);
+
+ connect(m_A, m_RVI.m_P);
+ connect(m_GND, m_RVI.m_N);
+ connect(m_GND, m_RVO.m_N);
+ }
+
+ protected:
+ NETLIB_RESETI()
+ {
+ m_last_state = 1;
+ m_RVI.do_reset();
+ m_RVO.do_reset();
+ m_is_timestep = m_RVO.m_P.net().solver()->has_timestep_devices();
+ m_RVI.set(NL_FCONST(1.0) / m_model.m_RI, m_model.m_VI, 0.0);
+ m_RVO.set(NL_FCONST(1.0) / m_model.m_ROL, m_model.m_VOL, 0.0);
+ }
+
+ NETLIB_UPDATEI()
+ {
+ if (m_last_state)
+ {
+ if (m_A.Q_Analog() < m_model.m_VTM)
+ {
+ m_last_state = 0;
+ if (m_is_timestep)
+ m_RVO.update_dev();
+ m_RVO.set(NL_FCONST(1.0) / m_model.m_ROH, m_model.m_VOH, 0.0);
+ m_RVO.m_P.schedule_solve_after(NLTIME_FROM_NS(1));
+ }
+ }
+ else
+ {
+ if (m_A.Q_Analog() > m_model.m_VTP)
+ {
+ m_last_state = 1;
+ if (m_is_timestep)
+ m_RVO.update_dev();
+ m_RVO.set(NL_FCONST(1.0) / m_model.m_ROL, m_model.m_VOL, 0.0);
+ m_RVO.m_P.schedule_solve_after(NLTIME_FROM_NS(1));
+ }
+ }
+ }
+
+ private:
+ analog_input_t m_A;
+ analog_input_t m_GND;
+ analog::NETLIB_SUB(twoterm) m_RVI;
+ analog::NETLIB_SUB(twoterm) m_RVO;
+ schmitt_trigger_model_t m_model;
+ state_var<int> m_last_state;
+ bool m_is_timestep;
+ };
+
+ NETLIB_DEVICE_IMPL(schmitt_trigger)
+
+ } // namespace devices
+} // namespace netlist
diff --git a/src/lib/netlist/devices/nld_schmitt.h b/src/lib/netlist/devices/nld_schmitt.h
new file mode 100644
index 00000000000..ecce59be616
--- /dev/null
+++ b/src/lib/netlist/devices/nld_schmitt.h
@@ -0,0 +1,25 @@
+// license:BSD-3-Clause
+// copyright-holders:Vas Crabb
+/*
+ * nld_schmitt.h
+ *
+ */
+
+//#pragma once
+
+#ifndef NLD_SCHMITT_H_
+#define NLD_SCHMITT_H_
+
+
+#include "../nl_setup.h"
+
+// ----------------------------------------------------------------------------------------
+// Macros
+// ----------------------------------------------------------------------------------------
+
+#define SCHMITT_TRIGGER(name, model) \
+ NET_REGISTER_DEV(SCHMITT_TRIGGER, name) \
+ NETDEV_PARAMI(name, MODEL, model)
+
+
+#endif /* NLD_SCHMITT_H_ */
diff --git a/src/lib/netlist/macro/nlm_base.cpp b/src/lib/netlist/macro/nlm_base.cpp
index 62e713c76dc..8ea6f148864 100644
--- a/src/lib/netlist/macro/nlm_base.cpp
+++ b/src/lib/netlist/macro/nlm_base.cpp
@@ -55,6 +55,7 @@ NETLIST_END()
static NETLIST_START(family_models)
NET_MODEL("FAMILY _(TYPE=CUSTOM FV=5 IVL=0.16 IVH=0.4 OVL=0.1 OVH=1.0 ORL=1.0 ORH=130.0)")
NET_MODEL("OPAMP _()")
+ NET_MODEL("SCHMITT_TRIGGER _()")
NET_MODEL("74XXOC FAMILY(FV=5 IVL=0.16 IVH=0.4 OVL=0.1 OVH=0.05 ORL=10.0 ORH=1.0e8)")
NET_MODEL("74XX FAMILY(TYPE=TTL)")
diff --git a/src/lib/netlist/macro/nlm_ttl74xx.cpp b/src/lib/netlist/macro/nlm_ttl74xx.cpp
index 369b5816bf0..7a1a5187c65 100644
--- a/src/lib/netlist/macro/nlm_ttl74xx.cpp
+++ b/src/lib/netlist/macro/nlm_ttl74xx.cpp
@@ -2,6 +2,7 @@
// copyright-holders:Couriersud
#include "nlm_ttl74xx.h"
+#include "../devices/nld_schmitt.h"
#include "../devices/nld_system.h"
@@ -229,6 +230,72 @@ static NETLIST_START(TTL_7411_DIP)
s2.C, /* C2 |5 10| B3 */ s3.B,
s2.Q, /* Y2 |6 9| A3 */ s3.A,
GND.I, /* GND |7 8| Y3 */ s3.Q
+ /* +--------------+ */
+ )
+NETLIST_END()
+
+/*
+ * DM7414/DM74LS14: Hex Inverter with
+ * Schmitt Trigger Inputs
+ *
+ */
+
+static NETLIST_START(TTL_7414_GATE)
+ SCHMITT_TRIGGER(X, "DM7414")
+ ALIAS(A, X.A)
+ ALIAS(Q, X.Q)
+ ALIAS(GND, X.GND)
+NETLIST_END()
+
+static NETLIST_START(TTL_74LS14_GATE)
+ SCHMITT_TRIGGER(X, "DM74LS14")
+ ALIAS(A, X.A)
+ ALIAS(Q, X.Q)
+ ALIAS(GND, X.GND)
+NETLIST_END()
+
+static NETLIST_START(TTL_7414_DIP)
+ SCHMITT_TRIGGER(s1, "DM7414")
+ SCHMITT_TRIGGER(s2, "DM7414")
+ SCHMITT_TRIGGER(s3, "DM7414")
+ SCHMITT_TRIGGER(s4, "DM7414")
+ SCHMITT_TRIGGER(s5, "DM7414")
+ SCHMITT_TRIGGER(s6, "DM7414")
+
+ NET_C(s1.GND, s2.GND, s3.GND, s4.GND, s5.GND, s6.GND)
+ DUMMY_INPUT(VCC)
+
+ DIPPINS( /* +--------------+ */
+ s1.A, /* A1 |1 ++ 14| VCC */ VCC.I,
+ s1.Q, /* Y1 |2 13| A6 */ s6.A,
+ s2.A, /* A2 |3 12| Y6 */ s6.Q,
+ s2.Q, /* Y2 |4 7414 11| A5 */ s5.A,
+ s3.A, /* A3 |5 10| Y5 */ s5.Q,
+ s3.Q, /* Y3 |6 9| A4 */ s4.A,
+ s1.GND, /* GND |7 8| Y4 */ s4.Q
+ /* +--------------+ */
+ )
+NETLIST_END()
+
+static NETLIST_START(TTL_74LS14_DIP)
+ SCHMITT_TRIGGER(s1, "DM74LS14")
+ SCHMITT_TRIGGER(s2, "DM74LS14")
+ SCHMITT_TRIGGER(s3, "DM74LS14")
+ SCHMITT_TRIGGER(s4, "DM74LS14")
+ SCHMITT_TRIGGER(s5, "DM74LS14")
+ SCHMITT_TRIGGER(s6, "DM74LS14")
+
+ NET_C(s1.GND, s2.GND, s3.GND, s4.GND, s5.GND, s6.GND)
+ DUMMY_INPUT(VCC)
+
+ DIPPINS( /* +--------------+ */
+ s1.A, /* A1 |1 ++ 14| VCC */ VCC.I,
+ s1.Q, /* Y1 |2 13| A6 */ s6.A,
+ s2.A, /* A2 |3 12| Y6 */ s6.Q,
+ s2.Q, /* Y2 |4 74LS14 11| A5 */ s5.A,
+ s3.A, /* A3 |5 10| Y5 */ s5.Q,
+ s3.Q, /* Y3 |6 9| A4 */ s4.A,
+ s1.GND, /* GND |7 8| Y4 */ s4.Q
/* +--------------+ */
)
NETLIST_END()
@@ -758,6 +825,8 @@ NETLIST_END()
NETLIST_START(TTL74XX_lib)
+ NET_MODEL("DM7414 SCHMITT_TRIGGER(VTP=1.7 VTM=0.9 VI=4.35 RI=6.15k VOH=3.5 ROH=120 VOL=0.1 ROL=37.5 TPLH=15 TPHL=15)")
+ NET_MODEL("DM74LS14 SCHMITT_TRIGGER(VTP=1.6 VTM=0.8 VI=4.4 RI=19.3k VOH=3.45 ROH=130 VOL=0.1 ROL=31.2 TPLH=15 TPHL=15)")
TRUTHTABLE_START(TTL_7400_GATE, 2, 1, "")
TT_HEAD("A,B|Q ")
@@ -1119,6 +1188,10 @@ NETLIST_START(TTL74XX_lib)
LOCAL_LIB_ENTRY(TTL_7408_DIP)
LOCAL_LIB_ENTRY(TTL_7410_DIP)
LOCAL_LIB_ENTRY(TTL_7411_DIP)
+ LOCAL_LIB_ENTRY(TTL_7414_GATE)
+ LOCAL_LIB_ENTRY(TTL_74LS14_GATE)
+ LOCAL_LIB_ENTRY(TTL_7414_DIP)
+ LOCAL_LIB_ENTRY(TTL_74LS14_DIP)
LOCAL_LIB_ENTRY(TTL_7416_DIP)
LOCAL_LIB_ENTRY(TTL_7420_DIP)
LOCAL_LIB_ENTRY(TTL_7425_DIP)
diff --git a/src/lib/netlist/macro/nlm_ttl74xx.h b/src/lib/netlist/macro/nlm_ttl74xx.h
index 18c0cfe6138..c8868e45f7f 100644
--- a/src/lib/netlist/macro/nlm_ttl74xx.h
+++ b/src/lib/netlist/macro/nlm_ttl74xx.h
@@ -85,11 +85,25 @@
NET_REGISTER_DEV(TTL_7411_DIP, name)
+#define TTL_7414_GATE(name) \
+ NET_REGISTER_DEV(TTL_7414_GATE, name)
+
+#define TTL_7414_DIP(name) \
+ NET_REGISTER_DEV(TTL_7414_DIP, name)
+
+
+#define TTL_74LS14_GATE(name) \
+ NET_REGISTER_DEV(TTL_74LS14_GATE, name)
+
+#define TTL_74LS14_DIP(name) \
+ NET_REGISTER_DEV(TTL_74LS14_DIP, name)
+
+
#define TTL_7416_GATE(name) \
NET_REGISTER_DEV(TTL_7416_GATE, name)
#define TTL_7416_DIP(name) \
- NET_REGISTER_DEV(TTL7416_DIP, name)
+ NET_REGISTER_DEV(TTL_7416_DIP, name)
#define TTL_7420_GATE(name) \
diff --git a/src/mame/audio/nl_zac1b11142.cpp b/src/mame/audio/nl_zac1b11142.cpp
index 0d2f8c2cc64..6e716788a3f 100644
--- a/src/mame/audio/nl_zac1b11142.cpp
+++ b/src/mame/audio/nl_zac1b11142.cpp
@@ -196,13 +196,15 @@ NETLIST_START(zac1b11142_schematics)
RES(R112, RES_K(100))
RES(R113, RES_M(1))
LM3900(U5B1)
+ TTL_74LS14_GATE(U4A1)
NET_C(ANAL5, R66.1, R67.1)
NET_C(R67.2, C28.1, R40.1, T7.B)
NET_C(R64.2, T6.C, U3A.3)
- NET_C(R65.2, U3A.2, U3A.4, U3A.1) // FIXME: pin 1 actually comes from a Schmitt trigger in U4A
+ NET_C(R65.2, U3A.2, U3A.4)
+ NET_C(U3A.1, U4A1.Q)
NET_C(U3A.5, R39.1, U5D.13)
- NET_C(R39.2, C37.1) // FIXME: this junction feeds a Schmitt trigger in U4A
+ NET_C(U4A1.A, R39.2, C37.1)
NET_C(R109.1, R94.2, R108.1, R95.1)
NET_C(R109.2, LEVELT)
NET_C(R110.2, R112.1, R111.1)
@@ -210,7 +212,7 @@ NETLIST_START(zac1b11142_schematics)
NET_C(R95.2, U5B1.PLUS)
NET_C(U5D.2, C50.2, R113.2, U5B1.OUT, R96.1)
NET_C(VCC, R64.1, R65.1, R94.1, R110.1, U5B1.VP)
- NET_C(GND, R66.2, C28.2, R40.2, T6.E, C37.2, R108.2, R111.2, U5B1.VM)
+ NET_C(GND, R66.2, C28.2, R40.2, T6.E, C37.2, R108.2, R111.2, U5B1.VM, U4A1.GND)
ALIAS(TROMBA, R96.2)