blob: dc1e80f73755ecfc5489b41c4125145c737fec35 (
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
|
// license:BSD-3-Clause
// copyright-holders:AJR
/**********************************************************************
Generic binary ripple counter emulation
**********************************************************************/
#ifndef MAME_MACHINE_RIPPLE_COUNTER_H
#define MAME_MACHINE_RIPPLE_COUNTER_H
#pragma once
#include "dirom.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> ripple_counter_device
class ripple_counter_device : public device_t, public device_rom_interface<14>
{
public:
// construction/destruction
ripple_counter_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock = XTAL());
// configuration
void set_stages(u8 stages) { m_count_mask = (1U << stages) - 1; override_address_width(stages); }
auto count_out_cb() { return m_count_out_cb.bind(); }
auto rom_out_cb() { return m_rom_out_cb.bind(); }
// control line handlers
DECLARE_WRITE_LINE_MEMBER(clock_w);
DECLARE_WRITE_LINE_MEMBER(reset_w);
// getters
u32 count() const { return m_count; }
protected:
// device-level overrides
virtual void device_validity_check(validity_checker &valid) const override;
virtual void device_resolve_objects() override;
virtual void device_start() override;
virtual void device_clock_changed() override;
// device_rom_interface overrides
virtual space_config_vector memory_space_config() const override;
virtual void rom_bank_post_change() override;
TIMER_CALLBACK_MEMBER(advance_counter);
private:
// internal helpers
void set_count(u32 count);
// device callbacks
devcb_write32 m_count_out_cb;
devcb_write8 m_rom_out_cb;
// device timers
emu_timer *m_count_timer;
// configuration parameters
u32 m_count_mask;
// running state
u32 m_count;
bool m_clk;
bool m_reset;
};
// device type definition
DECLARE_DEVICE_TYPE(RIPPLE_COUNTER, ripple_counter_device)
#endif // MAME_MACHINE_RIPPLE_COUNTER_H
|