Previous 199869 Revisions Next

r36320 Sunday 8th March, 2015 at 17:05:02 UTC by hap
better cmos i/o handling
[src/emu/cpu/hmcs40]hmcs40.c hmcs40.h

trunk/src/emu/cpu/hmcs40/hmcs40.c
r244831r244832
2121   FAMILY_HMCS47,
2222};
2323
24#define IS_CMOS true
25#define IS_PMOS false
24#define IS_PMOS 0
25#define IS_CMOS ~0
2626
2727#include "hmcs40.h"
2828#include "debugger.h"
r244831r244832
8989
9090
9191// device definitions
92hmcs43_cpu_device::hmcs43_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname)
93   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS43, is_cmos, 3, 10, 11, ADDRESS_MAP_NAME(program_1k), 7, ADDRESS_MAP_NAME(data_80x4), shortname, __FILE__)
92hmcs43_cpu_device::hmcs43_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname)
93   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS43, polarity, 3, 10, 11, ADDRESS_MAP_NAME(program_1k), 7, ADDRESS_MAP_NAME(data_80x4), shortname, __FILE__)
9494{ }
9595
9696hd38750_device::hd38750_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
r244831r244832
107107{ }
108108
109109
110hmcs44_cpu_device::hmcs44_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname)
111   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS44, is_cmos, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
110hmcs44_cpu_device::hmcs44_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname)
111   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS44, polarity, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
112112{ }
113113
114114hd38800_device::hd38800_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
r244831r244832
125125{ }
126126
127127
128hmcs45_cpu_device::hmcs45_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname)
129   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS45, is_cmos, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
128hmcs45_cpu_device::hmcs45_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname)
129   : hmcs40_cpu_device(mconfig, type, name, tag, owner, clock, FAMILY_HMCS45, polarity, 4, 11, 12, ADDRESS_MAP_NAME(program_2k), 8, ADDRESS_MAP_NAME(data_160x4), shortname, __FILE__)
130130{ }
131131
132132hd38820_device::hd38820_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
r244831r244832
185185   m_datamask = (1 << m_datawidth) - 1;
186186   m_pcmask = (1 << m_pcwidth) - 1;
187187   
188   UINT8 defval = (m_is_cmos) ? 0xf : 0;
189   m_read_r0.resolve_safe(defval);
190   m_read_r1.resolve_safe(defval);
191   m_read_r2.resolve_safe(defval);
192   m_read_r3.resolve_safe(defval);
193   m_read_r4.resolve_safe(defval);
194   m_read_r5.resolve_safe(defval);
195   m_read_r6.resolve_safe(defval);
196   m_read_r7.resolve_safe(defval);
188   m_read_r0.resolve_safe(0);
189   m_read_r1.resolve_safe(0);
190   m_read_r2.resolve_safe(0);
191   m_read_r3.resolve_safe(0);
192   m_read_r4.resolve_safe(0);
193   m_read_r5.resolve_safe(0);
194   m_read_r6.resolve_safe(0);
195   m_read_r7.resolve_safe(0);
197196   
198197   m_write_r0.resolve_safe();
199198   m_write_r1.resolve_safe();
r244831r244832
204203   m_write_r6.resolve_safe();
205204   m_write_r7.resolve_safe();
206205
207   m_read_d.resolve_safe((m_is_cmos) ? 0xffff : 0);
206   m_read_d.resolve_safe(0);
208207   m_write_d.resolve_safe();
209208
210209   // zerofill
r244831r244832
270269   m_prev_op = m_op = 0;
271270   
272271   // clear i/o
273   m_d = (m_is_cmos) ? 0xffff : 0;
272   m_d = m_polarity;
274273   for (int i = 0; i < 16; i++)
275      hmcs40_cpu_device::write_d(i, (m_is_cmos) ? 1 : 0);
274      hmcs40_cpu_device::write_d(i, 0);
276275   
277276   for (int i = 0; i < 8; i++)
278      hmcs40_cpu_device::write_r(i, (m_is_cmos) ? 0xf : 0);
277      hmcs40_cpu_device::write_r(i, 0);
279278}
280279
281280
r244831r244832
301300      case 7: inp = m_read_r7(index, 0xff); break;
302301   }
303302   
304   if (m_is_cmos)
305      return (inp & m_r[index]) & 0xf;
306   else
307      return (inp | m_r[index]) & 0xf;
303   return ((inp ^ m_polarity) | m_r[index]) & 0xf;
308304}
309305
310306void hmcs40_cpu_device::write_r(int index, UINT8 data)
311307{
312308   index &= 7;
313   data &= 0xf;
309   data = (data ^ m_polarity) & 0xf;
314310   m_r[index] = data;
315311   
316312   switch (index)
317313   {
318      case 0: m_write_r0(index, m_r[index], 0xff); break;
319      case 1: m_write_r1(index, m_r[index], 0xff); break;
320      case 2: m_write_r2(index, m_r[index], 0xff); break;
321      case 3: m_write_r3(index, m_r[index], 0xff); break;
322      case 4: m_write_r4(index, m_r[index], 0xff); break;
323      case 5: m_write_r5(index, m_r[index], 0xff); break;
324      case 6: m_write_r6(index, m_r[index], 0xff); break;
325      case 7: m_write_r7(index, m_r[index], 0xff); break;
314      case 0: m_write_r0(index, data, 0xff); break;
315      case 1: m_write_r1(index, data, 0xff); break;
316      case 2: m_write_r2(index, data, 0xff); break;
317      case 3: m_write_r3(index, data, 0xff); break;
318      case 4: m_write_r4(index, data, 0xff); break;
319      case 5: m_write_r5(index, data, 0xff); break;
320      case 6: m_write_r6(index, data, 0xff); break;
321      case 7: m_write_r7(index, data, 0xff); break;
326322   }
327323}
328324
r244831r244832
330326{
331327   index &= 15;
332328   
333   if (m_is_cmos)
334      return (m_read_d(index, 0xffff) & m_d) >> index & 1;
335   else
336      return (m_read_d(index, 0xffff) | m_d) >> index & 1;
329   return ((m_read_d(index, 0xffff) ^ m_polarity) | m_d) >> index & 1;
337330}
338331
339332void hmcs40_cpu_device::write_d(int index, int state)
340333{
341334   index &= 15;
335   state = (((state) ? 1 : 0) ^ m_polarity) & 1;
342336   
343   m_d = (m_d & ~(1 << index)) | (((state) ? 1 : 0) << index);
337   m_d = (m_d & ~(1 << index)) | state << index;
344338   m_write_d(index, m_d, 0xffff);
345339}
346340
r244831r244832
373367   index &= 15;
374368   
375369   if (index >= 4)
376   {
377370      logerror("%s read from output pin D%d at $%04X\n", tag(), index, m_prev_pc << 1);
378      return m_d >> index & 1;
379   }
380   else
381      return hmcs40_cpu_device::read_d(index);
371
372   return hmcs40_cpu_device::read_d(index);
382373}
383374
384375// HMCS44:
r244831r244832
479470         case 0x004: case 0x005: case 0x006: case 0x007:
480471            op_sem(); break;
481472         case 0x008: case 0x009: case 0x00a: case 0x00b:
482            op_lam(); break;
473/* ok */      op_lam(); break;
483474         case 0x010: case 0x011: case 0x012: case 0x013: case 0x014: case 0x015: case 0x016: case 0x017:
484475         case 0x018: case 0x019: case 0x01a: case 0x01b: case 0x01c: case 0x01d: case 0x01e: case 0x01f:
485            op_lmiiy(); break;
476/* ok */      op_lmiiy(); break;
486477         case 0x020: case 0x021: case 0x022: case 0x023:
487478            op_lbm(); break;
488479         case 0x030:
r244831r244832
491482            op_lta(); break;
492483         
493484         case 0x040:
494            op_lxa(); break;
485/* ok */      op_lxa(); break;
495486         case 0x04b:
496487            op_rec(); break;
497488         case 0x04f:
r244831r244832
506497            op_ib(); break;
507498         case 0x070: case 0x071: case 0x072: case 0x073: case 0x074: case 0x075: case 0x076: case 0x077:
508499         case 0x078: case 0x079: case 0x07a: case 0x07b: case 0x07c: case 0x07d: case 0x07e: case 0x07f:
509            op_lai(); break;
500/* ok */      op_lai(); break;
510501         
511502         case 0x080: case 0x081: case 0x082: case 0x083: case 0x084: case 0x085: case 0x086: case 0x087:
512503         case 0x088: case 0x089: case 0x08a: case 0x08b: case 0x08c: case 0x08d: case 0x08e: case 0x08f:
513            op_ai(); break;
504/* ok */      op_ai(); break;
514505         case 0x090:
515            op_sed(); break;
506/* ok */      op_sed(); break;
516507         case 0x094:
517            op_td(); break;
508/* ok */      op_td(); break;
518509         case 0x0a0:
519510            op_seif1(); break;
520511         case 0x0a1:
r244831r244832
549540
550541         case 0x140: case 0x141: case 0x142: case 0x143: case 0x144: case 0x145: case 0x146: case 0x147:
551542         case 0x148: case 0x149: case 0x14a: case 0x14b: case 0x14c: case 0x14d: case 0x14e: case 0x14f:
552            op_lxi(); break;
543/* ok */      op_lxi(); break;
553544         case 0x150: case 0x151: case 0x152: case 0x153: case 0x154: case 0x155: case 0x156: case 0x157:
554545         case 0x158: case 0x159: case 0x15a: case 0x15b: case 0x15c: case 0x15d: case 0x15e: case 0x15f:
555            op_lyi(); break;
546/* ok */      op_lyi(); break;
556547         case 0x160: case 0x161: case 0x162: case 0x163: case 0x164: case 0x165: case 0x166: case 0x167:
557548         case 0x168: case 0x169: case 0x16a: case 0x16b: case 0x16c: case 0x16d: case 0x16e: case 0x16f:
558            op_lbi(); break;
549/* ok */      op_lbi(); break;
559550         case 0x170: case 0x171: case 0x172: case 0x173: case 0x174: case 0x175: case 0x176: case 0x177:
560551         case 0x178: case 0x179: case 0x17a: case 0x17b: case 0x17c: case 0x17d: case 0x17e: case 0x17f:
561552            op_lti(); break;
r244831r244832
579570         case 0x1e8: case 0x1e9: case 0x1ea: case 0x1eb: case 0x1ec: case 0x1ed: case 0x1ee: case 0x1ef:
580571         case 0x1f0: case 0x1f1: case 0x1f2: case 0x1f3: case 0x1f4: case 0x1f5: case 0x1f6: case 0x1f7:
581572         case 0x1f8: case 0x1f9: case 0x1fa: case 0x1fb: case 0x1fc: case 0x1fd: case 0x1fe: case 0x1ff:
582            op_br(); break;
573/* ok */      op_br(); break;
583574
584575
585576         /* 0x200 */
r244831r244832
594585         case 0x218: case 0x219: case 0x21a: case 0x21b: case 0x21c: case 0x21d: case 0x21e: case 0x21f:
595586            op_mnei(); break;
596587         case 0x220: case 0x221: case 0x222: case 0x223:
597            op_xmb(); break;
588/* ok */      op_xmb(); break;
598589         case 0x224:
599590            op_rotr(); break;
600591         case 0x225:
r244831r244832
624615         case 0x288: case 0x289: case 0x28a: case 0x28b: case 0x28c: case 0x28d: case 0x28e: case 0x28f:
625616            op_ynei(); break;
626617         case 0x290:
627            op_red(); break;
618/* ok */      op_red(); break;
628619         case 0x2a0:
629620            op_reif1(); break;
630621         case 0x2a1:
r244831r244832
637628            op_retf(); break;
638629
639630         case 0x2c0: case 0x2c1: case 0x2c2: case 0x2c3: case 0x2c4: case 0x2c5: case 0x2c6: case 0x2c7:
640            op_lra(); break;
631/* ok */      op_lra(); break;
641632         case 0x2d0: case 0x2d1: case 0x2d2: case 0x2d3: case 0x2d4: case 0x2d5: case 0x2d6: case 0x2d7:
642633         case 0x2d8: case 0x2d9: case 0x2da: case 0x2db: case 0x2dc: case 0x2dd: case 0x2de: case 0x2df:
643634            op_redd(); break;
r244831r244832
653644         case 0x348: case 0x349: case 0x34a: case 0x34b: case 0x34c: case 0x34d: case 0x34e: case 0x34f:
654645         case 0x350: case 0x351: case 0x352: case 0x353: case 0x354: case 0x355: case 0x356: case 0x357:
655646         case 0x358: case 0x359: case 0x35a: case 0x35b: case 0x35c: case 0x35d: case 0x35e: case 0x35f:
656            op_lpu(); break;
647/* ok */      op_lpu(); break;
657648         case 0x360: case 0x361: case 0x362: case 0x363: case 0x364: case 0x365: case 0x366: case 0x367:
658649            op_tbr(); break;
659650         case 0x368: case 0x369: case 0x36a: case 0x36b: case 0x36c: case 0x36d: case 0x36e: case 0x36f:
660            op_p(); break;
651/* ok */      op_p(); break;
661652
662653         case 0x3a4:
663654            op_rtni(); break;
664655         case 0x3a7:
665            op_rtn(); break;
656/* ok */      op_rtn(); break;
666657
667658         case 0x3c0: case 0x3c1: case 0x3c2: case 0x3c3: case 0x3c4: case 0x3c5: case 0x3c6: case 0x3c7:
668659         case 0x3c8: case 0x3c9: case 0x3ca: case 0x3cb: case 0x3cc: case 0x3cd: case 0x3ce: case 0x3cf:
r244831r244832
672663         case 0x3e8: case 0x3e9: case 0x3ea: case 0x3eb: case 0x3ec: case 0x3ed: case 0x3ee: case 0x3ef:
673664         case 0x3f0: case 0x3f1: case 0x3f2: case 0x3f3: case 0x3f4: case 0x3f5: case 0x3f6: case 0x3f7:
674665         case 0x3f8: case 0x3f9: case 0x3fa: case 0x3fb: case 0x3fc: case 0x3fd: case 0x3fe: case 0x3ff:
675            op_cal(); break;
666/* ok */      op_cal(); break;
676667         
677668         
678669         default:
trunk/src/emu/cpu/hmcs40/hmcs40.h
r244831r244832
3232{
3333public:
3434   // construction/destruction
35   hmcs40_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int family, bool is_cmos, int stack_levels, int pcwidth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source)
35   hmcs40_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, int family, UINT16 polarity, int stack_levels, int pcwidth, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data, const char *shortname, const char *source)
3636      : cpu_device(mconfig, type, name, tag, owner, clock, shortname, source)
3737      , m_program_config("program", ENDIANNESS_LITTLE, 16, prgwidth, -1, program)
3838      , m_data_config("data", ENDIANNESS_LITTLE, 8, datawidth, 0, data)
r244831r244832
4040      , m_prgwidth(prgwidth)
4141      , m_datawidth(datawidth)
4242      , m_family(family)
43      , m_is_cmos(is_cmos)
43      , m_polarity(polarity)
4444      , m_stack_levels(stack_levels)
4545      , m_read_r0(*this), m_read_r1(*this), m_read_r2(*this), m_read_r3(*this), m_read_r4(*this), m_read_r5(*this), m_read_r6(*this), m_read_r7(*this)
4646      , m_write_r0(*this), m_write_r1(*this), m_write_r2(*this), m_write_r3(*this), m_write_r4(*this), m_write_r5(*this), m_write_r6(*this), m_write_r7(*this)
r244831r244832
102102   int m_prgmask;
103103   int m_datamask;
104104   int m_family;       // MCU family (42-47)
105   bool m_is_cmos;
105   UINT16 m_polarity;  // i/o polarity (pmos vs cmos)
106106   int m_stack_levels; // number of callstack levels
107107   UINT16 m_stack[4];  // max 4
108108   UINT16 m_op;        // current opcode
r244831r244832
244244class hmcs43_cpu_device : public hmcs40_cpu_device
245245{
246246public:
247   hmcs43_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname);
247   hmcs43_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname);
248248
249249protected:
250250   // overrides
r244831r244832
281281class hmcs44_cpu_device : public hmcs40_cpu_device
282282{
283283public:
284   hmcs44_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname);
284   hmcs44_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname);
285285
286286protected:
287287   // overrides
r244831r244832
317317class hmcs45_cpu_device : public hmcs40_cpu_device
318318{
319319public:
320   hmcs45_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_cmos, const char *shortname);
320   hmcs45_cpu_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, UINT16 polarity, const char *shortname);
321321
322322protected:
323323   // overrides


Previous 199869 Revisions Next


© 1997-2024 The MAME Team