Fix pulp_zero_mem to avoid illegal HW loop #10
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pulp_zero_memzeros a memory region with the following loop:This code may be translated into assembly similar to
On cores with more than one pipeline stage, this sequence can result in an illegal hardware loop configuration. In particular, one of the hardware loop constraints
requires the loop body to contain more than one instruction. Additionally, hardware loops do not allow memory ordering instructions (fence, fence.i) in the loop body.
The presence of
MemoryFence()appears to prevent the compiler from correctly deriving the hardware loop properties, potentially leading to an invalid loop configuration. While this issue does not manifest in GVSoC simulation, it may cause unexpected behavior in RTL simulations.A potential solution is to remove the
MemoryFence()from the loop. Doing so allows the compiler to correctly generate a valid hardware loop, typically inserting anopbefore the store instruction and thus avoiding the illegal configuration.This PR removes the
MemoryFence()from the main loop inpulp_zero_memto prevent the generation of illegal hardware loops.