Fix AHB memory non-full word transactions #9
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.
The behavior of non-full word writes and reads in the AHBLiteSlaveRAM class differs from the AHB memory provided by cmsdk (e.g. https://github.com/ForrestBlue/cortexm0ds/blob/master/logical/models/memories/cmsdk_ahb_ram.v). The main difference lies in active byte lanes. For example, in the case of the data bus width of 32 bits, AHBLiteSlaveRAM, when being written a half-word to an address 'h6, expects data to appear in lower bytes of the data bus. While the implementation by cmsdk expects the data in upper bytes.
I believe that AHBLiteSlaveRAM uses little-endian (because it is the most common).
Furthermore, AMBA AHB Specification (ARM IHI revision 0033C - ID090921) specifies the byte lane output in Table 6-1 in “6.2 Endianess”. It defines which byte lanes are used in HR(HW)DATA.
So I fixed the _rd and _wr methods in the AHBLiteSlaveRAM class. And since the behavior of _rd and _wr methods was changed, tests had to be fixed as well.
Also, the new implementation of _rd and _wr now supports a data bus width different from 32 or 64. The AMBA AHB Specification (ARM IHI revision 0033C (ID090921)) “2.2 Manager signals” Table 2-2 describes HRDATA and HWDATA as such:
Therefore, support for other sizes was added to the commit.