cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
boltzman
Visitor
Visitor
186 Views
Registered: ‎02-26-2021

swapb not working

So I have a miroblaze where I would like to easily swap data between big-endian and little-endian.

In IP Integrator I enabled the feature:

boltzman_0-1617414969221.png

 

My code looks like this:

for ( i = 0 ; i < length ; i++ ){
    getfsl(payload[i], 0);
    payload[i] = mb_swapb(payload[i]);
}

 

For some reason though, I have been unable to make this work. I see how payload[i] has the "correct" value (inverted) before mb_swapb is executed, and then after that it is just zero...

I have tried all sorts of variatios, like:

for ( i = 0 ; i < length ; i++ ){
    getfsl(payload[i], 0);
    payload[i] = mb_swapb(&payload[i]);
}

Which for some reason, do "work", however payload[i] end up being the address of payload[i] byte reversed.... (as it should I guess, since I am passing the location of payload[i], instead of the value itself).

For me, that alone is prove that the instruction is implemented in hw and is working find, however for some reason when I actually pass it a value instead of a memory location I just get all zeros...

I have tried copiying payload[i] to a local variable and other modifications but still no luck...

 

Can somebody help with this?

Tags (2)
0 Kudos
1 Reply
abhinayp
Xilinx Employee
Xilinx Employee
55 Views
Registered: ‎07-12-2018

Hi @boltzman 

This is a known issue in Vivado 2018.3 and 2019.1. It can only occur with area optimization when reorder instructions are enabled and pattern compare instructions are not enabled. So a simple workaround is to also enable pattern compare instructions (Enable Pattern Comparator on the General page of the MicroBlaze customization dialog).

 

It has been fixed in Vivado 2019.2.

Best Regards
Abhinay PS
------------------------------------------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give kudos to a post which you think is helpful and reply oriented.
-------------------------------------------------------------------------------------------------------------------------------

0 Kudos