From 156619b401e85bfe14f771a59bd8d0272fa257a4 Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 3 Mar 2019 16:56:13 -0500 Subject: Add skeleton CPU device and disassembler for HPC architecture --- src/devices/cpu/hpc/hpc.cpp | 102 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/devices/cpu/hpc/hpc.cpp (limited to 'src/devices/cpu/hpc/hpc.cpp') diff --git a/src/devices/cpu/hpc/hpc.cpp b/src/devices/cpu/hpc/hpc.cpp new file mode 100644 index 00000000000..6cf5f30eb37 --- /dev/null +++ b/src/devices/cpu/hpc/hpc.cpp @@ -0,0 +1,102 @@ +// license:BSD-3-Clause +// copyright-holders:AJR +/*************************************************************************** + + National Semiconductor High-Performance microController (HPC) + + Currently this device is just a stub with no actual execution core. + +***************************************************************************/ + +#include "emu.h" +#include "hpc.h" +#include "hpcdasm.h" + +// device type definitions +DEFINE_DEVICE_TYPE(HPC46104, hpc46104_device, "hpc46104", "HPC46104") + + +void hpc46104_device::internal_map(address_map &map) +{ + map(0x0000, 0x00bf).ram(); + map(0x00c0, 0x00c0).rw(FUNC(hpc46104_device::psw_r), FUNC(hpc46104_device::psw_w)); + map(0x00c4, 0x00cf).ram().share("core_regs"); + // TODO: many other internal registers + map(0x01c0, 0x02ff).ram(); +} + +std::unique_ptr hpc46104_device::create_disassembler() +{ + return std::make_unique(); +} + + +hpc_device::hpc_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, address_map_constructor map) + : cpu_device(mconfig, type, tag, owner, clock) + , m_program_config("program", ENDIANNESS_LITTLE, 16, 16, 0, map) + , m_program(nullptr) + , m_core_regs(*this, "core_regs") + , m_psw(0) + , m_icount(0) +{ +} + +hpc46104_device::hpc46104_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : hpc_device(mconfig, HPC46104, tag, owner, clock, address_map_constructor(FUNC(hpc46104_device::internal_map), this)) +{ +} + +device_memory_interface::space_config_vector hpc_device::memory_space_config() const +{ + return space_config_vector { + std::make_pair(AS_PROGRAM, &m_program_config), + }; +} + + +void hpc_device::device_start() +{ + m_program = &space(AS_PROGRAM); + + set_icountptr(m_icount); + + state_add(HPC_PSW, "PSW", m_psw); + state_add(HPC_SP, "SP", m_core_regs[0]); + state_add(HPC_PC, "PC", m_core_regs[1]); + state_add(STATE_GENPC, "GENPC", m_core_regs[1]).callimport().noshow(); + state_add(STATE_GENPCBASE, "CURPC", m_core_regs[1]).callimport().noshow(); + state_add(HPC_A, "A", m_core_regs[2]); + state_add(HPC_K, "K", m_core_regs[3]); + state_add(HPC_B, "B", m_core_regs[4]); + state_add(HPC_X, "X", m_core_regs[5]); + + save_item(NAME(m_psw)); +} + +void hpc_device::device_reset() +{ + m_psw = 0x00; + std::fill_n(&m_core_regs[0], 6, 0x0000); +} + + +u8 hpc_device::psw_r() +{ + return m_psw; +} + +void hpc_device::psw_w(u8 data) +{ + m_psw = data; +} + + +void hpc_device::execute_run() +{ + m_icount = 0; +} + +void hpc_device::execute_set_input(int inputnum, int state) +{ + // TODO +} -- cgit v1.2.3-70-g09d2 From c7054c697a46d09a163a9e139d51b75b8631b486 Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 3 Mar 2019 17:28:58 -0500 Subject: hpc: Debugging aid (nw) --- src/devices/cpu/hpc/hpc.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/devices/cpu/hpc/hpc.cpp') diff --git a/src/devices/cpu/hpc/hpc.cpp b/src/devices/cpu/hpc/hpc.cpp index 6cf5f30eb37..cdfbe43dc1a 100644 --- a/src/devices/cpu/hpc/hpc.cpp +++ b/src/devices/cpu/hpc/hpc.cpp @@ -93,6 +93,9 @@ void hpc_device::psw_w(u8 data) void hpc_device::execute_run() { + m_core_regs[1] = m_program->read_word(0xfffe); + debugger_instruction_hook(m_core_regs[1]); + m_icount = 0; } -- cgit v1.2.3-70-g09d2 From c63cd721ffff3fa110cdc8579cbc1dbafd444603 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 5 Mar 2019 12:45:11 -0500 Subject: hpc: Add HPC46003 type for future use (nw) - Further bit instruction disassembly adjustments (nw) --- src/devices/cpu/hpc/hpc.cpp | 20 ++++++++++++++++++++ src/devices/cpu/hpc/hpc.h | 15 +++++++++++++++ src/devices/cpu/hpc/hpcdasm.cpp | 32 ++++++++++++++++++++++++++++---- src/devices/cpu/hpc/hpcdasm.h | 9 +++++++++ src/tools/unidasm.cpp | 1 + 5 files changed, 73 insertions(+), 4 deletions(-) (limited to 'src/devices/cpu/hpc/hpc.cpp') diff --git a/src/devices/cpu/hpc/hpc.cpp b/src/devices/cpu/hpc/hpc.cpp index cdfbe43dc1a..9d10ffbbbf9 100644 --- a/src/devices/cpu/hpc/hpc.cpp +++ b/src/devices/cpu/hpc/hpc.cpp @@ -13,9 +13,19 @@ #include "hpcdasm.h" // device type definitions +DEFINE_DEVICE_TYPE(HPC46003, hpc46003_device, "hpc46003", "HPC46003") DEFINE_DEVICE_TYPE(HPC46104, hpc46104_device, "hpc46104", "HPC46104") +void hpc46003_device::internal_map(address_map &map) +{ + map(0x0000, 0x00bf).ram(); + map(0x00c0, 0x00c0).rw(FUNC(hpc46003_device::psw_r), FUNC(hpc46003_device::psw_w)); + map(0x00c4, 0x00cf).ram().share("core_regs"); + // TODO: many other internal registers + map(0x01c0, 0x01ff).ram(); +} + void hpc46104_device::internal_map(address_map &map) { map(0x0000, 0x00bf).ram(); @@ -25,6 +35,11 @@ void hpc46104_device::internal_map(address_map &map) map(0x01c0, 0x02ff).ram(); } +std::unique_ptr hpc46003_device::create_disassembler() +{ + return std::make_unique(); +} + std::unique_ptr hpc46104_device::create_disassembler() { return std::make_unique(); @@ -41,6 +56,11 @@ hpc_device::hpc_device(const machine_config &mconfig, device_type type, const ch { } +hpc46003_device::hpc46003_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : hpc_device(mconfig, HPC46003, tag, owner, clock, address_map_constructor(FUNC(hpc46003_device::internal_map), this)) +{ +} + hpc46104_device::hpc46104_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : hpc_device(mconfig, HPC46104, tag, owner, clock, address_map_constructor(FUNC(hpc46104_device::internal_map), this)) { diff --git a/src/devices/cpu/hpc/hpc.h b/src/devices/cpu/hpc/hpc.h index 3f1dad6be3e..5f73a0ee2e6 100644 --- a/src/devices/cpu/hpc/hpc.h +++ b/src/devices/cpu/hpc/hpc.h @@ -52,6 +52,20 @@ private: s32 m_icount; }; +class hpc46003_device : public hpc_device +{ +public: + // construction/destruction + hpc46003_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + +protected: + // device_disasm_interface overrides + virtual std::unique_ptr create_disassembler() override; + +private: + void internal_map(address_map &map); +}; + class hpc46104_device : public hpc_device { public: @@ -68,6 +82,7 @@ private: // device type declarations +DECLARE_DEVICE_TYPE(HPC46003, hpc46003_device) DECLARE_DEVICE_TYPE(HPC46104, hpc46104_device) #endif // MAME_CPU_HPC_HPC_H diff --git a/src/devices/cpu/hpc/hpcdasm.cpp b/src/devices/cpu/hpc/hpcdasm.cpp index 263cdadb6f1..54cec15e627 100644 --- a/src/devices/cpu/hpc/hpcdasm.cpp +++ b/src/devices/cpu/hpc/hpcdasm.cpp @@ -16,6 +16,26 @@ #include "util/strformat.h" #include +const char *const hpc16083_disassembler::s_regs[128] = +{ + "psw", nullptr, "SP", "PC", "A", "K", "B", "X", + "enir", "irpd", "ircd", "sio", "porti", nullptr, "halten", nullptr, + "porta", "portb", nullptr, "upic", nullptr, nullptr, nullptr, nullptr, + "dira", "dirb", "bfun", nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, "portd", nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + "enu", "enui", "rbuf", "tbuf", "enur", nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + "t4", "r4", "t5", "r5", "t6", "r6", "t7", "r7", + "pwmode", "portp", nullptr, nullptr, nullptr, nullptr, "eicon", "eicr", + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + "i4cr", "i3cr", "i2cr", "r2", "t2", "r3", "t3", "divby", + "tmmode", "t0con", "watchdog", nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr +}; + const char *const hpc16164_disassembler::s_regs[128] = { "psw", nullptr, "SP", "PC", "A", "K", "B", "X", @@ -151,7 +171,7 @@ void hpc_disassembler::disassemble_bit_op(std::ostream &stream, const char *op, stream << "["; format_register(stream, src); if (indir) - stream << "]"; + stream << "].b"; } offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_disassembler::data_buffer &opcodes, const hpc_disassembler::data_buffer ¶ms) @@ -189,6 +209,10 @@ offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_ bytes = 2; break; + case 0x38: case 0x39: case 0x3a: + reg = REGISTER_X; + break; + case 0x3f: case 0x89: case 0x8a: case 0xa9: case 0xaa: case 0xaf: @@ -483,15 +507,15 @@ offs_t hpc_disassembler::disassemble(std::ostream &stream, offs_t pc, const hpc_ break; case 0x38: - util::stream_format(stream, "%-8sX,[B]", "rbit"); + disassemble_op(stream, "rbit", reg, src, imm, indir, idx, false); break; case 0x39: - util::stream_format(stream, "%-8sX,[B]", "sbit"); + disassemble_op(stream, "sbit", reg, src, imm, indir, idx, false); break; case 0x3a: - util::stream_format(stream, "%-8sX,[B]", "ifbit"); + disassemble_op(stream, "ifbit", reg, src, imm, indir, idx, false); break; case 0x3b: diff --git a/src/devices/cpu/hpc/hpcdasm.h b/src/devices/cpu/hpc/hpcdasm.h index 85aa4f550f1..ed57c6b1a35 100644 --- a/src/devices/cpu/hpc/hpcdasm.h +++ b/src/devices/cpu/hpc/hpcdasm.h @@ -37,6 +37,15 @@ private: const char *const *m_regs; }; +class hpc16083_disassembler : public hpc_disassembler +{ +public: + hpc16083_disassembler() : hpc_disassembler(s_regs) { } + +private: + static const char *const s_regs[128]; +}; + class hpc16164_disassembler : public hpc_disassembler { public: diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index e8bb305bfa1..81b9f448140 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -361,6 +361,7 @@ static const dasm_table_entry dasm_table[] = { "hp_5061_3001", be, -1, []() -> util::disasm_interface * { return new hp_5061_3001_disassembler; } }, { "hp_5061_3011", be, -1, []() -> util::disasm_interface * { return new hp_5061_3011_disassembler; } }, { "hp_09825_67907", be, -1, []() -> util::disasm_interface * { return new hp_09825_67907_disassembler; } }, + { "hpc16083", le, 0, []() -> util::disasm_interface * { return new hpc16083_disassembler; } }, { "hpc16164", le, 0, []() -> util::disasm_interface * { return new hpc16164_disassembler; } }, { "hyperstone", be, 0, []() -> util::disasm_interface * { return new hyperstone_disassembler(&hyperstone_unidasm); } }, { "i4004", le, 0, []() -> util::disasm_interface * { return new i4004_disassembler; } }, -- cgit v1.2.3-70-g09d2 From 6b67495d92534dbba92142373503b4eabc56515a Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 5 Mar 2019 14:01:53 -0500 Subject: hpc: Notes (nw) --- src/devices/cpu/hpc/hpc.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/devices/cpu/hpc/hpc.cpp') diff --git a/src/devices/cpu/hpc/hpc.cpp b/src/devices/cpu/hpc/hpc.cpp index 9d10ffbbbf9..399ca9164af 100644 --- a/src/devices/cpu/hpc/hpc.cpp +++ b/src/devices/cpu/hpc/hpc.cpp @@ -6,6 +6,25 @@ Currently this device is just a stub with no actual execution core. +**************************************************************************** + + HPC feature options by part number + + HPC16xxx Military temperature range (-55°C to +125°C) + HPC26xxx Automotive temperature range (-40°C to +105°C) + HPC36xxx Industrial temperature range (-40°C to +85°C) + HPC46xxx Commercial temperature range (0°C to +75°C) + + HPCxx1xx 8-channel A/D converter + HPCxx0xx No A/D converter + + HPCxxx6x 16k bytes of on-chip ROM + HPCxxx8x 8k bytes of on-chip ROM + HPCxxx0x No on-chip ROM + + HPCxxxx4 512 bytes of on-chip RAM + HPCxxxx3 256 bytes of on-chip RAM + ***************************************************************************/ #include "emu.h" -- cgit v1.2.3-70-g09d2