From 29a9165acb671f6c4c79ee889dcb52d51cbb9c24 Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 23 Dec 2016 09:46:18 -0500 Subject: Further attempts to improve accuracy of 40105 emulation (nw) --- src/devices/machine/40105.cpp | 87 +++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 23 deletions(-) (limited to 'src/devices/machine/40105.cpp') diff --git a/src/devices/machine/40105.cpp b/src/devices/machine/40105.cpp index 981506b44b4..63db529d3bd 100644 --- a/src/devices/machine/40105.cpp +++ b/src/devices/machine/40105.cpp @@ -32,7 +32,7 @@ //************************************************************************** const device_type CD40105 = &device_creator; - +const device_type HC40105 = &device_creator; //************************************************************************** @@ -115,6 +115,54 @@ void cmos_40105_device::write(u8 data) m_d = data & 0x0f; } +WRITE8_MEMBER(cmos_40105_device::write) +{ + write(data); +} + + +//------------------------------------------------- +// load_input - load new data into FIFO +//------------------------------------------------- + +void cmos_40105_device::load_input() +{ + if (m_fifo.size() == 16) + { + logerror("Attempt to load data into full FIFO\n"); + return; + } + + m_fifo.push(m_d); + + // DIR remains low if FIFO is full, or else briefly pulses low + m_write_dir(0); + if (m_fifo.size() == 16) + m_dir = false; + else + m_write_dir(1); +} + + +//------------------------------------------------- +// output_ready - place new data at output +//------------------------------------------------- + +void cmos_40105_device::output_ready() +{ + if (m_fifo.size() == 0) + { + logerror("Attempt to output data from empty FIFO\n"); + return; + } + + m_q = m_fifo.front(); + m_write_q(m_q); + + m_dor = true; + m_write_dor(1); +} + //------------------------------------------------- // si_w - shift in write @@ -122,24 +170,16 @@ void cmos_40105_device::write(u8 data) WRITE_LINE_MEMBER( cmos_40105_device::si_w ) { - // activate on rising edge when ready + // load input on rising edge when ready if (m_dir && !m_si && state) { - m_fifo.push(m_d); - - // DIR remains low if FIFO is full, or else briefly pulses low - m_write_dir(0); - if (m_fifo.size() == 16) - m_dir = false; - else - m_write_dir(1); - - // signal availability of propagated data + load_input(); + } + else if (m_si && !state && m_fifo.size() > 0) + { + // data propagates through FIFO when SI goes low if (!m_dor) - { - m_dor = true; - m_write_dor(1); - } + output_ready(); } m_si = state; @@ -152,25 +192,26 @@ WRITE_LINE_MEMBER( cmos_40105_device::si_w ) WRITE_LINE_MEMBER( cmos_40105_device::so_w ) { - // activate on falling edge when ready + // shift out on falling edge when ready if (m_dor && m_so && !state) { - m_q = m_fifo.front(); m_fifo.pop(); + m_dor = false; m_write_dor(0); - m_write_q(m_q); // DOR remains low if FIFO is now empty, or else briefly pulses low if (m_fifo.size() > 0) - m_write_dor(1); - else - m_dor = false; + output_ready(); - // FIFO can no longer be full if (!m_dir) { + // raise DIR since FIFO is no longer full m_dir = true; m_write_dir(1); + + // load new input immediately if SI is held high + if (m_si) + load_input(); } } -- cgit v1.2.3