GARTHWILSON: You may not have stated such a requirement in one place but I appreciate the very desirable ability of a 2MHz 6502 to handle 48000 periodic interrupts per second. Unfortunately, it is a capability which is easily eroded by software overhead or the bus cycles required to store a larger program counter. The problem can be solved by increasing processor frequency. However, this increases overall energy consumption in addition to other implementation difficulties. Likewise, the drastic move of making a wider data bus has minimal gain unless all pieces of data are bus width aligned. Indeed, this would explain your hesitance with W65C816 and your advocacy of 65Org32.
You may not have set the interrupt criteria with the gravitas that I have accepted. Regardless, it is a question worth answering, partly for personal gratification but also because the current technology stack is a "house of cards" and getting worse. Unfortunately, I'm not the only one snagged with the problem of interrupts. It is a general cross-cutting concern which causes numerous problems. Indeed, if you get something working, add a privilege scheme and see if it still works. The answer is probably not.
Let's not be polite about the matter but the bodged NMI/IRQ/BRK system in 6502 is feature parity with MC6800. I hope that the Transputer fans, such as BigEd and drogon, would agree that a two level priority is preferable, in part because it avoids the rare but annoying case of
priority inversion. Admittedly, we must credit to the Gang Of Eight for getting NMI/IRQ/BRK to work first time. With the benefit of 45 years hindsight (and all modern tools), amateurs (in which I include myself) struggle to achieve the same result on any timescale.
For example,
MicroCoreLabs has weak implementation around reset and interrupts.
randyhyde is silent on the matter.
aleferri is similarly snagged with interrupts (although making good progress with this and other problems).
Proxy and I share similar doubts. On anycpu.org, similar problems typically occur with unique processor architectures. Most unnervingly, we
found that absolutely no-one knows if /ABORT may be used as a general purpose interrupt. Furthermore, Intel and AMD are both re-architecting x86 interrupts in a manner which is mutually incompatible. This leaves me with the concern that I might architect an interrupt methodology which would be considered obsolete by market leaders. Of particular note, I understand that Intel is collapsing previous work into a two level priority scheme.
After
reading the forum archive in full (and then posting a bout of duplicate topics before data settled), it occurred to me that making a 6502 or 65816 system was tractable. This has its own gratification but it was not an objective when I joined the 6502 forum. Specifically, I was only interested in extending 6502 bytecode to 64 bit. Regardless, it occurred to me that it might be possible to advance a solution empirically - or at least understand the problem from personal experience. Unfortunately, I have now discovered that the reference material is wrong. Worse, we have multiple silos of expertize where any
programmable logic expert could have corrected the discrete implementation if it were not quicker to type the correct solution into a CPLD or FPGA workflow. Indeed, while reading through anycpu.org, I subsequently discovered that the
correct "double flop" solution was published on Fri 14 Jun 2019.
Anyhow, interrupts are a tough problem and I still don't have an answer. I have devised numerous schemes in an attempt to answer this problem. Some of them are quite elegant. However, it would be preferable if any of them worked. My favorite is a scheme which divides a 64 bit vector into a 4 bit priority field, a
12 bit core number, 8 bit for bytecode dialect and 40 bit for address with provision to shuffle these fields around by a few bits, if required. Unfortunately, there is no mechanism to queue lower priority interrupts. Meanwhile, allocating one interrupt per core only provides the guarantee that all interrupts run concurrently - which is extremely unhelpful.
A more promising avenue is a duplicate set of vectors for every address-space extension; much like 65816. Unlike 65816, vectors may be selected automatically based upon the top bits of the program counter and therefore execution mode is implicit. This allows a system to retain 6502 cycle count when operating within a 16 bit address-space. Interrupt performance only degrades as usage of the address-space grows. Hypothetically, it is possible to make a faster bus or a wider bus. However, both increase the difficulty of construction and both increase energy consumption. There are also cases where pushing extra data to a wider, unaligned stack obtains no speed advantage. We also have the minor problem that duplicate vectors within the same page break multiple legacy ABIs. Most notably, Commodore and Acorn ABIs are already incompatible with 65816. Compatibility workarounds may be incompatible with further vector extensions. There are further compatibility and performance problems when trying to get 16 bit RTI, 24 bit RTI, 32 bit RTI, 40 bit RTI and suchlike working with a high level language.
As a pragmatic example, audio sampling with 65816 in native mode has worse performance (lower maximum frequency, worse jitter) than 65C02. Whereas 65Org32 - with 32 bit aligned stack - always has better performance.
In an attempt to stay within a 16 bit address-space while minimizing interrupt cycle count, the general case of unlimited interrupt sources may be handled with a tree of priority interrupt encoders. However, after working through the details, designing a module and receiving example units, it occurred to me that CA1, CA2, CB1 and CB2 pins of a 6522 may be used to make a quad-tree of interrupts. This has the advantage of zero external components (beyond any pull-up resistor required for open collector compatibility) while retaining much of the functionality of dedicated circuitry. In this arrangement we have branch and leaf 6522 chips. Shift registers within branches may be unavailable but timers and parallel ports remain available.
GARTHWILSON on Thu 11 Nov 2021 wrote:
How many interrupt sources do you plan to have enabled at once?
Personally, I plan to have:-
In this arrangement, any interrupt source (such as subordinate 6522, I2C thermometer alarm or 65SIB peripheral) may be connected to the root 6522.
If anyone wants a priority interrupt encoder module, just ask. However, it appears that the magic of 6522 makes it largely redundant.