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
|
// license:BSD-3-Clause
// copyright-holders:AJR
/***************************************************************************
74LS157 Quad 2-Line to 1-Line Data Selectors/Multiplexers (TTL)
****************************************************************************
____ ____
SELECT 1 |* \_/ | 16 Vcc
A1 IN 2 | | 15 STROBE
B1 IN 3 | | 14 A4 IN
Y1 OUT 4 | | 13 B4 IN
A2 IN 5 | 74LS157 | 12 Y4 OUT
B2 IN 6 | | 11 A3 IN
Y2 OUT 7 | | 10 B3 IN
GND 8 |___________| 9 Y3 OUT
***************************************************************************/
#ifndef MAME_MACHINE_74157_H
#define MAME_MACHINE_74157_H
#pragma once
//**************************************************************************
// DEVICE CONFIGURATION MACROS
//**************************************************************************
#define MCFG_74157_A_IN_CB(_devcb) \
devcb = &downcast<ls157_device &>(*device).set_a_in_callback(DEVCB_##_devcb);
#define MCFG_74157_B_IN_CB(_devcb) \
devcb = &downcast<ls157_device &>(*device).set_b_in_callback(DEVCB_##_devcb);
#define MCFG_74157_OUT_CB(_devcb) \
devcb = &downcast<ls157_device &>(*device).set_out_callback(DEVCB_##_devcb);
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> ls157_device
class ls157_device : public device_t
{
public:
// construction/destruction
ls157_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
// static configuration
template <class Object> devcb_base &set_a_in_callback(Object &&cb) { return m_a_in_cb.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_b_in_callback(Object &&cb) { return m_b_in_cb.set_callback(std::forward<Object>(cb)); }
template <class Object> devcb_base &set_out_callback(Object &&cb) { return m_out_cb.set_callback(std::forward<Object>(cb)); }
// data writes
DECLARE_WRITE8_MEMBER(a_w);
void a_w(u8 data);
DECLARE_WRITE8_MEMBER(b_w);
void b_w(u8 data);
DECLARE_WRITE8_MEMBER(ab_w);
void ab_w(u8 data);
DECLARE_WRITE8_MEMBER(ba_w);
void ba_w(u8 data);
DECLARE_WRITE8_MEMBER(interleave_w);
void interleave_w(u8 data);
// data line writes
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(b0_w);
DECLARE_WRITE_LINE_MEMBER(b1_w);
DECLARE_WRITE_LINE_MEMBER(b2_w);
DECLARE_WRITE_LINE_MEMBER(b3_w);
// control line writes
DECLARE_WRITE_LINE_MEMBER(select_w);
DECLARE_WRITE_LINE_MEMBER(strobe_w);
// output read
DECLARE_READ8_MEMBER(output_r);
protected:
ls157_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 mask);
// device-level overrides
virtual void device_start() override;
private:
// internal helpers
void write_a_bit(int bit, bool state);
void write_b_bit(int bit, bool state);
void update_output();
// callbacks & configuration
devcb_read8 m_a_in_cb;
devcb_read8 m_b_in_cb;
devcb_write8 m_out_cb;
u8 m_data_mask;
// internal state
u8 m_a;
u8 m_b;
bool m_select;
bool m_strobe;
};
// ======================> ls157_x2_device
class ls157_x2_device : public ls157_device
{
public:
// construction/destruction
ls157_x2_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
};
// ======================> hc157_device
class hc157_device : public ls157_device
{
public:
// construction/destruction
hc157_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
};
// ======================> hct157_device
class hct157_device : public ls157_device
{
public:
// construction/destruction
hct157_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
};
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
// device type definitions
DECLARE_DEVICE_TYPE(LS157, ls157_device)
DECLARE_DEVICE_TYPE(LS157_X2, ls157_x2_device)
DECLARE_DEVICE_TYPE(HC157, hc157_device)
DECLARE_DEVICE_TYPE(HCT157, hct157_device)
#endif // MAME_MACHINE_74157_H
|