openMSX
EEPROM_93C46.hh
Go to the documentation of this file.
1#ifndef EEPROM_93C46_HH
2#define EEPROM_93C46_HH
3
4#include "EmuTime.hh"
5#include "SRAM.hh"
6
7#include <climits>
8#include <string>
9
10namespace openmsx {
11
12class DeviceConfig;
13class XMLElement;
14
16{
17public:
18 static constexpr uint8_t ADDRESS_BITS = 7;
19 static constexpr uint32_t NUM_ADDRESSES = 1 << ADDRESS_BITS;
20 static constexpr uint32_t ADDRESS_MASK = NUM_ADDRESSES - 1;
21 static constexpr uint8_t DATA_BITS = 8; // only 8-bit mode implemented
22
23public:
24 explicit EEPROM_93C46(const XMLElement& xml); // unittest
25 EEPROM_93C46(const std::string& name, const DeviceConfig& config);
26
27 void reset();
28
29 [[nodiscard]] bool read_DO(EmuTime::param time) const;
30 void write_CS (bool value, EmuTime::param time);
31 void write_CLK(bool value, EmuTime::param time);
32 void write_DI (bool value, EmuTime::param time);
33
34 template<typename Archive>
35 void serialize(Archive& ar, unsigned version);
36
37 // for unittest
38 [[nodiscard]] const uint8_t* backdoor() const {
39 return &sram[0];
40 }
41
42private:
43 [[nodiscard]] uint8_t read(unsigned addr) const;
44 void write(unsigned addr, uint8_t value, EmuTime::param time);
45 void writeAll(uint8_t value, EmuTime::param time);
46 void erase(unsigned addr, EmuTime::param time);
47 void eraseAll(EmuTime::param time);
48
49 [[nodiscard]] bool ready(EmuTime::param time) const;
50 void clockEvent(EmuTime::param time);
51 void execute_command(EmuTime::param time);
52
53public: // for serialize
62
63private:
64 SRAM sram;
65 EmuTime completionTime = EmuTime::zero();
66 EmuTime csTime = EmuTime::zero();
67 State state = State::IN_RESET;
68 uint16_t shiftRegister = 0;
69 uint8_t bits = 0;
70 uint8_t address = 0;
71 bool pinCS = false;
72 bool pinCLK = false;
73 bool pinDI = false;
74 bool writeProtected = true;
75
76 static constexpr int SHIFT_REG_BITS = sizeof(shiftRegister) * CHAR_BIT;
77};
78
79} // namespace openmsx
80
81#endif
const uint8_t * backdoor() const
static constexpr uint32_t ADDRESS_MASK
static constexpr uint8_t ADDRESS_BITS
void write_CS(bool value, EmuTime::param time)
static constexpr uint32_t NUM_ADDRESSES
static constexpr uint8_t DATA_BITS
void serialize(Archive &ar, unsigned version)
void write_CLK(bool value, EmuTime::param time)
bool read_DO(EmuTime::param time) const
void write_DI(bool value, EmuTime::param time)
This file implemented 3 utility functions:
Definition Autofire.cc:11