alexforencich/cocotbext-axi

Byte swap

elgorwi opened this issue · 5 comments

First of all thanks for making this cocotb extension available.
I've written a simple testbench using AxiStreamSource and AxiStreamSink, which is working well.
Only thing I'm currently missing is the ability to do byte swapping when writing/reading data to/from the DUT.
I've worked around the issue by using a HDL wrapper module with byte swapping applied at input and output of the DUT. However, would be great if byte swapping could be supported directly by the cocotb AXI modules to avoid extra work writing HDL wrapper modules.

Thanks!

Define what you mean by "byte swapping".

With byte swapping I mean controlling how the data bytes are presented left to right on the tdata/tkeep signals. Would be nice if both little endian and big endian was supported.

The AXI stream specification is very specific about byte ordering:

image

I'm already bending the spec by supporting byte sizes of other than 8 bits (which I think is reasonable). However, if your IP expects the first byte to start on a byte lane other than [n:0], then it's not AXI stream compliant, and the most reasonable way forward is to write an HDL shim to convert your IP to AXI stream.

OK, understand if you prefer not to introduce non-standard features.
I’ll use a shim to work around the issue.
Thanks

Let me put it to you this way: I'm not necessarily opposed to it, but I'll have to be convinced it would be a useful feature, and to do that you'll have to overcome 1. the fact that the AXI stream spec is very explicit about byte ordering, and 2. my opinion that big endian makes no sense whatsoever and therefore should never be used, except inside of packet headers that require network byte order. Avalon is a slightly different story as it seems like it supports both orderings, just to make things more confusing.