Well, that is not going to test the full functionality, thats quite obvious. So I used some time in order to try to come up with a scheme that may test some, if not all, of the 6522 functionality:
Lets start with the IRQ timers. They are simple counters based on the CLK2 signal and thus count the number of clock cycles in the system from a given "init" time. The raster counter can be used (with some comparable logic) to get single-clock accuracy on how many CLK2 cycles that have actually passed at a give time.
The IRQ timers on the two 6522 can then be compared with respect to the main clock of the system and from that we can deduce that the each IRQ timer counts correctly. Unless the CLK2 itself is fuzzy. But if the CLK2 is not correct that would show up on the monitor, wouldn't it? Well, since the monitor signal and CLK2 both come from the VIA chip, it may not. For now, lets just assume that the system clock is a continuous counter at a given frequency.
Before we can start testing the IRQ, we would have to test other parts of the 6522. There is no way to start the IRQ output on the 6522 if one can't write data to it, so a non-working IRQ may actually be due to problems elsewere. If we can't write data to it for example. Now you may ask yourself if this is interesting at all (e.g. a non-working IRQ would mean that the chip is unusable, wouldn't it?). Well, as chips get older, more and more of them will stop working. At some point in the future it will be very difficult or impossible to get replacements, and at that point it may be interesting to have a partially working 6522 for some tasks in some old systems. Maybe you need the IRQ but would be ok without that lightpen input... or something like that.
So how do we test the data in/out? Event speed dependence will be important. Some chips may be be ok for keyboard but not for faster IO like disk drives. A easy way is to start by writing to the directional register (VIADDRA or VIADDRB). Writing here and reading it again should produce the same value (unlike most of the other registers), so one can start by cycling through different values (write + read + compare) at different speeds. The fastest way would be something like:
Code: Select all
LDX #$ff
loop:
LDA table,X
STA VIADDRA
CMP VIADDRA
BNE error
DEX
BNE loop
//success!
error:
//failed!
If that works, then one can test the IRQ and continue to start testing IO registers.
If we look at the schematics, one 6522 is responsible for serial port input, while the other is responsible for serial output. That is a nice way to test those datalines at different speeds, but it won't test the other lines. Thus, it is obvious that we need a dongle on the userport and joystick port to test the whole VIA1 6522 throughly (the one in UDE8 position). The VIA2 6522 can't be tested at different speeds without a dongle on the keyboard-connector inside the Vic-20.
If anyone else has a better idea (or comments) I would like to know.