1 // license:BSD-3-Clause
2 // copyright-holders:Ryan Holtz
3 /**********************************************************************
4 
5     5/74174/5 Hex/Quad D Flip-Flops with Clear
6 
7 ***********************************************************************
8 
9     Connection Diagram:
10               ___ ___                         ___ ___
11     CLEAR  1 |*  u   | 16  Vcc      CLEAR  1 |*  u   | 16  Vcc
12        Q1  2 |       | 15  Q6          Q1  2 |       | 15  Q4
13        D1  3 |       | 14  D6         /Q1  3 |       | 14  /Q4
14        D2  4 |       | 13  D5          D1  4 |       | 13  D4
15        Q2  5 |       | 12  Q5          D2  5 |       | 12  D3
16        D3  6 |       | 11  D4         /Q2  6 |       | 11  /Q3
17        Q3  7 |       | 10  Q4          Q2  7 |       | 10  Q3
18       GND  8 |_______| 9   CLOCK      GND  8 |_______| 9   CLOCK
19 
20               5/74174                         5/74175
21 
22 ***********************************************************************
23 
24     Function Table:
25      _________________________________
26     |       Inputs        |  Outputs* |
27     |---------------------|-----------|
28     | Clear | Clock |  D  |  Q  | /Q  |
29     |-------|-------|-----|-----|-----|
30     |   L   |   X   |  X  |  L  |  H  |
31     |   H   |   ^   |  H  |  H  |  L  |
32     |   H   |   ^   |  L  |  L  |  H  |
33     |   H   |   L   |  X  |  Q0 |  Q0 |
34     |_______|_______|_____|_____|_____|
35 
36     H = High Level (steady state)
37     L = Low Level (steady state)
38     X = Don't Care
39     ^ = Transition from low to high level
40     Q0 = The level of Q before the indicated steady-state input conditions were established.
41     * = 175 only
42 
43 **********************************************************************/
44 
45 #ifndef MAME_MACHINE_74175_H
46 #define MAME_MACHINE_74175_H
47 
48 #pragma once
49 
50 
51 class ttl741745_device : public device_t
52 {
53 public:
q1_callback()54 	auto q1_callback() { return m_q1_func.bind(); }
q2_callback()55 	auto q2_callback() { return m_q2_func.bind(); }
q3_callback()56 	auto q3_callback() { return m_q3_func.bind(); }
q4_callback()57 	auto q4_callback() { return m_q4_func.bind(); }
58 
59 	DECLARE_WRITE_LINE_MEMBER( clear_w );
60 	DECLARE_WRITE_LINE_MEMBER( d1_w );
61 	DECLARE_WRITE_LINE_MEMBER( d2_w );
62 	DECLARE_WRITE_LINE_MEMBER( d3_w );
63 	DECLARE_WRITE_LINE_MEMBER( d4_w );
64 	DECLARE_WRITE_LINE_MEMBER( clock_w );
65 
66 	uint8_t q_w();
67 
68 protected:
69 	ttl741745_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
70 
71 	virtual void device_start() override;
72 	virtual void device_reset() override;
73 
74 	virtual void init();
75 	virtual void tick();
76 
77 	devcb_write_line m_q1_func;
78 	devcb_write_line m_q2_func;
79 	devcb_write_line m_q3_func;
80 	devcb_write_line m_q4_func;
81 
82 	uint8_t m_clock;
83 	uint8_t m_clear;
84 
85 	uint8_t m_d1;
86 	uint8_t m_d2;
87 	uint8_t m_d3;
88 	uint8_t m_d4;
89 
90 	uint8_t m_q1;
91 	uint8_t m_q2;
92 	uint8_t m_q3;
93 	uint8_t m_q4;
94 };
95 
96 class ttl74174_device : public ttl741745_device
97 {
98 public:
99 	ttl74174_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
100 
q5_cb()101 	auto q5_cb() { return m_q5_func.bind(); }
q6_cb()102 	auto q6_cb() { return m_q6_func.bind(); }
103 
104 	DECLARE_WRITE_LINE_MEMBER( d5_w );
105 	DECLARE_WRITE_LINE_MEMBER( d6_w );
106 
107 protected:
108 	virtual void device_start() override;
109 
110 	virtual void init() override;
111 	virtual void tick() override;
112 
113 private:
114 	devcb_write_line m_q5_func;
115 	devcb_write_line m_q6_func;
116 
117 	uint8_t m_d5;
118 	uint8_t m_d6;
119 
120 	uint8_t m_q5;
121 	uint8_t m_q6;
122 };
123 
124 class ttl74175_device : public ttl741745_device
125 {
126 public:
127 	ttl74175_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
128 
not_q1_cb()129 	auto not_q1_cb() { return m_not_q1_func.bind(); }
not_q2_cb()130 	auto not_q2_cb() { return m_not_q2_func.bind(); }
not_q3_cb()131 	auto not_q3_cb() { return m_not_q3_func.bind(); }
not_q4_cb()132 	auto not_q4_cb() { return m_not_q4_func.bind(); }
133 
134 protected:
135 	virtual void device_start() override;
136 
137 	virtual void tick() override;
138 
139 private:
140 	devcb_write_line m_not_q1_func;
141 	devcb_write_line m_not_q2_func;
142 	devcb_write_line m_not_q3_func;
143 	devcb_write_line m_not_q4_func;
144 
145 	uint8_t m_not_q1;
146 	uint8_t m_not_q2;
147 	uint8_t m_not_q3;
148 	uint8_t m_not_q4;
149 };
150 
151 // device type definition
152 DECLARE_DEVICE_TYPE(TTL74174, ttl74174_device)
153 DECLARE_DEVICE_TYPE(TTL74175, ttl74175_device)
154 
155 #endif // MAME_MACHINE_74175_H
156