Previous 15994 Revisions Next

r10589 Friday 25th February, 2011 at 14:44:16 UTC by Curt Coder
[ABC1600] Added NMC9306 skeleton.
[src/mess]mess.mak
[src/mess/drivers]abc1600.c
[src/mess/includes]abc1600.h
[src/mess/machine]nmc9306.c* nmc9306.h*

src/mess/machine/nmc9306.c
r0r10589
1/**********************************************************************
2
3    National Semiconductor NMC9306 256-Bit Serial EEPROM emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "emu.h"
11#include "nmc9306.h"
12#include "machine/devhelpr.h"
13
14
15
16//**************************************************************************
17//  MACROS / CONSTANTS
18//**************************************************************************
19
20#define RAM_SIZE 32
21
22
23// instructions
24enum
25{
26   EWDS = 0,      // erase/write disable
27   WRAL,         // write all registers
28   ERAL,         // erase all registers
29   EWEN,         // erase/write enable
30   WRITE = 7,      // write register A3A2A1A0
31   READ,         // read register A3A2A1A0
32   ERASE         // erase register A3A2A1A0
33};
34
35
36
37//**************************************************************************
38//  DEVICE DEFINITIONS
39//**************************************************************************
40
41const device_type NMC9306 = nmc9306_device_config::static_alloc_device_config;
42
43
44
45//**************************************************************************
46//  DEVICE CONFIGURATION
47//**************************************************************************
48
49//-------------------------------------------------
50//  nmc9306_device_config - constructor
51//-------------------------------------------------
52
53nmc9306_device_config::nmc9306_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
54   : device_config(mconfig, static_alloc_device_config, "NMC9306", tag, owner, clock),
55     device_config_nvram_interface(mconfig, *this)
56{
57}
58
59
60//-------------------------------------------------
61//  static_alloc_device_config - allocate a new
62//  configuration object
63//-------------------------------------------------
64
65device_config *nmc9306_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
66{
67   return global_alloc(nmc9306_device_config(mconfig, tag, owner, clock));
68}
69
70
71//-------------------------------------------------
72//  alloc_device - allocate a new device object
73//-------------------------------------------------
74
75device_t *nmc9306_device_config::alloc_device(running_machine &machine) const
76{
77   return auto_alloc(&machine, nmc9306_device(machine, *this));
78}
79
80
81
82//**************************************************************************
83//  LIVE DEVICE
84//**************************************************************************
85
86//-------------------------------------------------
87//  nmc9306_device - constructor
88//-------------------------------------------------
89
90nmc9306_device::nmc9306_device(running_machine &_machine, const nmc9306_device_config &config)
91    : device_t(_machine, config),
92     device_nvram_interface(_machine, config, *this),
93      m_config(config)
94{
95}
96
97
98//-------------------------------------------------
99//  device_start - device-specific startup
100//-------------------------------------------------
101
102void nmc9306_device::device_start()
103{
104}
105
106
107//-------------------------------------------------
108//  nvram_default - called to initialize NVRAM to
109//  its default state
110//-------------------------------------------------
111
112void nmc9306_device::nvram_default()
113{
114}
115
116
117//-------------------------------------------------
118//  nvram_read - called to read NVRAM from the
119//  .nv file
120//-------------------------------------------------
121
122void nmc9306_device::nvram_read(emu_file &file)
123{
124   file.read(m_register, RAM_SIZE);
125}
126
127
128//-------------------------------------------------
129//  nvram_write - called to write NVRAM to the
130//  .nv file
131//-------------------------------------------------
132
133void nmc9306_device::nvram_write(emu_file &file)
134{
135   file.write(m_register, RAM_SIZE);
136}
137
138
139//-------------------------------------------------
140//  cs_w - chip select input
141//-------------------------------------------------
142
143WRITE_LINE_MEMBER( nmc9306_device::cs_w )
144{
145   m_cs = state;
146}
147
148
149//-------------------------------------------------
150//  ck_w - serial clock input
151//-------------------------------------------------
152
153WRITE_LINE_MEMBER( nmc9306_device::sk_w )
154{
155   m_sk = state;
156}
157
158
159//-------------------------------------------------
160//  di_w - serial data input
161//-------------------------------------------------
162
163WRITE_LINE_MEMBER( nmc9306_device::di_w )
164{
165   m_di = state;
166}
167
168
169//-------------------------------------------------
170//  do_r - serial data output
171//-------------------------------------------------
172
173READ_LINE_MEMBER( nmc9306_device::do_r )
174{
175   return m_do;
176}
src/mess/machine/nmc9306.h
r0r10589
1/**********************************************************************
2
3    National Semiconductor NMC9306 256-Bit Serial EEPROM emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9                            _____   _____
10                    CS   1 |*    \_/     | 8   Vcc
11                    SK   2 |             | 7   NC
12                    DI   3 |             | 6   NC
13                    DO   4 |_____________| 5   GND
14
15**********************************************************************/
16
17#pragma once
18
19#ifndef __NMC9306__
20#define __NMC9306__
21
22#include "emu.h"
23
24
25
26//**************************************************************************
27//  MACROS / CONSTANTS
28//**************************************************************************
29
30
31
32
33//**************************************************************************
34//  INTERFACE CONFIGURATION MACROS
35//**************************************************************************
36
37#define MCFG_NMC9306_ADD(_tag) \
38   MCFG_DEVICE_ADD(_tag, NMC9306, 0)
39
40
41
42//**************************************************************************
43//  TYPE DEFINITIONS
44//**************************************************************************
45
46
47// ======================> nmc9306_device_config
48
49class nmc9306_device_config :   public device_config,
50                        public device_config_nvram_interface
51{
52    friend class nmc9306_device;
53
54    // construction/destruction
55    nmc9306_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
56
57public:
58    // allocators
59    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
60    virtual device_t *alloc_device(running_machine &machine) const;
61
62protected:
63};
64
65
66// ======================> nmc9306_device
67
68class nmc9306_device :  public device_t,
69                  public device_nvram_interface
70{
71    friend class nmc9306_device_config;
72
73    // construction/destruction
74    nmc9306_device(running_machine &_machine, const nmc9306_device_config &_config);
75
76public:
77    DECLARE_WRITE_LINE_MEMBER( cs_w );
78    DECLARE_WRITE_LINE_MEMBER( sk_w );
79    DECLARE_WRITE_LINE_MEMBER( di_w );
80    DECLARE_READ_LINE_MEMBER( do_r );
81
82protected:
83    // device-level overrides
84    virtual void device_start();
85
86   // device_nvram_interface overrides
87   virtual void nvram_default();
88   virtual void nvram_read(emu_file &file);
89   virtual void nvram_write(emu_file &file);
90
91private:
92   UINT16 m_register[16];
93   
94   int m_cs;
95   int m_sk;
96   int m_do;
97   int m_di;
98   int m_a;
99
100   const nmc9306_device_config &m_config;
101};
102
103
104// device type definition
105extern const device_type NMC9306;
106
107
108
109#endif
src/mess/includes/abc1600.h
r10588r10589
4444   required_device<device_t> m_cio;
4545   required_device<device_t> m_fdc;
4646   required_device<device_t> m_rtc;
47   optional_device<device_t> m_nvram; // TODO change to required
47   required_device<nmc9306_device> m_nvram;
4848   required_device<device_t> m_crtc;
4949
5050   virtual void machine_start();
src/mess/mess.mak
r10588r10589
541541   $(MESS_MACHINE)/msm58321.o   \
542542   $(MESS_MACHINE)/msm8251.o   \
543543   $(MESS_MACHINE)/mos6530.o   \
544   $(MESS_MACHINE)/nmc9306.o   \
544545   $(MESS_MACHINE)/upd765.o   \
545546   $(MESS_MACHINE)/ncr5380.o   \
546547   $(MESS_MACHINE)/pc_lpt.o   \
src/mess/drivers/abc1600.c
r10588r10589
3838#include "machine/8530scc.h"
3939#include "machine/abc99.h"
4040#include "machine/e0516.h"
41#include "machine/nmc9306.h"
4142#include "machine/s1410.h"
4243#include "machine/wd17xx.h"
4344#include "machine/z80dart.h"
r10588r10589
384385     
385386   */
386387
388   UINT8 data = 0;
389
390   // data in   
391   data |= (e0516_dio_r(m_rtc) | m_nvram->do_r()) << 1;
392   
387393   return 0;
388394}
389395
r10588r10589
395401     
396402      PC0      CLOCK
397403      PC1      DATA OUT
398      PC2      enable RTC
399      PC3      enable NVRAM
404      PC2      RTC CS
405      PC3      NVRAM CS
400406     
401407   */
408   
409   int clock = BIT(data, 0);
410   int data_out = BIT(data, 1);
411   int rtc_cs = BIT(data, 2);
412   int nvram_cs = BIT(data, 3);
413   
414   e0516_cs_w(m_rtc, rtc_cs);
415   e0516_dio_w(m_rtc, data_out);
416   e0516_clk_w(m_rtc, clock);
417   
418   m_nvram->cs_w(nvram_cs);
419   m_nvram->di_w(data_out);
420   m_nvram->sk_w(clock);
402421}
403422
404423static Z8536_INTERFACE( cio_intf )
r10588r10589
496515   MCFG_Z80DART_ADD(Z8470AB1_TAG, XTAL_64MHz/16, dart_intf)
497516   MCFG_SCC8530_ADD(Z8530B1_TAG, XTAL_64MHz/16)
498517   MCFG_Z8536_ADD(Z8536B1_TAG, XTAL_64MHz/16, cio_intf)
499//   MCFG_NMC9306_ADD(NMC9306_TAG)
518   MCFG_NMC9306_ADD(NMC9306_TAG)
500519   MCFG_E0516_ADD(E050_C16PC_TAG, XTAL_32_768kHz)
501520   MCFG_WD179X_ADD(SAB1797_02P_TAG, fdc_intf)
502521   MCFG_FLOPPY_DRIVE_ADD(FLOPPY_0, abc1600_floppy_config)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team