I've been working on how to integrate the VIA into this circuit. My primary concern is to keep its clock input connected to PHI2, in order for internal timers to work as expected, while keeping the data bus valid as long as RDY is low.
I also want to avoid reads from and writes to the VIA being repeated every cycle that RDY is low, because it could mess with interrupts. For example if we happen to read the status register, and with counters if we happen to write them.
At the moment, I have only considered reads. The idea is to use the VIA's chip select input to select it only once during a RDY cycle. Additionally, we need to latch the data bus at that moment to keep the data available for the rest of the cycle.
So, here is the logic I came up with (please note that it is missing writes handling):
Attachment:
via-rdy-RevB.png [ 181.83 KiB | Viewed 4747 times ]
The inputs to this circuit are:
- CLK is the clock, CLK+ is the clock delayed 10ns to satisfy the CPU read hold times
- /IOCS is the chip select for the VIA's address
- /RDY is the inverted RDY signal we get from the output flip flop in the circuit above
The outputs are:
- IOCLK is the clock stretched with RDY
- VIA_LE is the latch enable signal for the VIA's data outputs
- /VIA_CS is /IOCS active for a single cycle
- /VIA_LOE is the output enable for the latch
Here is the timing diagram I came up with, that shows RDY going low for two cycles, and the data being latched. This is at around 8MHz and uses a 22V10 for /IOCS. I think it would be more practical to implement everything in a single CPLD but for now this speed makes the diagram more readable.
Attachment:
via-rdy-timing-RevA.png [ 345.98 KiB | Viewed 4833 times ]
As you can see, there is a period of 42ns of uncertainty / potential contention between the VIA's CS going high, and the latch's OE going low, but since they'll both be outputting the same bits, I'm not too worried, especially if I speed this up in a CPLD.
Next up is adding writes to this circuit. One issue I'm having is I want writes to happen at the end of IOCLK, just like they would if it was the actual slowed clock. However, it's not obvious to me how to detect the end of RDY low and do a write in the remaining time. It would probably mean that this circuit has to request an additional RDY low cycle for the write to happen, which might complicate the logic. We'll see what I can figure out next!