mirror of
https://github.com/holub/mame
synced 2025-04-22 08:22:15 +03:00
New device: SN54/74166 8-Bit Parallel-In/Serial-Out Shift Register
This commit is contained in:
parent
5d8deceb2a
commit
85c01f5721
@ -391,6 +391,18 @@ if (MACHINES["TTL74161"]~=null) then
|
||||
}
|
||||
end
|
||||
|
||||
---------------------------------------------------
|
||||
--
|
||||
--@src/devices/machine/74166.h,MACHINES["TTL74166"] = true
|
||||
---------------------------------------------------
|
||||
|
||||
if (MACHINES["TTL74166"]~=null) then
|
||||
files {
|
||||
MAME_DIR .. "src/devices/machine/74166.cpp",
|
||||
MAME_DIR .. "src/devices/machine/74166.h",
|
||||
}
|
||||
end
|
||||
|
||||
---------------------------------------------------
|
||||
--
|
||||
--@src/devices/machine/74175.h,MACHINES["TTL74175"] = true
|
||||
|
128
src/devices/machine/74166.cpp
Normal file
128
src/devices/machine/74166.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
// license: BSD-3-Clause
|
||||
// copyright-holders: Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
SN54/74166
|
||||
|
||||
8-Bit Parallel-In/Serial-Out Shift Register
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "74166.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
DEFINE_DEVICE_TYPE(TTL166, ttl166_device, "ttl166", "SN54/74166")
|
||||
|
||||
//-------------------------------------------------
|
||||
// machine_config_additions - device-specific
|
||||
// machine configurations
|
||||
//-------------------------------------------------
|
||||
|
||||
static MACHINE_CONFIG_FRAGMENT( ttl166 )
|
||||
MCFG_TIMER_DRIVER_ADD("timer", ttl166_device, qh_output)
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
machine_config_constructor ttl166_device::device_mconfig_additions() const
|
||||
{
|
||||
return MACHINE_CONFIG_NAME( ttl166 );
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// ttl153_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
ttl166_device::ttl166_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||
device_t(mconfig, TTL166, tag, owner, clock),
|
||||
m_timer(*this, "timer"),
|
||||
m_data_cb(*this), m_qh_cb(*this),
|
||||
m_data(0x00),
|
||||
m_ser(0), m_clk(0), m_shld(0)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void ttl166_device::device_start()
|
||||
{
|
||||
// resolve callbacks
|
||||
m_data_cb.resolve_safe(0x00);
|
||||
m_qh_cb.resolve_safe();
|
||||
|
||||
// register for save states
|
||||
save_item(NAME(m_data));
|
||||
save_item(NAME(m_ser));
|
||||
save_item(NAME(m_clk));
|
||||
save_item(NAME(m_shld));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_reset - device-specific reset
|
||||
//-------------------------------------------------
|
||||
|
||||
void ttl166_device::device_reset()
|
||||
{
|
||||
m_data = 0x00;
|
||||
m_ser = 0;
|
||||
m_clk = 0;
|
||||
m_shld = 0;
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// IMPLEMENTATION
|
||||
//**************************************************************************
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER( ttl166_device::qh_output )
|
||||
{
|
||||
m_qh_cb(param);
|
||||
}
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE
|
||||
//**************************************************************************
|
||||
|
||||
WRITE_LINE_MEMBER( ttl166_device::serial_w )
|
||||
{
|
||||
m_ser = state;
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( ttl166_device::clock_w )
|
||||
{
|
||||
if (m_clk == 0 && state == 1)
|
||||
{
|
||||
if (m_shld)
|
||||
{
|
||||
// shift next bit
|
||||
m_data <<= 1;
|
||||
m_data |= m_ser;
|
||||
}
|
||||
else
|
||||
{
|
||||
// load external data
|
||||
m_data = m_data_cb(0);
|
||||
}
|
||||
|
||||
// we need to delay the output a bit to allow for serial input
|
||||
m_timer->adjust(attotime::from_nsec(25), BIT(m_data, 7));
|
||||
}
|
||||
|
||||
m_clk = state;
|
||||
}
|
||||
|
||||
WRITE_LINE_MEMBER( ttl166_device::shift_load_w )
|
||||
{
|
||||
m_shld = state;
|
||||
}
|
88
src/devices/machine/74166.h
Normal file
88
src/devices/machine/74166.h
Normal file
@ -0,0 +1,88 @@
|
||||
// license: BSD-3-Clause
|
||||
// copyright-holders: Dirk Best
|
||||
/***************************************************************************
|
||||
|
||||
SN54/74166
|
||||
|
||||
8-Bit Parallel-In/Serial-Out Shift Register
|
||||
|
||||
___ ___
|
||||
SER 1 |* u | 16 VCC
|
||||
A 2 | | 15 SH//LD
|
||||
B 3 | | 14 H
|
||||
C 4 | | 13 QH
|
||||
D 5 | | 12 G
|
||||
CLK INH 6 | | 11 F
|
||||
CLK 7 | | 10 E
|
||||
GND 8 |_______| 9 /CLR
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MAME_DEVICES_MACHINE_74166_H
|
||||
#define MAME_DEVICES_MACHINE_74166_H
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_TTL166_ADD(_tag) \
|
||||
MCFG_DEVICE_ADD(_tag, TTL166, 0)
|
||||
|
||||
#define MCFG_TTL166_DATA_CB(_devcb) \
|
||||
devcb = &ttl166_device::set_data_callback(*device, DEVCB_##_devcb);
|
||||
|
||||
#define MCFG_TTL166_QH_CB(_devcb) \
|
||||
devcb = &ttl166_device::set_qh_callback(*device, DEVCB_##_devcb);
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
class ttl166_device : public device_t
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
ttl166_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||
|
||||
// configuration
|
||||
template <class Object> static devcb_base &set_data_callback(device_t &device, Object &&cb)
|
||||
{ return downcast<ttl166_device &>(device).m_data_cb.set_callback(std::forward<Object>(cb)); }
|
||||
|
||||
template <class Object> static devcb_base &set_qh_callback(device_t &device, Object &&cb)
|
||||
{ return downcast<ttl166_device &>(device).m_qh_cb.set_callback(std::forward<Object>(cb)); }
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER(serial_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(clock_w);
|
||||
DECLARE_WRITE_LINE_MEMBER(shift_load_w);
|
||||
|
||||
TIMER_DEVICE_CALLBACK_MEMBER(qh_output);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual machine_config_constructor device_mconfig_additions() const override;
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
||||
private:
|
||||
required_device<timer_device> m_timer;
|
||||
|
||||
// callbacks
|
||||
devcb_read8 m_data_cb;
|
||||
devcb_write_line m_qh_cb;
|
||||
|
||||
// state
|
||||
uint8_t m_data;
|
||||
int m_ser;
|
||||
int m_clk;
|
||||
int m_shld;
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
DECLARE_DEVICE_TYPE(TTL166, ttl166_device)
|
||||
|
||||
#endif // MAME_DEVICES_MACHINE_74166_H
|
Loading…
Reference in New Issue
Block a user