Previous 15994 Revisions Next

r2812 Wednesday 4th June, 2008 at 20:26:23 UTC by Curt Coder
[COP400] Synced with MAME.
[src/emu/cpu/cop400]410ops.c cop400.h cop410.c cop410ds.c cop420.c

src/emu/cpu/cop400/410ops.c
r2811r2812
141141
142142INLINE void WRITE_G(UINT8 data)
143143{
144   if (R.intf->microbus == COP400_MICROBUS_ENABLED)
145   {
146      data = (data & 0x0e) | R.microbus_int;
147   }
148
144149   G = data;
150
145151   OUT_G(G);
146152}
147153
r2811r2812
484490   skip = 1;
485491}
486492
493/*
494
495   Processor:         COP410C/COP411C
496
497    Mnemonic:           HALT
498
499    Hex Code:           33 38
500    Binary:             0 0 1 1 0 0 1 1 0 0 1 1 1 0 0 0
501
502    Description:        Halt processor
503
504*/
505
506INSTRUCTION(halt)
507{
508   R.halt = 1;
509}
510
487511/* Memory Reference Instructions */
488512
489513/*
r2811r2812
502526
503527INSTRUCTION(camq)
504528{
505   WRITE_Q((A << 4) | RAM_R(B));
529   /*
530
531      Excerpt from the COP410L data sheet:
532
533      False states may be generated on L0-L7 during the execution of the CAMQ instruction.
534      The L-ports should not be used as clocks for edge sensitive devices such as flip-flops,
535      counters, shift registers, etc. the following short program that illustrates this situation.
536
537      START:
538         CLRA      ;ENABLE THE Q
539         LEI 4      ;REGISTER TO L LINES
540         LBI TEST
541         STII 3
542         AISC 12
543      LOOP:
544         LBI TEST   ;LOAD Q WITH X'C3
545         CAMQ
546         JP LOOP
547
548      In this program the internal Q register is enabled onto the L lines and a steady bit
549      pattern of logic highs is output on L0,   L1, L6, L7, and logic lows on L2-L5 via the
550      two-byte CAMQ instruction. Timing constraints on the device are such that the Q
551      register may be temporarily loaded with the second byte of the CAMQ opcode (3C) prior
552      to receiving the valid data pattern. If this occurs, the opcode will ripple onto the L
553      lines and cause negative-going glitches on L0, L1, L6, L7, and positive glitches on
554      L2-L5. Glitch durations are under 2 ms, although the exact value may vary due to data
555      patterns, processing parameters, and L line loading. These false states are peculiar
556      only to the CAMQ instruction and the L lines.
557
558   */
559
560   UINT8 data = (A << 4) | RAM_R(B);
561
562   WRITE_Q(data);
563
564#ifdef CAMQ_BUG
565   WRITE_Q(0x3c);
566   WRITE_Q(data);
567#endif
506568}
507569
508570/*
src/emu/cpu/cop400/cop410.c
r2811r2812
1313
1414    TODO:
1515
16    - run interrupt test suite
17    - run production test suite
18   - run microbus test suite
1619    - remove LBIops
17    - run all test suites
1820
1921*/
2022
r2811r2812
3537
3638typedef struct
3739{
40   const cop400_interface *intf;
41
3842   UINT9    PC;
3943   UINT9   PREVPC;
4044   UINT4   A;
r2811r2812
5054   UINT8   G_mask;
5155   UINT8   D_mask;
5256   UINT8   si;
57   int      microbus_int;
58   int      halt;
5359} COP410_Regs;
5460
5561static COP410_Regs R;
r2811r2812
119125   {1, illegal    },{1, skgz       },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
120126   {1, illegal    },{1, illegal    },{1, ing       },{1, illegal    },{1, illegal    },{1, illegal    },{1, inl       },{1, illegal    },
121127   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
122   {1, illegal    },{1, illegal    },{1, omg       },{1, illegal    },{1, camq       },{1, illegal    },{1, obd       },{1, illegal    },
128   {1, halt       },{1, illegal    },{1, omg       },{1, illegal    },{1, camq       },{1, illegal    },{1, obd       },{1, illegal    },
123129
124130   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
125131   {1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },{1, illegal    },
r2811r2812
197203
198204/* Memory Maps */
199205
200static ADDRESS_MAP_START( cop410_internal_rom, ADDRESS_SPACE_DATA, 8 )
206static ADDRESS_MAP_START( cop410_internal_rom, ADDRESS_SPACE_PROGRAM, 8 )
201207   AM_RANGE(0x000, 0x1ff) AM_ROM
202208ADDRESS_MAP_END
203209
r2811r2812
213219   int i;
214220
215221   memset(&R, 0, sizeof(R));
216   R.G_mask = 0x0F;
217   R.D_mask = 0x0F;
218222
223   R.intf = (cop400_interface *) config;
224
225   assert(R.intf != NULL);
226
227   /* set output pin masks */
228
229   R.G_mask = 0x0f;
230   R.D_mask = 0x0f;
231
232   /* set clock divider */
233
234   cpunum_set_info_int(index, CPUINFO_INT_CLOCK_DIVIDER, R.intf->cki);
235
236   /* allocate serial timer */
237
219238   cop410_serial_timer = timer_alloc(cop410_serial_tick, NULL);
220239   timer_adjust_periodic(cop410_serial_timer, attotime_zero, index, ATTOTIME_IN_HZ(clock));
221240
241   /* initialize instruction length array */
242
222243   for (i=0; i<256; i++) InstLen[i]=1;
223244
224245   InstLen[0x60] = InstLen[0x61] = InstLen[0x68] = InstLen[0x69] = InstLen[0x33] = InstLen[0x23] = 2;
225246
247   /* initialize LBI opcode array */
248
226249   for (i=0; i<256; i++) LBIops[i] = 0;
227250   for (i=0x08; i<0x10; i++) LBIops[i] = 1;
228251   for (i=0x18; i<0x20; i++) LBIops[i] = 1;
229252   for (i=0x28; i<0x30; i++) LBIops[i] = 1;
230253   for (i=0x38; i<0x40; i++) LBIops[i] = 1;
231254
255   /* register for state saving */
256
232257   state_save_register_item("cop410", index, PC);
233258   state_save_register_item("cop410", index, R.PREVPC);
234259   state_save_register_item("cop410", index, A);
r2811r2812
246271   state_save_register_item("cop410", index, R.G_mask);
247272   state_save_register_item("cop410", index, R.D_mask);
248273   state_save_register_item("cop410", index, R.si);
274   state_save_register_item("cop410", index, R.microbus_int);
275   state_save_register_item("cop410", index, R.halt);
249276}
250277
251278static void cop411_init(int index, int clock, const void *config, int (*irqcallback)(int))
r2811r2812
269296   OUT_D(0);
270297   EN = 0;
271298   WRITE_G(0);
299
300   R.halt = 0;
272301}
273302
274303/****************************************************************************
r2811r2812
286315
287316      CALL_DEBUGGER(PC);
288317
318      if (R.intf->cko == COP400_CKO_HALT_IO_PORT)
319      {
320         R.halt = IN_CKO();
321      }
322
323      if (R.halt) continue;
324
289325      opcode = ROM(PC);
290326
291327      if (skipLBI == 1)
r2811r2812
470506
471507void cop411_get_info(UINT32 state, cpuinfo *info)
472508{
473   // COP411 is a 20-pin package version of the COP410, lacking some ports
509   // COP411 is a 20-pin package version of the COP410, missing D2/D3/G3/CKO
474510
475511   switch (state)
476512   {
src/emu/cpu/cop400/cop420.c
r2811r2812
1313
1414    TODO:
1515
16   - when is the microbus int cleared?
1617    - run interrupt test suite
1718    - run production test suite
19   - run microbus test suite
1820    - remove LBIops
21   - move cop440 stuff to cop440.c
1922
2023*/
2124
r2811r2812
3639
3740typedef struct
3841{
42   const cop400_interface *intf;
43
3944   UINT10    PC;
4045   UINT10   PREVPC;
4146   UINT4   A;
r2811r2812
5661   UINT4   in[4];
5762   UINT8   si;
5863   int      last_skip;
64   int      microbus_int;
65   int      halt;
5966} COP420_Regs;
6067
6168static COP420_Regs R;
r2811r2812
6875static emu_timer *cop420_serial_timer;
6976static emu_timer *cop420_counter_timer;
7077static emu_timer *cop420_inil_timer;
78static emu_timer *cop420_microbus_timer;
7179
7280#include "420ops.c"
7381
r2811r2812
206214
207215/* Memory Maps */
208216
209static ADDRESS_MAP_START( cop420_internal_rom, ADDRESS_SPACE_DATA, 8 )
217static ADDRESS_MAP_START( cop420_internal_rom, ADDRESS_SPACE_PROGRAM, 8 )
210218   AM_RANGE(0x000, 0x3ff) AM_ROM
211219ADDRESS_MAP_END
212220
r2811r2812
214222   AM_RANGE(0x00, 0x3f) AM_RAM
215223ADDRESS_MAP_END
216224
217static ADDRESS_MAP_START( cop444_internal_rom, ADDRESS_SPACE_DATA, 8 )
218   AM_RANGE(0x000, 0x7ff) AM_ROM
219ADDRESS_MAP_END
220
221static ADDRESS_MAP_START( cop444_internal_ram, ADDRESS_SPACE_DATA, 8 )
222   AM_RANGE(0x00, 0x7f) AM_RAM
223ADDRESS_MAP_END
224
225225/* Binary Counter */
226226
227227static TIMER_CALLBACK(cop420_counter_tick)
r2811r2812
253253   }
254254}
255255
256/* Microbus */
257
258static TIMER_CALLBACK(cop420_microbus_tick)
259{
260   UINT8 in = IN_IN();
261
262   if (!BIT(in, 2))
263   {
264      // chip select
265
266      if (!BIT(in, 1))
267      {
268         // read strobe
269
270         OUT_L(Q);
271
272         R.microbus_int = 1;
273      }
274      else if (!BIT(in, 3))
275      {
276         // write strobe
277
278         Q = IN_L();
279
280         R.microbus_int = 0;
281      }
282   }
283}
284
256285/****************************************************************************
257286 * Initialize emulation
258287 ****************************************************************************/
r2811r2812
261290   int i;
262291
263292   memset(&R, 0, sizeof(R));
264   R.G_mask = 0x0F;
265   R.D_mask = 0x0F;
266293
294   R.intf = (cop400_interface *) config;
295
296   assert(R.intf != NULL);
297
298   /* set output pin masks */
299
300   R.G_mask = 0x0f;
301   R.D_mask = 0x0f;
302
303   /* set clock divider */
304
305   cpunum_set_info_int(index, CPUINFO_INT_CLOCK_DIVIDER, R.intf->cki);
306
307   /* allocate serial timer */
308
267309   cop420_serial_timer = timer_alloc(cop410_serial_tick, NULL);
268310   timer_adjust_periodic(cop420_serial_timer, attotime_zero, index, ATTOTIME_IN_HZ(clock));
269311
312   /* allocate counter timer */
313
270314   cop420_counter_timer = timer_alloc(cop420_counter_tick, NULL);
271315   timer_adjust_periodic(cop420_counter_timer, attotime_zero, index, ATTOTIME_IN_HZ(clock));
272316
317   /* allocate IN latch timer */
318
273319   cop420_inil_timer = timer_alloc(cop420_inil_tick, NULL);
274320   timer_adjust_periodic(cop420_inil_timer, attotime_zero, index, ATTOTIME_IN_HZ(clock));
275321
322   /* allocate Microbus timer */
323
324   if (R.intf->microbus == COP400_MICROBUS_ENABLED)
325   {
326      cop420_microbus_timer = timer_alloc(cop420_microbus_tick, NULL);
327      timer_adjust_periodic(cop420_microbus_timer, attotime_zero, index, ATTOTIME_IN_HZ(clock));
328   }
329
330   /* initialize instruction length array */
331
276332   for (i=0; i<256; i++) InstLen[i]=1;
277333
278334   InstLen[0x60] = InstLen[0x61] = InstLen[0x62] = InstLen[0x63] =
279335   InstLen[0x68] = InstLen[0x69] = InstLen[0x6a] = InstLen[0x6b] =
280336   InstLen[0x33] = InstLen[0x23] = 2;
281337
338   /* initialize LBI opcode array */
339
282340   for (i=0; i<256; i++) LBIops[i] = 0;
283341   for (i=0x08; i<0x10; i++) LBIops[i] = 1;
284342   for (i=0x18; i<0x20; i++) LBIops[i] = 1;
r2811r2812
288346   for (i=0; i<256; i++) LBIops33[i] = 0;
289347   for (i=0x80; i<0xc0; i++) LBIops33[i] = 1;
290348
349   /* register for state saving */
350
291351   state_save_register_item("cop420", index, PC);
292352   state_save_register_item("cop420", index, R.PREVPC);
293353   state_save_register_item("cop420", index, A);
r2811r2812
310370   state_save_register_item("cop420", index, R.si);
311371   state_save_register_item("cop420", index, R.last_skip);
312372   state_save_register_item_array("cop420", index, R.in);
373   state_save_register_item("cop420", index, R.microbus_int);
374   state_save_register_item("cop420", index, R.halt);
313375}
314376
315377static void cop422_init(int index, int clock, const void *config, int (*irqcallback)(int))
r2811r2812
320382   R.D_mask = 0x0e; // only D2, D3 available
321383}
322384
323static void cop445_init(int index, int clock, const void *config, int (*irqcallback)(int))
324{
325   cop420_init(index, clock, config, irqcallback);
326
327   R.G_mask = 0x07;
328   R.D_mask = 0x03;
329}
330
331385/****************************************************************************
332386 * Reset registers to their initial values
333387 ****************************************************************************/
r2811r2812
340394   OUT_D(0);
341395   EN = 0;
342396   WRITE_G(0);
397
398   R.counter = 0;
399   R.timerlatch = 1;
343400}
344401
345402/****************************************************************************
r2811r2812
406463               skip = 0;
407464
408465               // push next PC
409               PUSH(PC + 1);
466               PUSH(PC);
410467
411468               // jump to interrupt service routine
412469               PC = 0x0ff;
r2811r2812
630687   }
631688}
632689
690/* COP44x */
691
692static void cop426_init(int index, int clock, const void *config, int (*irqcallback)(int))
693{
694   cop420_init(index, clock, config, irqcallback);
695
696   R.G_mask = 0x0e; // only G2, G3 available
697   R.D_mask = 0x0e; // only D2, D3 available
698}
699
700static void cop445_init(int index, int clock, const void *config, int (*irqcallback)(int))
701{
702   cop420_init(index, clock, config, irqcallback);
703
704   R.G_mask = 0x07;
705   R.D_mask = 0x03;
706}
707
708static ADDRESS_MAP_START( cop424_internal_rom, ADDRESS_SPACE_PROGRAM, 8 )
709   AM_RANGE(0x000, 0x3ff) AM_ROM
710ADDRESS_MAP_END
711
712static ADDRESS_MAP_START( cop424_internal_ram, ADDRESS_SPACE_DATA, 8 )
713   AM_RANGE(0x00, 0x3f) AM_RAM
714ADDRESS_MAP_END
715
716static ADDRESS_MAP_START( cop444_internal_rom, ADDRESS_SPACE_PROGRAM, 8 )
717   AM_RANGE(0x000, 0x7ff) AM_ROM
718ADDRESS_MAP_END
719
720static ADDRESS_MAP_START( cop444_internal_ram, ADDRESS_SPACE_DATA, 8 )
721   AM_RANGE(0x00, 0x7f) AM_RAM
722ADDRESS_MAP_END
723
633724void cop444_get_info(UINT32 state, cpuinfo *info)
634725{
635   // COP444 is functionally equivalent to COP420, but with twice the RAM/ROM
636
637726   switch (state)
638727   {
639728      /* --- the following bits of info are returned as pointers to data or functions --- */
r2811r2812
667756   }
668757}
669758
759void cop424_get_info(UINT32 state, cpuinfo *info)
760{
761   // COP424 is functionally equivalent to COP444, with only 1K ROM and 64x4 bytes RAM
762
763   switch (state)
764   {
765      /* --- the following bits of info are returned as pointers to data or functions --- */
766      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM:
767          info->internal_map8 = address_map_cop424_internal_rom;                        break;
768      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:
769          info->internal_map8 = address_map_cop424_internal_ram;                        break;
770
771      /* --- the following bits of info are returned as NULL-terminated strings --- */
772      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP424");            break;
773      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "National Semiconductor COPS"); break;
774
775      default: cop444_get_info(state, info); break;
776   }
777}
778
779void cop425_get_info(UINT32 state, cpuinfo *info)
780{
781   // COP425 is a 24-pin package version of the COP424, lacking the IN ports
782
783   switch (state)
784   {
785      /* --- the following bits of info are returned as NULL-terminated strings --- */
786      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP425");            break;
787      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "National Semiconductor COPS"); break;
788
789      default: cop444_get_info(state, info); break;
790   }
791}
792
793void cop426_get_info(UINT32 state, cpuinfo *info)
794{
795   // COP426 is a 20-pin package version of the COP424, with only L0-L7, G2-G3, D2-D3 ports
796
797   switch (state)
798   {
799      /* --- the following bits of info are returned as pointers to data or functions --- */
800      case CPUINFO_PTR_INIT:                     info->init = cop426_init;            break;
801
802      /* --- the following bits of info are returned as NULL-terminated strings --- */
803      case CPUINFO_STR_NAME:                     strcpy(info->s, "COP426");            break;
804      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "National Semiconductor COPS"); break;
805
806      default: cop444_get_info(state, info); break;
807   }
808}
809
670810void cop404_get_info(UINT32 state, cpuinfo *info)
671811{
672   // COP404 is a ROMless version of the COP444
812   // COP404 is a ROMless version of the COP444, which can emulate a COP410 or a COP424
673813
674814   switch (state)
675815   {
src/emu/cpu/cop400/cop400.h
r2811r2812
22
33    cop400.h
44
5    National Semiconductor COP400 Emulator.
5    National Semiconductor COPS Emulator.
66
77    Copyright Nicola Salmoria and the MAME Team.
88    Visit http://mamedev.org for licensing and usage restrictions.
r2811r2812
3535    COP400_SKL
3636};
3737
38typedef enum _cop400_cki_bond cop400_cki_bond;
39enum _cop400_cki_bond {
40   COP400_CKI_DIVISOR_4 = 4,
41   COP400_CKI_DIVISOR_8 = 8,
42   COP400_CKI_DIVISOR_16 = 16
43};
44
45typedef enum _cop400_cko_bond cop400_cko_bond;
46enum _cop400_cko_bond {
47   COP400_CKO_OSCILLATOR_OUTPUT = 0,
48   COP400_CKO_HALT_IO_PORT,
49   COP400_CKO_GENERAL_PURPOSE_INPUT
50};
51
52typedef enum _cop400_microbus cop400_microbus;
53enum _cop400_microbus {
54   COP400_MICROBUS_DISABLED = 0,
55   COP400_MICROBUS_ENABLED
56};
57
58/* interface */
59typedef struct _cop400_interface cop400_interface;
60struct _cop400_interface
61{
62   cop400_cki_bond      cki;         /* CKI bonding option */
63   cop400_cko_bond      cko;         /* CKO bonding option */
64   cop400_microbus      microbus;      /* microbus option */
65};
66#define COP400_INTERFACE(name) const cop400_interface (name) =
67
68/*
69
70   Prefix      Temperature Range
71
72   COP4xx      0C to 70C
73   COP3xx      -40C to +85C
74   COP2xx      -55C to +125C
75
76*/
77
78/* COP 41x */
3879extern void cop401_get_info(UINT32 state, cpuinfo *info);
3980extern void cop410_get_info(UINT32 state, cpuinfo *info);
4081extern void cop411_get_info(UINT32 state, cpuinfo *info);
4182
83/* COP 42x */
4284extern void cop402_get_info(UINT32 state, cpuinfo *info);
4385extern void cop420_get_info(UINT32 state, cpuinfo *info);
4486extern void cop421_get_info(UINT32 state, cpuinfo *info);
4587extern void cop422_get_info(UINT32 state, cpuinfo *info);
4688
89/* COP 44x */
4790extern void cop404_get_info(UINT32 state, cpuinfo *info);
91extern void cop424_get_info(UINT32 state, cpuinfo *info);
92extern void cop425_get_info(UINT32 state, cpuinfo *info);
93extern void cop426_get_info(UINT32 state, cpuinfo *info);
4894extern void cop444_get_info(UINT32 state, cpuinfo *info);
4995extern void cop445_get_info(UINT32 state, cpuinfo *info);
5096
src/emu/cpu/cop400/cop410ds.c
r2811r2812
231231               sprintf(buffer, "INL");
232232               break;
233233
234            case 0x38:
235               sprintf(buffer, "HALT");
236               break;
237
234238            case 0x3A:
235239               sprintf(buffer, "OMG");
236240               break;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team