-
Notifications
You must be signed in to change notification settings - Fork 154
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
bitread: Don't overwrite last frame #1335
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Tomasz Michalak <[email protected]>
Signed-off-by: Tomasz Michalak <[email protected]>
So I don't really understand what the original problem was. Can you make a better description for the issue and the solution? Maybe some diagrams? |
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'd like a better explaination for what the original problem was, and how this change fixes it. Maybe some diagrams? At a minimum, a comment in the code.
@litghost I added more details to the PR description. |
I think I know what is going on, and it has to do with how bitread models the FAR address register. I believe your analysis is not correct. If my analysis is correct, then the solution present in this PR is not correct. I'll take a look at the FAR address modelling code, and come back with a comment in a bit. |
I believe the bug is actually located here: https://github.com/SymbiFlow/prjxray/blob/master/lib/include/prjxray/xilinx/configuration.h#L253 This switch statement likely needs to advance "frame_address_register" by 1 frame when the CRC command is recieved. I'll annotate your example:
FAR = 0xc00000 because it was set via the "Frame Address" write
FAR = 0xc00001, because "Frame Data Input" write advanced it.
FAR = 0xc00000 because it was set via the "Frame Address" write.
FAR = 0xc00001 because it was set via the "Frame Address" write. Not that next write is a "Frame Data Input", because CRC has already advanced the FAR to the correct location!
At this point the FAR = 0xc00180 because the CRC command advanced it 1 frame! So this zero frame is writing into 0xc00180, not overwriting 0xc0017f! This is where I believe the bug occurred.
|
@litghost
This is true, but only for the first frame in a configuration row and this is how it is implemented. For the rest it is advanced by the FDRI write. Why? Because of how the configuration data is layed out in the bitstream (presented in the snippet above) and the fact that Type 2 writes don't have explicit FAR writes in between frames (it is auto-incremented).
Won't work for Type 2 writes where there is CRC only at the end of the packet.
Incorrect. First of all there is no 0xc00180 frame in the FPGA, the FAR counter in this particular case advances to 0 since it reaches the end of the available address range. Secondly look at the broader snippet and all above points. This being said I stand by my point. Maybe I should be more precise in the bug root cause which should say: This entire discussion proves that there should be an extension to the bitstream format chapter of the documentation where all of the above should go into. |
Your more detailed example doesn't change my point. The FAR is clearly advanced when the CRC command is issued, and if the bitread modeled that, no special logic would be required. |
Type 2 packets remember the previous register target (e.g. FDRI vs CRC vs CMD), but the FAR register behavior is likely independent of the Type 1/2 behavior. |
Analyzed the case with bits2rbt and bitread (with aux support required for bits2rbt) (PR) Without the fix, ie where the
clearly there is one missing bit ( With the fix the bit
|
This PR targets the following issue #1285
Background
The bitstream can be divided into 4 parts:
bitread
cares only about the configuration data part and fills in the underlying data structure which maps the frame addresses with the configuration words. Since FDRI writes can be in type 2 packets, where the FAR address is auto-incremented, thepart.yaml
file is used to make sure the frame addresses are actually present in the part.Analysis
By looking at the output of
bittool list_config_packets
with the bitstream provided the configuration part for the BLOCK RAM column in the bottom part of the fpga is as follows:There seems to be a zero frame (frame with all 0s) at the end of the configuration data.
Such a zero frame is present at the end of the configuration words for each row.
The bug only applies to the last row which happened to configure the targeted BRAM_R tile.
This is because between the previous rows there was a write to the CMD register:
which realigns the addresses. This packet is not present after the configuration data for the last row.
Bug
Due to the fact that the there is no WCFG write to the CMD register the zero frame is used to overwrite the content of the last configuration frame.
Fix
The fix makes sure the last frame does not get overwritten by adding a flag that signifies the end of the configuration data packets just before the zero frame.
Testing
Added a google unit test that reads the bitstream and checks that that the last configuration frame contains the word that was being overwritten before.