-core: Added 54/74160,161,162,163 device emulation. [Ryan Holtz]

This commit is contained in:
therealmogminer@gmail.com 2016-10-27 22:35:07 +02:00
parent 36190dfaa9
commit 93735cdf7e
5 changed files with 363 additions and 0 deletions

View File

@ -331,6 +331,18 @@ if (MACHINES["TTL74153"]~=null) then
}
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

View File

@ -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

View File

@ -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

View File

@ -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;
}

166
src/devices/machine/74161.h Normal file
View File

@ -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 */