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
|
/**********************************************************************
8 bit latch interface and emulation
Generic emulation of 74LS174/175, 74LS259 and other latches.
Apart from providing synched latch operation, these
latches can be configured to read their input bitwise from other
devices as well and individual bits can be connected to
discrete nodes.
Please see audio/dkong.c for examples.
**********************************************************************/
#ifndef __LATCH8_H_
#define __LATCH8_H_
#define LATCH8 DEVICE_GET_INFO_NAME(latch8)
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
typedef struct _latch8_devread latch8_devread;
struct _latch8_devread
{
/* only for byte reads, does not affect bit reads and node_map */
UINT32 from_bit;
const char *tag;
read8_device_func devread_handler;
read8_space_func read_handler;
};
typedef struct _latch8_config latch8_config;
struct _latch8_config
{
/* only for byte reads, does not affect bit reads and node_map */
UINT32 maskout;
UINT32 xorvalue; /* after mask */
UINT32 nosync;
UINT32 node_map[8];
const char * node_device[8];
latch8_devread devread[8];
};
/***************************************************************************
DEVICE CONFIGURATION MACROS
***************************************************************************/
/* add device */
#define MDRV_LATCH8_ADD(_tag) \
MDRV_DEVICE_ADD(_tag, LATCH8, 0)
/* Bit mask specifying bits to be masked *out* */
#define MDRV_LATCH8_MASKOUT(_maskout) \
MDRV_DEVICE_CONFIG_DATA32(latch8_config, maskout, _maskout)
/* Bit mask specifying bits to be inverted */
#define MDRV_LATCH8_INVERT(_xor) \
MDRV_DEVICE_CONFIG_DATA32(latch8_config, xorvalue, _xor)
/* Bit mask specifying bits not needing cpu synchronization. */
#define MDRV_LATCH8_NOSYNC(_nosync) \
MDRV_DEVICE_CONFIG_DATA32(latch8_config, nosync, _nosync)
/* Write bit to discrete node */
#define MDRV_LATCH8_DISCRETE_NODE(_device, _bit, _node) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(latch8_config, node_device, _bit, _device) \
MDRV_DEVICE_CONFIG_DATA32_ARRAY(latch8_config, node_map, _bit, _node)
/* Upon read, replace bits by reading from another device handler */
#define MDRV_LATCH8_DEVREAD(_bit, _tag, _handler, _from_bit) \
MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, from_bit, _from_bit) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, tag, _tag) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, devread_handler, _handler) \
/* Upon read, replace bits by reading from another machine handler */
#define MDRV_LATCH8_READ(_bit, _handler, _from_bit) \
MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, from_bit, _from_bit) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, read_handler, _handler) \
/* Accessor macros */
#define AM_LATCH8_READ(_tag) \
AM_DEVREAD(_tag, latch8_r)
#define AM_LATCH8_READBIT(_tag, _bit) \
AM_DEVREAD(_tag, latch8_bit ## _bit ## _q_r)
#define AM_LATCH8_WRITE(_tag) \
AM_DEVWRITE(_tag, latch8_w)
#define AM_LATCH8_READWRITE(_tag) \
AM_DEVREADWRITE(_tag, latch8_r, latch8_w)
/* device interface */
DEVICE_GET_INFO( latch8 );
/* write & read full byte */
READ8_DEVICE_HANDLER( latch8_r );
WRITE8_DEVICE_HANDLER( latch8_w );
/* reset the latch */
WRITE8_DEVICE_HANDLER( latch8_reset );
/* read bit x */
/* return (latch >> x) & 0x01 */
READ8_DEVICE_HANDLER( latch8_bit0_r );
READ8_DEVICE_HANDLER( latch8_bit1_r );
READ8_DEVICE_HANDLER( latch8_bit2_r );
READ8_DEVICE_HANDLER( latch8_bit3_r );
READ8_DEVICE_HANDLER( latch8_bit4_r );
READ8_DEVICE_HANDLER( latch8_bit5_r );
READ8_DEVICE_HANDLER( latch8_bit6_r );
READ8_DEVICE_HANDLER( latch8_bit7_r );
/* read inverted bit x */
/* return (latch >> x) & 0x01 */
READ8_DEVICE_HANDLER( latch8_bit0_q_r );
READ8_DEVICE_HANDLER( latch8_bit1_q_r );
READ8_DEVICE_HANDLER( latch8_bit2_q_r );
READ8_DEVICE_HANDLER( latch8_bit3_q_r );
READ8_DEVICE_HANDLER( latch8_bit4_q_r );
READ8_DEVICE_HANDLER( latch8_bit5_q_r );
READ8_DEVICE_HANDLER( latch8_bit6_q_r );
READ8_DEVICE_HANDLER( latch8_bit7_q_r );
/* write bit x from data into bit determined by offset */
/* latch = (latch & ~(1<<offset)) | (((data >> x) & 0x01) << offset) */
WRITE8_DEVICE_HANDLER( latch8_bit0_w );
WRITE8_DEVICE_HANDLER( latch8_bit1_w );
WRITE8_DEVICE_HANDLER( latch8_bit2_w );
WRITE8_DEVICE_HANDLER( latch8_bit3_w );
WRITE8_DEVICE_HANDLER( latch8_bit4_w );
WRITE8_DEVICE_HANDLER( latch8_bit5_w );
WRITE8_DEVICE_HANDLER( latch8_bit6_w );
WRITE8_DEVICE_HANDLER( latch8_bit7_w );
#endif /* __LATCH8_H_ */
|