diff options
Diffstat (limited to 'src/devices/cpu/tms32031')
-rw-r--r-- | src/devices/cpu/tms32031/32031ops.hxx | 116 | ||||
-rw-r--r-- | src/devices/cpu/tms32031/dis32031.cpp | 14 | ||||
-rw-r--r-- | src/devices/cpu/tms32031/dis32031.h | 4 | ||||
-rw-r--r-- | src/devices/cpu/tms32031/tms32031.cpp | 234 | ||||
-rw-r--r-- | src/devices/cpu/tms32031/tms32031.h | 75 |
5 files changed, 308 insertions, 135 deletions
diff --git a/src/devices/cpu/tms32031/32031ops.hxx b/src/devices/cpu/tms32031/32031ops.hxx index c97512b52b3..f419c85c943 100644 --- a/src/devices/cpu/tms32031/32031ops.hxx +++ b/src/devices/cpu/tms32031/32031ops.hxx @@ -2,9 +2,9 @@ // copyright-holders:Aaron Giles /*************************************************************************** - 32031ops.cpp + 32031ops.hxx - TMS32031/2 emulator + TMS320C3x family 32-bit floating point DSP emulator ***************************************************************************/ @@ -71,7 +71,7 @@ void tms3203x_device::illegal(uint32_t op) { - if ((machine().debug_flags & DEBUG_FLAG_ENABLED) != 0) + if (debugger_enabled()) { logerror("Illegal op @ %06X: %08X (tbl=%03X)\n", m_pc - 1, op, op >> 21); machine().debug_break(); @@ -88,7 +88,7 @@ void tms3203x_device::unimplemented(uint32_t op) inline void tms3203x_device::execute_one() { uint32_t op = ROPCODE(m_pc); - m_icount -= 2; // 2 clocks per cycle + burn_cycle(1); m_pc++; #if (TMS_3203X_LOG_OPCODE_USAGE) m_hits[op >> 21]++; @@ -118,6 +118,11 @@ void tms3203x_device::update_special(int dreg) } +void tms3203x_device::burn_cycle(int cycle) +{ + m_icount -= cycle * (m_is_lopower ? 16 : 1); +} + //************************************************************************** // CONDITION CODES @@ -393,7 +398,7 @@ void tms3203x_device::int2float(tmsreg &srcdst) // positive values; count leading zeros and shift else if ((int32_t)man > 0) { - cnt = count_leading_zeros(man); + cnt = count_leading_zeros_32(man); man <<= cnt; exp = 31 - cnt; } @@ -401,7 +406,7 @@ void tms3203x_device::int2float(tmsreg &srcdst) // negative values; count leading ones and shift else { - cnt = count_leading_ones(man); + cnt = count_leading_ones_32(man); man <<= cnt; exp = 31 - cnt; } @@ -585,13 +590,13 @@ void tms3203x_device::addf(tmsreg &dst, tmsreg &src1, tmsreg &src2) { if (man > 0) { - cnt = count_leading_zeros((uint32_t)man); + cnt = count_leading_zeros_32((uint32_t)man); man <<= cnt; exp -= cnt; } else { - cnt = count_leading_ones((uint32_t)man); + cnt = count_leading_ones_32((uint32_t)man); man <<= cnt; exp -= cnt; } @@ -698,13 +703,13 @@ void tms3203x_device::subf(tmsreg &dst, tmsreg &src1, tmsreg &src2) { if (man > 0) { - cnt = count_leading_zeros((uint32_t)man); + cnt = count_leading_zeros_32((uint32_t)man); man <<= cnt; exp -= cnt; } else { - cnt = count_leading_ones((uint32_t)man); + cnt = count_leading_ones_32((uint32_t)man); man <<= cnt; exp -= cnt; } @@ -847,13 +852,13 @@ void tms3203x_device::norm(tmsreg &dst, tmsreg &src) int cnt; if (man > 0) { - cnt = count_leading_zeros((uint32_t)man); + cnt = count_leading_zeros_32((uint32_t)man); man <<= cnt; exp -= cnt; } else { - cnt = count_leading_ones((uint32_t)man); + cnt = count_leading_ones_32((uint32_t)man); man <<= cnt; exp -= cnt; } @@ -1729,7 +1734,7 @@ void tms3203x_device::andn_imm(uint32_t op) #define ASH(dreg, src, count) \ { \ uint32_t _res; \ - int32_t _count = (int16_t)(count << 9) >> 9; /* 7 LSBs */ \ + int32_t _count = util::sext(count, 7); /* 7 LSBs */ \ if (_count < 0) \ { \ if (_count >= -31) \ @@ -2112,7 +2117,7 @@ void tms3203x_device::ldm_imm(uint32_t op) #define LSH(dreg, src, count) \ { \ uint32_t _res; \ - int32_t _count = (int16_t)(count << 9) >> 9; /* 7 LSBs */ \ + int32_t _count = util::sext(count, 7); /* 7 LSBs */ \ if (_count < 0) \ { \ if (_count >= -31) \ @@ -2214,7 +2219,7 @@ void tms3203x_device::mpyf_imm(uint32_t op) #define MPYI(dreg, src1, src2) \ { \ - int64_t _res = (int64_t)((int32_t)(src1 << 8) >> 8) * (int64_t)((int32_t)(src2 << 8) >> 8);\ + int64_t _res = mul_32x32(util::sext(src1, 24), util::sext(src2, 24));\ if (!OVM() || (_res >= -(int64_t)0x80000000 && _res <= (int64_t)0x7fffffff)) \ IREG(dreg) = _res; \ else \ @@ -2560,7 +2565,12 @@ void tms3203x_device::or_imm(uint32_t op) /*-----------------------------------------------------*/ -void tms3203x_device::maxspeed(uint32_t op) { unimplemented(op); } +void tms3203x_device::maxspeed(uint32_t op) +{ + // 0x10800000 MAXSPEED + // 0x10800001 LOPOWER + m_is_lopower = BIT(op, 0); +} /*-----------------------------------------------------*/ @@ -2695,7 +2705,7 @@ void tms3203x_device::rpts_reg(uint32_t op) IREG(TMR_RS) = m_pc; IREG(TMR_RE) = m_pc; IREG(TMR_ST) |= RMFLAG; - m_icount -= 3*2; + burn_cycle(3); m_delayed = true; } @@ -2705,7 +2715,7 @@ void tms3203x_device::rpts_dir(uint32_t op) IREG(TMR_RS) = m_pc; IREG(TMR_RE) = m_pc; IREG(TMR_ST) |= RMFLAG; - m_icount -= 3*2; + burn_cycle(3); m_delayed = true; } @@ -2715,7 +2725,7 @@ void tms3203x_device::rpts_ind(uint32_t op) IREG(TMR_RS) = m_pc; IREG(TMR_RE) = m_pc; IREG(TMR_ST) |= RMFLAG; - m_icount -= 3*2; + burn_cycle(3); m_delayed = true; } @@ -2725,7 +2735,7 @@ void tms3203x_device::rpts_imm(uint32_t op) IREG(TMR_RS) = m_pc; IREG(TMR_RE) = m_pc; IREG(TMR_ST) |= RMFLAG; - m_icount -= 3*2; + burn_cycle(3); m_delayed = true; } @@ -5482,7 +5492,7 @@ inline void tms3203x_device::execute_delayed(uint32_t newpc) { m_delayed = true; - if ((machine().debug_flags & DEBUG_FLAG_ENABLED) == 0) + if (!debugger_enabled()) { execute_one(); execute_one(); @@ -5514,7 +5524,7 @@ inline void tms3203x_device::execute_delayed(uint32_t newpc) void tms3203x_device::br_imm(uint32_t op) { m_pc = op & 0xffffff; - m_icount -= 3*2; + burn_cycle(3); } void tms3203x_device::brd_imm(uint32_t op) @@ -5528,7 +5538,7 @@ void tms3203x_device::call_imm(uint32_t op) { WMEM(++IREG(TMR_SP), m_pc); m_pc = op & 0xffffff; - m_icount -= 3*2; + burn_cycle(3); } /*-----------------------------------------------------*/ @@ -5538,7 +5548,7 @@ void tms3203x_device::rptb_imm(uint32_t op) IREG(TMR_RS) = m_pc; IREG(TMR_RE) = op & 0xffffff; IREG(TMR_ST) |= RMFLAG; - m_icount -= 3*2; + burn_cycle(3); } /*-----------------------------------------------------*/ @@ -5552,7 +5562,7 @@ void tms3203x_device::brc_reg(uint32_t op) if (condition(op >> 16)) { m_pc = IREG(op & 31); - m_icount -= 3*2; + burn_cycle(3); } } @@ -5569,7 +5579,7 @@ void tms3203x_device::brc_imm(uint32_t op) if (condition(op >> 16)) { m_pc += (int16_t)op; - m_icount -= 3*2; + burn_cycle(3); } } @@ -5591,7 +5601,7 @@ void tms3203x_device::dbc_reg(uint32_t op) if (condition(op >> 16) && !(res & 0x800000)) { m_pc = IREG(op & 31); - m_icount -= 3*2; + burn_cycle(3); } } @@ -5614,7 +5624,7 @@ void tms3203x_device::dbc_imm(uint32_t op) if (condition(op >> 16) && !(res & 0x800000)) { m_pc += (int16_t)op; - m_icount -= 3*2; + burn_cycle(3); } } @@ -5637,7 +5647,7 @@ void tms3203x_device::callc_reg(uint32_t op) { WMEM(++IREG(TMR_SP), m_pc); m_pc = IREG(op & 31); - m_icount -= 3*2; + burn_cycle(3); } } @@ -5647,7 +5657,7 @@ void tms3203x_device::callc_imm(uint32_t op) { WMEM(++IREG(TMR_SP), m_pc); m_pc += (int16_t)op; - m_icount -= 3*2; + burn_cycle(3); } } @@ -5661,7 +5671,7 @@ void tms3203x_device::trap(int trapnum) m_pc = RMEM(((IREG(TMR_IF) >> 16) << 8) + trapnum); else m_pc = RMEM(trapnum); - m_icount -= 4*2; + burn_cycle(4); } void tms3203x_device::trapc(uint32_t op) @@ -5678,7 +5688,7 @@ void tms3203x_device::retic_reg(uint32_t op) { m_pc = RMEM(IREG(TMR_SP)--); IREG(TMR_ST) |= GIEFLAG; - m_icount -= 3*2; + burn_cycle(3); check_irqs(); } } @@ -5688,7 +5698,7 @@ void tms3203x_device::retsc_reg(uint32_t op) if (condition(op >> 16)) { m_pc = RMEM(IREG(TMR_SP)--); - m_icount -= 3*2; + burn_cycle(3); } } @@ -5818,14 +5828,13 @@ void tms3203x_device::mpyaddi_0(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src3 << 8) >> 8) * (int64_t)((int32_t)(src4 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src3, 24), util::sext(src4, 24)); uint32_t ares = src1 + src2; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_ADD(src1,src2,ares)) ares = ((int32_t)src1 < 0) ? 0x80000000 : 0x7fffffff; } @@ -5842,14 +5851,13 @@ void tms3203x_device::mpyaddi_1(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src3 << 8) >> 8) * (int64_t)((int32_t)(src1 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src3, 24), util::sext(src1, 24)); uint32_t ares = src4 + src2; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_ADD(src4,src2,ares)) ares = ((int32_t)src4 < 0) ? 0x80000000 : 0x7fffffff; } @@ -5866,14 +5874,13 @@ void tms3203x_device::mpyaddi_2(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src1 << 8) >> 8) * (int64_t)((int32_t)(src2 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src1, 24), util::sext(src2, 24)); uint32_t ares = src3 + src4; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_ADD(src3,src4,ares)) ares = ((int32_t)src3 < 0) ? 0x80000000 : 0x7fffffff; } @@ -5890,14 +5897,13 @@ void tms3203x_device::mpyaddi_3(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src3 << 8) >> 8) * (int64_t)((int32_t)(src1 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src3, 24), util::sext(src1, 24)); uint32_t ares = src2 + src4; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_ADD(src2,src4,ares)) ares = ((int32_t)src2 < 0) ? 0x80000000 : 0x7fffffff; } @@ -5916,14 +5922,13 @@ void tms3203x_device::mpysubi_0(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src3 << 8) >> 8) * (int64_t)((int32_t)(src4 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src3, 24), util::sext(src4, 24)); uint32_t ares = src1 - src2; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_SUB(src1,src2,ares)) ares = ((int32_t)src1 < 0) ? 0x80000000 : 0x7fffffff; } @@ -5940,14 +5945,13 @@ void tms3203x_device::mpysubi_1(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src3 << 8) >> 8) * (int64_t)((int32_t)(src1 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src3, 24), util::sext(src1, 24)); uint32_t ares = src4 - src2; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_SUB(src4,src2,ares)) ares = ((int32_t)src4 < 0) ? 0x80000000 : 0x7fffffff; } @@ -5964,14 +5968,13 @@ void tms3203x_device::mpysubi_2(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src1 << 8) >> 8) * (int64_t)((int32_t)(src2 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src1, 24), util::sext(src2, 24)); uint32_t ares = src3 - src4; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_SUB(src3,src4,ares)) ares = ((int32_t)src3 < 0) ? 0x80000000 : 0x7fffffff; } @@ -5988,14 +5991,13 @@ void tms3203x_device::mpysubi_3(uint32_t op) uint32_t src2 = IREG((op >> 16) & 7); uint32_t src3 = RMEM(INDIRECT_1_DEF(op, op >> 8)); uint32_t src4 = RMEM(INDIRECT_1(op, op)); - int64_t mres = (int64_t)((int32_t)(src3 << 8) >> 8) * (int64_t)((int32_t)(src1 << 8) >> 8); + int64_t mres = mul_32x32(util::sext(src3, 24), util::sext(src1, 24)); uint32_t ares = src2 - src4; CLR_NZVUF(); if (OVM()) { - if (mres < -(int64_t)0x80000000 || mres > (int64_t)0x7fffffff) - mres = (mres < 0) ? 0x80000000 : 0x7fffffff; + mres = std::clamp(mres, -(int64_t)0x80000000, (int64_t)0x7fffffff); if (OVERFLOW_SUB(src2,src4,ares)) ares = ((int32_t)src2 < 0) ? 0x80000000 : 0x7fffffff; } diff --git a/src/devices/cpu/tms32031/dis32031.cpp b/src/devices/cpu/tms32031/dis32031.cpp index 6bb468e164a..b157f437b90 100644 --- a/src/devices/cpu/tms32031/dis32031.cpp +++ b/src/devices/cpu/tms32031/dis32031.cpp @@ -2,8 +2,8 @@ // copyright-holders:Aaron Giles /*************************************************************************** - dis32031.c - Disassembler for the portable TMS32C031 emulator. + dis32031.cpp + Disassembler for the portable TMS320C3x emulator. Written by Aaron Giles ***************************************************************************/ @@ -477,6 +477,8 @@ offs_t tms32031_disassembler::disassemble(std::ostream &stream, offs_t pc, const char temp[10]; sprintf(temp, "B%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); util::stream_format(stream, "%-6s%s", temp, regname[op & 31]); + if (((op >> 16) & 31) != 0) + flags = STEP_COND | ((op >> 21) & 1 ? step_over_extra(1) : 0); break; } @@ -485,6 +487,8 @@ offs_t tms32031_disassembler::disassemble(std::ostream &stream, offs_t pc, const char temp[10]; sprintf(temp, "B%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); util::stream_format(stream, "%-6s$%06X", temp, (pc + (((op >> 21) & 1) ? 3 : 1) + (int16_t)op) & 0xffffff); + if (((op >> 16) & 31) != 0) + flags = STEP_COND | ((op >> 21) & 1 ? step_over_extra(1) : 0); break; } @@ -494,6 +498,7 @@ offs_t tms32031_disassembler::disassemble(std::ostream &stream, offs_t pc, const char temp[10]; sprintf(temp, "DB%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); util::stream_format(stream, "%-6sAR%d,%s", temp, (op >> 22) & 7, regname[op & 31]); + flags = STEP_COND | ((op >> 21) & 1 ? step_over_extra(1) : 0); break; } @@ -502,6 +507,7 @@ offs_t tms32031_disassembler::disassemble(std::ostream &stream, offs_t pc, const char temp[10]; sprintf(temp, "DB%s%s", condition[(op >> 16) & 31], ((op >> 21) & 1) ? "D" : ""); util::stream_format(stream, "%-6sAR%d,$%06X", temp, (op >> 22) & 7, (pc + (((op >> 21) & 1) ? 3 : 1) + (int16_t)op) & 0xffffff); + flags = STEP_COND | ((op >> 21) & 1 ? step_over_extra(1) : 0); break; } @@ -537,12 +543,12 @@ offs_t tms32031_disassembler::disassemble(std::ostream &stream, offs_t pc, const case 0x0f0: util::stream_format(stream, "RETI%s", condition[(op >> 16) & 31]); - flags = STEP_OUT; + flags = STEP_OUT | (((op >> 16) & 31) != 0 ? STEP_COND : 0); break; case 0x0f1: util::stream_format(stream, "RETS%s", condition[(op >> 16) & 31]); - flags = STEP_OUT; + flags = STEP_OUT | (((op >> 16) & 31) != 0 ? STEP_COND : 0); break; diff --git a/src/devices/cpu/tms32031/dis32031.h b/src/devices/cpu/tms32031/dis32031.h index b6e03e4f31a..b82a68e0a75 100644 --- a/src/devices/cpu/tms32031/dis32031.h +++ b/src/devices/cpu/tms32031/dis32031.h @@ -2,8 +2,8 @@ // copyright-holders:Aaron Giles /*************************************************************************** - dis32031.c - Disassembler for the portable TMS32C031 emulator. + dis32031.h + Disassembler for the portable TMS320C3x emulator. Written by Aaron Giles ***************************************************************************/ diff --git a/src/devices/cpu/tms32031/tms32031.cpp b/src/devices/cpu/tms32031/tms32031.cpp index a1c209c541d..afa635c1b61 100644 --- a/src/devices/cpu/tms32031/tms32031.cpp +++ b/src/devices/cpu/tms32031/tms32031.cpp @@ -2,16 +2,77 @@ // copyright-holders:Aaron Giles /*************************************************************************** - tms32031.c - - TMS32031/2 emulator + tms32031.cpp + + TMS320C3x family 32-bit floating point DSP emulator + + TMS320C3x family difference table: + + |-------------------|-------------------|-------------------|-------------------| + | Feature | 'C30 | 'C31/'VC33 | 'C32 | + |-------------------|-------------------|-------------------|-------------------| + | External Bus | Two buses: | One bus: | One bus: | + | | Primary bus: | 32-bit data | 32-bit data | + | | 32-bit data | 24-bit address | 24-bit address | + | | 24-bit address | STRB active for | STRB active for | + | | STRB active for | 000000-7FFFFFh | 000000-7FFFFFh | + | | 000000-7FFFFFh | and | and | + | | and | 80A000-FFFFFFh | 880000-8FFFFFh | + | | 80A000-FFFFFFh | | 8-, 16-, 32-bit | + | | Expansion bus: | | data in | + | | 32-bit data | | 8-, 16-, 32-bit | + | | 13-bit address | | wide memory | + | | MSTRB active for | | STRB1 active for | + | | 800000-801FFFh | | 900000-FFFFFFh | + | | IOSTRB active for | | 8-, 16-, 32-bit | + | | 804000-805FFFh | | data in | + | | | | 8-, 16-, 32-bit | + | | | | wide memory | + | | | | IOSTRB active for | + | | | | 810000-82FFFFh | + |-------------------|-------------------|-------------------|-------------------| + | ROM (Words) | 4K | No | No | + |-------------------|-------------------|-------------------|-------------------| + | Boot Loader | No | Yes | Yes | + |-------------------|-------------------|-------------------|-------------------| + | On-Chip RAM | 2k | 2k('31)/34k('33) | 512 | + | (Words) | Address: | Address: | Address: | + | | 809800-809fff | 809800-809fff | 87fe00-87ffff | + | | | ('C31,'VC33) | | + | | | 800000-807fff | | + | | | ('VC33 only) | | + |-------------------|-------------------|-------------------|-------------------| + | DMA | 1 Channel | 1 Channel | 2 Channels | + | | CPU greater | CPU greater | Configurable | + | | priority then DMA | priority then DMA | priorities | + |-------------------|-------------------|-------------------|-------------------| + | Serial Ports | 2 | 1 | 1 | + |-------------------|-------------------|-------------------|-------------------| + | Timers | 2 | 2 | 2 | + |-------------------|-------------------|-------------------|-------------------| + | Interrupts | Level-Triggered | Level-Triggered | Level-Triggered | + | | | | or combination of | + | | | | edge- and | + | | | | level-triggered | + |-------------------|-------------------|-------------------|-------------------| + | Interrupt vector | Fixed 0-3Fh | Microprocessor: | Relocatable | + | table | | 0-3Fh fixed | | + | | | Boot loader: | | + | | | 809FC1-809FFF | | + | | | fixed | | + |-------------------|-------------------|-------------------|-------------------| + + TODO: + - merge and implement internal peripheral emulations + - implement chip family difference + - interlocked operation + - instruction pipelining ***************************************************************************/ #include "emu.h" #include "tms32031.h" #include "dis32031.h" -#include "debugger.h" //************************************************************************** @@ -88,14 +149,33 @@ const int GIEFLAG = 0x2000; //************************************************************************** // device type definition -DEFINE_DEVICE_TYPE(TMS32030, tms32030_device, "tms32030", "Texas Instruments TMS32030") -DEFINE_DEVICE_TYPE(TMS32031, tms32031_device, "tms32031", "Texas Instruments TMS32031") -DEFINE_DEVICE_TYPE(TMS32032, tms32032_device, "tms32032", "Texas Instruments TMS32032") +DEFINE_DEVICE_TYPE(TMS32030, tms32030_device, "tms32030", "Texas Instruments TMS320C30") +DEFINE_DEVICE_TYPE(TMS32031, tms32031_device, "tms32031", "Texas Instruments TMS320C31") +DEFINE_DEVICE_TYPE(TMS32032, tms32032_device, "tms32032", "Texas Instruments TMS320C32") +DEFINE_DEVICE_TYPE(TMS32033, tms32033_device, "tms32033", "Texas Instruments TMS320VC33") // memory map common to all 'C30 devices // TODO: expand to cover all the standard internal peripherals void tms3203x_device::common_3203x(address_map &map) { + //map(0x808000, 0x808000) DMA (0) Global control + //map(0x808004, 0x808004) DMA (0) Source address + //map(0x808006, 0x808006) DMA (0) Destination address + //map(0x808008, 0x808008) DMA (0) Transfer Counter + //map(0x808020, 0x808020) Timer 0 Global Control + //map(0x808024, 0x808024) Timer 0 Counter + //map(0x808028, 0x808028) Timer 0 Period Register + //map(0x808030, 0x808030) Timer 1 Global Control + //map(0x808034, 0x808034) Timer 1 Counter + //map(0x808038, 0x808038) Timer 1 Period Register + //map(0x808040, 0x808040) Serial Port (0) Global Control + //map(0x808042, 0x808042) FSX/DX/CLKX Serial Port (0) Control + //map(0x808043, 0x808043) FSR/DR/CLKR Serial Port (0) Control + //map(0x808044, 0x808044) Serial Port (0) R/X Timer Control + //map(0x808045, 0x808045) Serial Port (0) R/X Timer Counter + //map(0x808046, 0x808046) Serial Port (0) R/X Timer Period Register + //map(0x808048, 0x808048) Serial Port (0) Data-Transmit + //map(0x80804c, 0x80804c) Serial Port (0) Data-Receive map(0x808064, 0x808064).rw(FUNC(tms3203x_device::primary_bus_control_r), FUNC(tms3203x_device::primary_bus_control_w)); } @@ -104,38 +184,87 @@ void tms32030_device::internal_32030(address_map &map) { common_3203x(map); + //map(0x000000, 0x7fffff) STRB + //map(0x800000, 0x801fff) MSTRB + //map(0x804000, 0x805fff) IOSTRB + //map(0x808050, 0x808050) Serial Port 1 Global Control + //map(0x808052, 0x808052) FSX/DX/CLKX Serial Port 1 Control + //map(0x808053, 0x808053) FSR/DR/CLKR Serial Port 1 Control + //map(0x808054, 0x808054) Serial Port 1 R/X Timer Control + //map(0x808055, 0x808055) Serial Port 1 R/X Timer Counter + //map(0x808056, 0x808056) Serial Port 1 R/X Timer Period Register + //map(0x808058, 0x808058) Serial Port 1 Data-Transmit + //map(0x80805c, 0x80805c) Serial Port 1 Data-Receive + //map(0x808060, 0x808060) Expansion-Bus Control + //map(0x808064, 0x808064) Primary-Bus Control map(0x809800, 0x809fff).ram(); + //map(0x809800, 0x809bff).ram(); // RAM block 0 + //map(0x809c00, 0x809fff).ram(); // RAM block 1 + //map(0x80a000, 0xffffff) STRB } void tms32031_device::internal_32031(address_map &map) { common_3203x(map); + //map(0x000000, 0x7fffff) STRB + //map(0x808064, 0x808064) Primary-Bus Control map(0x809800, 0x809fff).ram(); + //map(0x809800, 0x809bff).ram(); // RAM block 0 + //map(0x809c00, 0x809fff).ram(); // RAM block 1 + //map(0x80a000, 0xffffff) STRB } void tms32032_device::internal_32032(address_map &map) { common_3203x(map); + //map(0x000000, 0x7fffff) STRB0 + //map(0x808010, 0x808010) DMA 1 Global control + //map(0x808014, 0x808014) DMA 1 Source address + //map(0x808016, 0x808016) DMA 1 Destination address + //map(0x808018, 0x808018) DMA 1 Transfer Counter + //map(0x808060, 0x808060) IOSTRB Bus Control + //map(0x808064, 0x808064) STRB0 Bus Control + //map(0x808068, 0x808068) STRB1 Bus Control + //map(0x810000, 0x82ffff) IOSTRB map(0x87fe00, 0x87ffff).ram(); + //map(0x87fe00, 0x87feff).ram(); // RAM block 0 + //map(0x87ff00, 0x87ffff).ram(); // RAM block 1 + //map(0x880000, 0x8fffff) STRB0 + //map(0x900000, 0xffffff) STRB1 +} + +void tms32033_device::internal_32033(address_map &map) +{ + common_3203x(map); + + //map(0x000000, 0x7fffff) STRB + map(0x800000, 0x807fff).ram(); + //map(0x800000, 0x803fff).ram(); // RAM block 2 + //map(0x804000, 0x807fff).ram(); // RAM block 3 + //map(0x808064, 0x808064) Primary-Bus Control + map(0x809800, 0x809fff).ram(); + //map(0x809800, 0x809bff).ram(); // RAM block 0 + //map(0x809c00, 0x809fff).ram(); // RAM block 1 + //map(0x80a000, 0xffffff) STRB } // ROM definitions for the internal boot loader programs // (Using assembled versions until the code ROMs are extracted from both DSPs) ROM_START( tms32030 ) - ROM_REGION(0x4000, "tms32030", 0) - ROM_LOAD( "c30boot.bin", 0x0000, 0x4000, BAD_DUMP CRC(bddc2763) SHA1(96b2170ecee5bec5abaa1741bb2d3b6096ecc262)) + ROM_REGION(0x4000, "internal_rom", 0) + ROM_LOAD( "c30boot.bin", 0x0000, 0x4000, BAD_DUMP CRC(bddc2763) SHA1(96b2170ecee5bec5abaa1741bb2d3b6096ecc262)) // TODO: programmable? ROM_END ROM_START( tms32031 ) - ROM_REGION(0x4000, "tms32031", 0) + ROM_REGION(0x4000, "internal_rom", 0) ROM_LOAD( "c31boot.bin", 0x0000, 0x4000, BAD_DUMP CRC(bddc2763) SHA1(96b2170ecee5bec5abaa1741bb2d3b6096ecc262) ) // Assembled from c31boot.asm (02-07-92) ROM_END ROM_START( tms32032 ) - ROM_REGION(0x4000, "tms32032", 0) + ROM_REGION(0x4000, "internal_rom", 0) ROM_LOAD( "c32boot.bin", 0x0000, 0x4000, BAD_DUMP CRC(ecf84729) SHA1(4d32ead450f921f563514b061ea561a222283616) ) // Assembled from c32boot.asm (03-04-96) ROM_END @@ -277,7 +406,7 @@ void tms3203x_device::tmsreg::from_double(double val) // tms3203x_device - constructor //------------------------------------------------- -tms3203x_device::tms3203x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t chiptype, address_map_constructor internal_map) +tms3203x_device::tms3203x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t chiptype, int clock_per_inst, address_map_constructor internal_map) : cpu_device(mconfig, type, tag, owner, clock), m_program_config("program", ENDIANNESS_LITTLE, 32, 24, -2, internal_map), m_chip_type(chiptype), @@ -289,9 +418,10 @@ tms3203x_device::tms3203x_device(const machine_config &mconfig, device_type type m_irq_pending(false), m_is_idling(false), m_icount(0), - m_program(nullptr), - m_cache(nullptr), + m_clock_per_inst(clock_per_inst), // 1('VC33)/2 clocks per cycle + m_internal_rom(*this, "internal_rom"), m_mcbl_mode(false), + m_is_lopower(false), m_xf0_cb(*this), m_xf1_cb(*this), m_iack_cb(*this), @@ -309,17 +439,22 @@ tms3203x_device::tms3203x_device(const machine_config &mconfig, device_type type } tms32030_device::tms32030_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms3203x_device(mconfig, TMS32030, tag, owner, clock, CHIP_TYPE_TMS32030, address_map_constructor(FUNC(tms32030_device::internal_32030), this)) + : tms3203x_device(mconfig, TMS32030, tag, owner, clock, CHIP_TYPE_TMS32030, 2, address_map_constructor(FUNC(tms32030_device::internal_32030), this)) { } tms32031_device::tms32031_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms3203x_device(mconfig, TMS32031, tag, owner, clock, CHIP_TYPE_TMS32031, address_map_constructor(FUNC(tms32031_device::internal_32031), this)) + : tms3203x_device(mconfig, TMS32031, tag, owner, clock, CHIP_TYPE_TMS32031, 2, address_map_constructor(FUNC(tms32031_device::internal_32031), this)) { } tms32032_device::tms32032_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : tms3203x_device(mconfig, TMS32032, tag, owner, clock, CHIP_TYPE_TMS32032, address_map_constructor(FUNC(tms32032_device::internal_32032), this)) + : tms3203x_device(mconfig, TMS32032, tag, owner, clock, CHIP_TYPE_TMS32032, 2, address_map_constructor(FUNC(tms32032_device::internal_32032), this)) +{ +} + +tms32033_device::tms32033_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : tms3203x_device(mconfig, TMS32033, tag, owner, clock, CHIP_TYPE_TMS32031, 1, address_map_constructor(FUNC(tms32033_device::internal_32033), this)) { } @@ -330,7 +465,7 @@ tms32032_device::tms32032_device(const machine_config &mconfig, const char *tag, tms3203x_device::~tms3203x_device() { #if (TMS_3203X_LOG_OPCODE_USAGE) - for (int i = 0; i < ARRAY_LENGTH(m_hits); i++) + for (int i = 0; i < std::size(m_hits); i++) if (m_hits[i] != 0) printf("%10d - %03X.%X\n", m_hits[i], i / 4, i % 4); #endif @@ -359,7 +494,7 @@ const tiny_rom_entry *tms3203x_device::device_rom_region() const inline uint32_t tms3203x_device::ROPCODE(offs_t pc) { - return m_cache->read_dword(pc); + return m_cache.read_dword(pc); } @@ -369,7 +504,7 @@ inline uint32_t tms3203x_device::ROPCODE(offs_t pc) inline uint32_t tms3203x_device::RMEM(offs_t addr) { - return m_program->read_dword(addr); + return m_program.read_dword(addr); } @@ -379,7 +514,7 @@ inline uint32_t tms3203x_device::RMEM(offs_t addr) inline void tms3203x_device::WMEM(offs_t addr, uint32_t data) { - m_program->write_dword(addr, data); + m_program.write_dword(addr, data); } @@ -390,18 +525,17 @@ inline void tms3203x_device::WMEM(offs_t addr, uint32_t data) void tms3203x_device::device_start() { // find address spaces - m_program = &space(AS_PROGRAM); - m_cache = m_program->cache<2, -2, ENDIANNESS_LITTLE>(); - - // resolve devcb handlers - m_xf0_cb.resolve_safe(); - m_xf1_cb.resolve_safe(); - m_iack_cb.resolve_safe(); - m_holda_cb.resolve_safe(); + space(AS_PROGRAM).cache(m_cache); + space(AS_PROGRAM).specific(m_program); // set up the internal boot loader ROM if (m_mcbl_mode) - m_program->install_rom(0x000000, 0x000fff, memregion(shortname())->base()); + { + if (m_internal_rom->base() != nullptr) + m_program.space().install_rom(0x000000, 0x000fff, m_internal_rom->base()); + else + m_program.space().unmap_read(0x000000, 0x000fff); + } // save state save_item(NAME(m_pc)); @@ -415,6 +549,7 @@ void tms3203x_device::device_start() save_item(NAME(m_is_idling)); save_item(NAME(m_mcbl_mode)); save_item(NAME(m_hold_state)); + save_item(NAME(m_is_lopower)); // register our state for the debugger state_add(TMS3203X_PC, "PC", m_pc); @@ -481,7 +616,7 @@ void tms3203x_device::device_reset() m_primary_bus_control = 0x000010f8; // reset internal stuff - m_delayed = m_irq_pending = m_is_idling = false; + m_delayed = m_irq_pending = m_is_idling = m_is_lopower = false; } @@ -682,6 +817,7 @@ void tms3203x_device::check_irqs() if (!m_delayed) { uint16_t intmask = 1 << (whichtrap - 1); + standard_irq_callback(whichtrap - 1, m_pc); // bit in IF is cleared when interrupt is taken IREG(TMR_IF) &= ~intmask; @@ -702,7 +838,7 @@ void tms3203x_device::check_irqs() // cycles it takes for one instruction to execute //------------------------------------------------- -uint32_t tms3203x_device::execute_min_cycles() const +uint32_t tms3203x_device::execute_min_cycles() const noexcept { return 1; } @@ -713,20 +849,31 @@ uint32_t tms3203x_device::execute_min_cycles() const // cycles it takes for one instruction to execute //------------------------------------------------- -uint32_t tms3203x_device::execute_max_cycles() const +uint32_t tms3203x_device::execute_max_cycles() const noexcept +{ + return 5 * 16; // max opcode cycle * low power operation mode +} + + +//------------------------------------------------- +// execute_clocks_to_cycles - convert the raw +// clock into cycles per second +//------------------------------------------------- + +uint64_t tms3203x_device::execute_clocks_to_cycles(uint64_t clocks) const noexcept { - return 4; + return (clocks + m_clock_per_inst - 1) / m_clock_per_inst; } //------------------------------------------------- -// execute_input_lines - return the number of -// input/interrupt lines +// execute_cycles_to_clocks - convert a cycle +// count back to raw clocks //------------------------------------------------- -uint32_t tms3203x_device::execute_input_lines() const +uint64_t tms3203x_device::execute_cycles_to_clocks(uint64_t cycles) const noexcept { - return 14; + return cycles * m_clock_per_inst; } @@ -743,10 +890,10 @@ void tms3203x_device::execute_set_input(int inputnum, int state) m_mcbl_mode = (state == ASSERT_LINE); if (m_mcbl_mode != old_mode) { - if (m_mcbl_mode) - m_program->install_rom(0x000000, 0x000fff, memregion(shortname())->base()); + if (m_mcbl_mode && (m_internal_rom->base() != nullptr)) + m_program.space().install_rom(0x000000, 0x000fff, m_internal_rom->base()); else - m_program->unmap_read(0x000000, 0x000fff); + m_program.space().unmap_read(0x000000, 0x000fff); } return; } @@ -808,12 +955,13 @@ void tms3203x_device::execute_run() // if we're idling, just eat the cycles if (m_is_idling) { + debugger_wait_hook(); m_icount = 0; return; } // non-debug case - if ((machine().debug_flags & DEBUG_FLAG_ENABLED) == 0) + if (!debugger_enabled()) { while (m_icount > 0) { @@ -876,7 +1024,7 @@ void tms3203x_device::execute_run() } // internal peripherals -WRITE32_MEMBER(tms3203x_device::primary_bus_control_w) +void tms3203x_device::primary_bus_control_w(offs_t offset, uint32_t data, uint32_t mem_mask) { // change in internal hold state if ((m_primary_bus_control ^ data) & HIZ) diff --git a/src/devices/cpu/tms32031/tms32031.h b/src/devices/cpu/tms32031/tms32031.h index b8f8c212a56..282ac81b7d2 100644 --- a/src/devices/cpu/tms32031/tms32031.h +++ b/src/devices/cpu/tms32031/tms32031.h @@ -4,7 +4,7 @@ tms32031.h - TMS32031/2 emulator + TMS320C3x family 32-bit floating point DSP emulator ***************************************************************************/ @@ -31,15 +31,14 @@ const int TMS3203X_IRQ0 = 0; // IRQ0 const int TMS3203X_IRQ1 = 1; // IRQ1 const int TMS3203X_IRQ2 = 2; // IRQ2 const int TMS3203X_IRQ3 = 3; // IRQ3 -const int TMS3203X_XINT0 = 4; // serial 0 transmit interrupt -const int TMS3203X_RINT0 = 5; // serial 0 receive interrupt -const int TMS3203X_XINT1 = 6; // serial 1 transmit interrupt -const int TMS3203X_RINT1 = 7; // serial 1 receive interrupt +const int TMS3203X_XINT0 = 4; // serial (0) transmit interrupt +const int TMS3203X_RINT0 = 5; // serial (0) receive interrupt +const int TMS3203X_XINT1 = 6; // serial 1 transmit interrupt (TMS320C30 only) +const int TMS3203X_RINT1 = 7; // serial 1 receive interrupt (TMS320C30 only) const int TMS3203X_TINT0 = 8; // timer 0 interrupt const int TMS3203X_TINT1 = 9; // timer 1 interrupt -const int TMS3203X_DINT = 10; // DMA interrupt -const int TMS3203X_DINT0 = 10; // DMA 0 interrupt (32032 only) -const int TMS3203X_DINT1 = 11; // DMA 1 interrupt (32032 only) +const int TMS3203X_DINT0 = 10; // DMA (0) interrupt +const int TMS3203X_DINT1 = 11; // DMA 1 interrupt (TMS320C32 only) const int TMS3203X_MCBL = 12; // Microcomputer/boot loader mode const int TMS3203X_HOLD = 13; // Primary bus interface hold signal @@ -138,25 +137,26 @@ public: protected: enum { - CHIP_TYPE_TMS32030, - CHIP_TYPE_TMS32031, - CHIP_TYPE_TMS32032 + CHIP_TYPE_TMS32030, // 'C30 + CHIP_TYPE_TMS32031, // 'C31/'VC33 + CHIP_TYPE_TMS32032 // 'C32 }; // construction/destruction - tms3203x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t chiptype, address_map_constructor internal_map); - void common_3203x(address_map &map); + tms3203x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint32_t chiptype, int clock_per_inst, address_map_constructor internal_map); + void common_3203x(address_map &map) ATTR_COLD; // device-level overrides - virtual void device_start() override; - virtual void device_reset() override; + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; - virtual const tiny_rom_entry *device_rom_region() const override; + virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD; // device_execute_interface overrides - virtual uint32_t execute_min_cycles() const override; - virtual uint32_t execute_max_cycles() const override; - virtual uint32_t execute_input_lines() const override; + virtual uint32_t execute_min_cycles() const noexcept override; + virtual uint32_t execute_max_cycles() const noexcept override; + virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const noexcept override; + virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const noexcept override; virtual void execute_run() override; virtual void execute_set_input(int inputnum, int state) override; @@ -172,8 +172,8 @@ protected: virtual std::unique_ptr<util::disasm_interface> create_disassembler() override; // internal peripheral device handlers - DECLARE_READ32_MEMBER(primary_bus_control_r) { return m_primary_bus_control; } - DECLARE_WRITE32_MEMBER(primary_bus_control_w); + uint32_t primary_bus_control_r() { return m_primary_bus_control; } + void primary_bus_control_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); // memory helpers uint32_t ROPCODE(offs_t pc); @@ -184,6 +184,7 @@ protected: void check_irqs(); void execute_one(); void update_special(int dreg); + void burn_cycle(int cycle); bool condition(int which); // floating point helpers @@ -732,7 +733,7 @@ protected: // configuration const address_space_config m_program_config; - uint32_t m_chip_type; + uint32_t m_chip_type; union int_double { @@ -742,9 +743,9 @@ protected: }; // core registers - uint32_t m_pc; + uint32_t m_pc; tmsreg m_r[36]; - uint32_t m_bkmask; + uint32_t m_bkmask; // internal peripheral registers enum primary_bus_control_mask : uint32_t @@ -766,13 +767,17 @@ protected: bool m_irq_pending; bool m_is_idling; int m_icount; + int m_clock_per_inst; // clock per instruction cycle uint32_t m_iotemp; - address_space * m_program; - memory_access_cache<2, -2, ENDIANNESS_LITTLE> *m_cache; + memory_access<24, 2, -2, ENDIANNESS_LITTLE>::cache m_cache; + memory_access<24, 2, -2, ENDIANNESS_LITTLE>::specific m_program; + + optional_memory_region m_internal_rom; bool m_mcbl_mode; bool m_hold_state; + bool m_is_lopower; devcb_write8 m_xf0_cb; devcb_write8 m_xf1_cb; @@ -798,7 +803,7 @@ class tms32030_device : public tms3203x_device public: // construction/destruction tms32030_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void internal_32030(address_map &map); + void internal_32030(address_map &map) ATTR_COLD; }; @@ -809,7 +814,7 @@ class tms32031_device : public tms3203x_device public: // construction/destruction tms32031_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void internal_32031(address_map &map); + void internal_32031(address_map &map) ATTR_COLD; }; @@ -820,7 +825,18 @@ class tms32032_device : public tms3203x_device public: // construction/destruction tms32032_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void internal_32032(address_map &map); + void internal_32032(address_map &map) ATTR_COLD; +}; + + +// ======================> tms32033_device + +class tms32033_device : public tms3203x_device +{ +public: + // construction/destruction + tms32033_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + void internal_32033(address_map &map) ATTR_COLD; }; @@ -828,5 +844,6 @@ public: DECLARE_DEVICE_TYPE(TMS32030, tms32030_device) DECLARE_DEVICE_TYPE(TMS32031, tms32031_device) DECLARE_DEVICE_TYPE(TMS32032, tms32032_device) +DECLARE_DEVICE_TYPE(TMS32033, tms32033_device) #endif // MAME_CPU_TMS32031_TMS32031_H |