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
|
// license:BSD-3-Clause
// copyright-holders:Dirk Best
/***************************************************************************
Input Merger
Used to connect multiple lines to a single device input while
keeping it pulled high or low
***************************************************************************/
#include "emu.h"
#include "input_merger.h"
#include <algorithm>
#include <iterator>
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type INPUT_MERGER_ACTIVE_HIGH = &device_creator<input_merger_active_high_device>;
const device_type INPUT_MERGER_ACTIVE_LOW = &device_creator<input_merger_active_low_device>;
//**************************************************************************
// INPUT ADAPTER
//**************************************************************************
//-------------------------------------------------
// input_merger_device - constructor
//-------------------------------------------------
input_merger_device::input_merger_device(machine_config const &mconfig, device_type type,
char const *name, char const *tag, device_t *owner, uint32_t clock, char const *shortname, char const *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
m_output_handler(*this)
{
}
//-------------------------------------------------
// input_merger_device - destructor
//-------------------------------------------------
input_merger_device::~input_merger_device()
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void input_merger_device::device_start()
{
m_output_handler.resolve_safe();
}
//**************************************************************************
// INPUT ADAPTER ACTIVE HIGH
//**************************************************************************
//-------------------------------------------------
// input_merger_active_high_device - constructor
//-------------------------------------------------
input_merger_active_high_device::input_merger_active_high_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
: input_merger_device(mconfig, INPUT_MERGER_ACTIVE_HIGH, "Input Merger (Active High)", tag, owner, clock, "input_merger_hi", __FILE__)
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void input_merger_active_high_device::device_reset()
{
std::fill(std::begin(m_state), std::end(m_state), false);
}
//-------------------------------------------------
// update_state - verify current input line state
//-------------------------------------------------
void input_merger_active_high_device::update_state()
{
bool state = std::any_of(std::begin(m_state), std::end(m_state), [&](bool state) { return state == true; });
m_output_handler(state ? ASSERT_LINE : CLEAR_LINE);
}
//**************************************************************************
// INPUT ADAPTER ACTIVE LOW
//**************************************************************************
//-------------------------------------------------
// input_merger_active_low_device - constructor
//-------------------------------------------------
input_merger_active_low_device::input_merger_active_low_device(machine_config const &mconfig, char const *tag, device_t *owner, uint32_t clock)
: input_merger_device(mconfig, INPUT_MERGER_ACTIVE_LOW, "Input Merger (Active Low)", tag, owner, clock, "input_merger_lo", __FILE__)
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void input_merger_active_low_device::device_reset()
{
std::fill(std::begin(m_state), std::end(m_state), true);
}
//-------------------------------------------------
// update_state - verify current input line state
//-------------------------------------------------
void input_merger_active_low_device::update_state()
{
bool state = std::any_of(std::begin(m_state), std::end(m_state), [&](bool state) { return state == false; });
m_output_handler(state ? ASSERT_LINE : CLEAR_LINE);
}
|