22// copyright-holders:Christian Brunschen
33/* **************************************************************************
44
5- Xicor 28-series Parallel EEPROM read and write logic,
6- including write protection command sequences.
7- Caters for different speeds such as X28C256, X28HC256, etc.
8- Caters for different storage sizes such as X28C64, X28C256, X28C010,
9- XM28C020, etc.
5+ Xicor 28-series Parallel EEPROM read and write logic,
6+ including write protection command sequences.
7+ Caters for different speeds such as X28C256, X28HC256, etc.
8+ Caters for different storage sizes such as X28C64, X28C256, X28C010,
9+ XM28C020, etc.
1010
1111***************************************************************************/
1212
2828
2929/* *
3030 * Template parameters
31- *
31+ *
3232 * AddressBits:
33- * The number of bits in the address bus.
33+ * The number of bits in the address bus.
3434 * _28_64 EEPROMs store 64 kbits = 8 kbytes = 13 address bits,
3535 * _28_256 ones store 256 kbits = 32 kbytes = 15 address bits,
3636 * _28_512 EEPROMs store 512 kbits = 64 kbytes = 16 address bits,
3737 * _28_010 ones store 1024 kbits = 128 kbytes = 17 address bits.
38- *
38+ *
3939 * PageSizeBytes:
4040 * These EEPROMs support writing an entire page at a time. These page sizes vary
4141 * by EEPROM size and by manufacturer. 64 and 128 byte page sizes are both common.
42- *
42+ *
4343 * TBLCUsec:
4444 * The EEPROM's T_BLC, the "Byte Load Cycle Time", in microseconds.
45- * After a byte write, if another byte on the same page is written within T_BLC,
45+ * After a byte write, if another byte on the same page is written within T_BLC,
4646 * those writes will be combined in a single programming cycle. Or in other words,
4747 * the programming cycle starts T_BLC after the most recent write.
4848 * Xicor X28C256 has T_BLC = 100 microseconds.
4949 * If TBLCUsec == 0, then there is no timed end to the Byte Load Cycle, so we
5050 * _must_ trigger programming in some other way. The only way to do that is to triggger
5151 * programming on read(), so that is what we do. See also ProgramOnRead below, for
5252 * explicitly enabling this behaviour.
53- *
53+ *
5454 * TWCUsec:
5555 * The EEPROM's T_WC, the "Write Cycle Time", in microseconds. This is the amount
5656 * of time it takes for the EEPROM to complete is programming cycle.
5757 * Xicor X28C256 has T_WC typ = 5ms = 5000 microseconds, max = 10ms = 10000 microseconds.
5858 * Xicor X28HC256 has T_WC typ = 3ms = 3000 microseconds, max = 5ms = 5000 microseconds.
59- *
59+ *
6060 * ProgramOnRead:
6161 * Instead of waiting for the TBLCUsec interval to elapse, whenever a Read hapens,
62- * immediately start any pending programming cycle.
62+ * immediately start any pending programming cycle.
6363 * This is not present on real devices but here it allows us to create a 'fast' eeprom.
6464 * In particular, if we know that the client always follows writes with reads to verify
6565 * that the programming cycle completes, then we can set TBLCUsec to 0 and thus implicitly
6666 * ProgramOnRead to true. We now have a device that obeys the EEPROM write
6767 * protection commands but does not have to wait for T_BLC to expire before writing the
6868 * buffered data to storage.
6969 * If we then also set TWCUsec to 0, we have a device that also immediately writes the
70- * buffered data to storage, giving us a very fast EEPROM device.
70+ * buffered data to storage, giving us a very fast EEPROM device.
7171 * This can be used for example for external EEPROM cartridges, where emulating the precise
7272 * timing of a particular chip is unlikely to be very important, and instead, allowing
7373 * that cartridge to be as quick as possible may give a more pleasant user experience.
7474 */
7575template <
76- int AddressBits,
77- uint32_t PageSizeBytes,
78- uint32_t TBLCUsec,
76+ int AddressBits,
77+ uint32_t PageSizeBytes,
78+ uint32_t TBLCUsec,
7979 uint32_t TWCUsec,
8080 bool ProgramOnRead = false
8181>
82- class x28_device :
82+ class x28_device :
8383 public device_t
8484{
8585public:
@@ -140,8 +140,8 @@ class x28_device :
140140 // idle state: reads work as normal, writes will succeed or fail depending on
141141 // m_write_enabled - except for those writes that are part of one of the protection
142142 // enable or disable sequences.
143- STATE_IDLE ,
144-
143+ STATE_IDLE ,
144+
145145 // After detecting the third write that initiates a protection enable sequence,
146146 // writing A0 to address 5555 (1555 on X28C64).
147147 // At this point the device will accept one page write, before then going into
@@ -152,7 +152,7 @@ class x28_device :
152152 // and writes the byte to an internal buffer.
153153 // As long as the next write is to the same page (higher address bits remain
154154 // the same) and the next write is initiated within T_BLC, more bytes can be
155- // written, and those too will be written to the internal buffer.
155+ // written, and those too will be written to the internal buffer.
156156 // If no more writes happen within T_BLC, thw programming cycle starts,
157157 // during which time the buffer will be saved to the corresponding page in
158158 // the persistent EEPROM storage.
@@ -194,7 +194,7 @@ class x28_device :
194194 // writing 55 to address 2AAA (0AAA on X28C64)
195195 COMMAND_STATE_PROTECION_DISABLE_5 ,
196196
197- // after detecting the sixth write in the protection disable command sequence,
197+ // after detecting the sixth write in the protection disable command sequence,
198198 // writing 20 to address 5555 (1555 on X28C64),
199199 // the device will return to COMMAND_STATE_NONE and STATE_IDLE with m_write_enabled = false.
200200 };
@@ -253,7 +253,7 @@ class xm28c040_device : public x28_device<19, 256, 100, 5000> {
253253
254254// a 256 kbit == 32 kbyte "fast timed" that uses only the Byte Load Cycle timer and
255255// also programs immediately on reading; where the Write Cycle is effectively
256- // infinitely quick and any pending writes are immediately committed and ready,
256+ // infinitely quick and any pending writes are immediately committed and ready,
257257// and returned without Toggle Bit polling or /DATA polling
258258class x28f256_device : public x28_device <15 , 64 , 100 , 0 , true > {
259259public:
0 commit comments