-
Notifications
You must be signed in to change notification settings - Fork 823
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
[otbn, rtl] Fix X-propagation issue in prefetch stage #22116
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I properly understand this change, with the exact if/else tree. Are we essentially just reversing the order of the last two cases in the if/else list? I think that would be easier to understand, so I fear I'm missing something...
if ({1'b0, insn_prefetch_addr} == prefetch_loop_end_addr_i && | ||
prefetch_loop_active_i && | ||
prefetch_loop_iterations_i > 32'd1) begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Indentation is a bit off here.
Not quite. Previously the first (the |
Oh, I think I understand now. Before this commit, the logic was something like:
With this commit, I think the structure becomes:
I think the behaviour is now slightly different (even without Xs), because we might have a situation where both I guess this makes perfect sense so that we properly handle the situation where But the code is getting a bit hard to understand! Can't we pull the stuff that controls |
I did actually try this and it generated a large number of errors. I think under the first two cases of the big opentitan/hw/ip/otbn/rtl/otbn_instruction_fetch.sv Lines 329 to 336 in 72db492
There's at least some times you don't want to kill an incoming instruction immediately after a branch, though I didn't really investigate the details. So your new |
Oh, I see. In which case, never mind :-) Thanks for explaining carefully. |
I just realised that the indentation is still awry and I don't want to accidentally leave a green tick lying around :-)
215278a
to
bbd1ad2
Compare
When executing near Xs in imem it's possible for Xs to be received on the incoming imem data. The prefetcher looks at the incoming data to see if its a branch instruction. Previous to this change this branch check took priority over a check related to looping which altered the request going to imem. So when the incoming imem data was X, when simulation propagated Xs though ifs we end up with an X on the imem request address. With this change the check for the branch happens regardless of whether or not the looping related logic activates and the branch logic itself does not alter the imem request so it avoids generating Xs on the external (to OTBN core) imem request interface. Signed-off-by: Greg Chadwick <gac@lowrisc.org>
bbd1ad2
to
eed3b21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the careful explanation, @GregAC, and the discussion, @rswarbrick. LGTM!
When executing near Xs in imem it's possible for Xs to be received on the incoming imem data. The prefetcher looks at the incoming data to see if its a branch instruction.
Previous to this change this branch check took priority over a check related to looping which altered the request going to imem. So when the incoming imem data was X, when simulation propagated Xs though ifs we end up with an X on the imem request address.
With this change the check for the branch happens regardless of whether or not the looping related logic activates and the branch logic itself does not alter the imem request so it avoids generating Xs on the external (to OTBN core) imem request interface.
Draft PR for as I don't think this is an essential fix. When running a regression I'm seeing some new failures though I think they were hidden behind previous X check failures (overall pass rate is similar). Further investigation should be done before merging this.
Fixes #21658 along with #22115