Emulating memory on nano for z80 computer system

I have been working on a z84 computer that currently employs two arduino nano's. I have a bunch of 74X series logic Ic's and a whole bunch of resistors, caps and transistors but that's it in terms of hardware. I have a backup z84 if something goes horribly wrong. I'd prefer not to go and buy flash memory, or an EEPROM as the wiring and glue logic is bit advanced for me. Plus, code generally does not emit smoke if you do something wrong.

The goal of this project is to further my understanding of programming by emulating various components on the arduino, so then I may program the z80 via serial interface. (Rather than banks of switches, etc)

I'm currently stuck on emulating memory, I only have a very basic test setup in which I have the z80 counting up the address list and I am unsure as to how I'm supposed to continue.

I have some more information on my blog that may prove to be useful in terms of pointing out how horribly wrong I'm going. There are pastebins containing both the code for the arduino master & the arduino slave. Plus a rather cruddy circuit diagram.

Blog with a bunch of info If that's not acceptable I can just link the references here. |500x187

https://pastebin.com/6ayR5pVj

https://pastebin.com/qyTk23H4

I think I'm headed in the right direction, attempting to use arrays to shuffle data around but I lack any formal knowledge.

Currently I can hit enter on the serial interface, providing the z80 starts up in the right state and it performs 4 clock cycles and spits out the address back to serial, that's all I have after a month or two.

Additionally I'd like to setup a Hex converter on the output so it's a bit more human readable. Apparently the best way to go about this is using a lookup table but I can't find much in the way of documentation for simpletons such as myself.

If someone could point me in the right direction, that would be great. Primarily I'm after appropriate documentation but if anyone has any experience with emulating hardware on the arduino I'd like to hear from them.

I'll be checking on this thread every couple of hours, any input would be appreciated. Thanks :)

Microcontrollers are not well suited for emulating memory. The controller has to wait for a valid Z80 address, read from up to 16 input pins, then look up the memory cell content and place it on another 8 pins, which have to be made output pins for that time. After the Z80 took the data, the output pins have to become tristate (inputs) again. The Z80 should not continue, e.g. read/write data, while the data bus is not yet in tristate mode.

As a first improvement an 8 bit buffer register should be used for the data bus, which can be switched by the Z80 into input and output state. This will reduce the risk of collisions when both components are in output state. Eventually two such buffers should be used, one for Z80 input and output, so that the Arduino pins, connected to these buffers, can stay permanently in input and output mode. Some Arduino pins can be freed when the address and data buffers share the same Arduino (input) pins, and one one of these buffers is enabled for output at a time.

A Z80 read cycle should immediately activate the WAIT signal, until the Arduino has provided the requested byte. Similarly for the write cycle, until the Arduino has fetched the byte from the input latch.

A more sophisticated approach could use parallel static RAM chips (6116...), and multiplexers for connection to the Arduino or Z80 (dual port RAM). Then the RAM can be filled by the Arduino first, then control can be passed to the Z80. The Z80 can use the RAM as both program and data storage.

Thanks for the info, this is quite the head start.

I currently have one arduino reading the address bus, and passing it along. From my understanding the functionality is similar to buffer, however I'm not particularly sure how one would go about detecting if an address is valid or not.

As for the buffer on the data pins, that could be difficult depending on how I want to go about it. Again, from what I understand I would have to construct a flip flop for each data pin. Something along the lines of this for handling output: |500x207 I'm guessing more or less the inverse of the above circuit for handling input.

Alternatively, I could add yet another nano to the mix, and attempt to code a buffer.

Can't say I'm particularly sure of how I would go about coming up with a buffer that handles both the data and address bus. I'm quickly approaching the point where this project is beyond my understanding.

I'm not an engineer, I don't have any training. More or less revolves around parsing the documentation and coming up with a workable implementation.

In terms of the more sophisticated approach, I could give it a shot although it would likely take a month or two for the parts to show up.

Once again, thanks for the advice.

The Z80 has several signals for bus control.

Also have a look at octal bus driver IC, like 74(LS/HC...)240-245, and 533/534/543 with registers.

What type of memory are you trying to emulate. Static or dynamic?

Paul

I was hoping to have the equivalent of an EEPROM, with a simple monitor on it for examining memory.

I'm considering using some kind of flash storage to store programs.