Bug fix: set shift count on MOV and OUT #2
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.
Hi. This is a great project. It helped me simulate a PIO algorithm for a quadrature encoder. I was also blown away by the documentation. You did such a spectacular job 👏
I ran into what I think is an oversight in the implementation of the MOV and OUT instructions.
According to the RP2040 datasheet, the MOV instruction clears the ISR and OSR shift counters. Additionally, when the destination for OUT instruction is the ISR register, it sets the ISR shift counter to the bit count.
I implemented the changes to the simulator. I'm providing test cases for the three operations. These test case PIO programs don't do anything useful but they show the issue and the fix.
Steps to reproduce the issue with mov isr
Expect ISR_SHIFT_COUNT=00000000 after
mov isr, null
,Before fix:
After fix:
Steps to reproduce the issue with mov osr
Expect OSR_SHIFT_COUNT=00000000 after
mov osr, x
Before fix:
After fix:
Steps to reproduce the issue with out isr
Expect ISR_SHIFT_COUNT=00000002 after
out isr, 2
Before fix:
After fix: