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

IRQ arrive on the last instruction of HW loop #107

Closed
Itaykeidar opened this issue Aug 4, 2019 · 9 comments
Closed

IRQ arrive on the last instruction of HW loop #107

Itaykeidar opened this issue Aug 4, 2019 · 9 comments
Assignees
Labels
Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system

Comments

@Itaykeidar
Copy link

In the waveform we can see next coincidence: hardware loop #1 is enabled, number of iterations is 6, the pointer to the last instruction in the loop is 0x8000_065E.
Instruction in the pointer 0x8000_065C executed normally, but before execution of instruction in pointer 0x8000_065E, interrupt arrived.
After exiting from interrupt processing function CPU finished loop iteration and moved to pointer 0x8000_064C. (pointer 0x8000_065C is the beginning of the loop).

Screenshot of waveform:
Capture

So we can conclude that last instruction in the loop was interrupted by IRQ processing and after it not executed.

To perform jump in hardware loop execution next signal is used: hwlp_jump_o of the riscv_hwloop_controller module.
This signal takes into account account next PC after execution of current instruction and if next PC is equal to HW loop end address hwlp_jump_o becomes 1.
In the next wavefrom we can see that hwlp_jump_o is active on ID stage of 0x8000_064C instruction.
Next time signal hwlp_jump_o was active for a short time during mret instruction execution.
It looks like design mixed up execution of mret with the last instruction in the loop.

Capture

@davideschiavone davideschiavone self-assigned this Aug 4, 2019
@Itaykeidar
Copy link
Author

Hi,

it seems the problem is the prefetch of next instruction.
here is a more simple example:
Capture

on the highlited bottom, is the select between the last fetched instruction and the next.
this chooses between the last HW loop command and the first command.
wrongfully it chooses the later.

this happens due to an interrupt that happened on the last hw line "0x800002fA":
image

it happens due to wrong selection of the address:
image

probably due to no clear in state machine, or missing condition.

thanks,
Itay K.

@davideschiavone
Copy link
Contributor

Thanks a lot Itay!

I will try to reproduce it and fix it as soon as possible, this issue has the top priority to me

@davideschiavone
Copy link
Contributor

Hello,

can you please send me the piece of assembly that you used?

or the binary of the HW loop part so that I can replicate it? I need to replicate the bug with the same compressed instructions that you are using.

Thanks
Davide

@davideschiavone davideschiavone added Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system wait_for_feedbacks and removed possible_bug labels Sep 19, 2019
@davideschiavone
Copy link
Contributor

I confirm it is a bug, can you please check with this fix?
78c4c44

@yaronbe1
Copy link

the fix for #148 fixes this issue also

@davideschiavone
Copy link
Contributor

Fixed by f19f072

@davideschiavone
Copy link
Contributor

The solution proposed contains a combinational loop,
please find the proposed fix for that combinatorial loop here:
#190

I will merge to master once I get feedback from your functional verification and sorry for inconvenience

@davideschiavone
Copy link
Contributor

is also this one fixed? @yaronbe1

@yaronbe1
Copy link

yaronbe1 commented Nov 12, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system
Projects
None yet
Development

No branches or pull requests

3 participants