Hi fans -
today I made some progress with substituting the timing HAL of the Apple IIe and IIc.
Here is what happened so far:
Weeks ago I took the equations from Jim Sather's book and plugged them into my PLD design software.
I then turned loose my proprietary PLD test and analysis tools on the JEDEC, and got lots of automatically generated test vectors.
Alas, when I took that JEDEC file to a programmer, and ran its test vectors against a real HAL (Apple part #341-0710-A date code 8429) plugged into it, I got hundreds of vector fails.
This does not necessary mean that Jim's equations would lead to a PAL that doesn't work in an Apple IIe, but it proves that his equations are not the same as the (unknown) equations in the original Apple part.
So I did not pursue this any further and decided to do my IOU substitute development without modelling the video pipeline in the Apple IIe in the high level simulations. This "hole" in the simulations then led to a few iterations of the WNDW signal equation until it was right. Had I modelled the video pipeline, then I would have seen the discrepancies already in the simulations. But this was impossible to do, having no proven HAL equations. If you are interested in my IOU substitution work, see post #14 and below of this thread:
OK, it was not a big loss of time. Writing about the pitfalls and design iterations with WNDW took me far more time than actually diagnosing and fixing it. But I thought that I should give an accurate account on how the work was done, and what went wrong. (Other people tend to show only the finished product and pretend they got it right the first time, because they are much smarter than the rest of us. Yeah, sure.)
After the IOU work was done (some further testing required, need an NTSC Apple IIe for that, which I hope to get soon) I reverse engineered the HAL. It took me a whole day until my RTL yielded a JEDEC file which, when ATVG vectors were generated for it, would run these vectors on the real HAL without fault. It turned out that the master timing state machine (PHI0, PHI1, Q3, RAS, AX) in the real HAL is far more tricky than you would expect. There are numerous detours in the state transition graph (STG) where it waits for certain conditions. This looks as if they added these exceptions to enable their state machine to recover from losing track with the M7 and COLREF signals. In normal operations, these exceptions are never taken.
After the ATVG vectors ran fine on the real HAL I had a > 95% chance that my version indeed is a faithful reproduction of the original HAL. This essentially is the test vector fault coverage. If there were some side branches in the STG of the HAL but not in my STG, then it is highly likely these would have been uncovered by these test vectors. But this is not a full state machine equivalence proof yet. This requires more work, and I first need to repair the machine I once built for this purpose, more than 30 years ago.
I did program a GAL16V8 with my JEDEC file and put it into my Apple IIe. It seems to work, but I can't check if all the colors are right before I got a NTSC Apple IIe. Here is a photo of the GAL running my Apple IIe:
In the background you can see part of the IOU and MMU PLD substitute slot card.
In the next days I will repair my PLD compare machine and if I can bring it back to life, I can let it compare the GAL to the HAL. This again is a fully automatic process. Just put the PLDs in and push a button. Seconds later you have a green light (match) or red light (difference). I'm a lazy guy so I always try to automate all mundane tasks as much as possible ;-)
Stay tuned !
Here is a question I have on the HALs which some more experienced Apple II aficionados my be able to answer:
In my NTSC Apple IIc, I found two different HAL part numbers:
341-0170-A date code 8441 (same Apple part# as the HAL from my PAL Apple IIe)
342-0170-A date code 8512 (note the "342" instead of the "341")
Unfortunately, the HALs in these Apple IIc are soldered in and before I know I indeed have a valid substitute, I don't want to take the risk to desolder the 342-0170-A).
Maybe somebody on this list knows about the difference (if any) between these two HAL versions.
Comments invited !
- Uncle Bernie