summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/am2847.h
blob: 0e70d2bf37fdf574cee8cdfea38b0e8e29cd4e8b (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
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
/**********************************************************************

    AMD Am2847/Am2896 Quad 80/96-Bit Static Shift Registers

    Pin-compatible with:
    * 2532B
    * TMS3120
    * TMS3409
    * MK1007
    * 3347

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

    Connection Diagram:
              ___ ___
    OUT A  1 |*  u   | 16  Vss
     RC A  2 |       | 15  IN D
     IN A  3 |       | 14  RC D
    OUT B  4 |       | 13  OUT D
     RC B  5 |       | 12  Vgg
     IN B  6 |       | 11  CP
    OUT C  7 |       | 10  IN C
      Vdd  8 |_______| 9   RC C

    Logic Symbol:

                2      5      9      14
                |      |      |      |
           _____|______|______|______|_____
          |   RC A   RC B   RC C   RC D    |
     3 ---| IN A                     OUT A |--- 1
     6 ---| IN A                     OUT B |--- 4
    10 ---| IN A                     OUT C |--- 7
    15 ---| IN A                     OUT D |--- 13
    11 ---| CP                             |
          |________________________________|


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

#pragma once

#ifndef AM2847_H
#define AM2847_H


#define MCFG_AM2847_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, AM2847, 0)

#define MCFG_AM2849_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, AM2849, 0)

#define MCFG_TMS3409_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, TMS3409, 0)

class am2847_base_device : public device_t
{
public:
	am2847_base_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, size_t size);

	DECLARE_WRITE_LINE_MEMBER( in_a_w );
	DECLARE_WRITE_LINE_MEMBER( in_b_w );
	DECLARE_WRITE_LINE_MEMBER( in_c_w );
	DECLARE_WRITE_LINE_MEMBER( in_d_w );
	void in_w(uint8_t data); // Or if you prefer...

	DECLARE_WRITE_LINE_MEMBER( rc_a_w );
	DECLARE_WRITE_LINE_MEMBER( rc_b_w );
	DECLARE_WRITE_LINE_MEMBER( rc_c_w );
	DECLARE_WRITE_LINE_MEMBER( rc_d_w );
	void rc_w(uint8_t data); // Or if you prefer...

	DECLARE_WRITE_LINE_MEMBER( cp_w );

	uint8_t out_r() const { return m_out; }

protected:
	virtual void device_start() override;
	virtual void device_reset() override;

	void init();
	void shift();

	class shifter
	{
	public:
		shifter() : m_buffer_size(0) { }
		void alloc(size_t size);
		void init();
		int shift(bool recycle, int in);
	protected:
		std::unique_ptr<uint16_t[]> m_buffer;
		size_t m_buffer_size;
	};

	shifter m_shifters[4];
	uint8_t m_in;
	uint8_t m_out;
	uint8_t m_rc;
	int m_cp;

	const size_t m_buffer_size;
};

class am2847_device : public am2847_base_device
{
public:
	// construction/destruction
	am2847_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};

class am2849_device : public am2847_base_device
{
public:
	// construction/destruction
	am2849_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};

class tms3409_device : public am2847_base_device
{
public:
	// construction/destruction
	tms3409_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
};

// device type definition
extern const device_type AM2847;
extern const device_type AM2849;
extern const device_type TMS3409;

#endif // AM2847_H