Previous 199869 Revisions Next

r26160 Thursday 14th November, 2013 at 18:12:09 UTC by Jürgen Buchmüller
Fixing crystal clock and working on timers/timing.
[/branches/alto2/src/emu/cpu/alto2]a2mem.c alto2.c
[/branches/alto2/src/emu/drivers]xtal.h
[/branches/alto2/src/emu/machine]diablo_hd.c diablo_hd.h
[/branches/alto2/src/mess/drivers]alto2.c

branches/alto2/src/emu/drivers/xtal.h
r26159r26160
11/*************************************************************************
22
3    xtal.h
3   xtal.h
44
5    Documentation and consistent naming for known existing crystals.
5   Documentation and consistent naming for known existing crystals.
66
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
7   Copyright Nicola Salmoria and the MAME Team.
8   Visit http://mamedev.org for licensing and usage restrictions.
99
1010***************************************************************************
1111
12    PCB Crystal Reference
13    ----------------------
14       _____     ________
15       |16 |    |o       |
16       |MHZ|    |16.0MHZ |
17       |___|    |________|
18       |   |
12   PCB Crystal Reference
13   ----------------------
14      _____     ________
15      |16 |    |o       |
16      |MHZ|    |16.0MHZ |
17      |___|    |________|
18      |   |
1919
20    There is a finite list of _manufactured_ crystals. This file aims
21    to document all of the known speeds that crystals were available in.
22    Feel free to add to the list if you find another speed crystal on
23    a PCB, but please DON'T GUESS!
20   There is a finite list of _manufactured_ crystals. This file aims
21   to document all of the known speeds that crystals were available in.
22   Feel free to add to the list if you find another speed crystal on
23   a PCB, but please DON'T GUESS!
2424
25    Remember that some very high frequencies (typically above 100MHz) are
26    generated by a frequency multiplying IC from a lower frequency
27    crystal.
25   Remember that some very high frequencies (typically above 100MHz) are
26   generated by a frequency multiplying IC from a lower frequency
27   crystal.
2828
29    This is intended as a reference of existing parts to prevent incorrect
30    clock speed measurements with digital frequency counters being used
31    in drivers. When measuring clocks, remember that most parts have a
32    tolerance so be sure to reference existing parts only and not just
33    accept direct readings as 100% true.
29   This is intended as a reference of existing parts to prevent incorrect
30   clock speed measurements with digital frequency counters being used
31   in drivers. When measuring clocks, remember that most parts have a
32   tolerance so be sure to reference existing parts only and not just
33   accept direct readings as 100% true.
3434
35    MAME doesn't yet support fractions in crystal frequencies. For example,
36    XTAL_3_579545MHz should actually be 3579545.454545...Hz (39375000/11).
37    This is no problem though: see above note about tolerance.
35   MAME doesn't yet support fractions in crystal frequencies. For example,
36   XTAL_3_579545MHz should actually be 3579545.454545...Hz (39375000/11).
37   This is no problem though: see above note about tolerance.
3838
39    (Thanks to Guru for starting this documentation.)
39   (Thanks to Guru for starting this documentation.)
4040
4141**************************************************************************/
4242
4343enum
4444{
4545/*
46    Name                = Frequency     Examples
47    ------------------    ------------  ------------------------------------------------------------ */
46   Name                = Frequency     Examples
47   ------------------    ------------  ------------------------------------------------------------ */
4848   XTAL_32_768kHz      = 32768,        /* 32.768kHz, used to drive RTC chips */
4949   XTAL_1MHz           = 1000000,      /* Used to drive OKI M6295 chips */
5050   XTAL_1_75MHz        = 1750000,      /* RCA CDP1861 */
r26159r26160
173173   XTAL_28_37516MHz    = 28375160,     /* Amiga PAL systems */
174174   XTAL_28_48MHz       = 28480000,     /* Chromatics CGC-7900 */
175175   XTAL_28_63636MHz    = 28636363,     /* Later Leland games and Atari GT, Amiga NTSC, Raiden2 h/w (8x NTSC subcarrier)*/
176   XTAL_29_4912MHz     = 29491200,     /* Xerox Alto-II system clock (tagged 29.4MHz in the schematics) */
176177   XTAL_30MHz          = 30000000,     /* Impera Magic Card */
177178   XTAL_30_4761MHz     = 30476100,     /* Taito JC */
178179   XTAL_30_8MHz        = 30800000,     /* 15IE-00-013 */
branches/alto2/src/emu/cpu/alto2/a2mem.c
r26159r26160
893893#if   ALTO2_HAMMING_CHECK
894894   // Initialize the hamming codes and parity bit
895895   for (UINT32 addr = 0; addr < ALTO2_IO_PAGE_BASE; addr++)
896      hamming_code(1, addr, 0);
896      hamming_code(1, addr, m_mem.ram[addr]);
897897#endif
898898}
branches/alto2/src/emu/cpu/alto2/alto2.c
r26159r26160
5252   m_ucode(0),
5353   m_const(0),
5454   m_iomem(0),
55//   m_ucode_map(*this, "^maincpu"),
56//   m_const_map(*this, "^const"),
57//   m_iomem_map(*this, "^iomem"),
5855   m_ucode_crom(0),
5956   m_const_data(0),
6057   m_icount(0),
branches/alto2/src/emu/machine/diablo_hd.c
r26159r26160
9696   m_wrlast(-1),
9797   m_sector_callback_cookie(0),
9898   m_sector_callback(0),
99   m_sector_timer(0),
99   m_timer(0),
100100   m_image(0),
101101   m_handle(0),
102102   m_disk(0)
r26159r26160
153153#define   DIABLO31_SECTOR_MARK_PULSE_POST DIABLO31_BIT_TIME(16)   //!< pulse width of sector mark after the next sector began
154154
155155#define   DIABLO44_ROTATION_TIME attotime::from_msec(25)         //!< DIABLO 44 rotation time is approx. 25ms
156#define   DIABLO44_SECTOR_TIME   attotime::from_msec(25/12)      //!< DIABLO 44 sector time
157
156#define   DIABLO44_SECTOR_TIME attotime::from_msec(25/12)         //!< DIABLO 44 sector time
158157/**
159158 * @brief DIABLO 44 bit clock is 5000kHz ~= 200ns per bit
160159 * ~= 125184 bits/track (?)
r26159r26160
11991198}
12001199
12011200/**
1202 * @brief timer callback that is called thrice per sector in the rotation
1203 *
1204 * The timer is called three times at the events:
1205 * 0: sector mark goes inactive
1206 * 1: sector mark goes active
1207 * 2: in the middle of the active phase
1208 *
1209 * @param id timer id
1210 * @param arg argument supplied to timer_insert (unused)
1211 */
1212void diablo_hd_device::next_sector(void* ptr, int arg)
1213{
1214   (void)ptr;
1215
1216   switch (arg) {
1217   case 0:
1218      m_sector_timer->adjust(m_sector_mark_0_time, 1);
1219      /* deassert sector mark */
1220      sector_mark_1();
1221      break;
1222   case 1:
1223      m_sector_timer->adjust(m_sector_mark_1_time, 2);
1224      /* assert sector mark */
1225      sector_mark_0();
1226      break;
1227   case 2:
1228      /* next sector starting soon now */
1229      m_sector_timer->adjust(m_sector_time - m_sector_mark_0_time, 0);
1230      /* call the sector_callback, if any */
1231      if (m_sector_callback)
1232         (void)(*m_sector_callback)(m_sector_callback_cookie, m_unit);
1233   }
1234}
1235
1236/**
12371201 * @brief deassert the sector mark
12381202 *
12391203 */
r26159r26160
12751239void diablo_hd_device::device_start()
12761240{
12771241   m_image = static_cast<diablo_image_device *>(subdevice("drive"));
1278   LOG_DRIVE((0,"   m_image=%p\n", m_image));
12791242
12801243   m_diablo31 = true;   // FIXME: get from m_handle meta data?
12811244   m_packs = 1;      // FIXME: get from configuration?
12821245
1246   m_cache = global_alloc_array(UINT8*, DIABLO_PAGES);
1247   m_bits = global_alloc_array(UINT32*, DIABLO_PAGES);
1248
1249   m_timer = timer_alloc(1, 0);
1250}
1251
1252void diablo_hd_device::device_reset()
1253{
1254   m_handle = m_image->get_chd_file();
1255   m_disk = m_image->get_hard_disk_file();
1256   LOG_DRIVE((0,"[DIABLO] m_image=%p m_handle=%p m_disk=%p\n", m_image, m_handle, m_disk));
1257
12831258   if (m_diablo31) {
12841259      snprintf(m_description, sizeof(m_description), "DIABLO31");
12851260      m_rotation_time = DIABLO31_ROTATION_TIME;
r26159r26160
12951270      m_sector_mark_1_time = DIABLO44_SECTOR_MARK_PULSE_PRE;
12961271      m_bit_time = DIABLO44_BIT_TIME(1);
12971272   }
1273   LOG_DRIVE((0,"[DIABLO] rotation time       : %.0fns\n", 1e9 * m_rotation_time.as_double()));
1274   LOG_DRIVE((0,"[DIABLO] sector time         : %.0fns\n", 1e9 * m_sector_time.as_double()));
1275   LOG_DRIVE((0,"[DIABLO] sector mark 0 time  : %.0fns\n", 1e9 * m_sector_mark_0_time.as_double()));
1276   LOG_DRIVE((0,"[DIABLO] sector mark 1 time  : %.0fns\n", 1e9 * m_sector_mark_1_time.as_double()));
1277   LOG_DRIVE((0,"[DIABLO] bit time            : %.0fns\n", 1e9 * m_bit_time.as_double()));
12981278
1299   m_cache = global_alloc_array(UINT8*, DIABLO_PAGES);
1300   m_bits = global_alloc_array(UINT32*, DIABLO_PAGES);
1301
1302   m_sector_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(diablo_hd_device::next_sector),this));
1303   m_sector_timer->adjust(m_sector_time - m_sector_mark_0_time, 0);
1304}
1305
1306void diablo_hd_device::device_reset()
1307{
1308   m_handle = m_image->get_chd_file();
1309   m_disk = m_image->get_hard_disk_file();
1310   LOG_DRIVE((0,"   m_handle=%p m_disk=%p\n", m_image, m_handle, m_disk));
1311
13121279   m_s_r_w_0 = 1;               /* seek/read/write not ready */
13131280   m_ready_0 = 1;               /* drive is not ready */
13141281   m_sector_mark_0 = 1;         /* sector mark clear */
r26159r26160
13321299   m_wrlast = -1;
13331300   m_rdfirst = -1;
13341301   m_rdlast = -1;
1302
1303   timer_set(m_sector_time - m_sector_mark_0_time, 1, 0);
13351304}
13361305
1306/**
1307 * @brief timer callback that is called thrice per sector in the rotation
1308 *
1309 * The timer is called three times at the events:
1310 * 0: sector mark goes inactive
1311 * 1: sector mark goes active
1312 * 2: in the middle of the active phase
1313 *
1314 * @param id timer id
1315 * @param arg argument supplied to timer_insert (unused)
1316 */
1317void diablo_hd_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
1318{
1319   LOG_DRIVE((0,"[DIABLO] id=%d param=%d ptr=%p timer expires in %lldns\n", id, param, ptr));
1320
1321   switch (param) {
1322   case 0:
1323      timer.adjust(m_sector_mark_0_time, 1);
1324      /* deassert sector mark */
1325      sector_mark_1();
1326      break;
1327   case 1:
1328      timer.adjust(m_sector_mark_1_time, 2);
1329      /* assert sector mark */
1330      sector_mark_0();
1331      break;
1332   case 2:
1333      /* next sector starting soon now */
1334      timer.adjust(m_sector_time - m_sector_mark_0_time, 0);
1335      /* call the sector_callback, if any */
1336      if (m_sector_callback)
1337         (void)(*m_sector_callback)(m_sector_callback_cookie, m_unit);
1338   }
1339}
1340
13371341MACHINE_CONFIG_FRAGMENT( diablo_drive )
13381342   MCFG_DIABLO_ADD("drive")
13391343MACHINE_CONFIG_END
branches/alto2/src/emu/machine/diablo_hd.h
r26159r26160
6767   int rd_clock(int index);
6868
6969protected:
70   virtual void    device_start();
71   virtual void    device_reset();
70   virtual void device_start();
71   virtual void device_reset();
72   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
7273   virtual machine_config_constructor device_mconfig_additions() const;
7374
7475private:
r26159r26160
111112   int m_wrlast;                     //!< set to last bit of a sector that was written to
112113   void *m_sector_callback_cookie;         //!< cookie to pass to callback
113114   void (*m_sector_callback)(void*,int);   //!< callback to call at the start of each sector
114   emu_timer* m_sector_timer;            //!< sector timer
115   emu_timer* m_timer;                  //!< sector timer
115116   diablo_image_device* m_image;         //!< diablo_image_device interfacing the CHD
116117   chd_file* m_handle;                  //!< underlying CHD handle
117118   hard_disk_file* m_disk;               //!< underlying hard disk file
r26159r26160
160161   //! squeeze a array of clock and data bits into a sector's data
161162   void squeeze_sector();
162163
163   //! timer callback that is called thrice per sector in the rotation
164   TIMER_CALLBACK_MEMBER( next_sector );
165
166164   //! deassert the sector mark
167165   void sector_mark_1();
168166
r26159r26160
171169};
172170
173171#define MCFG_DIABLO_DRIVES_ADD()   \
174   MCFG_DEVICE_ADD(DIABLO_HD_0, DIABLO_HD, 0)   \
175   MCFG_DEVICE_ADD(DIABLO_HD_1, DIABLO_HD, 0)   \
172   MCFG_DEVICE_ADD(DIABLO_HD_0, DIABLO_HD, ATTOSECONDS_TO_HZ(attotime::from_nsec(300).as_double()))   \
173   MCFG_DEVICE_ADD(DIABLO_HD_1, DIABLO_HD, ATTOSECONDS_TO_HZ(attotime::from_nsec(300).as_double()))   \
176174
177175#endif   // !defined(_DIABLO_HD_DEVICE_)
branches/alto2/src/mess/drivers/alto2.c
r26159r26160
241241
242242static MACHINE_CONFIG_START( alto2, alto2_state )
243243   /* basic machine hardware */
244   MCFG_CPU_ADD("maincpu", ALTO2, XTAL_20_16MHz)
244   // SYSCLK is Display Control part A51 (tagged 29.4MHz) divided by 8
245   MCFG_CPU_ADD("maincpu", ALTO2, XTAL_29_4912MHz/8)
245246   MCFG_CPU_PROGRAM_MAP(alto2_ucode_map)
246247   MCFG_CPU_DATA_MAP(alto2_const_map)
247248   MCFG_CPU_IO_MAP(alto2_iomem_map)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team