summaryrefslogtreecommitdiffstats
path: root/src/devices/machine/82s129.h
blob: 9b5ef9d3bf19bd6ed6d048f846382f0c7c9b4164 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
/*****************************************************************************

    82S129/6 1K-bit TTL bipolar PROM

******************************************************************************

    Connection Diagrams:

             N Package
              ___ ___
       A6  1 |*  u   | 16  Vcc
       A5  2 |       | 15  A7
       A4  3 |       | 14  /CE2
       A3  4 |       | 13  /CE1
       A0  5 |       | 12  O1
       A1  6 |       | 11  O2
       A2  7 |       | 10  O3
      GND  8 |_______| 9   O4


             A Package

          3   2   1  20  19
          |   |   |   |   |
       /---------------------|
       | A5  A6  NC  Vcc A7  |
       |                     |
    4 -| A4             /CE2 |- 18
    5 -| A3             /CE1 |- 17
    6 -| A0               O1 |- 16
    7 -| A1               NC |- 15
    8 -| A2               O2 |- 14
       |                     |
       | NC  GND NC  O4  O3  |
       |_____________________|
          |   |   |   |   |
          9  10  11  12  13

**********************************************************************/

#ifndef MAME_MACHINE_82S129_H
#define MAME_MACHINE_82S129_H

#pragma once


#define MCFG_82S126_OUTPUT_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_out_cb(DEVCB_##_devcb);

#define MCFG_82S126_O1_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o1_cb(DEVCB_##_devcb);

#define MCFG_82S126_O2_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o2_cb(DEVCB_##_devcb);

#define MCFG_82S126_O3_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o3_cb(DEVCB_##_devcb);

#define MCFG_82S126_O4_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o4_cb(DEVCB_##_devcb);

#define MCFG_82S129_OUTPUT_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_out_cb(DEVCB_##_devcb);

#define MCFG_82S129_O1_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o1_cb(DEVCB_##_devcb);

#define MCFG_82S129_O2_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o2_cb(DEVCB_##_devcb);

#define MCFG_82S129_O3_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o3_cb(DEVCB_##_devcb);

#define MCFG_82S129_O4_CB(_devcb) \
	downcast<prom82s129_base_device &>(*device).set_o4_cb(DEVCB_##_devcb);

#define MCFG_82S129_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, PROM82S129, 0)

#define MCFG_82S126_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, PROM82S126, 0)

class prom82s129_base_device : public device_t
{
public:
	// static configuration helpers
	template <class Object> devcb_base &set_out_cb(Object &&cb) { return m_out_func.set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_o1_cb(Object &&cb) { return m_o1_func.set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_o2_cb(Object &&cb) { return m_o2_func.set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_o3_cb(Object &&cb) { return m_o3_func.set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_o4_cb(Object &&cb) { return m_o4_func.set_callback(std::forward<Object>(cb)); }

	DECLARE_WRITE_LINE_MEMBER( ce1_w );
	DECLARE_WRITE_LINE_MEMBER( ce2_w );

	DECLARE_WRITE8_MEMBER( a_w );
	DECLARE_WRITE_LINE_MEMBER( a0_w );
	DECLARE_WRITE_LINE_MEMBER( a1_w );
	DECLARE_WRITE_LINE_MEMBER( a2_w );
	DECLARE_WRITE_LINE_MEMBER( a3_w );
	DECLARE_WRITE_LINE_MEMBER( a4_w );
	DECLARE_WRITE_LINE_MEMBER( a5_w );
	DECLARE_WRITE_LINE_MEMBER( a6_w );
	DECLARE_WRITE_LINE_MEMBER( a7_w );

	DECLARE_READ8_MEMBER( output_r );
	DECLARE_READ_LINE_MEMBER( o1_r );
	DECLARE_READ_LINE_MEMBER( o2_r );
	DECLARE_READ_LINE_MEMBER( o3_r );
	DECLARE_READ_LINE_MEMBER( o4_r );

	uint8_t get_output() const { return m_out; }

protected:
	// construction/destruction
	prom82s129_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);

	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	void write_line(uint8_t line, uint8_t state);
	void init();
	void update();

	required_memory_region  m_region;

	// callbacks
	devcb_write_line m_out_func;
	devcb_write_line m_o1_func;
	devcb_write_line m_o2_func;
	devcb_write_line m_o3_func;
	devcb_write_line m_o4_func;

	// inputs
	uint8_t m_ce1;      // pin 13
	uint8_t m_ce2;      // pin 14
	uint8_t m_a;        // pins 5,6,7,4,3,2,1,15 from LSB to MSB

	// outputs
	uint8_t m_out;      // pins 12-9 from LSB to MSB

	// data
	std::unique_ptr<uint8_t[]>  m_data;

	static const uint32_t PROM_SIZE;
};

class prom82s126_device : public prom82s129_base_device
{
public:
	prom82s126_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};

class prom82s129_device : public prom82s129_base_device
{
public:
	prom82s129_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};

// device type definition
DECLARE_DEVICE_TYPE(PROM82S126, prom82s126_device)
DECLARE_DEVICE_TYPE(PROM82S129, prom82s129_device)

#endif // MAME_MACHINE_82S129_H