cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Participant
Participant
533 Views
Registered: ‎09-26-2016

Strange behaviour with WSTRB mask when writing over AXI

Jump to solution

Hi all,

 

I did a simple test of copying several bytes from array defined in Microblaze to a custom packaged AXI (full) slave. I used a memcpy function. The code bellow is self explanatory what I was trying to do:

 

memcpy((void *)(ADDRESS_TO_WRITE), data_array, 1);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 2);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 3);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 4);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 5);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 6);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 7);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 8);
memcpy((void *)(ADDRESS_TO_WRITE), data_array, 16);

In some cases, WSTRB mask didn't behave as I would expect. Bellow are screenshots for each upper transaction. Bolted comments show cases where I would expect different WSTRB mask. I thought, that the mask should be such to achieve the smallest possible number of transactions. But that is obviously not true.

 

1. Copying 1 byte. 1 transaction with WSTRB b'0001. OK.

write_1_byte.JPG

 

2. Copying 2 bytes. 1 transaction with WSTRB b'0011. OK.

write_2_bytes.JPG

 

3. Copying 3 bytes. 3 transaction with WSTRB b'0001, b'0010, b'0100. I would expect 1 transaction with WSTRB b'0111.

write_3_bytes.JPG

 

4. Copying 4 bytes. 1 transaction with WSTRB b'1111. OK.

write_4_bytes.JPG

 

5. Copying 5 bytes. 5 transaction with WSTRB b'0001, b'0010, b'0100, b'1000, b'0001.  I would expect 2 transactions with WSTRB b'1111 and b'0001.

write_5_bytes.JPG

 

6. Copying 6 bytes. 6 transaction with WSTRB b'0001, b'0010, b'0100, b'1000, b'0001, b'0010.  I would expect 2 transactions with WSTRB b'1111 and b'0011.

write_6_bytes.JPG

 

7. Copying 7 bytes. 7 transaction with WSTRB b'0001, b'0010, b'0100, b'1000, b'0001, b'0010, b'0100.  I would expect 2 transactions with WSTRB b'1111 and b'0111.

write_7_bytes.JPG

 

8. Copying 8 bytes. 8 transaction with WSTRB b'0001, b'0010, b'0100, b'1000, b'0001, b'0010, b'0100, b'1000.  I would expect 2 transactions with WSTRB b'1111 and b'1111.

write_8_bytes.JPG

 

9. Copying 16 bytes. 4 transaction with WSTRB b'1111. This is reasonable.

write_16_bytes.JPG

 

Any hint regarding such behaviour is very appreciated. Thank you in advance.

 

Matic

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Explorer
Explorer
606 Views
Registered: ‎03-31-2016

Re: Strange behaviour with WSTRB mask when writing over AXI

Jump to solution

When dealing with a processor you must always look at the assembly code.

 

For the three byte case the there is almost certainly not an assembly instruction to do a 3 byte copy so it hast to split it up somehow. 

 

It could probably do 2 bytes in once and 1 byte in another but that like the rest of the case you are questioning depend on just how good the compiler is at optimizing and potentially the alignment of the addresses.

View solution in original post

0 Kudos
1 Reply
Highlighted
Explorer
Explorer
607 Views
Registered: ‎03-31-2016

Re: Strange behaviour with WSTRB mask when writing over AXI

Jump to solution

When dealing with a processor you must always look at the assembly code.

 

For the three byte case the there is almost certainly not an assembly instruction to do a 3 byte copy so it hast to split it up somehow. 

 

It could probably do 2 bytes in once and 1 byte in another but that like the rest of the case you are questioning depend on just how good the compiler is at optimizing and potentially the alignment of the addresses.

View solution in original post

0 Kudos