ushort arrays in volatile properties of HDL workers aren't readable for all indices
Bug Summary
The final one or two indices of a ushort
array will often return the wrong value.
This wrong value tends to be a value that is near the front of the array.
This is worse when the ushort
array starts from a byte offset that is not a multiple of 4 (i.e. it starts in the middle of a 32 bit word).
Workaround
Use a ulong
array instead.
Steps to reproduce
A project that causes this issue is available here.
A rough explanation:
- Make a HDL worker with N
ushort
arrayvolatile
properties of increasing length (1, 2, up to N).- This covers starting the array in the middle of a 32 bit word.
- Drive a constant to each array index.
- I wrote the index + 1 to each index to avoid any
0
s.
- I wrote the index + 1 to each index to avoid any
- Drive
ctl_out.finished
with'1'
. - Create an assembly and application with just this worker.
- Create an application with just this worker.
- Use
ocpirun
with-d
to dump properties.
Environment info
- OpenCPI Version used: release-v2.4.6
- Operating System and version: CentOS 7 + Arch Linux
Possible fixes (Optional)
I've found several potential problems with proptypes.cpp_gen
and how the entities it generates interact with the wci
infrastructure.
At the bare minimum, the ushort_read_array_property
entity uses srl
after a width truncation when it should be before. Remedying that fixes the issue when the array aligns with 32 bit words, but not when it starts half way. In that case, the error then moves to break the first index of the array instead.
The reason for that is due to how the byte offset is changed by decoder.vhd
. For some reason, when a ushort array starts in the high bytes of a 32 bit word, the byte enable to read the first index is still f
when it should be c
. This results in the offset
losing its lowest two bits, so the ushort_read_array_property
is given an incorrect offset
to read from.
Whilst I have come up with a rewrite of the aforementioned line from decode.vhd
, I think I'm addressing a symptom rather than the root cause.
Hopefully, I'll be able to continue looking into this in the near future.
Acceptance criteria
The example listed functions correctly.