From c60d4a0760d4e5dfeec53fae04a7d5dcd8af078e Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 11 Jul 2024 21:12:57 +0200 Subject: h8: add system clock getter (divided clock()) --- src/devices/cpu/h8/h8.h | 3 ++- src/devices/cpu/h8/h8_sci.cpp | 18 +++++++++--------- src/devices/cpu/h8/h8_timer8.cpp | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/devices/cpu/h8/h8.h b/src/devices/cpu/h8/h8.h index 0c6abbaa13c..37f2661f984 100644 --- a/src/devices/cpu/h8/h8.h +++ b/src/devices/cpu/h8/h8.h @@ -66,7 +66,8 @@ public: void do_sci_tx(int sci, int state) { m_sci_tx[sci](state); } void do_sci_clk(int sci, int state) { m_sci_clk[sci](state); } - u64 now_as_cycles() const { return machine().time().as_ticks(clock()) - m_cycles_base; } + u64 system_clock() const { return execute_clocks_to_cycles(clock()); } + u64 now_as_cycles() const { return machine().time().as_ticks(system_clock()) - m_cycles_base; } protected: enum { diff --git a/src/devices/cpu/h8/h8_sci.cpp b/src/devices/cpu/h8/h8_sci.cpp index 9f089266111..0144e9a25c0 100644 --- a/src/devices/cpu/h8/h8_sci.cpp +++ b/src/devices/cpu/h8/h8_sci.cpp @@ -253,25 +253,25 @@ void h8_sci_device::clock_update() std::string new_message; switch(m_clock_mode) { case INTERNAL_ASYNC: - new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps\n", int(m_cpu->clock() / m_divider), int(m_cpu->clock() / (m_divider*16))); + new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps\n", int(m_cpu->system_clock() / m_divider), int(m_cpu->system_clock() / (m_divider*16))); break; case INTERNAL_ASYNC_OUT: - new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps, output\n", int(m_cpu->clock() / m_divider), int(m_cpu->clock() / (m_divider*16))); + new_message = util::string_format("clock internal at %d Hz, async, bitrate %d bps, output\n", int(m_cpu->system_clock() / m_divider), int(m_cpu->system_clock() / (m_divider*16))); break; case EXTERNAL_ASYNC: new_message = "clock external, async\n"; break; case EXTERNAL_RATE_ASYNC: - new_message = util::string_format("clock external at %d Hz, async, bitrate %d bps\n", int(m_cpu->clock()*m_internal_to_external_ratio), int(m_cpu->clock()*m_internal_to_external_ratio/16)); + new_message = util::string_format("clock external at %d Hz, async, bitrate %d bps\n", int(m_cpu->system_clock()*m_internal_to_external_ratio), int(m_cpu->system_clock()*m_internal_to_external_ratio/16)); break; case INTERNAL_SYNC_OUT: - new_message = util::string_format("clock internal at %d Hz, sync, output\n", int(m_cpu->clock() / (m_divider*2))); + new_message = util::string_format("clock internal at %d Hz, sync, output\n", int(m_cpu->system_clock() / (m_divider*2))); break; case EXTERNAL_SYNC: new_message = "clock external, sync\n"; break; case EXTERNAL_RATE_SYNC: - new_message = util::string_format("clock external at %d Hz, sync\n", int(m_cpu->clock()*m_internal_to_external_ratio)); + new_message = util::string_format("clock external at %d Hz, sync\n", int(m_cpu->system_clock()*m_internal_to_external_ratio)); break; } if(new_message != m_last_clock_message) { @@ -289,7 +289,7 @@ void h8_sci_device::device_start() m_internal_to_external_ratio = 0; m_external_to_internal_ratio = 0; } else { - m_external_to_internal_ratio = (m_external_clock_period*m_cpu->clock()).as_double(); + m_external_to_internal_ratio = (m_external_clock_period*m_cpu->system_clock()).as_double(); m_internal_to_external_ratio = 1/m_external_to_internal_ratio; } @@ -413,7 +413,7 @@ u64 h8_sci_device::internal_update(u64 current_time) m_clock_event = 0; if(m_clock_event) { - m_sync_timer->adjust(attotime::from_ticks(m_clock_event - m_cpu->now_as_cycles(), m_cpu->clock())); + m_sync_timer->adjust(attotime::from_ticks(m_clock_event - m_cpu->now_as_cycles(), m_cpu->system_clock())); m_cpu->internal_update(); } @@ -457,7 +457,7 @@ void h8_sci_device::clock_start(int mode) m_clock_step = m_divider; u64 now = mode == CLK_TX ? m_cpu->total_cycles() : m_cpu->now_as_cycles(); m_clock_event = (now / m_clock_step + 1) * m_clock_step; - m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->clock())); + m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->system_clock())); m_cpu->internal_update(); break; } @@ -467,7 +467,7 @@ void h8_sci_device::clock_start(int mode) LOGMASKED(LOG_CLOCK, "Simulating external clock\n", m_clock_mode == EXTERNAL_RATE_ASYNC ? "async" : "sync"); u64 now = mode == CLK_TX ? m_cpu->total_cycles() : m_cpu->now_as_cycles(); m_clock_event = u64(u64(now * m_internal_to_external_ratio + 1) * m_external_to_internal_ratio + 1); - m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->clock())); + m_sync_timer->adjust(attotime::from_ticks(m_clock_event - now, m_cpu->system_clock())); m_cpu->internal_update(); break; } diff --git a/src/devices/cpu/h8/h8_timer8.cpp b/src/devices/cpu/h8/h8_timer8.cpp index 16f0ee757a1..c6ba496ea27 100644 --- a/src/devices/cpu/h8/h8_timer8.cpp +++ b/src/devices/cpu/h8/h8_timer8.cpp @@ -81,7 +81,7 @@ void h8_timer8_channel_device::update_tcr() case 1: case 2: case 3: m_clock_type = DIV; m_clock_divider = m_div_tab[((m_tcr & TCR_CKS)-1)*2 + m_extra_clock_bit]; - if(V>=1) util::stream_format(message, "clock %dHz", m_cpu->clock()/m_clock_divider); + if(V>=1) util::stream_format(message, "clock %dHz", m_cpu->system_clock()/m_clock_divider); break; case 4: -- cgit v1.2.3