Nice progress Dani. I'm excited to see the 6502 and 6526 models working together. Very cool.
(I will be posting an NMOS version of the 6502 component shortly. You may not need or want the NMOS functionality but I thought I would mention it anyways just in case).
Cheers.
Just saw your post on the 100Mhz TTL cpu! Nice achievement!
So far, I'm doing fine with our previous model. Even though I do have some good assembly knowledge, I'm not an expert... and I usually revert to the most basic opcodes. So far, everything I've thrown at your model, has worked for me, but thanks!
Meanwhile, I've spent the weekend getting close and personal with the TOD on a real 6526, putting it through all possible transitions... both valid, and invalid ones. Even though TOD behaviour accuracy won't be critical for any possible 6526 uses, I want to know how it behaves.
My findings so far.
TOD is composed by 4 registers, Hours, Minutes, Seconds, and Tenths. Each one is (almost) a full fledged counter, with apparently some additional logic to turn them into a BCD counters.
Boths minutes and seconds are the same. High nibble represents first digit, low nibble, the second. High nibble is a 3 bit counter, lower nibble, 4 bit. Whenever high nibble transitions from 5 to 6, it reverts to 0 and pushes a tick pulse to the next counter. Same goes for lower nibble, when transitioning from 9 to A.
However, if you write an invalid value on them (let´s say, 6A) they happily count over, rolling back to zero after 7 (3bit) and F (4 bit). In this cases, no increment happens for the next in line counter.
In the tenths register, only the lower nibble is usable. Again, 4 bit counter than resets to 0 when transitioning from 9 to A and pushing a tick, in this case, to the seconds lower nibble. Writing and A allows you to count all over to F and then it rolls over to 0, without a tick. Upper nibble always reads 0.
As TOD can be programmed to work with both a 50HZ or 60 Hz signal, there must by some kind of internal counter to control this. It's not readable, it's not writeable, but it's there. It's also not clearly visible on the die, but it has to be there. Writing to the tenths register always resets this counter (if clock is not running!). So far, in my design, this is an aditional counter hardwired to an input of all 0s. Again, this doesn't seem to be the way it's really implemented, but behaviour should be the same.
Hours register is the most complicated. Low nibble, this is the last digit of the hour. In the upper nibble, high order bit is the PM/AM flag. Lower bit is the first digit of hours (Only 1, or 0). 2 and 3 bits always read 0, and there doesn't seem to be any evidence of any storage for them existing on the die.
For this, the cycle is as follows (Expected) 01 - 02 - 03 - 04 - 05 - 06 - 07 - 08 - 09 - 10 - 11 - 12 - 01
Whenever 12 is written here, the AM/PM flag flips, so, Writing 0x12 in this register results in 0x92 being actually stored. Writing 0x92 results in 0x12.
Same as other registers, the lower nibble is a full 4 bit counter, so writing 0x0a allows to go up untill 0x0F, then it flips to 0x00 (Invalid by the way). Writing 0x13, then it goes until 0x1F, and rolls over to 0x10. In both this invalid counts, AM/PM flag is never affected.
There's no indication on which value does TOD take on reset. Testing reveals that, most of the time, it gets set to 81:00:00:0. There's no clear indication on what the AM/PM flag represents. 1 is PM? AM? I guess it's up to the programmer here! But, on a few ocassions, it resets to 01:00:00:0. So probably everything except the AM/PM flag is wired to reset to a specific value, but the flag maybe takes whatever's on the bus.
Besides this, everything else is pretty well documented already. The latching of the TOD value on read, the stop and restart of the TOD on writes, and ALARM.
Regarding ALARM, I have yet to investigate
it's famous bug. Same goes for the
ALARM initial value which is, at least for me, completely unknown.