summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/dl11.h
blob: e0b0f07a2c7cbde40849864d76419a725e95f880 (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
// license:BSD-3-Clause
// copyright-holders:Sergey Svishchev
/***************************************************************************

    DEC DL11-type SLU (serial line unit)

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

#ifndef MAME_MACHINE_DL11_H
#define MAME_MACHINE_DL11_H

#pragma once

#include "machine/pdp11.h"
#include "machine/z80daisy.h"

#include "diserial.h"


/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

// ======================> dl11_device

class dl11_device : public device_t,
					public device_serial_interface,
					public device_z80daisy_interface
{
public:
	// construction/destruction
	dl11_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);

	void set_rxc(int clock) { m_rxc = clock; }
	void set_txc(int clock) { m_txc = clock; }
	void set_rxvec(int vec) { m_rxvec = vec; }
	void set_txvec(int vec) { m_txvec = vec; }

	auto txd_wr_callback() { return m_write_txd.bind(); }
	auto txrdy_wr_callback() { return m_write_txrdy.bind(); }
	auto rxrdy_wr_callback() { return m_write_rxrdy.bind(); }

	uint16_t read(offs_t offset);
	void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);

	DECLARE_READ_LINE_MEMBER( rxrdy_r );
	DECLARE_READ_LINE_MEMBER( txrdy_r );

	DECLARE_WRITE_LINE_MEMBER( rx_w ) { device_serial_interface::rx_w(state); }

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

	// device_serial_interface overrides
	virtual void tra_callback() override;
	virtual void tra_complete() override;
	virtual void rcv_complete() override;

	// device_z80daisy_interface overrides
	virtual int z80daisy_irq_state() override;
	virtual int z80daisy_irq_ack() override;
	virtual void z80daisy_irq_reti() override;

private:
	/* registers */

	static constexpr uint16_t DLRCSR_RD      = CSR_DONE | CSR_IE;
	static constexpr uint16_t DLRCSR_WR      = CSR_IE;

	static constexpr uint16_t DLRBUF_ERR     = 0100000;
	static constexpr uint16_t DLRBUF_OVR     = 0040000;
	static constexpr uint16_t DLRBUF_RBRK    = 0020000;
	static constexpr uint16_t DLRBUF_PERR    = 0020000;

	static constexpr uint16_t DLTCSR_XBRK    = 0000001;
	static constexpr uint16_t DLTCSR_RD      = CSR_DONE | CSR_IE | DLTCSR_XBRK;
	static constexpr uint16_t DLTCSR_WR      = CSR_IE | DLTCSR_XBRK;

	devcb_write_line   m_write_txd;
	devcb_write_line   m_write_rxrdy;
	devcb_write_line   m_write_txrdy;

	line_state  m_rxrdy;
	line_state  m_txrdy;

	int m_rxc;
	int m_txc;
	int m_rxvec;
	int m_txvec;

	uint16_t m_rcsr;
	uint16_t m_rbuf;
	uint16_t m_tcsr;
	uint16_t m_tbuf;
};


// device type definition
DECLARE_DEVICE_TYPE(DL11, dl11_device)

#endif