diff options
author | 2013-07-29 07:34:22 +0000 | |
---|---|---|
committer | 2013-07-29 07:34:22 +0000 | |
commit | ef3fdf419561d4c237630d1aeb4a31be91708ceb (patch) | |
tree | a042b7cf6bd4fd6afda13bd9a2d9e4652c5b0352 /src/emu/machine/eepromser.h | |
parent | b25cb902d5f6fdadf9485b1a3ab60f4762246300 (diff) |
Rewrite serial EEPROM devices, breaking them out into separate chips of
the proper size and protocol. Update all drivers, removing custom
implementations, and replacing them with standard ones. Moved core read,
write, erase functionality into the EEPROM base class a simulated delays
in write/erase cycles. Still some more testing/verification work left
to do.
Diffstat (limited to 'src/emu/machine/eepromser.h')
-rw-r--r-- | src/emu/machine/eepromser.h | 257 |
1 files changed, 190 insertions, 67 deletions
diff --git a/src/emu/machine/eepromser.h b/src/emu/machine/eepromser.h index 42177ace744..99caeab6b54 100644 --- a/src/emu/machine/eepromser.h +++ b/src/emu/machine/eepromser.h @@ -49,24 +49,49 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_SERIAL_EEPROM_ADD(_tag, _cells, _cellbits, _interface) \ - MCFG_DEVICE_ADD(_tag, SERIAL_EEPROM, 0) \ - MCFG_EEPROM_SIZE(_cells, _cellbits) \ - serial_eeprom_device::static_set_interface(*device, _interface); - -#define MCFG_SERIAL_EEPROM_DATA(_data, _size) \ - serial_eeprom_device::static_set_default_data(*device, _data, _size); -#define MCFG_SERIAL_EEPROM_DEFAULT_VALUE(_value) \ - serial_eeprom_device::static_set_default_value(*device, _value); - -#define MCFG_EEPROM_93C46_ADD(_tag) \ - MCFG_SERIAL_EEPROM_ADD(_tag, 64, 16, eeprom_interface_93C46_93C66B) - -#define MCFG_EEPROM_93C46_8BIT_ADD(_tag) \ - MCFG_SERIAL_EEPROM_ADD(_tag, 128, 8, eeprom_interface_93C46_93C66B) - -#define MCFG_EEPROM_93C66B_ADD(_tag) \ - MCFG_SERIAL_EEPROM_ADD(_tag, 256, 16, eeprom_interface_93C46_93C66B) +// standard 93CX6 class of 16-bit EEPROMs +#define MCFG_EEPROM_SERIAL_93C06_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C06_16BIT, 0) +#define MCFG_EEPROM_SERIAL_93C46_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C46_16BIT, 0) +#define MCFG_EEPROM_SERIAL_93C56_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C56_16BIT, 0) +#define MCFG_EEPROM_SERIAL_93C57_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C57_16BIT, 0) +#define MCFG_EEPROM_SERIAL_93C66_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C66_16BIT, 0) +#define MCFG_EEPROM_SERIAL_93C76_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C76_16BIT, 0) +#define MCFG_EEPROM_SERIAL_93C86_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C86_16BIT, 0) + +// some manufacturers use pin 6 as an "ORG" pin which, when pulled low, configures memory for 8-bit accesses +#define MCFG_EEPROM_SERIAL_93C46_8BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C46_8BIT, 0) +#define MCFG_EEPROM_SERIAL_93C56_8BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C56_8BIT, 0) +#define MCFG_EEPROM_SERIAL_93C57_8BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C57_8BIT, 0) +#define MCFG_EEPROM_SERIAL_93C66_8BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C66_8BIT, 0) +#define MCFG_EEPROM_SERIAL_93C76_8BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C76_8BIT, 0) +#define MCFG_EEPROM_SERIAL_93C86_8BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_93C86_8BIT, 0) + +// ER5911 has a separate ready pin, a reduced command set, and supports 8/16 bit out of the box +#define MCFG_EEPROM_SERIAL_ER5911_8BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_ER5911_8BIT, 0) +#define MCFG_EEPROM_SERIAL_ER5911_16BIT_ADD(_tag) \ + MCFG_DEVICE_ADD(_tag, EEPROM_SERIAL_ER5911_16BIT, 0) + +// optional enable for streaming reads +#define MCFG_EEPROM_SERIAL_ENABLE_STREAMING() \ + eeprom_serial_base_device::static_enable_streaming(*device); \ + +// pass-throughs to the base class for setting default data +#define MCFG_EEPROM_SERIAL_DATA MCFG_EEPROM_DATA +#define MCFG_EEPROM_SERIAL_DEFAULT_VALUE MCFG_EEPROM_DEFAULT_VALUE @@ -75,78 +100,176 @@ //************************************************************************** -// ======================> serial_eeprom_interface +// ======================> eeprom_serial_base_device -struct serial_eeprom_interface +class eeprom_serial_base_device : public eeprom_base_device { - const char *m_cmd_read; // read command string, e.g. "0110" - const char *m_cmd_write; // write command string, e.g. "0111" - const char *m_cmd_erase; // erase command string, or 0 if n/a - const char *m_cmd_lock; // lock command string, or 0 if n/a - const char *m_cmd_unlock; // unlock command string, or 0 if n/a - bool m_enable_multi_read; // set to 1 to enable multiple values to be read from one read command - int m_reset_delay; // number of times eeprom_read_bit() should return 0 after a reset, - // before starting to return 1. +protected: + // construction/destruction + eeprom_serial_base_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file); + +public: + // inline configuration helpers + static void static_set_address_bits(device_t &device, int addrbits); + static void static_enable_streaming(device_t &device); + +protected: + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + + // read interfaces differ between implementations + + // commands + enum eeprom_command + { + COMMAND_INVALID, + COMMAND_READ, + COMMAND_WRITE, + COMMAND_ERASE, + COMMAND_LOCK, + COMMAND_UNLOCK, + COMMAND_WRITEALL, + COMMAND_ERASEALL + }; + + // states + enum eeprom_state + { + STATE_IN_RESET, + STATE_WAIT_FOR_START_BIT, + STATE_WAIT_FOR_COMMAND, + STATE_READING_DATA, + STATE_WAIT_FOR_DATA, + STATE_WAIT_FOR_COMPLETION + }; + + // events + enum eeprom_event + { + EVENT_CS_RISING_EDGE = 1 << 0, + EVENT_CS_FALLING_EDGE = 1 << 1, + EVENT_CLK_RISING_EDGE = 1 << 2, + EVENT_CLK_FALLING_EDGE = 1 << 3 + }; + + // internal helpers + void set_state(eeprom_state newstate); + void handle_event(eeprom_event event); + void execute_command(); + void execute_write_command(); + + // subclass helpers + void base_cs_write(int state); + void base_clk_write(int state); + void base_di_write(int state); + int base_do_read(); + int base_ready_read(); + + // subclass overrides + virtual void parse_command_and_address() = 0; + + // configuration state + UINT8 m_command_address_bits; // number of address bits in a command + bool m_streaming_enabled; // true if streaming is enabled + + // runtime state + eeprom_state m_state; // current internal state + UINT8 m_cs_state; // state of the CS line + attotime m_last_cs_rising_edge_time; // time of the last CS rising edge + UINT8 m_oe_state; // state of the OE line + UINT8 m_clk_state; // state of the CLK line + UINT8 m_di_state; // state of the DI line + bool m_locked; // are we locked against writes? + UINT32 m_bits_accum; // number of bits accumulated + UINT32 m_command_address_accum; // accumulator of command+address bits + eeprom_command m_command; // current command + UINT32 m_address; // current address extracted from command + UINT32 m_shift_register; // holds data coming in/going out }; -// ======================> serial_eeprom_device +// ======================> eeprom_serial_93cxx_device -class serial_eeprom_device : public base_eeprom_device, - public serial_eeprom_interface +class eeprom_serial_93cxx_device : public eeprom_serial_base_device { -public: +protected: // construction/destruction - serial_eeprom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + eeprom_serial_93cxx_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file); - // inline configuration helpers - static void static_set_interface(device_t &device, const serial_eeprom_interface &interface); +public: + // read handlers + DECLARE_READ_LINE_MEMBER(do_read); // combined DO+READY/BUSY - // I/O operations - DECLARE_WRITE_LINE_MEMBER( write_bit ); - DECLARE_READ_LINE_MEMBER( read_bit ); - DECLARE_WRITE_LINE_MEMBER( set_cs_line ); - DECLARE_WRITE_LINE_MEMBER( set_clock_line ); + // write handlers + DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high) + DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high) + DECLARE_WRITE_LINE_MEMBER(di_write); // DI protected: - // device-level overrides - virtual void device_start(); - virtual void device_reset(); + // subclass overrides + virtual void parse_command_and_address(); +}; - // internal helpers - UINT32 decode_value(int numbits, int bitsfromend = 0); - void fill_data_buffer(offs_t address); - void write(int bit); - bool command_match(const char *cmd, int ignorebits = 0); - static const int SERIAL_BUFFER_LENGTH = 40; +// ======================> eeprom_serial_er5911_device - // runtime state - int m_serial_count; - char m_serial_buffer[SERIAL_BUFFER_LENGTH]; - int m_data_buffer; - int m_read_address; - int m_clock_count; - int m_latch; - int m_reset_line; - int m_clock_line; - bool m_sending; - bool m_locked; - int m_reset_counter; -}; +class eeprom_serial_er5911_device : public eeprom_serial_base_device +{ +protected: + // construction/destruction + eeprom_serial_er5911_device(const machine_config &mconfig, device_type devtype, const char *name, const char *tag, device_t *owner, const char *shortname, const char *file); +public: + // read handlers + DECLARE_READ_LINE_MEMBER(do_read); // DO + DECLARE_READ_LINE_MEMBER(ready_read); // READY/BUSY only -// device type definition -extern const device_type SERIAL_EEPROM; + // write handlers + DECLARE_WRITE_LINE_MEMBER(cs_write); // CS signal (active high) + DECLARE_WRITE_LINE_MEMBER(clk_write); // CLK signal (active high) + DECLARE_WRITE_LINE_MEMBER(di_write); // DI + +protected: + // subclass overrides + virtual void parse_command_and_address(); +}; //************************************************************************** -// GLOBAL VARIABLES +// DERIVED TYPES //************************************************************************** -extern const serial_eeprom_interface eeprom_interface_93C46_93C66B; - +// macro for declaring a new device class +#define DECLARE_SERIAL_EEPROM_DEVICE(_baseclass, _lowercase, _uppercase, _bits) \ +class eeprom_serial_##_lowercase##_##_bits##bit_device : public eeprom_serial_##_baseclass##_device \ +{ \ +public: \ + eeprom_serial_##_lowercase##_##_bits##bit_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); \ +}; \ +extern const device_type EEPROM_SERIAL_##_uppercase##_##_bits##BIT; \ + +// standard 93CX6 class of 16-bit EEPROMs +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c06, 93C06, 16) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 16) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c56, 93C56, 16) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c57, 93C57, 16) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c66, 93C66, 16) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c76, 93C76, 16) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c86, 93C86, 16) + +// some manufacturers use pin 6 as an "ORG" pin which, when pulled low, configures memory for 8-bit accesses +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c46, 93C46, 8) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c56, 93C56, 8) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c57, 93C57, 8) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c66, 93C66, 8) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c76, 93C76, 8) +DECLARE_SERIAL_EEPROM_DEVICE(93cxx, 93c86, 93C86, 8) + +// ER5911 has a separate ready pin, a reduced command set, and supports 8/16 bit out of the box +DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 8) +DECLARE_SERIAL_EEPROM_DEVICE(er5911, er5911, ER5911, 16) #endif |