Skip to content

H8 improvements: H8/3437, I2C master and Sun Fire V120 stub #13016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/src/cpu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,8 @@ if CPUS["H8"] then
MAME_DIR .. "src/devices/cpu/h8/h83217.h",
MAME_DIR .. "src/devices/cpu/h8/h83337.cpp",
MAME_DIR .. "src/devices/cpu/h8/h83337.h",
MAME_DIR .. "src/devices/cpu/h8/h83437.cpp",
MAME_DIR .. "src/devices/cpu/h8/h83437.h",
MAME_DIR .. "src/devices/cpu/h8/h8s2245.cpp",
MAME_DIR .. "src/devices/cpu/h8/h8s2245.h",
MAME_DIR .. "src/devices/cpu/h8/h8s2319.cpp",
Expand All @@ -737,6 +739,8 @@ if CPUS["H8"] then
MAME_DIR .. "src/devices/cpu/h8/h8_dma.h",
MAME_DIR .. "src/devices/cpu/h8/h8_dtc.cpp",
MAME_DIR .. "src/devices/cpu/h8/h8_dtc.h",
MAME_DIR .. "src/devices/cpu/h8/h8_i2c.cpp",
MAME_DIR .. "src/devices/cpu/h8/h8_i2c.h",
MAME_DIR .. "src/devices/cpu/h8/h8_intc.cpp",
MAME_DIR .. "src/devices/cpu/h8/h8_intc.h",
MAME_DIR .. "src/devices/cpu/h8/h8_port.cpp",
Expand Down
48 changes: 38 additions & 10 deletions src/devices/cpu/h8/h83337.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ DEFINE_DEVICE_TYPE(H83336, h83336_device, "h83336", "Hitachi H8/3336")
DEFINE_DEVICE_TYPE(H83337, h83337_device, "h83337", "Hitachi H8/3337")


h83337_device::h83337_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u32 start) :
h8_device(mconfig, type, tag, owner, clock, address_map_constructor(FUNC(h83337_device::map), this)),
h83337_device::h83337_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, address_map_constructor map_delegate, u32 start) :
h8_device(mconfig, type, tag, owner, clock, map_delegate),
m_scl_w(*this),
m_sda_w(*this),
m_sda_r(*this, 1),
m_intc(*this, "intc"),
m_adc(*this, "adc"),
m_i2c(*this, "i2c"),
m_port1(*this, "port1"),
m_port2(*this, "port2"),
m_port3(*this, "port3"),
Expand All @@ -42,10 +46,16 @@ h83337_device::h83337_device(const machine_config &mconfig, device_type type, co
m_timer16(*this, "timer16"),
m_timer16_0(*this, "timer16:0"),
m_watchdog(*this, "watchdog"),
m_sci0_i2c_view(*this, "sci0_i2c_view"),
m_ram_start(start)
{
}

h83337_device::h83337_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u32 start) :
h83337_device(mconfig, H83337, tag, owner, clock, address_map_constructor(FUNC(h83337_device::map), this), 0xf780)
Copy link
Member

@galibert galibert Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The H83337 here should be "type". That breaks mame -valid.

{
}

h83337_device::h83337_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
h83337_device(mconfig, H83337, tag, owner, clock, 0xf780)
{
Expand Down Expand Up @@ -97,8 +107,8 @@ void h83337_device::map(address_map &map)
map(0xffb9, 0xffb9).rw(m_port6, FUNC(h8_port_device::ff_r), FUNC(h8_port_device::ddr_w));
map(0xffba, 0xffba).rw(m_port5, FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
map(0xffbb, 0xffbb).rw(m_port6, FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
map(0xffbd, 0xffbd).rw(m_port8, FUNC(h8_port_device::ff_r), FUNC(h8_port_device::ddr_w));
map(0xffbe, 0xffbe).rw(m_port7, FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
map(0xffbd, 0xffbd).w(m_port8, FUNC(h8_port_device::ddr_w));
map(0xffbe, 0xffbe).r(m_port7, FUNC(h8_port_device::port_r));
map(0xffbf, 0xffbf).rw(m_port8, FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
map(0xffc0, 0xffc0).rw(m_port9, FUNC(h8_port_device::ff_r), FUNC(h8_port_device::ddr_w));
map(0xffc1, 0xffc1).rw(m_port9, FUNC(h8_port_device::port_r), FUNC(h8_port_device::dr_w));
Expand All @@ -119,12 +129,17 @@ void h83337_device::map(address_map &map)
map(0xffd2, 0xffd3).rw(m_timer8_1, FUNC(h8_timer8_channel_device::tcor_r), FUNC(h8_timer8_channel_device::tcor_w));
map(0xffd4, 0xffd4).rw(m_timer8_1, FUNC(h8_timer8_channel_device::tcnt_r), FUNC(h8_timer8_channel_device::tcnt_w));

map(0xffd8, 0xffd8).rw(m_sci[0], FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
map(0xffd9, 0xffd9).rw(m_sci[0], FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
map(0xffda, 0xffda).rw(m_sci[0], FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
map(0xffdb, 0xffdb).rw(m_sci[0], FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
map(0xffdc, 0xffdc).rw(m_sci[0], FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
map(0xffdd, 0xffdd).r(m_sci[0], FUNC(h8_sci_device::rdr_r));
map(0xffd8, 0x0ffdf).view(m_sci0_i2c_view);
m_sci0_i2c_view[0](0xffd8, 0xffd8).rw(m_sci[0], FUNC(h8_sci_device::smr_r), FUNC(h8_sci_device::smr_w));
m_sci0_i2c_view[0](0xffd9, 0xffd9).rw(m_sci[0], FUNC(h8_sci_device::brr_r), FUNC(h8_sci_device::brr_w));
m_sci0_i2c_view[0](0xffda, 0xffda).rw(m_sci[0], FUNC(h8_sci_device::scr_r), FUNC(h8_sci_device::scr_w));
m_sci0_i2c_view[0](0xffdb, 0xffdb).rw(m_sci[0], FUNC(h8_sci_device::tdr_r), FUNC(h8_sci_device::tdr_w));
m_sci0_i2c_view[0](0xffdc, 0xffdc).rw(m_sci[0], FUNC(h8_sci_device::ssr_r), FUNC(h8_sci_device::ssr_w));
m_sci0_i2c_view[0](0xffdd, 0xffdd).r(m_sci[0], FUNC(h8_sci_device::rdr_r));
m_sci0_i2c_view[1](0xffd8, 0xffd8).rw(m_i2c, FUNC(h8_i2c_device::iccr_r), FUNC(h8_i2c_device::iccr_w));
m_sci0_i2c_view[1](0xffd9, 0xffd9).rw(m_i2c, FUNC(h8_i2c_device::icsr_r), FUNC(h8_i2c_device::icsr_w));
m_sci0_i2c_view[1](0xffde, 0xffde).rw(m_i2c, FUNC(h8_i2c_device::icdr_r), FUNC(h8_i2c_device::icdr_w));
m_sci0_i2c_view[1](0xffdf, 0xffdf).rw(m_i2c, FUNC(h8_i2c_device::icmr_sar_r), FUNC(h8_i2c_device::icmr_sar_w));

map(0xffe0, 0xffe7).r(m_adc, FUNC(h8_adc_device::addr8_r));
map(0xffe8, 0xffe8).rw(m_adc, FUNC(h8_adc_device::adcsr_r), FUNC(h8_adc_device::adcsr_w));
Expand All @@ -137,6 +152,12 @@ void h83337_device::device_add_mconfig(machine_config &config)
{
H8_INTC(config, m_intc, *this);
H8_ADC_3337(config, m_adc, *this, m_intc, 35);

H8_I2C(config, m_i2c);
m_i2c->scl_cb().set([this](int state) { m_scl_w(state); });
m_i2c->sda_cb().set([this](int state) { m_sda_w(state); });
m_i2c->sda_out_cb().set([this]() { return m_sda_r(); });

H8_PORT(config, m_port1, *this, h8_device::PORT_1, 0x00, 0x00);
H8_PORT(config, m_port2, *this, h8_device::PORT_2, 0x00, 0x00);
H8_PORT(config, m_port3, *this, h8_device::PORT_3, 0x00, 0x00);
Expand Down Expand Up @@ -224,6 +245,7 @@ void h83337_device::device_reset()
m_wscr = 0x08;
m_stcr = 0x00;
m_syscr = 0x09;
m_sci0_i2c_view.select(0);
}

u8 h83337_device::syscr_r()
Expand Down Expand Up @@ -261,6 +283,12 @@ void h83337_device::stcr_w(u8 data)
m_timer8_0->set_extra_clock_bit(BIT(data, 0));
m_timer8_1->set_extra_clock_bit(BIT(data, 1));

// IICE (enable access to I2C registers in place of SCI0)
if (BIT(data, 4))
m_sci0_i2c_view.select(1);
else
m_sci0_i2c_view.select(0);

m_stcr = data;
}

Expand Down
13 changes: 13 additions & 0 deletions src/devices/cpu/h8/h83337.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "h8_intc.h"
#include "h8_adc.h"
#include "h8_i2c.h"
#include "h8_port.h"
#include "h8_timer8.h"
#include "h8_timer16.h"
Expand Down Expand Up @@ -54,6 +55,10 @@ class h83337_device : public h8_device {
auto read_port9() { return m_read_port [PORT_9].bind(); }
auto write_port9() { return m_write_port[PORT_9].bind(); }

auto scl_cb() { return m_scl_w.bind(); }
auto sda_cb() { return m_sda_w.bind(); }
auto sda_out_cb() { return m_sda_r.bind(); }

u8 wscr_r();
void wscr_w(u8 data);
u8 stcr_r();
Expand All @@ -64,10 +69,16 @@ class h83337_device : public h8_device {
void mdcr_w(u8 data);

protected:
h83337_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, address_map_constructor map_delegate, u32 start);
h83337_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u32 start);

devcb_write_line m_scl_w;
devcb_write_line m_sda_w;
devcb_read_line m_sda_r;

required_device<h8_intc_device> m_intc;
required_device<h8_adc_device> m_adc;
required_device<h8_i2c_device> m_i2c;
required_device<h8_port_device> m_port1;
required_device<h8_port_device> m_port2;
required_device<h8_port_device> m_port3;
Expand All @@ -83,6 +94,8 @@ class h83337_device : public h8_device {
required_device<h8_timer16_channel_device> m_timer16_0;
required_device<h8_watchdog_device> m_watchdog;

memory_view m_sci0_i2c_view;

u32 m_ram_start;
u8 m_wscr;
u8 m_stcr;
Expand Down
57 changes: 57 additions & 0 deletions src/devices/cpu/h8/h83437.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
// copyright-holders:Lubomir Rintel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple copyright-holders should be comma-separated.

/***************************************************************************

h83437.cpp

H8-3437 family emulation

***************************************************************************/

#include "emu.h"
#include "h83437.h"

DEFINE_DEVICE_TYPE(H83434, h83434_device, "h83434", "Hitachi H8/3434")
DEFINE_DEVICE_TYPE(H83436, h83436_device, "h83436", "Hitachi H8/3436")
DEFINE_DEVICE_TYPE(H83437, h83437_device, "h83437", "Hitachi H8/3437")


h83437_device::h83437_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u32 start) :
h83337_device(mconfig, type, tag, owner, clock, address_map_constructor(FUNC(h83437_device::map), this), start),
m_porta(*this, "porta"),
m_portb(*this, "portb")
{
}

h83437_device::h83437_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
h83437_device(mconfig, H83437, tag, owner, clock, 0xf780)
{
}

h83434_device::h83434_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
h83437_device(mconfig, H83434, tag, owner, clock, 0xfb80)
{
}

h83436_device::h83436_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) :
h83437_device(mconfig, H83436, tag, owner, clock, 0xf780)
{
}

void h83437_device::map(address_map &map)
{
h83337_device::map(map);
map(0xffaa, 0xffaa).rw(m_porta, FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
map(0xffab, 0xffab).rw(m_porta, FUNC(h8_port_device::port_r), FUNC(h8_port_device::ddr_w));
map(0xffbc, 0xffbc).rw(m_portb, FUNC(h8_port_device::dr_r), FUNC(h8_port_device::dr_w));
map(0xffbd, 0xffbd).r(m_portb, FUNC(h8_port_device::port_r));
map(0xffbe, 0xffbe).w(m_portb, FUNC(h8_port_device::ddr_w));
}

void h83437_device::device_add_mconfig(machine_config &config)
{
h83337_device::device_add_mconfig(config);
H8_PORT(config, m_porta, *this, h8_device::PORT_A, 0x00, 0x00);
H8_PORT(config, m_portb, *this, h8_device::PORT_B, 0x00, 0x00);
}
60 changes: 60 additions & 0 deletions src/devices/cpu/h8/h83437.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
// copyright-holders:Lubomir Rintel
/***************************************************************************

h83437.h

H8-3437 family emulation

H8-300-based mcus.

Variant ROM RAM
H8/3434 32K 1K
H8/3436 48K 2K
H8/3437 60K 2K

***************************************************************************/

#ifndef MAME_CPU_H8_H83437_H
#define MAME_CPU_H8_H83437_H

#pragma once

#include "h83337.h"
#include "h8_port.h"

class h83437_device : public h83337_device {
public:
h83437_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);

auto read_porta() { return m_read_port [PORT_A].bind(); }
auto write_porta() { return m_write_port[PORT_A].bind(); }
auto read_portb() { return m_read_port [PORT_B].bind(); }
auto write_portb() { return m_write_port[PORT_B].bind(); }

protected:
h83437_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u32 start);

required_device<h8_port_device> m_porta;
required_device<h8_port_device> m_portb;

virtual void device_add_mconfig(machine_config &config) override ATTR_COLD;
void map(address_map &map) ATTR_COLD;
};

class h83434_device : public h83437_device {
public:
h83434_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
};

class h83436_device : public h83437_device {
public:
h83436_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
};

DECLARE_DEVICE_TYPE(H83434, h83434_device)
DECLARE_DEVICE_TYPE(H83436, h83436_device)
DECLARE_DEVICE_TYPE(H83437, h83437_device)

#endif // MAME_CPU_H8_H83437_H
Loading
Loading