There is a problem about the clock cycle used by the operator when executed in the MPC5744P

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

There is a problem about the clock cycle used by the operator when executed in the MPC5744P

916 Views
dyc09052110
Contributor I

Hi:

 When I execute a for (unsigned short i = 0; i <5000; i ++) {} in the MPC5744P, It takes about  500us. When I execute a for (unsigned short i = 0; i <5000; i ++) { a = b+c;} in the MPC5744P, It takes about 1000us.The MPC5744P clock speed is 160MHz.But according to the MPC5744P reference manual, the '+' operator takes only one clock cycle, the '*' operator takes two clock cycles, Why this code takes so long time?Or what else should I use to speed up the execution?This question has bothered me for a long time and hope you can help me.

Thanks very much!

0 Kudos
5 Replies

745 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, I would recommend to disassemble your C code to see how many and which instructions has been used by compiler.

0 Kudos

745 Views
dyc09052110
Contributor I

Hi, I have done in accordance with your method and found that for a n1 = n2 + n3 operation, the compiler requires seven instructions. The disassembly results are as follows:n1 = n2 + n3;

1  e_lhz  r9, 10(r31)

2  e_rlwinm  r10, r9, 0, 16, 31

3  e_lhz  r9, 12(r31)

4  e_rlwinm  r9, r9, 0, 16, 31

5  add r9, r10, r9

6  e_rlwinm  r9, r9, 0, 16, 31

7  e_sth, 8(r31).

If I use the assembly instructions to achieve a "+" operation in MPC5744P, also need to use seven instructions to achieve this operation?

0 Kudos

745 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

You may try to change optimization setting of you compiler to higher level.

pastedImage_1.png

Also you could try to define operand as register type like this

register int n1, n2, n3;

This definition places operand directly into register thus it could shrink generated code.

0 Kudos

745 Views
dyc09052110
Contributor I

HI:

I want to use LSP intrinsic functions of MPC5744P in S32, but i can not find related header files. Can you help me?

Thanks very much!

0 Kudos

745 Views
dyc09052110
Contributor I

I have been in accordance with the second method you said to optimize the code and achieved some results.I carry out radar signal processing on MPC5744P.But the current program execution speed is still not meet the real-time requirements.I would like to know can i write assembly code in the MPC5744P ?If so, what is the instruction set for the MPC5744P and how can I use it in the MPC5744P?

If not, what module in the MPC5744P can speed up the execution of the code and how can I use these modules?
Thanks very much!
0 Kudos