This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-AM64X: Xin and Xout instructions with 0 bytes

Part Number: PROCESSOR-SDK-AM64X

Hi,

I am working with an algorithm that requires me to xin/xout 0 bytes of data. (I agree it does not add value to xout 0 bytes, but I need to do this in my program for correct functioning.) Currently checked it in BS_RAM memory.

    xout 0x1E, &R2, 0
    xin 0x1E, &R2, 0

These instructions xout and xin 4 bytes of data instead of zero! Not sure why :/

    xout 0x1E, &R2, 1
    xin 0x1E, &R2, 1

These instructions xout and xin 1 byte of data.

Can you confirm this? How do I xout 0 bytes of data?

Best Regards,

Madhurya

  • Hello Madhurya,

    What exactly are you trying to accomplish by doing an XIN / XOUT with 0 bytes? For example, are you trying to get the PRU core to pause for one clock cycle? If you are just trying to get the PRU core to pause for a clock cycle, you would want to use NOP (no operation) instead of an actual assembly command.

    Regards,

    Nick

  • Hi Nick!

    Nop(e), I'm not trying to pause the PRU core. .

    I have an algorithm that increments the Xout bytes from 0,4,8,16,32. Since I wrote the program in this way, I need to xout 0 bytes in the first instant.

    I found a fix by clearing the data from the respective memory location to nullify the xout of 2 bytes that was caused by xout 0 bytes instruction.

    I still suggest this should be documented as a default for xout instructions.

    Best Regards,

    Madhurya

  • Hello Madhurya,

    Nice pun :P

    To make sure I understand what you are observing:
    xout & xin were not designed to move 0 bytes of data. Because of this, that behavior is undefined. It looks like when you passed in length = 0, the assembler defaulted to 32 bits or 4 bytes. I am not sure if that behavior is replicable across all compiler / assembler settings, and all compiler / assembler releases.

    I am unclear on your workaround. Did you observe xout with length = 0 moving 2 bytes at one point in time, and moving 4 bytes at a different point in time? If I understand correctly, you just wrote zeros into the memory addresses that would get moved with your xout with length = 0 command?

    Regards,

    Nick

  • Hi Nick!

    No, I did not observe xout with length = 0 moving 2 bytes at one point in time and moving 4 bytes at a different point in time. It always xout's 4 bytes if I try to xout 0 bytes.

    Yes, the workaround is to clear the content in the memory.

    clear:
        zero &r2, 32
        ldi R10.w0, 0x0001;
        xout 0x1E, &R10, 2
        xout 0x1E, &R2 , 32 ; empty contents of the previous load with Xout 0 bytes.

    Best Regards,

    Madhurya

  • Hello Madhurya,

    Apologies for the delayed response. I am sending your thread to a member of our compiler team to double-check if there is a way to xout 0 bytes, or if your workaround is the best approach.

    Regards,

    Nick

  • I assembled similar code that uses XOUT.  Here is the assembler listing ...

           1 00000000 0000002F0F3F8A          xout    0x1e, &r10, 0
           2 00000004 0000002F0F018A          xout    0x1e, &r10, 4

    Notice how the encoding of an XOUT of 0 bytes is different from the encoding of the same XOUT of 4 bytes.  So, as far as the assembler is concerned, it is valid to XOUT zero bytes.  What the PRU does with that particular instruction encoding is beyond my expertise.

    Thanks and regards,

    -George