diff options
author | 2016-10-27 22:35:07 +0200 | |
---|---|---|
committer | 2016-10-28 02:37:22 +0200 | |
commit | 93735cdf7e3dbdf75bcd0c29994fd99ff119f6a4 (patch) | |
tree | da75e0baebd4bf26b5da2bf54e04d7a676871fef | |
parent | 36190dfaa9ace8b0dead9132fc61ccceeccb6e08 (diff) |
-core: Added 54/74160,161,162,163 device emulation. [Ryan Holtz]
-rw-r--r-- | scripts/src/machine.lua | 12 | ||||
-rw-r--r-- | scripts/target/mame/arcade.lua | 1 | ||||
-rw-r--r-- | scripts/target/mame/mess.lua | 1 | ||||
-rw-r--r-- | src/devices/machine/74161.cpp | 183 | ||||
-rw-r--r-- | src/devices/machine/74161.h | 166 |
5 files changed, 363 insertions, 0 deletions
diff --git a/scripts/src/machine.lua b/scripts/src/machine.lua index 028a8aba135..4ff994b3d04 100644 --- a/scripts/src/machine.lua +++ b/scripts/src/machine.lua @@ -333,6 +333,18 @@ end --------------------------------------------------- -- +--@src/devices/machine/74161.h,MACHINES["TTL74161"] = true +--------------------------------------------------- + +if (MACHINES["TTL74161"]~=null) then + files { + MAME_DIR .. "src/devices/machine/74161.cpp", + MAME_DIR .. "src/devices/machine/74161.h", + } +end + +--------------------------------------------------- +-- --@src/devices/machine/74181.h,MACHINES["TTL74181"] = true --------------------------------------------------- diff --git a/scripts/target/mame/arcade.lua b/scripts/target/mame/arcade.lua index 55f33df751f..51deb6f04ae 100644 --- a/scripts/target/mame/arcade.lua +++ b/scripts/target/mame/arcade.lua @@ -357,6 +357,7 @@ MACHINES["TTL74123"] = true MACHINES["TTL74145"] = true MACHINES["TTL74148"] = true MACHINES["TTL74153"] = true +--MACHINES["TTL74161"] = true MACHINES["TTL74181"] = true MACHINES["TTL7474"] = true MACHINES["KBDC8042"] = true diff --git a/scripts/target/mame/mess.lua b/scripts/target/mame/mess.lua index db1ca7f86d2..3c5026f459c 100644 --- a/scripts/target/mame/mess.lua +++ b/scripts/target/mame/mess.lua @@ -363,6 +363,7 @@ MACHINES["8530SCC"] = true --MACHINES["TTL74145"] = true --MACHINES["TTL74148"] = true --MACHINES["TTL74153"] = true +--MACHINES["TTL74161"] = true --MACHINES["TTL74181"] = true --MACHINES["TTL7474"] = true --MACHINES["KBDC8042"] = true diff --git a/src/devices/machine/74161.cpp b/src/devices/machine/74161.cpp new file mode 100644 index 00000000000..50cb769ad0f --- /dev/null +++ b/src/devices/machine/74161.cpp @@ -0,0 +1,183 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/***************************************************************************** + + 54/74161 4-bit binary counter + +*****************************************************************************/ + +#include "emu.h" +#include "74161.h" + +const device_type TTL74160 = &device_creator<ttl74160_device>; +const device_type TTL74161 = &device_creator<ttl74161_device>; +const device_type TTL74162 = &device_creator<ttl74162_device>; +const device_type TTL74163 = &device_creator<ttl74163_device>; + +ttl7416x_device::ttl7416x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, bool synchronous_reset, uint8_t limit) + : device_t(mconfig, type, name, tag, owner, clock, shortname, __FILE__) + , m_output_func(*this) + , m_tc_func(*this) + , m_clear(0) + , m_pe(0) + , m_cet(0) + , m_cep(0) + , m_clock(0) + , m_p(0) + , m_out(0) + , m_tc(0) + , m_last_clock(0) + , m_last_out(0) + , m_last_tc(0) + , m_synchronous_reset(synchronous_reset) + , m_limit(limit) +{ +} + +ttl74160_device::ttl74160_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : ttl7416x_device(mconfig, TTL74160, "54/74160 Decade Counter", tag, owner, clock, "ttl74160", false, 10) +{ +} + +ttl74161_device::ttl74161_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : ttl7416x_device(mconfig, TTL74160, "54/74160 Decade Counter", tag, owner, clock, "ttl74160", false, 16) +{ +} + +ttl74162_device::ttl74162_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : ttl7416x_device(mconfig, TTL74160, "54/74160 Decade Counter", tag, owner, clock, "ttl74160", true, 10) +{ +} + +ttl74163_device::ttl74163_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : ttl7416x_device(mconfig, TTL74160, "54/74160 Decade Counter", tag, owner, clock, "ttl74160", true, 16) +{ +} + +void ttl7416x_device::device_start() +{ + save_item(NAME(m_clear)); + save_item(NAME(m_pe)); + save_item(NAME(m_cet)); + save_item(NAME(m_cep)); + save_item(NAME(m_clock)); + save_item(NAME(m_p)); + save_item(NAME(m_out)); + save_item(NAME(m_tc)); + save_item(NAME(m_last_clock)); + save_item(NAME(m_last_out)); + save_item(NAME(m_last_tc)); + + m_output_func.resolve_safe(); + m_tc_func.resolve_safe(); +} + +void ttl7416x_device::device_reset() +{ + init(); +} + +void ttl7416x_device::tick() +{ + if (m_synchronous_reset && m_clear) + { + init(); + return; + } + + m_last_out = m_out; + m_last_tc = m_tc; + + if (m_pe) + { + m_out = m_p & 0xf; + } + else + { + if (bool(m_cet) && bool(m_cep)) + { + increment(); + } + } + + if (m_out != m_last_out) + { + m_last_out = m_out; + m_output_func(m_out); + } + + if (m_tc != m_last_tc) + { + m_last_tc = m_tc; + m_tc_func(m_tc); + } +} + +void ttl7416x_device::increment() +{ + m_out = (m_out + 1) % (m_limit + 1); + + if (m_out == m_limit) + m_tc = 1; + else + m_tc = 0; +} + +WRITE_LINE_MEMBER( ttl7416x_device::clear_w ) +{ + m_clear = state; + if (!m_synchronous_reset) + init(); +} + + +WRITE_LINE_MEMBER( ttl7416x_device::pe_w ) +{ + m_pe = state; +} + +WRITE_LINE_MEMBER( ttl7416x_device::cet_w ) +{ + m_cet = state; +} + +WRITE_LINE_MEMBER( ttl7416x_device::cep_w ) +{ + m_cep = state; +} + +WRITE_LINE_MEMBER( ttl7416x_device::clock_w ) +{ + m_last_clock = m_clock; + m_clock = state; + if (m_clock != m_last_clock && m_clock != 0) + { + tick(); + } +} + +READ_LINE_MEMBER( ttl7416x_device::output_r ) +{ + return m_out; +} + +READ_LINE_MEMBER( ttl7416x_device::tc_r ) +{ + return m_tc; +} + +void ttl7416x_device::init() +{ + m_clear = 0; + m_pe = 1; + m_cet = 0; + m_cep = 0; + m_clock = 0; + m_p = 0; + + m_out = 0; + m_tc = 0; + + m_last_out = 0; + m_tc = 0; +} diff --git a/src/devices/machine/74161.h b/src/devices/machine/74161.h new file mode 100644 index 00000000000..90f24c5ac6b --- /dev/null +++ b/src/devices/machine/74161.h @@ -0,0 +1,166 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/***************************************************************************** + + 5/74160..3 BCD decade counter / 4-bit binary counter + +*********************************************************************** + + Connection Diagram: + ___ ___ + *R 1 |* u | 16 Vcc + CP 2 | | 15 TC + P0 3 | | 14 Q0 + P1 4 | | 13 Q1 + P2 5 | | 12 Q2 + P3 6 | | 11 Q3 + CEP 7 | | 10 CET + GND 8 |_______| 9 /PE + + *MR for 160 and 161 + *SR for 162 and 163 + + Logic Symbol: + + 9 3 4 5 6 + | | | | | + ____|___|___|___|___|____ + | | + | PE P0 P1 P2 P3 | + 7 ---| CEP | + | | + 10 ---| CET TC |--- 15 + | | + 2 ---| CP | + | MR Q0 Q1 Q2 Q3 | + |_________________________| + | | | | | + | | | | | + 1 14 13 12 11 + + +*********************************************************************** + + Mode Select Table: + + MR PE CET CEP Action on clock edge + L X X X Reset (clear) + H L X X Load Pn..Qn + H H H H Count (increment) + H H L X No change (hold) + H H X L No change (hold) + +**********************************************************************/ + +#pragma once + +#ifndef TTL74161_H +#define TTL74161_H + +#include "emu.h" + +#define MCFG_74161_OUTPUT_CB(_devcb) \ + devcb = &ttl74161_device::set_output_cb(*device, DEVCB_##_devcb); + +#define MCFG_74161_TC_CB(_devcb) \ + devcb = &ttl74161_device::set_comp_output_cb(*device, DEVCB_##_devcb); + +#define MCFG_74160_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, TTL74160, 0) + +#define MCFG_74161_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, TTL74161, 0) + +#define MCFG_74162_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, TTL74162, 0) + +#define MCFG_74163_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, TTL74163, 0) + +class ttl7416x_device : public device_t +{ +public: + // construction/destruction + ttl7416x_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, bool synchronous_reset, uint8_t limit); + + // static configuration helpers + template<class _Object> static devcb_base &set_output_cb(device_t &device, _Object object) { return downcast<ttl7416x_device &>(device).m_output_func.set_callback(object); } + template<class _Object> static devcb_base &set_tc_cb(device_t &device, _Object object) { return downcast<ttl7416x_device &>(device).m_tc_func.set_callback(object); } + + // public interfaces + DECLARE_WRITE_LINE_MEMBER( clear_w ); + DECLARE_WRITE_LINE_MEMBER( pe_w ); + DECLARE_WRITE_LINE_MEMBER( cet_w ); + DECLARE_WRITE_LINE_MEMBER( cep_w ); + DECLARE_WRITE_LINE_MEMBER( clock_w ); + + DECLARE_READ_LINE_MEMBER( output_r ); + DECLARE_READ_LINE_MEMBER( tc_r ); + +protected: + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + +private: + void init(); + void tick(); + void increment(); + + // callbacks + devcb_write8 m_output_func; + devcb_write_line m_tc_func; + + // inputs + uint8_t m_clear; // pin 1 + uint8_t m_pe; // pin 9 + uint8_t m_cet; // pin 10 + uint8_t m_cep; // pin 7 + uint8_t m_clock; // pin 2 + uint8_t m_p; // pins 3-6 from LSB to MSB + + // outputs + uint8_t m_out; // pins 14-11 from LSB to MSB + uint8_t m_tc; // pin 15 + + // old state + uint8_t m_last_clock; + uint8_t m_last_out; + uint8_t m_last_tc; + + const bool m_synchronous_reset; + const uint8_t m_limit; +}; + +class ttl74160_device : public ttl7416x_device +{ +public: + ttl74160_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +}; + +class ttl74161_device : public ttl7416x_device +{ +public: + ttl74161_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +}; + +class ttl74162_device : public ttl7416x_device +{ +public: + ttl74162_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +}; + +class ttl74163_device : public ttl7416x_device +{ +public: + ttl74163_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); +}; + +// device type definition +extern const device_type TTL74160; +extern const device_type TTL74161; +extern const device_type TTL74162; +extern const device_type TTL74163; + + +#endif /* TTL74161_H */ |