I have now redesigned the whole VPA,VMA,E based system and greatly simplified it. So now there is actually no "E-clock" as such, and the whole code generating the 40/60 clock is now gone.
Code: Select all
Z3.CK = CLK16;
Z3.D = E & !VMA5 & !VPA & !CPU_AS;
VMA1.CK = CLK8;
VMA2.CK = CLK8;
VMA3.CK = CLK8;
VMA4.CK = CLK8;
VMA5.CK = CLK8;
VMA1.D = VPA # CPU_AS;
VMA2.D = VMA1 # VPA # CPU_AS;
VMA3.D = VMA2 # VPA # CPU_AS;
VMA4.D = VMA3 # VPA # CPU_AS;
VMA5.D = VMA4 # VPA # CPU_AS;
!E = CPU_AS # VPA # VMA2;
VMA = VPA;
Now because of the setup time of the ACIA we need to wait around 500ns in total. So what I do is I wait 2 x clk8 cycles and then issue "E", is basically easier to understand as a output enable of the ACIA (but a bit more complicated than that).
So we select the ACIA by setting the CS low, two clocks later set Enable high which then outputs data onto the bus. But there is a setup time here also for the data to actually be valid. So I wait another 3 clock cycles and then issue DTACK via Z3.
So far this seems to be running very well for the past hour. Initially I did not have any delays on the "E" signal, and I had some intermittent crashes. The likely the ACIA may have a slight bus conflict with data on the bus from something else. So I just avoid this by delaying "E" couple of clock cycles. "E" and DTACK (Z3) are deselected when either CPU_AS or VPA goes high which terminates the cycle.
So from this there is no actual 40/60 E-clock anymore, simply used as "E" as a enable line only for the ACIA. Which is what actually the E-clock is for, but we do not need to constantly run this signal at 500KHz, its only asserted when we need it. So this greatly simplifies the code and how it all works.
Technically now the ACIA are running at a higher speed even if the CPU is running at a stock 8 MHz. I do not think this will be a problem compatible wise. The only side effect I know of this is where a sampled sound is playing and when you move the mouse the sound slows down. The effect will actually be less as the ACIA are running at a higher speed. So I do not see this as a problem.
So now I have the ACIA running from the system clock, I can now get back to overclocking the CPU over 50Mhz