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.

66AK2H14 does not generate an exception on illegal crosspath usage

Other Parts Discussed in Thread: 66AK2H14

The 66AK2H14 DSP should have generated an exception when running the program below, but it does not do so.  The CMATMPY and DADD instructions are executed simultaneously from the loop buffer, and both try to use the crosspath at the same time, which is illegal.  The assembler does not complain (while it could have seen the error), and the DSP does not trap when executing the code (it normally does so with similar resource conflicts).  Instead, B0 (which is 0) now reads as 1, because B2 (which is 1) is read through the crosspath simultaneously, leading to unexpected results (one would expect that 0 + 0 yields 0, but instead, A0 is incremented on all but the last iteration.

John


(asm code:)

        .global asm_bug
asm_bug:

        MVK             5,B31
        MVC             B31,ILC

        ZERO            A1:A0
        ZERO            B1:B0
        MVK             1,B2

        SPLOOP          4

        ; load B2 (= 1) through crosspath
        CMATMPY .M1x    B3:B2,A19:A18:A17:A16,A27:A26:A25:A24 

        NOP             3

        ; DADD overlaps with CMATMPY
        ; load B0 (= 0) through crosspath, but B0 reads as 1!
        DADD    .S1x    B1:B0,A1:A0,A1:A0

        SPKERNEL        5
||      STW             A0,*A4++

        RETNOP  .S2     B3,5

(C++ code:)

#include <xdc/runtime/System.h>


extern "C" {
  void asm_bug(int out[5]);
}

int main()
{
  int out[5];

  asm_bug(out);

  for (int i = 0; i < 5; i ++)
    System_printf("%d %d\n", i, out[i]);
  
  return 0;
}