Firstly C, thanks very much for the schematic - makes it much easier for me to understand.
Unfortunately I haven't got the ICs to implement memory mapping at the moment and I've also gotten a little sidetracked with another task.
Think about memory mapping a moment.
The important thing is add little delay to a memory access as possible.. For My schematic that is switching time of the 74xx153. You loose this much time when accessing memory.
There are many ways to do this. Look at my schematic for ways you could modify it. What do you gain with the change, what do you loose?
Note that you could plan ahead to make adding memory management easy.
You could inset a memory breadboard between Z80 & memory.
I've had a PIO sitting around doing nothing and as an I2C interface is on my wishlist, I've wired it into the SBC and hooked it up. All good so far.
I've been following this guide - http://www.blunk-electronic.de/train-z/pdf/howto_program_the_Z80-SIO.pdf - page 28 outlines an I2C interface using the PIO, which goes on to include some simple assembly routines to cover the basics. It doesn't quite go as far as setting up a working I2C interface in software, but it seems to be a good starting point.
What are you wanting to build,
A microcontroller or A microcomputer?
If you want to build a microcontroller, save a lot of time and money and start with a microcontroller.
If you want to build and learn about a microcomputer,
Get in the micorcomputer mind set, thinking the computer way of doing things.
First look at PIO
You have two signals that most microcontrollers do not have, ARDY & ASTB.
These two signals let bytes of data flow at rate both z80 & connected circuit can handle. Because you are handshaking at byte, you can send many bytes in a row with the same value. At the same time software load on Z80 is lower.
Signals like these are easy to get in hardware with a microcomputer.
Look at a chip that was built to make it simpler to do I/O
Intel 8212
http://blog.copcea.ro/files/datasheets/diverse/8212.pdfThe dashed box is around a 74xx273 & a 74xx244 logic equal. You have the clear input of the 273 and the tri-state output of 244.
Best idea is not to do I
2C with out adding a proper I
2C master like PCF8584.
To do I
2C with anything less wastes more and more CPU time just to run the interface.
Then you talk about SPI, again best done in hardware. If the only thing SPI is a SD card used for storage then this might be worth the chips needed.
When you shift to bit-banning you loose a huge amount of speed and need a huge number of instructions on CPU to make up for missing hardware.
Keep in mind that you can only do a single thing at a time on an I
2C or SPI bus.
So step one, cross off I
2C & SPI from your lists of wants and instead list the function of the chip that you would attach.
Then think smart,
That PCF8584 costs about $4. It is cheaper to add an interface on Z80 that can talk to a microcontroller and let the microconrtroller then talk to I
2C & SPI. This also lets Z80 do more with less software overhead.
If you are wanting to learn microcontroller stuff, use a microcontroller to start.
If you are wanting to learn microprocessors then look at areas that microprocessors are good at.
If you want something to interface, how about a HD44780 LCD controller
Many used the HDLC mode of SIO to link systems. This gives you a packet like interface with 8-bit transparency for data and command/status. IBM called this SDLC and had huge networks.
Many used SCSI as a parallel interface between 8 systems. Not hard to do in hardware/software and supports 8-bit transparency.
If you want really extreme, Connect an ESP32 to your Z80.
Think about many CPU's.
One TurboDos system I worked with had over 200 uses running CP/M programs. That is 200 Z80's for the users + more.
One 68K system with 8 users used a Z80 to do all IO.
The basics are
Memory management
Multi-port memory
Multi-processor shared bus
Processor with Many buses.