summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/machine/74381.cpp151
-rw-r--r--src/devices/machine/74381.h61
-rw-r--r--src/devices/machine/am25s55x.cpp2
-rw-r--r--src/devices/machine/am25s55x.h2
4 files changed, 214 insertions, 2 deletions
diff --git a/src/devices/machine/74381.cpp b/src/devices/machine/74381.cpp
new file mode 100644
index 00000000000..65514a414e3
--- /dev/null
+++ b/src/devices/machine/74381.cpp
@@ -0,0 +1,151 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+/***************************************************************************
+
+ 74381.cpp
+ TI SN74S381 ALU / Function Generator
+
+***************************************************************************/
+
+#include "emu.h"
+#include "74381.h"
+
+/*****************************************************************************/
+
+DEFINE_DEVICE_TYPE(SN74S381, sn74s381_device, "sn74s381", "TI SN74S381 ALU / Function Generator")
+
+//-------------------------------------------------
+// sn74s381_device - constructor
+//-------------------------------------------------
+
+sn74s381_device::sn74s381_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
+ : device_t(mconfig, SN74S381, tag, owner, clock)
+ , m_a(0)
+ , m_b(0)
+ , m_s(0)
+ , m_cn(0)
+ , m_f(0)
+ , m_p(false)
+ , m_g(false)
+ , m_f_out(*this)
+ , m_p_out(*this)
+ , m_g_out(*this)
+{
+}
+
+void sn74s381_device::device_start()
+{
+ save_item(NAME(m_a));
+ save_item(NAME(m_b));
+ save_item(NAME(m_s));
+ save_item(NAME(m_cn));
+ save_item(NAME(m_f));
+ save_item(NAME(m_p));
+ save_item(NAME(m_g));
+
+ m_f_out.resolve_safe();
+ m_p_out.resolve_safe();
+ m_g_out.resolve_safe();
+}
+
+void sn74s381_device::device_reset()
+{
+ m_a = 0;
+ m_b = 0;
+ m_s = 0;
+ m_cn = 0;
+ m_f = 0;
+ m_p = false;
+ m_g = false;
+
+ m_f_out(0);
+ m_p_out(true);
+ m_g_out(true);
+}
+
+void sn74s381_device::a_w(uint8_t data)
+{
+ m_a = data;
+ update();
+}
+
+void sn74s381_device::b_w(uint8_t data)
+{
+ m_b = data;
+ update();
+}
+
+void sn74s381_device::s_w(uint8_t data)
+{
+ m_s = data;
+ update();
+}
+
+void sn74s381_device::cn_w(int state)
+{
+ m_cn = state;
+ update();
+}
+
+void sn74s381_device::update()
+{
+ switch (m_s)
+ {
+ case 0: // Clear
+ m_f = 0;
+ m_p = true;
+ m_g = true;
+ break;
+ case 1: // B - A
+ {
+ const uint8_t c = 1 - m_cn;
+ const uint8_t d = (m_a + c) & 0xf;
+ m_f = (m_b - d) & 0xf;
+ m_p = (( m_a ^ m_b) >> 3) == 0;
+ m_g = ((~m_a & m_b) >> 3) != 0;
+ break;
+ }
+ case 2: // A - B
+ {
+ const uint8_t c = 1 - m_cn;
+ const uint8_t d = (m_b + c) & 0xf;
+ m_f = (m_a - d) & 0xf;
+ m_p = ((m_a ^ m_b) >> 3) == 0;
+ m_g = ((m_a & ~m_b) >> 3) != 0;
+ break;
+ }
+ case 3: // A + B
+ {
+ const uint8_t c = m_cn;
+ const uint8_t d = (m_b + c) & 0xf;
+ m_f = (m_a + d) & 0xf;
+ m_p = ((m_a ^ m_b) >> 3) != 0;
+ m_g = ((m_a & m_b) >> 3) != 0;
+ break;
+ }
+ case 4: // A ^ B
+ m_f = m_a ^ m_b;
+ m_p = (m_a >> 3) != (m_b >> 3);
+ m_g = false;
+ break;
+ case 5: // A | B
+ m_f = m_a | m_b;
+ m_p = (m_a >> 3) != 0 || (m_b >> 3) != 0;
+ m_g = false;
+ break;
+ case 6: // A & B
+ m_f = m_a & m_b;
+ m_p = (m_a >> 3) != 0 && (m_b >> 3) != 0;
+ m_g = false;
+ break;
+ case 7: // Preset
+ m_f = 0xf;
+ m_p = true;
+ m_g = false;
+ break;
+ }
+
+ m_f_out(m_f);
+ m_p_out(m_p ? 0 : 1);
+ m_g_out(m_g ? 0 : 1);
+}
diff --git a/src/devices/machine/74381.h b/src/devices/machine/74381.h
new file mode 100644
index 00000000000..2aef6456540
--- /dev/null
+++ b/src/devices/machine/74381.h
@@ -0,0 +1,61 @@
+// license:BSD-3-Clause
+// copyright-holders:Ryan Holtz
+/***************************************************************************
+
+ 74381.h
+ SN74S381 ALU / Function Generator
+
+***************************************************************************/
+
+#ifndef MAME_MACHINE_74381_H
+#define MAME_MACHINE_74381_H
+
+#pragma once
+
+//**************************************************************************
+// TYPE DEFINITIONS
+//**************************************************************************
+
+// ======================> sn74s381_device
+
+class sn74s381_device : public device_t
+{
+public:
+ // construction/destruction
+ sn74s381_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
+
+ void a_w(uint8_t data);
+ void b_w(uint8_t data);
+ void s_w(uint8_t data);
+ void cn_w(int state);
+
+ auto f() { return m_f_out.bind(); }
+ auto p() { return m_p_out.bind(); }
+ auto g() { return m_g_out.bind(); }
+
+protected:
+ // device-level overrides
+ virtual void device_start() override;
+ virtual void device_reset() override;
+
+ void update();
+
+ uint8_t m_a;
+ uint8_t m_b;
+ uint8_t m_s;
+ uint8_t m_cn;
+
+ uint8_t m_f;
+ bool m_p;
+ bool m_g;
+
+ devcb_write8 m_f_out;
+ devcb_write_line m_p_out;
+ devcb_write_line m_g_out;
+};
+
+
+// device type definition
+DECLARE_DEVICE_TYPE(SN74S381, sn74s381_device)
+
+#endif // MAME_MACHINE_74381_H
diff --git a/src/devices/machine/am25s55x.cpp b/src/devices/machine/am25s55x.cpp
index c1b4bbd310b..b1624179463 100644
--- a/src/devices/machine/am25s55x.cpp
+++ b/src/devices/machine/am25s55x.cpp
@@ -2,7 +2,7 @@
// copyright-holders:Ryan Holtz
/***************************************************************************
- am25s55x.h
+ am25s55x.cpp
AMD Am25S557/Am25S558 8x8-bit Combinatorial Multiplier
***************************************************************************/
diff --git a/src/devices/machine/am25s55x.h b/src/devices/machine/am25s55x.h
index 6501c6065c3..1fa3cab8102 100644
--- a/src/devices/machine/am25s55x.h
+++ b/src/devices/machine/am25s55x.h
@@ -16,7 +16,7 @@
// TYPE DEFINITIONS
//**************************************************************************
-// ======================> am25s557_base_device
+// ======================> am25s55x_device
class am25s55x_device : public device_t
{