summaryrefslogtreecommitdiffstats
path: root/src/devices/machine/am9519.h
blob: cae08467b404b2db4645b8fdf0e2fc3f0a1f32ef (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
// license:BSD-3-Clause
// copyright-holders:Wilbert Pol,Carl
/***************************************************************************

    AMD AM9519

    Universal Interrupt Controller

                            _____   _____
                   _CS   1 |*    \_/     | 28  VCC
                   _WR   2 |             | 27  C/_D
                   _RD   3 |             | 26  _IACK
                   DB7   4 |             | 25  IREQ7
                   DB6   5 |             | 24  IREQ6
                   DB5   6 |             | 23  IREQ5
                   DB4   7 |    AM9519   | 22  IREQ4
                   DB3   8 |             | 21  IREQ3
                   DB2   9 |             | 20  IREQ2
                   DB1  10 |             | 19  IREQ1
                   DB0  11 |             | 18  IREQ0
                  _RIP  12 |             | 17  GINT
                    EI  13 |             | 16  _EO
                   GND  14 |_____________| 15  _PAUSE

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

#ifndef MAME_MACHINE_AM9519_H
#define MAME_MACHINE_AM9519_H


/***************************************************************************
    DEVICE CONFIGURATION MACROS
***************************************************************************/

#define MCFG_AM9519_OUT_INT_CB(_devcb) \
	downcast<am9519_device &>(*device).static_set_out_int_callback(DEVCB_##_devcb);


class am9519_device : public device_t
{
public:
	am9519_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);

	template <class Object> devcb_base &static_set_out_int_callback(Object &&cb) { return m_out_int_func.set_callback(std::forward<Object>(cb)); }

	DECLARE_READ8_MEMBER( stat_r );
	DECLARE_READ8_MEMBER( data_r );
	DECLARE_WRITE8_MEMBER( cmd_w );
	DECLARE_WRITE8_MEMBER( data_w );
	u32 acknowledge();

	DECLARE_WRITE_LINE_MEMBER( ireq0_w ) { set_irq_line(0, state); }
	DECLARE_WRITE_LINE_MEMBER( ireq1_w ) { set_irq_line(1, state); }
	DECLARE_WRITE_LINE_MEMBER( ireq2_w ) { set_irq_line(2, state); }
	DECLARE_WRITE_LINE_MEMBER( ireq3_w ) { set_irq_line(3, state); }
	DECLARE_WRITE_LINE_MEMBER( ireq4_w ) { set_irq_line(4, state); }
	DECLARE_WRITE_LINE_MEMBER( ireq5_w ) { set_irq_line(5, state); }
	DECLARE_WRITE_LINE_MEMBER( ireq6_w ) { set_irq_line(6, state); }
	DECLARE_WRITE_LINE_MEMBER( ireq7_w ) { set_irq_line(7, state); }

	IRQ_CALLBACK_MEMBER(iack_cb);

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;
	virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;

private:
	static constexpr device_timer_id TIMER_CHECK_IRQ = 0;

	inline void set_timer() { timer_set(attotime::zero, TIMER_CHECK_IRQ); }
	void set_irq_line(int irq, int state);

	devcb_write_line m_out_int_func;

	u8 m_isr;
	u8 m_irr;
	u8 m_prio;
	u8 m_imr;
	u8 m_irq_lines;

	u8 m_curcnt;
	u8 m_mode;
	u8 m_cmd;
	u8 m_aclear;
	u8 m_count[8];
	u8 m_resp[8][4];
};

DECLARE_DEVICE_TYPE(AM9519, am9519_device)

#endif // MAME_MACHINE_AM9519_H