I need to emulate an MCU that adheres to an industrial communication protocol.
The MCU has a 4 KB RAM addressable using special ethernet frames.
Ethernet frames can read and write to the RAM using address, length, and bytes.
Some registers (specific addresses) in the RAM do special stuff. For example, you can request a read from an EEPROM and have a special 4 byte area in the RAM be populated with the contents from the EEPROM.
I think this is quite similar to writing an emulator.
Questions:
How should I represent the 4 KB RAM, simply a [] u8?
Some areas in the RAM are readonly. How can I represent that?
It’d probably be easier to use [] u8 and check if the address is valid.
There is also no point to read only memory that doesn’t get modified by something special, that thing is probably in the scope of the emulator, so it’d need to modify it anyway.