ElEctric_EyE wrote:
...But the old school 6502 MOS manual says that A0-A15 was only valid during phase2 high...The timing diag's look a bit different to me, compared to the 6502.
Except your circuit is not using the NMOS part and is expected to run much faster than any of the NMOS parts. Of course, it is possible to plug the CMOS part into most boards designed for the NMOS MPU, as the low speeds are less timing-critical. However, WDC's timing model on the 'C02 has more in common with the '816 than might seem to be the case and it's best to comply with it for a trouble-free circuit. As Garth (I think) said, "You can get away with murder at 1 MHz." You won't at 10 or 12 MHz.
My opinion, for what it's worth, is that your address decoding methodology is improper. Chips selects should not be qualified by Ø2 at all. Although bus states are dependent on the phase of Ø2, the bus changes do not coincide with the rise and fall of the clock, and that is where I think your circuit is going to have trouble.
The 65xx family has, for all practical purposes, two operating states. One is present while Ø2 is low, which is when the MPU fiddles with A0-A15 and conditions control outputs, such as R/W. During that time, the data bus is invalid. The other state is when Ø2 is high, which is when the data bus becomes valid and a read or write operation can be carried out. Your design is not acknowledging these characteristics of the 'C02 (also true of the '816) and, I believe, is headed toward a timing train wreck.
Consider your SRAM, for example. It has three control inputs: /CS, /OE and /WE. The idealized (read "correct") way to address this part is for /CS to be asserted as soon as any address to which the SRAM is to respond is placed on A0-A15 by the MPU. A0-A15 is guaranteed to be stable no more than tADS nanoseconds after the fall of Ø2, an interval of 30ns maximum on a 'C02 running at 14 MHz. During the time period denoted by tADS, A0-A15 are changing and the address bus is not valid. Add on the gate delays in your glue logic and just about all of Ø2 low will be used up in address setup. Keep in mind that the SRAM itself will have some delay after selected before its internal logic produces the correct row/column address.
Of course, the SRAM has to know whether it is to be read or written. A read operation can be qualified by inverting the MPU's R/W output and applying the output of the inverter to /OE. According to the timing diagram, R/W also becomes valid at tADS. Therefore, assuming a clock rate of 14 MHz, the needed SRAM setup will occur no more than 30ns plus gate delays after the fall of Ø2 and, if you are using 12-15ns SRAM, the part should be ready for business by the time the MPU gets around to accessing D0-D7.
Depending on the SRAM, you may be able to dispense with qualifying /OE and may be able to simply tie it to /CS. In other cases, that arrangement could be ambiguous during a write cycle, causing difficult to diagnose conditions. You need to carefully read the narrative for the SRAM you are using to verify that asserting /OE during a write operation is an acceptable procedure. If not, you must qualify it with an inverted R/W signal.
Now, here comes the important part.
The MPU does not access D0-D7 until well after the rise of Ø2. In a read cycle, the MPU doesn't sample D0-D7 until tDSR nanoseconds before the next fall of Ø2. At 14 MHz, this will be 10ns. Additionally, the data must remain on D0-D7 for at least 10ns after the fall of Ø2, referred to as tDHR on the timing diagram. Therefore, the addressed device ***MUST*** stay open for access until tDHR has expired. There's no sure way to guarantee this if addressing is qualified by Ø2 as you are doing. In your design, as soon as Ø2 falls, your chip decode will become invalid, chip select will be deasserted following gate delays (very short with 74AC logic), and in the case of the SRAM, it is not likely you will meet the tDHR timing requirement. Ergo there won't be any data to read.
During a write cycle, you will have another circuit bug. As I said above, the data bus is never valid when Ø2 is low. If you directly connect the SRAM's /WE input to the MPU's R/W output, you will be telling the SRAM to accept data (assuming a write cycle) while Ø2 is low, a period during which the MPU is fiddling with the address lines. At higher clock speeds, it's very likely the SRAM may react to /WE while the address bus is in transition. The result is the invalid data on the data bus will be written to an invalid address in the SRAM.
To avoid this sort of write glitch you need to qualify R/W with Ø2 so that the only time the SRAM's /WE can be asserted is when Ø2 is high. Again referring to the timing diagram, the MPU will place data on D0-D7 at tDMS nanoseconds after the rise of Ø2, a period guaranteed to be no more than 25ns at 14 MHz. By that time, your SRAM will have already been selected and as soon as Ø2 rises, /WE will see a low input and the SRAM will accept data from D0-D7. The MPU will continue to hold the data on D0-D7 for tDHW nanoseconds after the next fall of Ø2, which would be at least 10ns.
The write glitch can occur with any hardware that can accept data, such as a 6522, a UART, etc. You must qualify R/W with Ø2 to assure that data cannot be written to a chip until after the address inputs have stabilized.
Lastly, in situations where all you need is an inverter, it's best to use an inverter, not a NAND gate with all inputs tied together. Inverters are generally faster that NANDs, and can be had six to a package (hex inverter), thus using less board real estate.