-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daisy chain module edge case #123
Comments
This whole thing is admitably a very edgy edge case 😈 I am not even sure if it can happen in real hardware, but it can be easily reproduced using the Simulator. Here is a commit: e9d4f3d . If you do a In
The overarching question is: Do we want to fix this at all? This situation is not very likely to occur in hardware. If we would like to fix it, then one idea might be to add a "I changed my mind" input to the Daisy chain module, which works like this: If the signal is asserted AND we are still waiting until its our turn (i.e. the CPU was not even able to look at our request) THEN the interrupt request latch is deleted. Happy to discuss. Here or via email or via video call. |
Definitely something we want to fix. I'll need to think about it. |
Just in case our messages overlapped, I added this comment: #123 (comment) |
Wouldn't the timer deassert the /INT line as soon as one of its registers became 0? Thus it would no longer be part of the interrupt daisy chain setup?! |
@bernd-ulmann Hi Bernd - I guess there is a misunderstanding on your side. Let me explain: As the correct and edge case proven Interrupt and Daisy chain protocol is not-trivial, Michael and I came up with the idea to have a reusable Daisy chain and interrupt protocol handler device that we can just plug-in to all our interrupt enabled hardware. Currently this is "just" the VGA and the Timer, but in future there will be more, so we wanted to make sure, that not every new device needs to be "battle hardened" over and over again. The timer interrupt as it is released in V1.6, is using it's own Daisy chain logic. And there, everything works fine. Now, here in the While I did this refactoring, I discovered, that the module, which is absolutely great in itself and handles a lot of complexity, has this edge case issue described here. If you want to learn more, here is the documentation about this new module. You can compare this module to a library in C that contains the functionality, so that not each and every device we make needs to have code for this logic again and again. |
After some thought, I've come up with three possible solutions. These are (in no particular order): A: Remove the latching mechanism from the B: Have the CPU treat the ISR address = 0x0000 as a special case. In other words, if the CPU receives an ISR address of 0x0000, the CPU should ignore the interrupt request and therefore not set the Program Counter. This requires changing the CPU, and giving the CPU knowledge of a "special" value. However, the existing devices (timer and VGA) currently treat the ISR address 0x0000 as a special case. On the other hand, I can think of a situation where the application wants to implement a "watch-dog" functionality and have a timer interrupt specifically point to address 0x0000 (which is the Cold Reset). I.e. a user might indeed want the system to Cold Reset if a given timer interrupt occurs. This is not possible with the current implementation of the timer module. C: Other computer architectures have a separate interrupt enable register, so we could do that too. That way, the device will no longer treat the ISR address 0x0000 as a special value. When an application wants to enable interrupts, the program must first set the ISR address and then set the enable bit. When the application wants to disable interrupts, the program must clear the enable bit (but leave the ISR address untouched). The race condition mentioned in this issue can still occur, in that the instruction disabling interrupts might be in the process of being executed when the interrupt request fires. That would mean the ISR is entered AFTER the programmer has disabled interrupts. Looking forward to our call on Tuesday to discuss this issue! |
What call? I missed something, it seems... :-) Regarding your suggestions: All three are great. The easiest one to implement might be to give each device capable of issuing interrupts a command and status register (CSR) with a dedicated interrupt enable bit so the device would not have to test for an ISR of zero. ...but this would not clear an already pending interrupt which would be serviced nevertheless but at least with the correct ISR, right? Didn't we originally say that the timer module is disabled if any of the three timer registers contains zero? In this case we could avoid the problem by just setting the PRE or CNT register to zero instead of chainging INT or am I missing something here? |
@MJoergen re (A) I think the latching is super-awesome. It prevents large challenges for the implementors and takes away the burden of the "wait until it is your turn" logic. So we should keep it like that. Let's discuss on Tuesday. |
I stumbled over the following situation in the context of the refactoring of the timer module to use our new daisy chain module. Consider this situation:
this_grant_n_o
to zero0x0000
on the data bus 💣 💣 💣The text was updated successfully, but these errors were encountered: