Skip to content
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

picorv32_waitirq_insn #221

Open
htminuslab opened this issue Aug 25, 2022 · 2 comments
Open

picorv32_waitirq_insn #221

htminuslab opened this issue Aug 25, 2022 · 2 comments

Comments

@htminuslab
Copy link

Hi All,

I am after a HLT (HALT) kind of wait function and was happy to find the "picorv32_waitirq_insn" function. However, I am not sure I understand what the attended behavior should be. In the PicoRV32 the picorv32_waitirq_insn function triggers on any interrupt even if it is masked out. This makes the function somewhat useless?

Possible fix is to include the mask in line 1544:

1543  if (ENABLE_IRQ && (decoder_trigger || do_waitirq) && instr_waitirq) begin
1544    if (irq_pending) begin

change to:

1543  if (ENABLE_IRQ && (decoder_trigger || do_waitirq) && instr_waitirq) begin
1544    if (irq_pending & ~irq_mask) begin   // add mask

Have I missed anything?

Thanks,
Hans.

@jix
Copy link
Member

jix commented Aug 25, 2022

The current behavior matches the instruction's description "Pause execution until an interrupt becomes pending.". When a temporarily masked interrupt occurs, it is still pending, despite being masked. This is intended, see also #12 (comment).

@htminuslab
Copy link
Author

Hi Jix, thanks I missed the #12 comment although no explanation is given why one wants to trigger on a disabled interrupt. My use model is to enable the interrupt(s) and then issue the picorv32_waitirq_insn function. During that time I use the "do_waitirq" signal to lower the system clock. I have 15 int sources and without the mask the picorv32_waitirq_insn function would just fall through as in my system there is always a pending (masked) interrupt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants