The project entails a ZILOG Z84C0020 , 64KB of RAM, 82C51A UART, 82C55A PIO and a SPLD for glue logic along with an AT90USB1286-based TEENSY 2.0++ as a system contoller.
For the Z80 cock source, the OC2A output of the AVR provides the Z80 clock. Timer 2 is an 8-bit timer. If you set up the code so that the AVR clock is the clock source, the OC2A pin toggles with an OCR2A match and set the mode to "mode 2", CTC mode then the OC2A output will toggle at a rate dependent of the the AVR clock source. If OCR2A is set to "0", you effectively have a divide-by-2 clock. The TEENSY 2.00++ clock is 16MHz, which means the fastest my Z80 could run would be 8MHz by setting OCR2A to "1" would drop that to 4MHz. The output frequency would be AVR_CLK / ((OCR2A + 1) * 2). The minimum Z80 clock could be 16MHz/((255+1)*2) or 31.250KHz. As you migth imagine, the Z80 clock could even be set to something "odd", say 3.2MHz or 1.454MHz. The Z80 clock could be changed on-the-fly, even used to suspend the Z80 in a "standby mode" by forcing the Z80 clock pin low during a halt instruction execution.
Since I plan to implement a "single-stepping" feature using the TEENSY, running the Z80 at a low frequency of sub-100KHz would be useful as it would give the AVR time to monitor and toggle the appropriate Z80 control pins.
At the moment, I want to use the TEENSY as a virtual hardware device in that it will emulate an 82C51A UART and provide disk I/O using an SD memory card. I'll just need to see how fast I can get the AVR to respond to the chip select lines.
If I have to use an actual 82C51A UART on the board then the OC1A output of the AVR provides the UART clock. In that case, I would feed the TXD and RXD pins of the 82C51A to the AVR's TX and RX pins and allow the AVR to act as a pass-though device using it's USB interface. Entering a certain control character, intercepted by the AVR could break the pass-through connection and return the user back to the accessing the AVR system monitor's commands. Timer 1 of the AT90USB1286 is an 16-bit timer, which means I could effectively divide the AVR's clock down to 122Hz. With 16-bit resolution, I can effectively support ANY baud rate. At 115.2K, 57.6K, 38.4K, 19.2K and 9600 baud, the error is 0.08%. That's pretty darn good but for simplicity, I may still keep the 82C51A as my UART.
With the AVR as the system controller, at reset, I can have the AVR download a "monitor" or CP/M bootloader into the RAM starting at address 0x0000. Since the AVR controls the Z80 RESET pin, the Z80 can be held in a RESET state until the memory dump is complete, then the RESET pin released so the Z80 can continue to execute code from 0x000.
I acquired a few GAL20V8Z parts off of eBay to use as an I/O and memory decoder. With the Z80 running at 8MHz, I wanted to be able to insert a single wait-state for memory and I/O. This MAY be required at 8MHz with my RAM chips but likely not at the lower speeds, hence it should be under AVR control.
Have you been successful ? Can you load software into memory using the Teensy and replace the 8251 with the Teensy? Can you share the Teensy software?