summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/devices/nld_74125.cpp
blob: 1240619e1d6b752102db81a89b689c5af437824b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// license:GPL-2.0+
// copyright-holders:Couriersud
/*
 * nld_74125.cpp
 *
 */

#include "nl_base.h"

#include <type_traits>

namespace netlist
{
	namespace devices
	{

	template <typename D>
	NETLIB_OBJECT(74125_base)
	{
		NETLIB_CONSTRUCTOR(74125_base)
		, m_TE(*this, "FORCE_TRISTATE_LOGIC", 0)
		, m_A(*this, "A", NETLIB_DELEGATE(A))
		, m_G(*this, pstring(D::invert_g::value ? "G" : "GQ"), NETLIB_DELEGATE(G))
		, m_Y(*this, "Y", m_TE())
		//, m_Y(*this, "Y")
		, m_power_pins(*this)
		{
		}

	private:
		//NETLIB_RESETI() {}

		NETLIB_UPDATE_PARAMI()
		{
			// this one is only called during startup. Ensure all outputs
			// are in a consistent state.
			m_Y.set_tristate(m_G() ^ D::invert_g::value,
				D::ts_off_on::value(), D::ts_on_off::value());
			m_Y.push(m_A(), m_A() ? D::sig_off_on::value() : D::sig_on_off::value());
		}

		NETLIB_HANDLERI(A)
		{
			m_Y.push(m_A(), m_A() ? D::sig_off_on::value() : D::sig_on_off::value());
		}

		NETLIB_HANDLERI(G)
		{
			m_Y.set_tristate(m_G() ^ D::invert_g::value,
				D::ts_off_on::value(), D::ts_on_off::value());
		}

		param_logic_t      m_TE;
		logic_input_t      m_A;
		logic_input_t      m_G;
		tristate_output_t  m_Y;
		nld_power_pins     m_power_pins;
	};

	struct desc_74125 : public desc_base
	{
		using invert_g = desc_const<0>;
		using ts_off_on = time_ns<11>;
		using ts_on_off = time_ns<13>;
		using sig_off_on = time_ns<8>;
		using sig_on_off = time_ns<12>;
	};

	struct desc_74126 : public desc_74125
	{
		using invert_g = desc_const<1>;
	};

	using NETLIB_NAME(74125) = NETLIB_NAME(74125_base)<desc_74125>;
	using NETLIB_NAME(74126) = NETLIB_NAME(74125_base)<desc_74126>;

	NETLIB_DEVICE_IMPL(74125,     "TTL_74125_GATE",     "")
	NETLIB_DEVICE_IMPL(74126,     "TTL_74126_GATE",     "")

	} //namespace devices
} // namespace netlist